1.1 - Approximation of is an irrational number with infinitely many

advertisement
1.1 - Approximation of
 is an irrational number with infinitely many difference decimal digits. How can it be approximated
as accurately as possible? One method is to approximate  by a partial sum of a series of .
1. Formulas for 
Using trigonometric identities and the Taylor series of tan −1 x, we can derived the following 4
formulas for  :
(a)   4 tan −1 1
(b)   6 tan −1
1
3
(c)   4 tan −1  12   tan −1
(d)   4 4 tan −1  15  − tan −1
1
3
1
239
Derivations of these formulas:
(a) It is directly from tan −1 1   .
4
3
(b) It is also directly from tan −1
 .
6
3
tan  tan
. Let   tan −1 1 and   tan −1 1 . Then
(c) It is known that tan   
2
3
1 − tan tan
−1 1
−1 1
tantan  2   tan tan
3
tan    tan tan −1 1  tan −1 1

2
3
1 − tantan −1  1  tantan −1  1 
2

1
2

1 −  12 
1
3

1
3
5
6
1−
2
 1.
1
6
Because
 tan −1 1  tan −1 1   ,
4
3
  4 tan −1 1  tan −1 1
.
2
3
4tan − tan 3 
tan − tan
(d) It is also known that tan −  
and tan4 
. Let
1  tan tan
1 − 6 tan 2   tan 4 
  tan −1 1 and   tan −1 1 . Then
5
239
1
tan4 tan −1  15  − tan tan −1 239
tan 4 tan −1 1 − tan −1 1

.
5
239
1  tan 4 tan −1  1  tan −1 1
tan −1 1
2
5
239
Because
tan 4 tan −1 1
5


tan 4 tan
Hence,
1
−1
1
5
4tantan −1  15  − tan 3 tan −1  15 
1 − 6 tan 2 tan −1  15   tan 4 tan −1  15 
4
1
5
−  15 
3
2
1 − 6    
− tan
1
5
−1
1
239
1
5

4
1
 120
119
120
1
− 239
119
120
1
239
119
1
4 tan −1 1
5
− tan −1
  4 4 tan −1
1
 tan1   , or
4
239
1 − tan −1 1
.
5
239
2. Series for 
Recall in Calculus II, the Taylor series of tan −1 x is

−1
tan x 
∑−1 n−1 2n1− 1 x 2n−1 ,
− 1 ≤ x ≤ 1.
n1
Directly from this series and four formulas of  given in 1., we can derive four series of  as follows.
(a)   4 tan −1 1, x  1:

  4 tan −1 1  4 ∑−1 n−1
n1
(b)   6 tan −1
1
3
1 :
3
, x
  6 tan
(c)   4 tan −1  12   tan −1
n1

n−1
 4 ∑−1 n−1
n1
1
239
  4 4 ∑−1
n1
 4 ∑−1 n−1
n1
n1
1
2n − 1
1
2n − 1


 6 ∑−1
2n−1
n−1
1
2n − 1
1
3
.
, x 1  1 and x 2  1 :
2
3
1
3
∑−1
(d)   4 4 tan −1  15  − tan −1

1
3
−1

4

1 1 2n−1  4 ∑−1 n−1 1 .
2n − 1
2n − 1
n1
1
2
2n−1
1
2
2n−1
 ∑−1 n−1
n1
1
3

2n−1
1
2n − 1
1
3
2n−1
.
, x 1  1 , and x 2  1 :
5
239
1
5
2n−1
1
4 1
5
2n − 1
2n−1
n−1

1
2n − 1

− ∑−1 n−1
n1
−
1
239
2n−1
1
2n − 1
1
239
2n−1
.
3. Approximation Error:

N
N
If   ∑ n1 a n , then  ≈ ∑ n1 a n for some N ≥ 1. How should we choose N so that  − ∑ n1 a n  
for a given accuracy requirement   0? It is known from Calculus II that an alternating series
N
−1 n b n where b n  0 converges if
∑ n1
(i) b n  b n1 ; and
(ii) lim n→ b n  0.
It is also known from Calculus II that

approximation error 
∑−1 b n − ∑−1 b n
n1

N
n
n
n1

∑ b n  b N1 .
nN1
In practice, for a given accuracy requirement   0, if we choose the smallest positive integer N such
2
that
b N1  ,
then

N
∑−1 b n − ∑−1 n b n
approximation error 
 b N1  . (*)
n
n1
n1
Hence, the approximation error is guaranteed to satisfy the accuracy requirement. Note that this is a
sufficient condition, that is, N can be larger than it is necessary.
Example Approximate the following two series within 10 −4 . For each approximation, find N first.

i.
∑−1
n1

n
2
3
n
ii.
∑−1 n
n1
5 2
3
n
−
1
4
n
For this example,   10 −4  0. 0001.
n
i. b n  23 . Observe that
2
3
b N1 
N1
 0. 0001
if and only if
N  1 ln 2
3
 ln0. 0001
ln
2
3

0
N1 
ln0. 0001
ln0. 0001
N
− 1  21. 715 5.
2
ln 3
ln 23
Let N  22 (the smallest integer). Then

∑−1
n
n1
2
3
n
22
≈
∑−1 n
n1
2
3
n
 −0. 399 946 537 1.
For this example, we can compute the limit of the series exactly. Recall in Calculus II, for geometric
series

∑ ar n  ar 1 1− r
if |r|  1.
n1
So,

∑−1 n
n1
∑−1 n
n
2
3
n1
n
 −2
3
1
1 − − 23
 −0. 4
− 0. 4 − −0. 399 946 537 1  0. 000 053  0. 0001. Note that
and the true error is
21
2
3
 − 0. 400 080 194 and |−0. 4 − −0. 400 080 194|  0. 000 080 194  0. 0001
and
20
∑−1 n
n1
n
2
3
 −0. 399 879 708 5 and |−0. 4 − −0. 399 879 708 5|  0. 000 120 291 5  0. 0001.
So, the smallest positive integer N is 20. This shows that the condition (*) is sufficient but not
necessary.
ii. b n  5 2
3
3
n
−
1
4
n
. Consider the inequality
N1
N1
b N1  5 2
− 1
≤ 0. 0001.
3
4
For this example, we cannot solve N exactly from above inequality. Let us try a few N ′ s. Let
N  22.
23
23
− 1
 0. 0004455  0. 0001.
b 23  5 2
3
4
Let N  26.
27
27
− 1
 0. 000088  0. 0001.
b 27  5 2
3
4
Check the case when N  25
26
26
b 26  5 2
− 1
 1. 320 07  10 −4  0. 0001.
3
4
So, N  26 and

∑−1
n1
n
5 2
3
n
−
1
4
26
n
≈
∑−1 n
n1
5 2
3
n
−
1
4
n
 −1. 79995.
We can also find a starting choice of N graphically. Define
x1
x1
− 1
and gx  0. 0001.
fx  5 2
3
4
Sketch y  fx and y  gx for 1 ≤ x ≤ 40 (or larger than 40 if it is needed).
y
y 2.0
1
0.1
1.5
0.01
0.001
1.0
0.0001
0.5
1e-5
1e-6
0.0
0
10
20
30
40
x
0
10
20
30
40
x
(a) Green: y  fx; Red: y  gx
(b) Scaling with log: Green: y  fx; Red: y  gx
Since the magnitude of fx is much larger than the one of gx, the intersection of these two graphs
does not show clearly in (a). Scaling the functions using log, we sketch the graphs of y  fx and
y  gx in (b). We see from the graphs the intersection x is in the interval 25, 27. We start the
checking process with N  26.
Example Approximate  using formulas (a)-(d) within 10 −4 . Find N first for each formula.

4 .
(a)   4 ∑ n1 −1 n−1 1 , b n 
2n − 1
2n − 1
We can solve N exactly.
4
4
4

 0. 0001
2N  1
2N  1 − 1
4 , N 1
4
− 1  19999. 5.
2N  1 
2 0. 0001
0. 0001
20000
 3. 141 542 65.
So, let N  20000.  ≈ 4 ∑ n1 −1 n−1 1
2n − 1
b N1 

−1 n−1
n1
2n−1
2n−1
2N1
6
6
1
1
(b)   6 ∑
, bn 
, b N1 
2n
−
1
2N
1
3
3
We cannot solve N algebraically. We find graphically a starting choice of N. Define
1
2n − 1
1
3
2x1
6
2x  1
1
and gx  0. 0001.
3
Sketch the graphs y  fx and y  gx for 1 ≤ x ≤ 10 with scaling by log:
fx 
y
0.1
0.01
0.001
0.0001
1e-5
1
2
3
4
5
6
7
8
9
10
x
Scaling with log: Green: y  fx; Red: y  gx
From the graphs, we estimate that the intersection is about x  7 or 8. When N  8,
17
b9  6
17
1
3
b8  6
15
1
3
 3. 105 786 97  10 −5  0. 0001.
When N  7,
15
 1. 055 967 57  10 −4  0. 0001.
2n−1
So, N  8.  ≈ 6 ∑
8
−1 n−1
n1
1
2n − 1
1
3
 3. 141 568 72.
4
1 2n−1  1 2n−1 , b n 
1 2n−1  1 2n−1
2n − 1
2
3
2
3
2N1
2N1
4
1
b N1 
 1
.
2N  1
2
3
We cannot solve N algebraically. We find again graphically a starting choice of N. Define
4
1 2x1  1 2x1 and gx  0. 0001.
fx 
2x  1
2
3

(c)   4 ∑ n1 −1 n−1
5
1
2n − 1
.
Sketch the graphs y  fx and y  gx for 1 ≤ x ≤ 10:
y
0.1
0.01
0.001
0.0001
1e-5
1e-6
1e-7
1
2
3
4
5
6
7
8
9
10
x
Scaling with log: Green: y  fx; Red: y  gx
From the graphs, we estimate that the intersection is about x  5 or 6. When N  6,
1 13  1 13  9. 438 272 15  10 −6  0. 0001.
b7  1
13
2
3
When N  5,
b6  4
11
1
2
So, let N  6.  ≈ 4 ∑ n1 −1 n−1
6
11

1
2n − 1
1
3
11
1
2
 1. 796 095 56  10 −4  0. 0001.
2n−1

1
3
2n−1
 3. 141 561 59.
2n−1
2n−1
1
1 2n−1 , b n 
1
4
4 1
−
4 1
−
5
5
2n − 1
239
239
2n − 1
2N1
2N1
4
1
b N1 
4 1
−
5
2N  1
239
We cannot solve N algebraically. We find again graphically a starting choice of N. Define
2x1
2x1
1
4
fx 
4 1
−
and gx  0. 0001.
5
239
2x  1
Sketch the graphs y  fx and y  gx for 1 ≤ x ≤ 10:

(d)   4 ∑ n1 −1 n−1
6
2n−1
y
0.01
0.001
0.0001
1e-5
1e-6
1e-7
1e-8
1e-9
1e-10
1e-11
1e-12
1e-13
1e-14
1
2
3
4
5
6
7
8
9
10
x
Scaling with log: Green: y  fx; Red: y  gx
From the graphs, we estimate that the intersection is about x  2 or 3. When N  2,
5
5
1
b3  4 4 1
−
 1. 024 000 00  10 −3  0. 0001.
5
5
239
When N  3,
7
7
1
b4  4 4 1
−
 2. 925 714 29  10 −5  0. 0001.
5
7
239
2n−1
2n−1
3
1
So, let N  3.  ≈ 4 ∑ n1 −1 n−1 1
4 1
−
 3. 141 621 03.
5
2n − 1
239
4. MatLab Program:
MatLab M-file approx_pi.m using the formula (a) for :
%approximate pi by a partial sum of a series
%
clear
format long
epsinput(’type in an accuracy requirement and press enter ’);
n1;
s0;
bn4/(2*n-1);
while bneps
ss(-1)^(n-1)*bn;
nn1;
bn4/(2*n-1);
end
disp(’Output: (1) N; (2) approximation of pi; (3) b_(N1)’)
[ n-1; s; bn ]
(Here is what you see in the Editor of MatLab)
7
Run the program by typing in approx_pi (without .m) then inputting the accuracy requirements (one at a
time): 0.0001 and 0.00001 in MatLab:
For the accuracy requirement 0. 0001, we have
20000
≈4
∑ −1 n−1 2n1− 1
 3. 14154265359
n1
and for the accuracy requirement 0. 00001, we have
200000
≈4
∑ −1 n−1 2n1− 1
 3. 1415876536.
n1
Now we modify the MatLab M-file approx_pi.m using the formula (c). Mainly, we replace the formula
4
bn 
by
2n − 1
1 2n−1  1 2n−1 .
4
bn 
2
3
2n − 1
8
We first open approxi.m in the Editor Window and the save (using Save As) it with a new name as
approx_pi3.m. We then replace the formula for bn (in bold) in the M-file.
%approximate pi by a partial sum of a series
%
clear
format long
epsinput(’type in an accuracy requirement and press enter ’);
n1;
s0;
bn4/(2*n-1)*((1/2)^(2*n-1)(1/3)^(2*n-1));
while bneps
ss(-1)^(n-1)*bn;
nn1;
bn4/(2*n-1)*((1/2)^(2*n-1)(1/3)^(2*n-1));
end
disp(’Output: (1) N; (2) approximation of pi; (3) b_(N1)’)
[ n-1; s; bn ]
We save the file. Here is what you have in the Editor of MatLab:
Now we run the M-file approx_pi3.m with accuracy requirements 0. 0001 and 0. 00001:
9
For the accuracy requirement 0. 0001, we have
6
≈
∑−1 n−1 2n4− 1
n1
1
2
2n−1

1
3
2n−1
1
3
2n−1
 3. 141561587877590
and for the accuracy requirement 0. 00001, we have
7
≈
∑−1 n−1 2n4− 1
n1
1
2
2n−1

 3. 141599340966198.
Exercises:

1. Formulas (1)-(4) are used to approximate  to within 10 −5 . For each approximation , find N (as small as

possible) such that | − |  10 −5 .
2. (1) Write MatLab M-files for approximating  by the series formula (b) and (d). Name them as
approx_pi2.m and approx_pi4.m.
(2) Approximate  by formulas (a)-(d) (all 4 formulas) to within 10 −6 using the MatLab M-files
approx_pi.m, approx_pi2.m, approx_pi3.m and approx_pi4.m.
(3) Output (i) the value of N, (ii) the approximation of , and (iii) the value of b N1 for each formula.
You may first click on the M-file approxi3.m and copy/paste the content to a new M-file. Save the M-file
as approxi2.m and then modify it.

3. The Taylor series for e x centered at 0 is e x  ∑ n0 1 x n for −  x  . Approximate e −1 using the
n!
N
series to within 10 −6 . (1) Find N; and (2) approximate e −1 by ∑ n0 1 −1 n by MatLab or calculator.
n!
2n

for −  x  . Approximate
4. The Taylor series for cosx centered at 0 is cosx  ∑ n0 −1 n x
2n!
N
cos1 using the series to within 10 −10 . (a) Find N; and (b) approximate cos1 by ∑ n0 −1 n 1 by
2n!
MatLab or calculator.
10
5. Approximate ln2 using a partial sum of a series to within 10 −5 . (1) What is the power series you are
using? (2) What is the number of terms for this partial sum? (3) What is your approximation?
6. Approximate 2 using a partial sum of a series to within 10 −5 . (1) What is the power series you are
using? (2) What is the number of terms for this partial sum? (3) What is your approximation?
11
Download