0

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
    You can use the error bound given here. In your case you need to choose $n$ so that $$ \frac{1}{{2^n (n + 1)!}}\left( {\frac{\pi }{4}} \right)^{n + 1} < 10^{ - 16} . $$ It took me less than a minute to find this information via Google. – Gary Feb 25 '22 at 03:56
  • 1
    Well I was working on this for about 4 hours before posting it here, so who's the real hero? Just kidding, it's you. Thanks a bunch. I'd looked at the wiki page before, but I guess I didn't understand it. Thanks again. – Gabriel's Feather Feb 25 '22 at 04:10

1 Answers1

2

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}$$