Hardy's approximation for the cosine
I was reading about the Hardy's approximation for the cosine function (here and also in Mathworld):
$$\cos \left(\frac{\pi}{2} x\right) \approx 1-\frac{x^{2}}{x+(1-x) \sqrt{\frac{2-x}{3}}}$$ For $0<x<1$
What I would like to know is, how was this approximation derived? What other uses does it have? The links also include a graph showing the error between $\cos(x)$ and the approximation. There isn't much information on the internet about this interesting formula.
Solution 1:
(Cross posting my answer from the Wikipedia help desk.)
Here is a way you might reverse engineer the formula, though I have no idea how Hardy derived it.
Let $C(x) = \cos(πx/2)$. We know from the Taylor series that:$$C(x) = 1 - \frac{x^2}{\text{constant}} + \text{other terms}$$
Rewrite this as $C(x) = 1 - \frac{x^2}{K(x)}$ where K is to be determined. We also know $C(1) = 0$ from which $K(1)=1$. Expand $K$ at $x=1$ to get: $$K(x)=1+(\text{constant})\cdot (x-1)+\text{higher terms}$$
Again, collecting the the constant and higher terms into a single function, write $K(x)=1+(x-1)L(x)$.
At this point you can get a fairly good approximation for $C$ by plugging in a linear approximation for $L$. But we also know $C(1/2)=\sqrt{2}/2$ which would imply (after some computation) $L(1/2) = 1 - \sqrt{1/2}$. So, perhaps a better approximation of $L$ would be: $$L(x)\approx 1 -\sqrt{\frac{1}{2}+m(x-\frac 1 2)}$$ (For some constant m.)
If you plug in $C(2/3)=1/2$ you get $m=-1/3$ which produces the approximation given, but other values of $m$ might work just as well or better. I found $m=-.337$ gives the lowest mean square error on the interval.
Note that there are points in the derivation where different choices could be made, for example you could write $C(x) = 1 - x^2⋅K(x)$ or $K(x)=1+\frac{(x-1)}{L(x)}$. It might be fun to explore these variations to see how they compare with the one given.