Taylor Approximation Homework: Error Analysis and Comparison of Approaches, Assignments of Computer Science

Homework problems related to taylor approximation of functions, error analysis, and comparison of different methods. The problems involve finding the accuracy of approximations for given functions and ranges of values, constructing taylor polynomials, and analyzing the error in taylor polynomials. Some problems require using matlab to compute the ratios of errors using different methods.

Typology: Assignments

Pre 2010

Uploaded on 09/17/2009

koofers-user-9yw
koofers-user-9yw 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Homework 3
Due on Thursday, February 7
1. (Problem 1 on page 33) Consider the error (1.11, below) in approximating the error function. If we
restrict ourselves to k3, then over what range of values of xis the approximation accurate to within 103?
Ek(x) = 2(1)k+1x2k+3
(2k+ 3)(k+ 1)!πeξ.
2. (Problem 2 on page 33) If we are interested only in x[0,1
2], then how many terms in the error
function approximation do we need to take to get an accuracy of 104?
3. (Problem 5 on page 33) Construct a Taylor approximation for
f(x) = Zx
0
tpet2
dt, 0p < 1, x [0,1
2]
that is accurate to within 103for all values of pin the indicated range. (You need to write out the Taylor
polynomial and show that the remainder is smaller than 103.)
4. (Problem 7 on page 33) For
f(x) = Zx
0
t1sin t dt, x [π
4,π
4],
construct a Taylor approximation that is accurate to within 104over the indicated interval.
5. (Problem 9 on page 33) What is the error in a Taylor polynomial of degree 4 for f(x) = xusing
x0=9
16 , for all x[1
4,1].
6. (Problem 1 on page 35) Write each of the following in the form x=f×2βfor some f[1
2,1].
1. x= 25;
2. x= 13;
3. x=1
3;
4. x=1
10 .
Problems seven and eight are simple exercises on using MATLAB. All CISE machines have access to MAT-
LAB (either installed copy or through the online license server). To start MATLAB, you can either click
on the MATLAB icon if available or enter matlab at the command prompt. There are many available
and easy-to-find online resources for matlab tutorials and documentations. For example, you should quickly
browse through the following tutorials:
http://www.math.ufl.edu/help/matlab-tutorial/
http://www.math.siu.edu/matlab/tutorials.html
1
pf3

Partial preview of the text

Download Taylor Approximation Homework: Error Analysis and Comparison of Approaches and more Assignments Computer Science in PDF only on Docsity!

Homework 3

Due on Thursday, February 7

  1. (Problem 1 on page 33) Consider the error (1.11, below) in approximating the error function. If we restrict ourselves to k ≤ 3, then over what range of values of x is the approximation accurate to within 10−^3?

Ek(x) =

2(−1)k+1x^2 k+ (2k + 3)(k + 1)!

π

eξ^.

  1. (Problem 2 on page 33) If we are interested only in x ∈ [0, 12 ], then how many terms in the error function approximation do we need to take to get an accuracy of 10−^4?
  2. (Problem 5 on page 33) Construct a Taylor approximation for

f (x) =

∫ (^) x

0

t−pe−t

2 dt, 0 ≤ p < 1 , x ∈ [0,

]

that is accurate to within 10−^3 for all values of p in the indicated range. (You need to write out the Taylor polynomial and show that the remainder is smaller than 10−^3 .)

  1. (Problem 7 on page 33) For

f (x) =

∫ (^) x

0

t−^1 sin t dt, x ∈ [−

π 4

π 4

],

construct a Taylor approximation that is accurate to within 10−^4 over the indicated interval.

  1. (Problem 9 on page 33) What is the error in a Taylor polynomial of degree 4 for f (x) =

x using x 0 = 169 , for all x ∈ [ 14 , 1].

  1. (Problem 1 on page 35) Write each of the following in the form x = f × 2 β^ for some f ∈ [ 12 , 1].
    1. x = 25;
    2. x = 13;
    3. x = 13 ;
    4. x = 101.

Problems seven and eight are simple exercises on using MATLAB. All CISE machines have access to MAT- LAB (either installed copy or through the online license server). To start MATLAB, you can either click on the MATLAB icon if available or enter matlab at the command prompt. There are many available and easy-to-find online resources for matlab tutorials and documentations. For example, you should quickly browse through the following tutorials:

http://www.math.ufl.edu/help/matlab-tutorial/ http://www.math.siu.edu/matlab/tutorials.html

For this assignment, you are only required to open a MATLAB window and try out a few examples. Al- though look long superficially, the two problems are in fact straightforward. Of course, you will have plenty of opportunity to work out more challenging problems with MATLAB later on this semester.

Problem 7 A. (Problem 11 on page 29) We can compute e−x^ using Taylor polynomials in two ways, either using

e−x^ ≈ 1 − x +

x^2 −

x^3 + · · ·

or using

e−x^ ≈

1 + x + 12 x^2 + 16 x^3 + · · ·

Discuss, in your own words, which approach is more accurate. In particular, which one is more (or less) susceptible to rounding error?

B. The following MATLAB M-function computes the degree-k Taylor approximation for ex:

1 + x +

x^2 +

x^3 + · · · +

k!

xk

function sum=EvalExp(x, k)

sum=1; for n=1:k sum=sum+x^n/factorial(n); end

Save these lines in a file called EvalExp.m and place it in your MATLAB working directory. You can do this using any text editors, including MATLAB’s own. You can run it by simply entering, e.g., EvalExp(1, 100), at the MATLAB command prompt. For example, the following commands find the ratio between the errors using the two methods above for approximating e−^10 using the degree-100 Taylor approximation: (exp is the native MATLAB function that computes ex)

xx=20; abs((exp(-xx)-EvalExp(-xx, 100)))/abs((exp(-xx)-1/EvalExp(xx, 100)))

For this part, you will compute the ratios of the errors using the following input values for xx = 0. 1 , 1 , 10 , 20 , 30 and the degree of the Taylor polynomial k = 50, 100 , 200. You need to turn in three tables (for three values of k) with a ratio for each value of xx. Do your results corroborate with your answer above?

C. What does the semi-colon (;) do in MATLAB?

Problem 8 A. (Problem 12 on page 29) What is the machine epsilon for a computer that uses binary arithmetic, 24 bits for the fraction, and rounds? What if it chops?