Polynomial approximations for the arctan on the unit circle

171 Views Asked by At

I have the following function:

$$f(x, y) = \frac{\text{sgn}(x)}{\pi} \arctan\left( \frac{y}{x} \right)$$

And here you can find a plot I made with GeoGebra.

My objective is to find a polynomial expansion that approximates this function. It doesn't behave so smoothly but I'm only interested in a good approximation only on the unit circle ($x^2 + y^2 = 1$)! I was thinking about leveraging the fact that this function is odd, so maybe an odd polynomial expansion would be better here. Also, the quality of the approximation is not so important near $x = 0$.

I only know Taylor expansions, which do not seem to help much here because of the discontinuities. Do you know other tools which may be of any help in this situation?

Even an approximation for the function without the sign: $$g(x, y) = \frac{1}{\pi} \arctan\left( \frac{y}{x} \right)$$ could be interesting. However, my first thought was that $f$ is smoother on the unit circle.

Another thought: can reinterpreting this as a complex function $f(z) = \frac{1}{\pi} \text{Arg}(z)$ can be useful?

1

There are 1 best solutions below

1
On BEST ANSWER

If you are calculating $\arctan(y/x)$, I can only assume you are interested in calculating the polar angle of a point with coordinates $(x,y)$.

If this is indeed what you are interested in I would strongly recommend you make use of the two-argument arctangent atan2, which is defined by

$$\operatorname{atan2}(x,y)=\begin{cases}\arctan(y/x)&x>0 \\ \arctan(y/x)+\pi & x<0~\&~y\geq0 \\ \arctan(y/x)-\pi & x<0 ~\&~y<0 \\ \pi/2 & x=0~\&~ y>0 \\ -\pi/2 & x=0~\&~y<0 \\ \text{undefined}& (x,y)=(0,0)\end{cases}$$

Somewhat confusingly, some software packages switch the order of the arguments, writing the above instead as $\operatorname{atan2}(y,x)$. I personally dislike this convention and do not use it.


In terms of approximating the function on the unit circle, we know that $x^2+y^2=1$ and thus $x=\pm\sqrt{1-y^2}$. So we can try to approximate $\arctan\left(\frac{y}{\pm\sqrt{1-y^2}}\right)$. (PLOT)

A Taylor series around $y=0$ is perfect, because, as you said, you are not too concerned about the approximation near $x=0$ ($y=1$). Wolfram Alpha says

$$\arctan\left(\frac{y}{\pm\sqrt{1-y^2}}\right)=\boldsymbol \pm\left(y+\frac{y^3}{6}+\frac{3y^5}{40}+\frac{5y^7}{112}+\mathrm O(y^9)\right)$$

Which is Good enough, I think?