2
$\begingroup$

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$enter image description here

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)!}$?

$\endgroup$
  • 2
    $\begingroup$ Using polynomial interpolation you cannot get uniform convergence. I guess that that is probably the obstruction. $\endgroup$ – Mathematician 42 Nov 26 '16 at 21:19
  • 2
    $\begingroup$ The Taylor expansion is the best polynomial approximation/interpolation of $f(x)$ on $x \in [-\epsilon,\epsilon]$ as $\epsilon \to 0$. If you don't let $\epsilon \to 0$ you might have some convergence problems with your sequence of interpolation polynomials $\endgroup$ – reuns Nov 26 '16 at 21:22
  • $\begingroup$ These run far outside of the equation box for me. I recommend writing these terms in matrices if you know any linear algebra.... not only would this make it easier to write, but solving the equations might exhibit special symmetries in the matrix form you didn't notice prior that could help in determining whether $a_n$ approaches a fixed value $c_n$ $\endgroup$ – Brevan Ellefsen Nov 26 '16 at 22:58
  • $\begingroup$ @BrevanEllefsen I know how to do in matrices. But it's more complicated to do on Mathematica. $\endgroup$ – Billy Rubina Nov 26 '16 at 23:17
2
$\begingroup$

The least squares fit polynomial to a function $f(x)$ over an interval $[a,b]$ is the polynomial $p(x)=a_0 + a_1x + \dots + a_dx^d$ with coefficients $a_i$ chosen to minimize $$ \int_{a}^{b} (p(x) - f(x))^2 \, dx. $$

The least squares fit polynomial to $f(x)=\cos(x)$ over the interval $[-\pi,\pi]$ actually does approach the Taylor series polynomial as you increase the degree.


A faster and more numerically stable way to compute the least squares fit polynomial for $f(x)$ is to let $p(x)$ be a linear combination of orthogonal polynomials (such as the Legendre polynomials). In other words, let $p(x) = \sum_{i=0}^d a_i P_i(x),$ where $P_i(x)$ is the Legendre polynomial of degree $i.$ The solution for $a_i$ is then $$ a_i = \frac{2i+1}{2} \int_{-1}^1 P_i(x) f(x) \, dx. $$

$\endgroup$
  • 1
    $\begingroup$ But how can I see/prove it? From a few computations, the coefficients do not seem to be going to a common limit. $\endgroup$ – Billy Rubina Nov 27 '16 at 5:00
  • 1
    $\begingroup$ I don't know a proof of this. I have only done numerical computations. Try degree 8, 10, and 12 polynomials. For these degrees, the $x^4$ coefficient is 0.0415223, 0.0416610, and 0.0416665 (getting very close to 1/24). Are you sure you are computing the least squares polynomial correctly? $\endgroup$ – J. Heller Nov 27 '16 at 6:08
  • 1
    $\begingroup$ Also, use SVD (singular value decomposition) to solve for the coefficients of the polynomial (if you solve numerically rather than symbolically) because the linear system of equations is very ill-conditioned. $\endgroup$ – J. Heller Nov 27 '16 at 6:27
  • 1
    $\begingroup$ @J.Heller a problem is that the sequence of least-square polynomials behave very badly with respect to some noise, that's why the orthogonal polynomials are preferred $\endgroup$ – reuns Nov 28 '16 at 4:27
  • 1
    $\begingroup$ @OppaHilbertStyle "Elementary Numerical Analysis" by Conte and de Boor is good. The Wikipedia article on Legendre polynomials is also detailed enough to see how to derive the formula for $a_i$. $\endgroup$ – J. Heller Nov 28 '16 at 21:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.