Find $n$ such that $\tan 1$ and its Taylor series up to $n$ agree to 1000 decimal places

139 Views Asked by At

I know the Taylor series for $\tan x$ is,

$$\tan x = \sum_{n\,=\,1}^\infty \frac {(-1)^{n-1}2^{2n} (2^{2n}-1) B_{2n}} {(2n)!} x^{2n - 1} $$

I am trying to find a value for $n$ such that $|\tan 1 -\sum_0^na_n|< 10^{-1000}$. At first, I thought this was an error question where I calculate smallest $n$ such that $a_n < 10^{-1000}$, then $n+1$ is what I am looking for. This requires computing and I realized there is no way that is what I am supposed to be doing for an analysis problem.

I am now trying to do it analytically and could use some help. I am trying to work with

$$\left |\tan 1 - \sum_{n\,=\,1}^\infty \frac {(-1)^{n-1}2^{2n} (2^{2n}-1) B_{2n}} {(2n)!} \right | $$

but I am stuck.

1

There are 1 best solutions below

1
On BEST ANSWER

I may be totally off topic, so forgive me if this is the case.

Since this is an alternate expansion, would it be sufficient to find $n$ such that $$A=\frac {2^{2n} (2^{2n}-1) B_{2n}} {(2n)!}<\epsilon $$

If this is the case, you would find here that, for large values of $n$ $$B_{2n}\approx 4\,\sqrt{\pi\, n} \,\left(\frac n {\pi\, e}\right)^{2n}$$ Using Stirling approximation for the factorial, this gives $$A \approx 2 \left(2^{2 n}-1\right) \pi ^{-2 n}\approx 2\left(\frac 2 {\pi}\right)^{2n}$$ from which the problem becomes simple $$n=\frac{\log \left(\frac{\epsilon }{2}\right)}{2\log \left(\frac{2}{\pi }\right)}$$

For $\epsilon=10^{-1000}$, the approximate solution is then $n=2550$.

Edit

Using illimited precision and exact values of Bernoulli numbers

  • for $n=2550$, $A=-1.2293 \times 10^{-1000}$
  • for $n=2551$, $A=+4.9821 \times 10^{-1001}$

Edit

In fact, we do not need to use Stirling approximation for the factorial since Bernoulli numbers can be expressed in terms of the Riemann zeta function as $$B_{2n}=(-1)^{n+1} \frac {2 (2n)!}{(2\pi)^{2n}}\sum_{i=1}^\infty \frac 1 {i^{2n}}$$ Then $$\frac {(-1)^{n-1}2^{2n} (2^{2n}-1) B_{2n}} {(2n)!}=2 \frac{2^{2 n}-1}{{\pi }^{2 n}}\sum_{i=1}^\infty \frac 1 {i^{2n}}$$ and, using the first term of the summation, we arrive to the previous approximation for $A$.

But take care : this is not an alternating series and all terms are positive. So, what we got is a lower bound for the number of terms to be added together.

So, if we define the approximate coefficient as $$u_n=2^{2 n+1} \pi ^{-2 n}$$ we have $$\sum_{n=1}^\infty u_n=\frac{8}{\pi ^2-4}$$ $$\sum_{n=1}^p u_n=\frac{8}{\pi ^2-4}-\frac{2^{2 p+3} \pi ^{-2 p}}{\pi ^2-4}$$ and so we want $$\frac{2^{2 p+3} \pi ^{-2 p}}{\pi ^2-4}< \epsilon$$ $$p>\frac{\log \left(\frac{1}{8} \left(\pi ^2-4\right) \epsilon \right)}{\log \left(\frac{4}{\pi ^2}\right)}$$ which leads to the same answer. However, this last approach seems to be more rigorous than the previous one.

Edit

Without any approximation, we can define the error as $$\Delta=\sum_{n=p+1}^\infty 2 \left(2^{2 n}-1\right) \pi ^{-2 n} \zeta (2 n)$$ Generating values for $p=100$ to $p=5000$ by steps of $100$, a linear regression gives a perfect fit (standard errors smaller than $10^{-14}$) $$\log(\Delta)=0.309654 -0.903165 \, p$$ which then gives for the number $p$ of terms to be retained $$p=0.342854 -1.10722 \log (\epsilon )$$ while the first approximation which was given here $$p=\frac{\log \left(\frac{\epsilon }{2}\right)}{2\log \left(\frac{2}{\pi }\right)}$$ write $$p=0.767464 -1.10722 \log (\epsilon )$$

Edit

If we define $$a_n=\frac {(-1)^{n-1}2^{2n} (2^{2n}-1) B_{2n}} {(2n)!}$$,we can notice that $\frac{a_{n+1}}{a_n}$ becomes very quickly very close to $\frac {4} {\pi^2}$. So,let us write $$\tan(1)=\sum_{i=1}^n a_i+a_n \sum_{i=n+1}^p \big(\frac {4} {\pi^2}\big)^{i-n}+a_n \sum_{i=p+1}^\infty \big(\frac {4} {\pi^2}\big)^{i-n}$$ and so, the error for stopping after $p$ terms is given by $$\Delta_n=a_n \sum_{i=p+1}^\infty \big(\frac {4} {\pi^2}\big)^{i-n}=a_n\,\frac{4^{-n+p+1} \pi ^{2 n-2 p}}{\pi ^2-4}$$ and for $\Delta_n < \epsilon$, this gives $$p_n=n+\frac{\log \left(\frac{\left(\pi ^2-4\right) \epsilon }{4 a_n}\right)}{\log \left(\frac{4}{\pi ^2}\right)}$$ Using $\epsilon=10^{-1000}$, this gives $$p_1=2550.0365$$ $$p_2=2549.8201$$ $$p_3=2549.8056$$ $$p_4=2549.8041$$ $$p_5=2549.8040$$ These justify that we can safely use $$p\approx p_1=1+\frac{\log \left(\frac{\left(\pi ^2-4\right) \epsilon }{4 }\right)}{\log \left(\frac{4}{\pi ^2}\right)}$$