# Find an approximation of $f(x) = \frac{1}{(\pi-\cos^{-1}(x))}$ in certain range

$$f(x) = \frac{1}{(\pi-\cos^{-1}(x))}$$ is very steep and hard to approximate near $$1/-1$$ points.

I need to have an approximation in the range -1...0.7, (not full -1..1). This smaller area allows to have potentially better/more efficient approximations than ones available from the literature.

How do I approach this task in Octave/Matlab?

Currently I've created function : (v(1)+(v(2)+(v(3)+(v(4)+(v(5)+v(6).*x).*x).*x).*x)) (as an example, there are several candidates), merit function - integral of it's difference to target function (1/(pi-acos(x))) and trying to optimize vector v using fminsearch. Sometimes it finds good solutions, but more often does not.

Is there a good/better approach to such problems to get to good solutions more reliably?

Close to $$\pm1$$, the derivative of the arc cosine is unbounded. This is what causes your trouble. You can improve on this by squaring the function or its supplement.
The plot below shows the close matching between the curve of the arc cosine and $$\sqrt{2(1-x)}$$ or $$\pi-\sqrt{2(1+x)}$$.