0
$\begingroup$

When one needs to compute say $\cos (58^\circ)$ with an error of at most $10^{-4}$, how does one go about it?

What is an appropriate centre of the Taylor expansion, and how does one determine the required degree of the Taylor polynomial?

2 Answers 2

14

Since we have to use Taylor's Theorem to solve this problem, let's first recall what it (or at least one formulation) is:

Taylor's Theorem:
Let $n\in\Bbb N$, let $I=[a,b]$, and let $f:I\rightarrow \Bbb R$ be such that $f$ and its derivatives $f'$, $f''$, $\ldots\,$, $f^{(n)}$ are continuous on $I$ and that $f^{(n+1)}$ exists on $(a,b)$. If $x_0\in I$, then for any $x$ in $I$ there exists a point $c$ between $x$ and $x_0$ such that $ f(x)=\color{darkgreen}{f(x_0)+f'(x_0)(x-x_0)+{f''(x_0)\over 2!}(x-x_0)^2+ {f'''(x_0)\over 3!}(x-x_0)^3}$ $\color{darkgreen} { +\cdots +{f^{(n)}(x_0)\over n!}(x-x_0)^n} +\color{maroon}{{f^{(n+1)}(c)\over (n+1)!}(x-x_0)^{n+1}} $

The darkgreen term in Taylor's Theorem $P_n(x)=\textstyle \color{darkgreen}{f(x_0)+f'(x_0)(x-x_0)+{f''(x_0)\over 2!}(x-x_0)^2+ {f'''(x_0)\over 3!}(x-x_0)^3} \color{darkgreen} { +\cdots +{f^{(n)}(x_0)\over n!}(x-x_0)^n} $ is the Taylor polynomial of the function $f$ of degree $n$ centered at $x_0$.

The maroon term in Taylor's Theorem, $\tag{1} E_n(x)=\color{maroon}{{f^{(n+1)}(c)\over (n+1)!} (x-x_0)^{n+1}}$ is called the the error term. Where "$c$" depends on both $x_0$ and $x$.


If we estimate the function $f(x)$ with the value of $P_n(x)$, then the error in approximation is given by $E_n(x)$. Now, of course, we can't in practice hope to know what $E_n(x)$ is exactly; but if we can find a number $M$ so that $\tag{2} \max_{t\text{ btw }x_0\text{ and }x } \Biggl|\, {f^{(n+1)}(t)\over (n+1)! (x-x_0)^{n+1}} \, \Biggr | \le M, $ then we would know from Taylor's Theorem that $\tag{3} \bigl|\,f(x)-P_n(x)\,\bigr|\le M. $ The general procedure for approximating a function's value $f(x)$ with a Taylor polynomial $P_n(x)$ to within a certain degree of accuracy, say $\epsilon$, is to first determine a value of $n$, the degree of the Taylor Polynomial, needed so that the right hand side of $(2)$ is less than or equal to $\epsilon$. Then $(3)$ would tell us that the Taylor polynomial of degree $n$ will approximate the value of $f(x)$ to within $\epsilon$.


Now on to your problem. This is calculus, we will use radians for angular measurements.

We wish to estimate $\cos (29\pi/90)$ to within $1/10^4$ using Taylor's Theorem. Since $29\pi/90\approx\pi/3$, we will do so by using a Taylor polynomial of $f(x)=\cos x$ centered at $x_0=\pi/3$ and using $x=29\pi/90$ in Taylor's Theorem.

But what should should the degree $n$ of the polynomial be? We can use the remarks above to determine this:

We want the error in approximation, $E_n(29\pi/90) $ to satisfy $\tag{4} \bigl|\,E_n(29\pi/90)\,\bigr|\le {1\over 10^4}. $ Using $(1)$ to write the term $E_n(29\pi/90)$ more explicitly, we want

$ \Biggl|\,{ f^{(n+1)} (c)\over (n+1)!} \bigl({\textstyle{29\pi\over 90}-{\pi\over3}}\bigr)^{n+1}\,\Biggr|\le {1\over 10^4}; $ which simplifies to

$\tag{5} \Biggl|\,{ f^{(n+1)} (c)\over (n+1)!}\bigl({\textstyle{- \pi\over 90}}\bigr )^{n+1}\,\Biggr|\le {1\over 10^4}. $ Since we do not know what $c$ is, we find an upper bound for the expression on the left hand side of $(5)$; that is, we find an $M$ as in $(2)$. We can be slack here and use the fact that all derivatives of $f(x)=\cos x$ produce functions with absolute value at most 1. So, we have $\tag{6} \bigl|E_n(29\pi/90)\bigr|= \Biggl|\,{ f^{(n+1)} (c)\over (n+1)!}\bigl({\textstyle{- \pi\over 90}}\bigr )^{n+1}\,\Biggr|\le \Biggl|\, {1\over (n+1)!}({ -\pi\over 90} )^{n+1}\,\Biggr|. $ Now we find an $n$ so that the right hand side of $(6)$ is less than or equal to $1/10^4$. Then it will follow that inequality $(4)$ holds for this value of $n$, and consequently that $P_n(29\pi/90)$ approximates $\cos(29\pi/90)$ to within $1/10^4$. It turns out that (nicely) $n=2$ does the job, as direct verification will attest (you can plug values of $n$ into the right hand side of $(6)$ until you see the inequality is satisfied).


So, $n=2$, and the desired approximation is $P_2(29\pi/90)$.

We, of course, need to find $P_2(29\pi/90)$. Towards this end we first find the general form of $P_2(x)$ which is: $ P_2(x)=f(\pi/3)+f'(\pi/3)(x-\pi/3)+{f''(\pi/3)\over2!}(x-\pi/3)^2. $

We have: $ \eqalign{ f(\pi/3) &= \cos(\pi/3)=1/2\cr f'(\pi/3)&=-\sin(\pi/3)=\sqrt3/2\cr f''(\pi/3)&= -\cos(\pi/3)=-1/2\cr } $

So $ P_2(x) = {1\over 2}-{\sqrt3\over2}(x-{\pi/3})-{1\over 2\cdot2!}(x-{\pi/3})^2. $

Finally, the desired approximation is: $ P_2(29\pi/90) = {1\over 2}-{\sqrt3\over2}(-\pi/90)-{1\over 2\cdot2!}(-\pi/90)^2. $

  • 1
    I can't decide whether to love or to hate this answer!2012-04-12
0

If you wish to calculate, then you can solve $input^x/x! = accuracy$ and round the result up to the nearest multiple of $4$ (so the final term is an addition). For your case, the solution is $8$, as you should always choose the largest positive solution. Thence, $8$ is the largest degree of the Taylor polynomial you ask for.

To ad hoc the number of terms you will need in the Taylor expansion for cosine, convert the value being given to cosine into radians, and multiply that number by $e$, rounding up the result to the nearest multiple of $4$. That number is the degree of the expansion for which every greater degree yields a more accurate approximation of cosine for the given input. This is because $n!$ dominates $x^n$ if $x$ is less than $n/e$. If you are solving one term at a time, continue until the term's result is less than your error margin, then do one or two more terms*. This works because every further term will not only retreat further from the margin, it will alternate addition and subtraction.

As for the question of "the centre", if I'm right about what you're asking, then the answer is $2 \pi e$, or $20$, due to the equivalence of inputs for cosine and the domination mentioned above.

*Mind, a proof requires far more detail than I am prepared to provide here.