NEWS:
- The Final Exam will be on Tuesday, May 16, 1:30-3:30pm in MTH0409.
You can bring a cheat sheet: letter size, two-sided, must be handwritten.
The final exam covers the topics of the two exams (see below), and Numerical Integration.- I will post the solution of Assignment 7 on Tue, May 9 at 10pm. No homeworks will be accepted after that time.
- Assignment 7 was handed out on May 3. It is due on Monday, May 8.
Solution: Problems 1,2 , Problem 3
Problem 2: It should say: We want to approximate integral I = ...
Problem 3: The exact value for the integral is I=0.460730475133672 (computed with vpaintegral)
Problem 3(a): In order to find the number of function evaluations write your function as an m-file f.m as follows: E.g., for f(x)=x·sin(x) we would usefunction y = f(x) global NEV % keep track of number of function evaluations NEV NEV = NEV + length(x); y = x.*sin(x); % IMPORTANT: use .* ./ .^ instead of * / ^and then use e.g.global NEV % declare NEV as global variable NEV=0; Q = integral(@f,a,b,'RelTol',1e-3,'AbsTol',1e-3) NEV % number of function evaluations used for "integral"Problem 3(b),(c): Look at the example for Gauss-Legendre quadrature and Gauss-Jacobi quadrature below. Choose alpha, beta appropriately for 3(c).- Exam 2 was on Monday, May 1.
Solution
Practice problems
It will coverNonlinear least squares and numerical integration will NOT be on the exam.
- interpolation with polynomials: divided difference algorithm, error formula
(piecewise polynomials and splines will NOT be on the exam)- linear least squares problem: (i) normal equations, (ii) orthogonalization
You do NOT have to perform Gram-Schmidt to find decomposition A=PS or Q=QR. But if you are given A=PS or A=QR you have to know how to use it to solve the least squares problem.- one nonlinear equation: bisection method, secant method, Newton method
- nonlinear system: Newton method
Contraction mapping theorem- you need to know how to use the Matlab commands qr, \, fzero, fsolve.
Solution of practice problems- I posted the solution of Assignment 6 on April 27. No late homework submissions will be accepted on April 27 or later.
- Assignment 6 was DUE ON APRIL 25, 9pm at my office MATH4409 (write submission day/time on homework)
Solution: Problem 1, Problem 2, Problem 3, Problem 4, Problem 5- Read Numerical Integration (updated!), Adaptive numerical integration, how to use the Matlab command integral(see below)
- Nonlinear least squares problem: Example for Gauss-Newton method and lsqnonlin
- Assignment 6 was handed out on April 14, it is due on April 24.
- Assignment 5 was handed out on March 31, due on April 10.
Solution: Problem 1, Problem 2, Problem 3, Problem 4- How to import CO2 data from NOAA into Matlab
- Read the notes on the linear least squares problem and the example for least squares problem
- Read the material about piecewise linear interpolation, piecewise cubic Hermite interpolation, cubic spline interpolation.
Look at the example for piecewise cubic interpolation methods- Read the material about interpolation with multiple nodes
- Example from class: Polynomial interpolation with equidistant and Chebyshev nodes
- Exam 1 was on Wed, March 15. solution
The exam covers the material of Assignments 1 through 4:The following topics will NOT be on the exam: invnormest, sparse matrix type in Matlab, interpolation.
- Taylor approximation, error propagation, roundoff error, condition number, numerically stable/unstable algorithms
- Gaussian elimination without/with pivoting, Cholesky decomposition, norms, condition of a matrix, residuals
- Matlab commands lu, \, chol
practice problems
solution- Try out polynomial interpolation!
- Assignment 4 was posted on Feb. 27, it is due on March 6.
Solution: Problems 1,2, Problems 3, Problems 4, Problems 5- Assignment 3, due Feb. 24 (posted Feb. 16)
Solution: problem 1, problem 2, problem 3- Assignment 2 was handed out on Feb. 3, it was due on Feb. 13.
Solution- Assignment 1 was handed out on Jan. 27, it was due on Feb. 6.
- Please read the information below about Matlab.
Information about exams, homeworks, grades
c1 = norm(A,1)*invnormest(L,U)For the ∞-norm condition number use
ci = norm(A,Inf)*invnormest(U',L')For the Cholesky decomposition use invnormest(C',C). The m-file invnormest_simple.m explains the basic algorithm for estimating ||A-1||
A = sparse(iv,jv,av);Example: The full matrix given by A = [0 7 0; 0 0 8; 9 0 0] can be defined as a sparse matrix by
A = sparse([1 2 3],[2 3 1],[7 8 9])
h = (b-a)/(n-1); xj = a + (j-1)h for j = 1,...,nMatlab: x = linspace(a,b,n)
xj = (a+b)/2 + cos(π(j-1/2)/n)·(b-a)/2 for j = 1,...,n.The node polynomial has the bound
|(x-x1)...(x-xn)| ≤ 2 ((b-a)/4)n for x in [a,b]
x
contains the x-coordinates of the nodes, the column
vector y
contains the function values at the nodes, the
vector yp
contains the derivatives at the nodes. The vector
xi
contains the points where we want to evaluate the
interpolating function, the vector yi
contains the
corresponding values of the interpolating function.
hermite.m
. Then use yi =
hermite(x,y,yp,xi)
yi = spline(x,[sl;y;sr],xi)
yi =
spline(x,y,xi)
xs = fzero(@f,[a,b])
Here the function f is given in the m-file f.m. If the function f is defined by an @-expression use xs=fzero(f,[a,b])
.
f=@(x)sin(x); xs=fzero(f,[3,4])
function y = f(x)Then use x = fsolve(@f,x0) where x0 is the initial guess.
y = ...
opt = optimset('TolFun',1e-5,'TolX',1e-5);There are many other options (e.g., display each iteration, or use the Jacobian) , type doc fsolve for more information.
x = fsolve(@f,x0,opt);
We will use Matlab to see how various algorithms work.
How to hand in Matlab results for homeworks:
How to use the publish command in Matlab: