0% found this document useful (0 votes)
75 views2 pages

MIT18 330S12 hw2 PDF

This document outlines 5 homework problems for the numerical analysis course 18.330 at MIT in Spring 2012. The problems cover: 1) Using properties of big O notation to show relationships between functions as a parameter approaches zero. 2) Explaining the midpoint rule for numerical integration and determining its order of accuracy. 3) Implementing the rectangle rule and trapezoidal rule in Matlab to integrate a function over an interval and analyzing the convergence. 4) Repeating the convergence analysis from problem 3 with a different function. 5) Implementing forward and centered difference methods in Matlab to numerically differentiate a function and analyzing convergence.

Uploaded by

Arindam Sen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views2 pages

MIT18 330S12 hw2 PDF

This document outlines 5 homework problems for the numerical analysis course 18.330 at MIT in Spring 2012. The problems cover: 1) Using properties of big O notation to show relationships between functions as a parameter approaches zero. 2) Explaining the midpoint rule for numerical integration and determining its order of accuracy. 3) Implementing the rectangle rule and trapezoidal rule in Matlab to integrate a function over an interval and analyzing the convergence. 4) Repeating the convergence analysis from problem 3 with a different function. 5) Implementing forward and centered difference methods in Matlab to numerically differentiate a function and analyzing convergence.

Uploaded by

Arindam Sen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

18.

330 :: Homework 2 :: Spring 2012 :: Due March 1

1. (1 pt) Let α and β be real numbers. If a quantity f (h) is O(hα ) as h → 0, show that

hβ f (h) = O(hα+β ).

2. (2 pts) Consider the “midpoint rule”,


Z 1 N −1
X 1
f (x) dx ' h f ((j + )h), h = 1/N.
0 j=0
2

Draw a picture to explain the “midpoint” interpretation. How accurate is the method, i.e., what is the
order of accuracy? Justify your answer.
x
3. (3 pts) Consider the function f (x) = 1+x 4 over the interval [−1, 2]. To integrate this function numeri-

cally, write a script to implement the first-order rectangle rule and the second-order trapezoidal rule.
(Now is a good time to learn about vector operations and the “sum” command in Matlab, if you do not
already know them.)

• How do you write the quadrature formulas to deal with the fact that the interval is [−1, 2] instead
of [0, 1]? In particular, how you relate h to N , and what is your choice of grid points xj ?
R2
• What is the value of −1 f (x) dx, to 10 decimal places?
• Do a log-log plot of the absolute value of the truncation error of each method as a function of h.
(Choose an adequate range of h that spans several orders of magnitude.) Explain how you can
spot the order of convergence of each method from your plot.

4. (1 pt) Repeat the convergence plots as in question 3, but with the function g(x) = (x + 1)3 (x − 2)2
on [−1, 2]. What order of accuracy do you now observe for each method? (Bonus, 1pt: explain your
observation.)
x
5. (3 pts) Consider the same function f (x) = 1+x 4 on [−1, 2]. To differentiate this function numerically,

write a script to implement the first-order forward difference and the second-order centered difference.
We are interested in computing the derivative not just at one point, but at every point of a fine grid with
spacing h (except at the two endpoints). For simplicity, you may want to use the same grid convention
as in the previous questions.

• What is the value of f 0 (1), to 10 decimal places?


• Do a log-log plot of the truncation error of each method as a function of h. Measure the truncation
error as the maximum over all the gridpoints (except the 2 endpoints) of the absolute value of the
difference between the numerical derivative and the “exact” derivative. A very accurate numerical
derivative is a good substitute for “exact”. Explain how you can spot the order of convergence of
each method from your plot.

(You are free to use any method when asked about numerical values, including analytical/symbolic,
but please mention how you obtained your answer.)
MIT OpenCourseWare
http://ocw.mit.edu

18.330 Introduction to Numerical Analysis


Spring 2012

For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.

You might also like