TITLE: Is it possible to use polynomial interpolation to show that $\cos(x) = \sum_{n=0}^{\infty} \frac{(-1)^nx^{2n}}{(2n)!}$?
QUESTION [5 upvotes]: Several months ago, I discovered that one can make use a system of linear equations to obtain a polynomial that approaches certain functions. And I know these is the series representation for:
$$\displaystyle \cos(x) = 1 - {x^{2} \over 2!} + {x^{4} \over 4!} - \cdots = \sum_{n=0}^{\infty} \frac{(-1)^nx^{2n}}{(2n)!}$$
So I decided to test this and try to obtain this series with the bakground I learned above. So I did the following:
I'd need a systems of equations in the following form:
$$\begin{cases}
 a_1 x_1+a_0=\cos(x_1) \\
 a_1 x_2+a_0=\cos(x_2) \\
\end{cases}$$
$$\begin{cases}
 a_2 x^2_1+a_1 x_1+a_0=\cos(x_1) \\
 a_2 x^2_2+a_1 x_2+a_0=\cos(x_2) \\
 a_2 x^2_3+a_1 x_3+a_0=\cos(x_3) \\
\end{cases}$$
$$\begin{cases}
 a_3 x^3_1+a_2 x_1^2+a_1 x_1+a_0=\cos(x_1) \\
 a_3 x^3_2+a_2 x^2_2+a_1 x_2+a_0=\cos(x_2) \\
 a_3 x^3_3+a_2 x^2_3+a_1 x_3+a_0=\cos(x_3) \\
 a_3 x^3_4+a_2 x^2_4+a_1 x_4+a_0=\cos(x_4)\\
\end{cases}$$
So, find a solution for $a_n$ should give me the coefficients of a polynomial that approaches the $\cos(x)$ at $x_n$. And hence, I did this:
$$\begin{cases}
 a_0+\frac{\pi  a_1}{4}=\frac{1}{\sqrt{2}} \\
 a_0+\frac{\pi  a_1}{2}=0 \\
\end{cases}$$
$$\begin{cases}
 a_0+\frac{\pi  a_1}{4}+\frac{\pi ^2 a_2}{16}=\frac{1}{\sqrt{2}} \\
 a_0+\frac{\pi  a_1}{2}+\frac{\pi ^2 a_2}{4}=0 \\
 a_0+\frac{3 \pi  a_1}{4}+\frac{9 \pi ^2 a_2}{16}=-\frac{1}{\sqrt{2}} \\
\end{cases}$$
$$\begin{cases}
 a_0+\frac{\pi  a_1}{4}+\frac{\pi ^2 a_2}{16}+\frac{\pi ^3 a_3}{64}=\frac{1}{\sqrt{2}} \\
 a_0+\frac{\pi  a_1}{2}+\frac{\pi ^2 a_2}{4}+\frac{\pi ^3 a_3}{8}=0 \\
 a_0+\frac{3 \pi  a_1}{4}+\frac{9 \pi ^2 a_2}{16}+\frac{27 \pi ^3 a_3}{64}=-\frac{1}{\sqrt{2}} \\
 a_0+\pi  a_1+\pi ^2 a_2+\pi ^3 a_3=-1 \\
\end{cases}$$
And (using Mathematica), I've found the solutions:
$$\begin{array}{cc}
 a_0= \sqrt{2} & a_1= -\frac{2 \sqrt{2}}{\pi } \\
\end{array}$$
$$\begin{array}{ccc}
 a_0= \sqrt{2} & a_1= -\frac{2 \sqrt{2}}{\pi } & a_2= 0 \\
\end{array}$$
$$\begin{array}{cccc}
 a_0= 1 & a_1= \frac{2 \left(8 \sqrt{2}-11\right)}{3 \pi } & a_2= -\frac{16 \left(\sqrt{2}-1\right)}{\pi ^2} & a_3= \frac{32 \left(\sqrt{2}-1\right)}{3 \pi ^3} \\
\end{array}$$
My thinking is that as we put more equations in the system for more values of $\cos$, it will give a polynomial that better approaches $\cos$. And as I put more equations with more values for cosine at the system, the solutions were:


$$\begin{array}{cc}
 a_0= \sqrt{2} & a_1= -\frac{2 \sqrt{2}}{\pi } \\
\end{array}$$

$$\begin{array}{ccc}
 a_0= \sqrt{2} & a_1= -\frac{2 \sqrt{2}}{\pi } & a_2= 0 \\
\end{array}$$

$$\begin{array}{cccc}
 a_0= 1 & a_1= \frac{2 \left(8 \sqrt{2}-11\right)}{3 \pi } &  a_2= -\frac{16 \left(\sqrt{2}-1\right)}{\pi ^2} &  a_3= \frac{32 \left(\sqrt{2}-1\right)}{3 \pi ^3} \\
\end{array}$$

$$\begin{array}{ccccc}
 a_0= 5-3 \sqrt{2} & a_1= -\frac{122-91 \sqrt{2}}{3 \pi } & a_2= -\frac{2 \left(129 \sqrt{2}-164\right)}{3 \pi ^2} & \\  a_3= \frac{16 \left(17 \sqrt{2}-22\right)}{3 \pi ^3} & a_4= -\frac{32 \left(3
   \sqrt{2}-4\right)}{3 \pi ^4} \\
\end{array}$$

$$\begin{array}{cccccc}
 a_0= -5 \left(2 \sqrt{2}-3\right) & a_1= \frac{2 \left(707 \sqrt{2}-990\right)}{15 \pi } & a_2= -\frac{4 \left(222 \sqrt{2}-307\right)}{3 \pi ^2} &\\  a_3= \frac{8 \left(153 \sqrt{2}-214\right)}{3 \pi
   ^3} & a_4= -\frac{64 \left(12 \sqrt{2}-17\right)}{3 \pi ^4} & a_5= \frac{128 \left(7 \sqrt{2}-10\right)}{15 \pi ^5} \\
\end{array}$$

$$\begin{array}{ccccccc}
 a_0= 35-24 \sqrt{2} & a_1= \frac{8 \left(434 \sqrt{2}-615\right)}{15 \pi } & a_2= -\frac{4 \left(9014 \sqrt{2}-12725\right)}{45 \pi ^2} & \\ a_3= \frac{128 \left(31 \sqrt{2}-44\right)}{3 \pi ^3} &
   a_4= -\frac{32 \left(317 \sqrt{2}-452\right)}{9 \pi ^4} & a_5= \frac{1024 \left(7 \sqrt{2}-10\right)}{15 \pi ^5} & \\ a_6= -\frac{512 \left(7 \sqrt{2}-10\right)}{45 \pi ^6} \\
\end{array}$$

$$\begin{array}{cccccccc}
 a_0= -3 (16 \sqrt{2}-23) & a_1= \frac{2 \left(25220 \sqrt{2}-35733\right)}{105 \pi } & a_2= -\frac{4 \left(20270 \sqrt{2}-28671\right)}{45 \pi ^2} & \\ a_3= \frac{8 \left(19044
   \sqrt{2}-26999\right)}{45 \pi ^3} &  a_4= -\frac{32 \left(989 \sqrt{2}-1404\right)}{9 \pi ^4} & a_5= \frac{256 \left(360 \sqrt{2}-511\right)}{45 \pi ^5} & \\ a_6= -\frac{512 \left(55
   \sqrt{2}-78\right)}{45 \pi ^6} & a_7= \frac{2048 \left(12 \sqrt{2}-17\right)}{315 \pi ^7} \\
\end{array}$$


Now, here I expected a miracle:
$\quad \quad \quad\quad \quad\quad$
I expected that somehow, the coefficients of $a_n$ converged to the coefficients of the series I gave in the beginning (because of the better polynomial that approaches $\cos$) but just by looking at it, this doesn't seems to be the case. But I don't know how to prove this is actually not the case: Is it possible that the method I employed could yield the results I expect or is it impossible?
I understand that my thinking is poorly justified and perhaps too vague but I want to know if something can be made with it or if it is possible to use polynomial interpolation to show that $\cos(x) = \sum_{n=0}^{\infty} \frac{(-1)^nx^{2n}}{(2n)!}$?

REPLY [2 votes]: You can do what you wanted to do here with Mathematica.
Unprotect[Power]; 0^0 = 1;
ClearAll[sys, doit, a];
sys[n_?OddQ] := Table[With[{x = Pi (m - (n - 1)/2)/(n - 1)}, 
   Sum[a[k] x^k/k!, {k, 0, n - 1}] == Cos[x]], {m, 0, n - 1}];
doit[n_?OddQ] := (soln = Solve[sys[n], Array[a, n, 0]][[1]];
   f[x_] := Sum[a[k] x^k/k!, {k, 0, n - 1}] /. soln);
doit[7]; Print[soln, N[Table[soln[[n, 2]], {n, 7}], 5]];
Plot[{Cos[x], f[x]}, {x, -Pi, Pi}]
(*
{a[0] -> 1, a[1] -> 0, a[2] -> (-517 + 270*Sqrt[3])/(5*Pi^2),
a[3] -> 0, a[4] -> (-216*(-68 + 39*Sqrt[3]))/Pi^4,
a[5] -> 0, a[6] -> (46656*(-26 + 15*Sqrt[3]))/Pi^6}
{1.0000, 0, -0.99996, 0, 0.99789, 0, -0.93361}
*)

The purpose of 0^0=1 is to avoid a glitch. The sys[]
function returns a list of polynomial equations, The main
doit[] function solves the polynomials equations to find the coefficients. The doit[7] sets the function f[]
to be a 6th degree polynomial with the coefficients
found by solving the system of equations. The found 
coefficients are then printed and the Plot[] does a
comparison of the actual Cos[] function with the found
f[] polynomial function.
The key idea here is to interpolate the $\,\cos\,$
function at a set of points uniformly distributed
over the whole interval $\,[-\pi,\pi].$ The difference in the function and its polynomial 
interpolation is pretty good even for $\,n=7.$
In fact, the coefficients are getting very close
to the actual coefficients of the Taylor series.