Find a minimal $N \in \mathbb{N}$ such that $|f(x)-T_Nf(x,0)| \le 10^{-6}$ without using Lagrange

48 Views Asked by At

Let $f: \mathbb{R} \rightarrow \mathbb{R}, f(x):=\cos(x)e^x$.

Find a minimal $N \in \mathbb{N}$ such that $$|f(x)-T_Nf(x,0)| \le 10^{-6} \quad (x \in [-\frac{1}{10}, \frac{1}{10}]).$$

I've encountered this question here on Math SE before (here) but I would like to know how to solve it without using Lagrange.

After identifying all the derivatives up to $f^{(4)}$ (for instance), I got

$$\left|\,\cos(x)e^x-(-\frac16 x^4-\frac13x^3+1)\,\right| = \left|\,\cos(x)e^x+\frac16 x^4+\frac13x^3-1)\,\right| \le \\ \cos(\frac{1}{10})e^{1/10}+ \frac16 \cdot \frac{1}{10^4} + \frac13 \cdot \frac{1}{10^3} -1 \approx 0.11,$$

which isn't even close. So how to approach it?

Thanks in advance!

2

There are 2 best solutions below

0
On BEST ANSWER

One easy way is to use complex numbers. You have $$ e^x\cos x=\operatorname{Re} e^x(\cos x+i\sin x)=\operatorname{Re} e^{(1+i)x}=\operatorname{Re} \sum_{k=0}^\infty\frac{(1+i)^kx^k}{k!}=\sum_{k=0}^\infty\frac{[(1+i)^k+(1-i)^k]x^k}{2k!}. $$ Then, for $|x|\leq 10^{-1}$, and using a fairly crude estimate at the end, \begin{align} \left|e^x\cos x-\sum_{k=0}^N\frac{[(1+i)^k+(1-i)^k]x^k}{2k!}\right| &=\left|\sum_{k=N+1}^\infty\frac{[(1+i)^k+(1-i)^k]x^k}{2k!}\right|\\ \ \\ &\leq \sum_{k=N+1}^\infty\frac{|1+i|^k10^{-k}}{k!}\\ \ \\ &= \sum_{k=N+1}^\infty\frac{(\sqrt2)^k10^{-k}}{k!}\\ \ \\ &\leq\frac1{(N+1)!}\sum_{k=N+1}^\infty (0.15)^k\\ \ \\ &=\frac{1}{(N+1)!}\frac{0.15^{N+1}}{1-0.15}\leq1.2\,\frac{0.15^N}{(N+1)!}. \end{align} The last expression has values $$ \begin{array} \text{N} &\hspace{1cm} 1.2\,\frac{0.15^N}{(N+1)!}\\ \hline1& \hspace{1cm} 0.09\\ 2&\hspace{1cm}0.0045\\ 3&\hspace{1cm}0.000169\\ 4&\hspace{1cm}5.06E-06\\ 5&\hspace{1cm}1.27E-07\\ \end{array} $$ So $N=5$ is enough. I don't think you can guarantee that it is minimal without "cheating" in some sense, i.e. having a priori a good estimate of $\cos 0.1\,e^{0.1}$.

0
On

A couple of notes: $$\left.\frac{d^n}{dx^n}e^x\cos x\right|_{x=0}=\Re\left.\frac{d^n}{dx^n}e^{(1+i)x}\right|_{x=0}=\left.\Re(1+i)^ne^{(1+i)x}\right|_{x=0}=\Re\left(\sqrt2e^{\pi i/4}\right)^n=2^{n/2}\cos{\frac{n\pi}4}$$ So you have the first derivative wrong.

There is also an exact expression for the error: $$\begin{align}f(x)-f(0)&=\int_0^xf^{\prime}(t)dt=\left.-(x-t)f^{\prime}(t)\right|_0^x+\int_0^x(x-t)f^{\prime\prime}(t)dt\\ &=f^{\prime}(0)\cdot x+\int_0^x(x-t)f^{\prime\prime}(t)dt\\ &=f^{\prime}(0)\cdot x+\frac{f^{\prime\prime}(0)}2x^2+\frac{f^{\prime\prime\prime}(0)}6x^3+\frac{f^{(4)}(0)}{24}x^4+\frac1{24}\int_0^x(x-t)^4f^{(5)}(t)dt\end{align}$$ But it really isn't all that much of an improvement in this case. Here $$\left|\frac{d^n}{dx^n}e^x\cos x\right|\le\left|(1+i)^ne^{(1+i)x}\right|\le2^{n/2}e^{0.1}$$ So either way you get an estimate of $$\frac{(0.1)^5}{5!}2^{5/2}e^{0.1}\approx5.2\times10^{-7}$$ The actual error is $$e^{0.1}\cos(0.1)-(1+0.1-\frac13(0.1)^3-\frac16(0.1)^4)=-3.33\times10^{-7}$$ So I think your biggest problem was when you set $f^{\prime}(0)=0$ when in fact $f^{\prime}(0)=1$.