0

The function I'm attacking is shown here:

y(a) = pi/2 + arctan(np.sqrt(a/((2*R)-a))) - arccos(1-(a/R))

Visualized here: https://www.desmos.com/calculator/pf39xc033q

function diagram

Eq1 is left in radians, Eq2 I put into degrees just to make the function easier to see.

I have y(a), but I'm looking to get a(y), and I cannot seem to make anything work. If someone could point me in the right direction, I would really appreciate it.

Spektre
  • 49,595
  • 11
  • 110
  • 380
  • How is your question related to Python? –  Apr 05 '16 at 09:40
  • You're basically looking for the inverse function, but `numpy` is for numerical stuff. You're looking for a symbolic mathematics package, such as `sympy`. If you're trying to solve this equation on Mathematica, it has its own site [here](http://mathematica.stackexchange.com/). Putting that on Maple I get an inverse with stuff that nightmares are made of. – Reti43 Apr 05 '16 at 09:50
  • On the other hand, if you want a numerical approximation, you can generate some values for `a` and `y(a)` and then invert the mapping. For any value not in `y(a)`, you can interpolate. – Reti43 Apr 05 '16 at 09:58

2 Answers2

2

Notice that

y == Pi/2+ArcTan[Sqrt[a/((2*R)-a)]]-ArcCos[1-a/R] && 0<=a<2 R

is exactly equivalent to

y == Pi/2-1/2 ArcCos[1-a/R] && 0<=a<2 R

and thus

a == R(1-Cos[2 y-Pi]) && 0<=y<=Pi/2 && 0<R

and simplify that to

a == 2 R Cos[y]^2 && 0<=y<=Pi/2 && 0<R

All this written using Mathematica notation because there was a Wolfram-Mathematica tag.

Check this very carefully to make certain that there is no mistake.

Bill
  • 3,664
  • 1
  • 12
  • 9
0

If you do not have luck with analytical solution then approximate.

The shape is non-increasing so you can use binary search. If it would not be the case you could still use Approximation search or any other approximation or optimization approach.

You could also fit polynomial parametric curve to your function and compute its inverse analytically. Or you could fit the graphically inverted curve into polynomial directly. Beware some functions are not able to fit with polynomials very accurately.

For really hard functions use LUT and its inverse LUT see

Community
  • 1
  • 1
Spektre
  • 49,595
  • 11
  • 110
  • 380