Docsity

Problem Set 2 with Solution for Numerical Analysis | MATH 433, Assignments of Mathematical Methods for Numerical Analysis and Optimization

Toggle sidebar
bg1
Math 433 - Numerical Analysis - Spring 2008
Homework 2: SOLUTIONS
Assigned: Friday, January 18, 2008.
Due: Friday, January 25, 2008.
•Include a cover page and a problem sheet.
•Always clearly label all plots (title, x-label, y-label, and legend).
•Use the subplot command from MATLAB when comparing 2 or more plots to
make comparisons easier and to save paper.
•Include all of your script.
•Place a comment at the top of each function or script that you submit which
includes the name of the function or script, your name, the date and MATH
433.
PROBLEMS:
1. Finite Differences.
Consider the function f(x) = 1+ cos(x+2), x0= 0. Approximate the derivative
f0(x0) by computing Df =f(x0+h)−f(x0−h)
2hfor a sequence of increasing small h
values, for example, h= 10−n,n= 1,...,25. Plot the error against husing
the logarithmic scale (use command loglog instead of plot) and explain your
observations. Make a table with the following information.
n h Df f0(0) −Df (f0(0) −Df)/h (f0(0) −Df)/h2(f0(0) −Df )/h3
Discuss the results, especially the rate of convergence (order of accuracy).
Some Problems Using Taylor Polynomials.
2. Consider a function f(x) = ln x. Find the fourth order Taylor polynomial
about the point x0= 2. Then determine the minimum number of terms (i.e.
n) that would guarantee an absolute error of no more than 10−3in the Taylor
approximation for f(x) for all xin the interval [1,2].
3. Show that
f00(x) = f(x−h)−2f(x) + f(x+h)
h2+O(h2)
for sufficiently small hby expanding f(x±h) out to at least fourth order using
Taylor polynomials.
1
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Problem Set 2 with Solution for Numerical Analysis | MATH 433 and more Assignments Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

Math 433 - Numerical Analysis - Spring 2008 Homework 2: SOLUTIONS Assigned: Friday, January 18, 2008. Due: Friday, January 25, 2008.

  • Include a cover page and a problem sheet.
  • Always clearly label all plots (title, x-label, y-label, and legend).
  • Use the subplot command from MATLAB when comparing 2 or more plots to make comparisons easier and to save paper.
  • Include all of your script.
  • Place a comment at the top of each function or script that you submit which includes the name of the function or script, your name, the date and MATH

PROBLEMS:

  1. Finite Differences. Consider the function f (x) = 1+cos(x+2), x 0 = 0. Approximate the derivative f ′(x 0 ) by computing Df = f^ (x^0 +h) 2 −hf (x^0 −h) for a sequence of increasing small h values, for example, h = 10−n, n = 1,... , 25. Plot the error against h using the logarithmic scale (use command loglog instead of plot) and explain your observations. Make a table with the following information. n h Df f ′(0) − Df (f ′(0) − Df )/h (f ′(0) − Df )/h^2 (f ′(0) − Df )/h^3

Discuss the results, especially the rate of convergence (order of accuracy).

Some Problems Using Taylor Polynomials.

  1. Consider a function f (x) = ln x. Find the fourth order Taylor polynomial about the point x 0 = 2. Then determine the minimum number of terms (i.e. n) that would guarantee an absolute error of no more than 10−^3 in the Taylor approximation for f (x) for all x in the interval [1, 2].
  2. Show that

f ′′(x) =

f (x − h) − 2 f (x) + f (x + h) h^2

  • O(h^2 )

for sufficiently small h by expanding f (x ± h) out to at least fourth order using Taylor polynomials.

  1. Consider the function f (x) = cos(πx/2).

a) Expand f (x) in a Taylor series about the point x 0 = 0. b) Find an expression for the remainder. c) Estimate the number of terms that would be required to guarantee accuracy for f (x) within 10−^5 (six significant digit accuracy) for all x in the interval [− 1 , 1]. d) Plot f (x) and its 1st, 3rd, 5th and 7th degree Taylor polynomials over [− 2 , 2]. (Use the Matlab command subplot to generate a number of plots on the same page).

Finite Precision Arithmetic

  1. Use three-digit rounding arithmetic to compute the following sums (sum in the given order):

(a)

∑^6

k=

3 k^

(b)

∑^6

k=

37 −k

observe this behavior from the loglog plot of the error vs. h. For h up to 10−^5 , the error decreases linearly in agreement with the linear convergence of the given finite difference formula. For smaller h, error starts increasing due to roundoff errors, which means that approximations with h smaller than 10−^5 are not accurate.

10 ! 10 10 ! 9 10 ! 8 10 ! 7 10 ! 6 10 ! 5 10 ! 4 10 ! 3 10 ! 2 10

(^10)! 1 ! 11

10!^10

10 ! 9

10!^8

10 ! 7

10 ! 6

10 ! 5

10 ! 4

10!^3

10 ! 2

h

abs(error)

loglog plot of error vs h

! 2 !1.5! 1 !0.5 0 0.5 1 1.5 2

! 4

! 3

! 2

! 1

0

1

2

x

y

Taylor polynomials of function f(x)=cos(pi x/2)

f(x) P 1 (x)=P 0 (x) P 3 (x)=P 2 (x) P 5 (x)=P 4 (x) P 7 (x)=P 6 (x)