Upload
vanessa-parks
View
221
Download
4
Embed Size (px)
Citation preview
Review
• Taylor Series and Error Analysis• Roots of Equations• Linear Algebraic Equations• Optimization• Numerical Differentiation and Integration• Ordinary Differential Equations• Partial Differential Equations• Curve Fitting
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
1
Taylor Series
• Lagrange remainder
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
2
Roots of Equations
• Bracketing Methods• Bisection Method
• False Position Method
• Open Methods• Fixed Point Iteration
• Newton-Raphson Method
• Secant Method
• Roots of Polynomials• Müller’s Method
• Bairstow’s Method
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
3
Bisection Method
• Example:
• Use range of [202:204]
• Root is in upper subinterval
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
4
Bisection Method
• Use range of [203:204]
• Root is in lower subintervalNumerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
5
Fixed Point Iteration Example
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
6
Special attention
Read Chap 6.1, 6.6
Newton-Raphson Method
• Use tangent to guide you to the root
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
7
Linear Algebraic Systems
• Gaussian Elimination• Forward Elimination• Back Substitution
• LU Decomposition
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
8
Gaussian Elimination
• Forward elimination
• Eliminate x1 from row 2
• Multiply row 1 by a21/a11
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
9
Gaussian Elimination
• Eliminate x1 from row 2• Subtract row 1 from row 2
• Eliminate x1 from all other rows in the same way
• Then eliminate x2 from rows 3-n and so onNumerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
10
Gaussian Elimination
• Forward elimination
• Back substitute to solve for x
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
11
LU Decomposition
• Substitute the factorization into the linear system
• We have transformed the problem into two steps• Factorize A into L and U• Solve the two sub-problems
• LD = B• UX = D
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
12
LU Decomposition
• Example
• Factorize A using forward elimination
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
13
LU Decomposition
• Example
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
14
LU Decomposition
• Example
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
15
LU Decomposition
• Example
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
16
Optimization Methods• One-dimensional unconstrained optimization
• Golden-Section
• Quadratic Interpolation
• Newton’s Method
• Multidimensional unconstrained optimization• Direct Methods
• Gradient Methods
• Constrained Optimization• Linear Programming
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
17
Golden-section search
• Algorithm• Pick two interior points in the interval using the
golden ratio
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
18
Golden-section search
• Two possibilities
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
19
Golden-section search
• Example
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
20
Golden-section search
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
21
Golden-section search
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
22
Newton’s Method
• Newton-Raphson could be used to find the root of an function
• When finding a function optimum, use the fact that we want to find the root of the derivative and apply Newton-Raphson
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
23
Newton’s Method
• Example
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
24
Newton’s Method
• Example
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
25
Quadratic interpolation
• Use a second order polynomial as an approximation of the function near the optimum
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
26
Special attention
Gradient Methods
• Given a starting point, use the gradient to tell you which direction to proceed
• The gradient gives you the largest slope out from the current position
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
27
Special attention
Numerical Integration• Newton-Cotes
• Trapezoidal Rule• Simpson’s Rules (Special attention for
unevenly distributed points)
• Romberg Integration• Gauss Quadrature
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
28
Newton-Cotes Formulas• Trapezoidal Rule
• Simpson’s 1/3 Rule
• Simpson’s 3/8 Rule
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
29
Special attention
Read Chap 21.2-3
Integration of Equations
• Romberg Integration• Use two estimates of integration and then
extrapolate to get a better estimate
• Special case where you always halve the interval - i.e. h2=h1/2
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
30
Romberg Integration
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
31
Ordinary Differential Equations• Runge-Kutta Methods
• Euler’s Method• Heun’s Method• RK4
• Multistep Methods• Boundary Value Problems• Eigenvalue Problems
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
32
Euler’s Method
• Example:
• True:• h=0.5
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
33
Heun’s Method
• Local truncation error is O(h3) and global truncation error is O(h2)
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
34
Heun’s Method
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
35
Classic 4th-order R-K method
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
36
Special attention to
ODE equation system
Not only one equation
Curve Fitting
• Least Squares Regression• Interpolation• Fourier Approximation
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
37
Polynomial Regression• An mth order polynomial will require that you
solve a system of m+1 linear equations
• Standard error
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
38
Special attention
Lecture note 19
Chap 17.1
Newton (divided difference) Interpolation polynomials
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
39
Newton (divided difference) Interpolation polynomials
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
40
Interpolation• General Scheme for Divided Difference
Coefficients
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
41
Interpolation
• General Scheme for Divided Difference Coefficients
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
42
Interpolation
• Example:• Estimate ln 2 with data points at (1,0),
(4,1.386294)• Linear interpolation
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
43
Interpolation
• Example:• Estimate ln 2 with data points at (1,0),
(4,1.386294), (5,1.609438)• Quadratic interpolation
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
44
Interpolation
• Example:• Estimate ln 2 with data points at (1,0),
(4,1.386294), (5,1.609438), (6,1.791759)• Cubic interpolation
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
45
Spline Interpolation
• Spline interpolation applies low-order polynomial to connect two neighboring points and uses it to interpolate between them.
• Typical Spline functions
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
46
Cubic Spline Functions
• This gives us n-1 equation with n-1 unknowns – the second derivatives
• Once we solve for the second derivatives, we can plug it into the Lagrange interpolating polynomial for second derivative to solve for the splines
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
47
Cubic Spline Functions
• Example: (3,2.5), (4.5,1), (7,2.5), (9,0.5)• At x=x1=4
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
48
Cubic Spline Functions
• At x=x2=7
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
49
Cubic Spline Functions
• Solve the system of equations to find the second derivatives
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
50
Cubic Spline Equations
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
51
Cubic Spline Equations
• Substituting for other intervals
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
52
Final Exam• December 13 Friday, 10:30 AM~12:30
PM, ITE 119• Closed book, three cheat sheets
(8.5x11in) allowed • Office hours:
• December 12, 1-3pm, or by appointment• TA December 10, 11am-12noon or by
appointment
Numerical MethodsLecture 22
Prof. Jinbo BiCSE, UConn
53