Even assuming f(x) is a known function, the problem does not have a unique solution. Regardless, it requires a more or less standard application of arcsin:f(x)*n = arcsin(a) or
f(x)*n = π - arcsin(a).
There may be a question of efficiency of course, in which case a lookup table may be a viable alternative.