Approximating sin(x) with Chebyshev interpolation up to a certain error threshold.

552 Views Asked by At

Question:

Let $p_n(x)$ be the Chebyshev interpolation of function $f(x)= \sin(x)$ on $[0, \pi/2]$. If we require $||f - p_n|| < 10^{-16}$, what is the smallest value of n that should be used?

I am allowed to use a computer to help and I've been messing around with Chebfun in Matlab without much success. I can't see how to find the error (which should be $\max|f(x) - p_n(x)|$ for all $x$ in the interval $[0, \pi/2]$) using that library.

1

There are 1 best solutions below

0
On

Too long for a comment.

Making the problem more general and using the error bound given in @Gary's comment, you are looking for $n$ such that $$\frac{1}{{2^n (n + 1)!}}\left( {\frac{\pi }{4}} \right)^{n + 1} \leq 10^{ - k}$$ that is to say $$(n+1)! \geq 2 \left(\frac{\pi}{8}\right)^{n+1} 10^k$$ If you look at this question of mine, you will see a magnificent approximation by @robjohn.

Applied to to this problem $$\color{blue}{n \sim \frac \pi 8 e^{1+W(t)}-\frac 3 2} \qquad \text{where} \qquad \color{blue}{t=\frac{4}{e \pi }\log \left(\frac{8 \times 10^{2 k} }{\pi ^2}\right)}$$ where $W(t)$ is Lambert function. As usual, you will use $\lceil n \rceil$.

Using it for $k=32$, this will give, as a real, $n=22.3097$ while the exact solution is $n=22.3101$. Checking $$\frac{1}{{2^{22}\, 23!}}\left( {\frac{\pi }{4}} \right)^{23}=3.56\times 10^{-32} > 10^{-32}$$ $$\frac{1}{{2^{23}\, 24!}}\left( {\frac{\pi }{4}} \right)^{24}=5.83\times 10^{-34} < 10^{-32}$$