Bhaskara approximation of cos(x)

2.1k Views Asked by At

In my knowledge the best aproximation of $\sin$ and $\cos$ is Bhaskara approximation which is : $$\sin(x) \simeq \frac{16 (\pi -x) x}{5 \pi ^2-4 (\pi -x) x}\qquad (0\leq x\leq\pi)$$ and $$\cos(x) \simeq\frac{\pi ^2-4x^2}{\pi ^2+x^2}\qquad (-\frac \pi 2 \leq x\leq\frac \pi 2)$$

what is the best approximation of $\cos(x)$ for $ -\pi\leq x\leq 0$ (by a regular function ) ?

3

There are 3 best solutions below

1
On

There is no such thing as a "best" approximation for a function, there are always minor tweaks you can make to produce better approximations.

However, to your question, you can massage the approximation you gave by noticing that $$-\pi\leq x\leq 0 \iff -\frac \pi2\leq x+\frac \pi2\leq \frac \pi2$$

0
On

The approximation for $\sin(x)$ on $[-\pi/2, \pi/2]$ that fits Bhaskara’s spirit the best is

$$\frac{22 \pi^2 x - 24 x^3}{\pi (7 \pi^2 + 4 x^2)}.$$

It is exact for $\lvert x \rvert \in\{0, \pi/6, \pi/2\}$ and its derivative is zero at the end points. Shift left over $\pi/2$ to get an approximation of $\cos(x)$ on $[-\pi, 0]$.

This is a better approximation in terms of maximum absolute error than Padé’s of the same degree. (Remez’ algorithm can find an even better one. See section 6 of this exposition.) Scaling to the interval $[-1,1]$ gives the nicer looking approximation $$\frac{11 x - 3 x^3}{7 + x^2} \approx \sin \left(\tfrac{\pi}2 x\right).$$

0
On

In terms of approximation, you can do a lot of things depending on how many terms you want to include in the expression. Most of the time, this is done using Padé approximants.

For example, for your question, using the simple $[3,2]$ Padé approximant built around $x=-\frac \pi 2$, we get $$\cos(x)=\left(x+\frac{\pi }{2}\right)\frac {1-\frac{7}{60} \left(x+\frac{\pi }{2}\right)^2 } {1+\frac{1}{20}\left(x+\frac{\pi }{2}\right)^2 }$$ which leads to an absolute error of $0.0042$ at the bounds.

For sure, you could go further and use the $[5,4]$ Padé approximant $$\cos(x)=\left(x+\frac{\pi }{2}\right)\frac {1-\frac{53}{396} \left(x+\frac{\pi }{2}\right)^2+\frac{551 }{166320}\left(x+\frac{\pi }{2}\right)^4 } {1+\frac{13}{396} \left(x+\frac{\pi }{2}\right)^2+\frac{5 }{11088}\left(x+\frac{\pi }{2}\right)^4 }$$ which leads to an absolute error of $3.0\times 10^{-6}$ at the bounds. This is equivalent to the Taylor series to $O\left(\left(x+\frac{\pi }{2}\right)^{11}\right)$.

To give you an idea of the possible improvements; consider that $P_n$ is the $[2n+1,2n]$ Padé approximant of $\cos(x)$ built around $x=-\frac{\pi }{2}$ and compute the norm $$\Phi_n=\int_{-\pi}^0 \big[\cos(x)-P_n\big]^2\,dx$$

$$\left( \begin{array}{cc} n & \Phi_n \\ 1 & 3.92 \times 10^{-6} \\ 2 & 1.26 \times 10^{-12}\\ 3 & 2.23 \times 10^{-20} \end{array} \right)$$

All of these have been done only based on the information (function and derivative values) at $x=-\frac{\pi}{2}$.

But we can try to cover the whole range and consider for example $$\cos(x) \sim \left(x+\frac{\pi }{2}\right)\frac {1+a \left(x+\frac{\pi }{2}\right)^2+b\left(x+\frac{\pi }{2}\right)^4 } {1+c \left(x+\frac{\pi }{2}\right)^2+d\left(x+\frac{\pi }{2}\right)^4 }$$ and obtain

$$a=\frac{-1952+672 \pi -192 \pi ^2+56 \pi ^3}{\pi ^3(\pi ^2-10)}$$ $$b=\frac{-3456+1056 \pi +768 \pi ^2-240 \pi ^3 } {\pi ^5 \left(\pi ^2-10\right) }$$ $$c=\frac{-192+72 \pi -104 \pi ^2+32 \pi ^3 } {\pi ^2 \left(\pi ^2-10\right) } $$ $$d=\frac{-4704+1504 \pi +400 \pi ^2-128 \pi ^3} {\pi ^4 \left(\pi ^2-10\right) }$$ which gives a maximum absolute error equal to $5.96\times 10^{-8}$ and a norm equal to $2.73\times 10^{-15}$ (which is $461$ times smaller than $\Phi_2$).

You could notice that the coefficients are extremely close to those of $P_2$ but these minor changes make a lot of difference.

All these approximations have been built for answering your question.