So i have this equation:
$ y = x^2 * sqrt(1-x^2)$
when i work out the chebyshev polynomials and the taylor polynomials there is an offset of 0.18 between them.
to work out the polynomials i used:
$ T_0 = 1 $
$ T_1 = x $
$ T_2 = 2x^2 - 1$
$ T_3 = 4x^3 - 3x$
$ T_4 = 8x^4 - 8x^2 +1$
the polynomial would now be sum of all:
$sum of ... a_n *T_n$
now to work out the coefficient i used:
$a_n = \frac{2}{\pi} \int^{1}_{-1} (\frac{f(x)}{\sqrt{1-x^2}}T_n)dx$
$f(x) = x^2 \sqrt{1-x^2}$
so for $T_0 we$ get
$a_0 = \frac{2}{\pi} \int^{1}_{-1} (\frac{x^2 \sqrt{1-x^2}}{\sqrt{1-x^2}}T_0)dx$
$a_0 = \frac{2}{\pi} \int^{1}_{-1} (x^2 * (1) )dx$
soving this we get
$a_0 = \frac {4}{7\pi} = 0.1819..$
so that 0.18 is not suppose to be there. without the 0.18, my chebyshev and taylor is almost identical but with it there we can see the shift.
I dont see anything wrong with my work, are we not suppose to include the first term or am i missing something?
Why do you expect them to be identical?
As the function is positive over most of the interval $[-1,1]$, it is not really surprising that the mean over the interval is also positive.
Taylor
$$ x^2\sqrt{1-x^2}=x^2(1-\tfrac12x^2-\tfrac18x^4+...) $$
Chebyshev
This can be understood as the Fourier cosine expansion of $$ f(\cos(s))=\cos^2s\,|\sin s| =\frac{a_0}2+a_1\cos(s)+a_2\cos(2s)+... $$ over $[0,\pi]$, inserting $x=\arccos(s)$ into the partial sums. The coefficients are $$ a_k=\frac2\pi\int_0^\pi f(\cos(s))\cos(ks)\,ds $$ giving $a_1=a_3=0$ because of odd symmetry around $s=\frac\pi2$ and \begin{align} a_0&=\tfrac2\pi[-\tfrac13\cos^3s]_0^\pi=\tfrac4{3\pi}=0.424412,\\ a_2&=\tfrac2\pi[-\tfrac25\cos^5 s+\tfrac13\cos^3s]_0^\pi=\tfrac4{15\pi},\\ a_4&=\tfrac2\pi[-\tfrac87\cos^7 s+\tfrac85\cos^5 s-\tfrac13\cos^3s]_0^\pi=-\tfrac{52}{105\pi}. \end{align}
As you can see, the Taylor expansion is extremely good around $x=0$ and far away at the boundaries while the Chebyshev approximation distributes the error more equally over the whole interval.