MATH-321 In One Slide MATH-321 & MATLAB Command
Final Exam From Coordinator 1. Formulas for the error bounds and RK methods will be provided if needed. 2. The exam consists of written questions on the new material and MCQs on the old material. 3. Two questions about Matlab .
Formula Error Equation Some Comments on Root finding Formula Error Equation Newton’s 𝑝 𝑛 = 𝑝 𝑛−1 − 𝑓( 𝑝 𝑛−1 ) 𝑓′( 𝑝 𝑛−1 ) Secant 𝑝 𝑛 = 𝑝 𝑛−1 − 𝑓( 𝑝 𝑛−1 )( 𝑝 𝑛−1 − 𝑝 𝑛−2 ) 𝑓 𝑝 𝑛−1 −𝑓( 𝑝 𝑛−2 ) 𝑝 𝑛 = 𝑎 𝑛−1 + 𝑏 𝑛−1 2 𝑝 ∗ − 𝑝 𝑛 ≤ 𝑏−𝑎 2 𝑛 Bisection Fixed-point 𝑝 𝑛 =𝑓( 𝑝 𝑛−1 ) 𝑔′(𝑥) ≤𝑘 ∀𝑥
Sec:4.1 Numerical Differentiation Backward-difference Formula 𝑓 ′ 𝒙 𝟎 = 𝑓 𝒙 𝟎 −𝑓( 𝒙 𝟎 −𝒉) ℎ + ℎ 2 𝑓′′(𝜉) Forward-difference Formula 𝑓 ′ 𝒙 𝟎 = 𝑓 𝒙 𝟎 +𝒉 −𝑓( 𝒙 𝟎 ) ℎ − ℎ 2 𝑓′′(𝜉) where 𝜉 between 𝒙 𝟎 and 𝒙 𝟎 −𝐡 𝒙 𝟎 −𝐡 𝒙 𝟎 where 𝜉 between 𝒙 𝟎 and 𝒙 𝟎 +𝐡 𝒙 𝟎 𝒙 𝟎 +𝐡 Central Difference for f’(x) 𝒙 𝟎 −𝐡 𝒙 𝟎 𝒙 𝟎 +𝐡 Central Difference for f’’(x) 𝒙 𝟎 −𝐡 𝒙 𝟎 𝒙 𝟎 +𝐡
Sec:4.3 Elements of Numerical Integration The Trapezoidal Rule 𝑎 𝑏 𝑓 𝑥 𝑑𝑥 = 𝒉 𝟐 𝒇 𝒙 𝟎 +𝒇 𝒙 𝟏 − 𝒉 𝟑 𝟏𝟐 𝒇 ′′ 𝝃 ℎ=𝑏−𝑎 Simpson’s Rule 𝑎 𝑏 𝑓 𝑥 𝑑𝑥 = 𝒉 𝟑 𝒇 𝒙 𝟎 +𝟒𝒇 𝒙 𝟏 +𝒇( 𝒙 𝟐 ) − 𝒉 𝟓 𝟗𝟎 𝒇 𝟒 𝝃 ∗ ℎ=(𝑏−𝑎)/2 The midpoint Rule 𝑎 𝑏 𝑥 0 𝒚=𝒇(𝒙) 𝑎 𝑏 𝑓 𝑥 𝑑𝑥 =(𝒃−𝒂)𝒇 𝒂+𝒃 𝟐 + 𝒉 𝟑 𝟑 𝒇 ′′ 𝝃 𝑥 0 =(𝑏+𝑎)/2
Sec:5.2 EULER’S METHOD Euler’s Method 𝑤 𝑖+1 = 𝑤 𝑖 +ℎ𝑓 𝑡 𝑖 , 𝑤 𝑖 𝑤 0 =𝛼
Sec:3.3 Divided Differences Example 𝒙 𝒊 𝒇(𝒙 𝒊 ) 1 3 2 6 3 19 5 99 Calculate f (4) using Newton’s interpolating polynomials of order 3. Given the data 𝒙 𝒊 𝒇[𝒙 𝒊 ] First Second Third 1 3 2 6 19 5 99 𝟑 𝟓 𝟏𝟑 𝟏 𝟗 𝟒𝟎 𝒑 𝟑 𝒙 =𝟑+𝟑 𝒙−𝟏 +𝟓 𝒙−𝟏 𝒙−𝟐 +𝟏(𝒙−𝟏)(𝒙−𝟐)(𝒙−𝟑) The coefficients of the Newton forward divided-difference form of the interpolating polynomial are along the diagonal in the table. 𝒑 𝟑 𝟒 =𝟒𝟖
MATH-321 and MATLAB Command Root-finding (Ch.2) Numerical Differentiation Initial Value Prob (IVP) (Ch.4) (Ch.5) The Bisection Method Euler Mod. Euler Huen’s RK4 Forward Difference Ode45, ode23, ode113, ode15s, ode23s, ode23t, ode23tb, ode15i, Fixed- Point Iteration Newton's Method Backward Difference Secant Method Central Difference y’ Central Difference y’’ f=@(x) x^3+x+1; fzero(f,1) Linear System (Ch.6,7) h=0.01; x=0:h:pi/2; diff(sin(x))/h \ linsolve pcg minres Gmres lu Gaussian elim Jacobi Gauss-Seidel LU fact roots([1 0 1 1]) Numerical integration (Ch.4) Interpolation (Ch.3) Midpoint Trapozidal Simpson’s Composite Lagrange Poly integral, trapz, quad Divided Differences Least Squares (Ch.8) Cubic Spline \ linsolve spline , interp1 , csape f=@(x) x.^3+x+1; quad(f,0,1) Finite-Difference Methods integral(f,0,1) (Ch.11)
After EXAM-2
Sec:11.3 Finite-Difference Methods for Linear Problems cq19 Final171 𝒚(𝒙 𝒊+𝟏 )−𝟐𝒚( 𝒙 𝒊 )+ 𝒚(𝒙 𝒊−𝟏 ) 𝒉 𝟐 +𝟑 𝒚(𝒙 𝒊+𝟏 )− 𝒚(𝒙 𝒊−𝟏 ) 𝟐𝒉 2 𝒚 (𝒙 𝒊 ) ≈ − 2 𝒙 𝒊 +𝟑 𝒘 𝒊+𝟏 −𝟐 𝒘 𝒊 + 𝒘 𝒊−𝟏 𝒉 𝟐 +𝟑 𝒘 𝒊+𝟏 − 𝒘 𝒊−𝟏 𝟐𝒉 −𝟐 𝒘 𝒊 =𝟐 𝒙 𝒊 +𝟑
Sec:7.3 The Jacobi and Gauss-Siedel Iterative Techniques Example Keep the diagonal on the left hand side Use GS to find the second iteraton GS Method Change the coeff of LHS to be one by division 𝒙 (𝟎) =(𝟎,𝟎,𝟎,𝟎 ) 𝑻 find 𝒙 (𝟐)
Sec:7.3 The Jacobi and Gauss-Siedel Iterative Techniques Convergence Criterion for the Gauss-Seidel Method Definition A is strictly diagonally dominant That is, the diagonal coefficient in each of the equations must be larger than the sum of the absolute values of the other coefficients in the equation 𝑎 𝑖𝑖 > 𝑗=1 𝑗≠𝑖 𝑛 𝑎 𝑖𝑗 , 𝑓𝑜𝑟 𝑎𝑙𝑙 𝑖 Example Example1 Use GS to find the second iteraton 10 -1 2 0 -1 11 -1 3 2 -1 10 -1 0 3 -1 -8 THM: A is strictly diagonally dominant
𝑨=𝑳𝑼 𝑳= 𝑼= Sec:6.5 Matrix Factorization LU factorization Find -2R1+R2R2 -3R2+R3R3 -4R2+R4R4 -4R1+R3R3 -3R1+R4R4 -R3+R4R4 𝑳= 𝑼= Solve 𝑳𝑼𝒙 =[𝟏,𝟏,𝟏,𝟏] 𝑻 𝑨𝒙=𝒃 1 𝑳𝒚=𝒃 𝑳𝑼𝒙=𝒃 2 𝑼𝒙=𝒚
𝑼= Sec:6.1 Linear systems of Equations 𝑷= (Pivoting) 𝑷𝑨= -2R1+R2R2 permutation matrix 𝑷= -(4/3)R2+R4R4 𝑷𝑨= (2/3)R3+R4R4 𝑼=
3 Cases: Sec:6.1 Linear systems of Equations unique solution infinite number of solutions no solution
Sec:8.1 Discrete Least Squares Approximation Fit the data in Table with the discrete least squares polynomial of degree at most 2. Derivation for linear or polynomial of degree two 𝒑 𝟐 (𝒙) = 𝒂 𝟎 + 𝒂 𝟏 𝒙+ 𝒂 𝟐 𝒙 𝟐 Matrix Form = 𝒊=𝟏 𝒎 𝒚 𝒊 − 𝒂 𝟎 − 𝒂 𝟏 𝒙 𝒊 𝟐 1.0 1.284 1.6487 2.117 2.7183 = 1 0 0 2 1 0.25 0.25 2 1 0.5 0.5 2 1 0.75 0.75 2 1 1 1 2 𝒂 𝟎 𝒂 𝟏 𝒂 𝟐 𝑬 𝒂 𝟎 , 𝒂 𝟏 𝝏𝑬 𝝏 𝒂 𝟎 =𝟎 𝝏𝑬 𝝏 𝒂 𝟏 =𝟎 8.7680 30.5736 122.8038 5 15 55 15 55 225 55 225 979 𝒂 𝟎 𝒂 𝟏 𝒂 𝟐 = 𝑚 𝒙 𝒊 𝑥 𝑖 2 𝒙 𝒊 𝑥 𝑖 2 𝑥 𝑖 3 𝑥 𝑖 2 𝑥 𝑖 3 𝑥 𝑖 4 𝒂 𝟎 𝒂 𝟏 𝒂 𝟐 = 𝒚 𝒊 𝒙 𝒊 𝒚 𝒊 𝑥 𝑖 2 𝒚 𝒊
EXAM-1 and EXAM-2
first divided difference second divided difference Sec:3.3 Divided Differences Example 𝒙 𝑓[𝑥] 𝑥 0 =1 𝑓[ 𝑥 0 ] =1 𝑥 1 =2 𝑓[ 𝑥 1 ] =8 𝑥 2 =4 𝑓 𝑥 2 = 14 Fit a second-order polynomial to the three points 𝒙 𝑓[𝑥] first divided difference second divided difference 𝑥 0 =1 𝑓[ 𝑥 0 ] =1 𝑓 𝑥 0 , 𝑥 1 = 8−1 2−1 =7 𝑥 1 =2 𝑓[ 𝑥 1 ] =8 𝑓 𝑥 1 , 𝑥 2 = 14−8 4−2 =3 𝑥 2 =4 𝑓 𝑥 2 = 14 = 𝒇 𝒙 𝟏 , 𝒙 𝟐 −𝒇 𝒙 𝟎 , 𝒙 𝟏 𝒙 𝟐 − 𝒙 𝟎 = 𝟑−𝟕 𝟒−𝟏 =− 𝟒 𝟑 𝒇 𝒙 𝟎 , 𝒙 𝟏 , 𝒙 𝟐 𝑝 2 𝑥 =𝒇[ 𝒙 𝟎 ]+𝒇[ 𝒙 𝟎 , 𝒙 𝟏 ] 𝒙− 𝑥 0 +𝒇[ 𝒙 𝟎 , 𝒙 𝟏 , 𝒙 𝟐 ] 𝒙− 𝑥 0 𝒙− 𝑥 1 𝑝 2 𝑥 =𝟏+𝟕 𝒙−1 − 𝟒 𝟑 𝒙−1 𝒙−2
Sec:5.2 The Bisection Method Example: Use Bisection method to find the root of the function 𝑓 (𝑥) = 10 𝑥 6 −149 𝑥 5 +10𝑥−149 10( 𝑥 4 +1) in [12, 16] 12 16 Change of sign -34.8 17.6 𝒙 𝟏 = True root: 𝑥 𝑟 ∗ =14.9 12 14 Change of sign 16 Iter1 𝒏 𝒙 𝒏 -34.8 -12.6 17.6 1 14.0000000000 2 15.0000000000 3 14.5000000000 4 14.7500000000 5 14.8750000000 6 14.9375000000 7 14.9062500000 8 14.8906250000 9 14.8984375000 10 14.9023437500 11 14.9003906250 12 14.8994140625 13 14.8999023438 14 14.9001464844 15 14.9000244141 16 14.8999633789 𝒙 𝟐 = 14 15 16 Iter2 Change of sign -12.6 1.5 17.6 𝒙 𝟑 = Change of sign 14.5 14 15 Iter3 -5.8 1.5 -12.6
Sec:6.1 Fixed- Point Iteration Step 1 Example1 Use simple fixed-point iteration to locate the root of 𝒇 𝒙 = 𝒆 −𝒙 −𝒙 rearranging the function 𝒙= 𝒆 −𝒙 𝒙=𝒈(𝒙) 𝒙 𝒏 Step 2 𝒏 𝒙 𝒊+𝟏 =𝒈( 𝒙 𝒊 ) 1 0.0000000000000 2 1.0000000000000 3 0.3678794411714 4 0.6922006275553 5 0.5004735005636 6 0.6062435350856 7 0.5453957859750 8 0.5796123355034 9 0.5601154613611 10 0.5711431150802 11 0.5648793473910 12 0.5684287250291 𝒙 𝒊+𝟏 = 𝒆 − 𝒙 𝒊 Starting with an initial guess of x0 = 0 𝒙 𝟏 =𝒈 𝒙 𝟎 = 𝒆 −𝟎 =𝟏 𝒙 𝟐 =𝒈 𝒙 𝟏 = 𝒆 −𝟏 =0.367879 𝒙 𝟑 =𝒈 𝒙 𝟐 = 𝒆 −𝟎.𝟑𝟔𝟕𝟖𝟕𝟗 =0.692201 ⋮ ⋮ ⋮ ⋮ Thus, each iteration brings the estimate closer to the true value of the root: 0.56714329
Sec:2.3 Newton’s Method and Its Extensions Backward difference 𝑓 ′ 𝑥 𝑛 ≈ 𝑓 𝑥 𝑛 −𝑓( 𝑥 𝑛−1 ) 𝑥 𝑛 − 𝑥 𝑛−1 To approximate the roots of 𝑓 𝑥 =0 Given initial guess 𝑥 1 The Secant Method 𝑥 𝑛+1 = 𝑥 𝑛 − 𝑓( 𝑥 𝑛 ) 𝑓′( 𝑥 𝑛 ) 𝑥 𝑛+1 = 𝑥 𝑛 − 𝑓( 𝑥 𝑛 )( 𝑥 𝑛 − 𝑥 𝑛−1 ) 𝑓 𝑥 𝑛 −𝑓( 𝑥 𝑛−1 )
Sec:5.2 EULER’S METHOD 𝑡 𝑖 𝑤 𝑖 𝑦(𝑡 𝑖 ) Example 𝑤 𝑖+1 = 𝑤 𝑖 +ℎ 𝑤 𝑖 − 𝑡 𝑖 2 +1 𝑤 0 = 0.5 Use Euler’s method with h = 0.4 to approximate the solutions for the following initial-value problems 𝑤 1 = 𝑤 0 +ℎ 𝑤 0 − 𝑡 0 2 +1 =0.5+0.4 0.5−0+1 𝑦 ′ =𝑦− 𝑡 2 +1 0≤ 𝑡 ≤2, 𝑦(0) = 0.5 =1.1 →𝑦(0.4)≈1.1 𝑤 2 = 𝑤 1 +ℎ 𝑤 1 − 𝑡 1 2 +1 =1.1+0.4 1.1− 0.4 2 +1 𝒘 𝟎 𝒘 𝟏 𝒘 𝟐 𝒘 𝟑 𝒘 𝟒 𝒘 𝟓 =1.876 →𝑦(0.8)≈1.876 𝒕 𝟎 𝒕 𝟏 𝒕 𝟐 𝒕 𝟑 𝒕 𝟒 𝒕 𝟓 0.4 0.8 1.2 1.6 2 0.0 0.5000 0.5000 0.4 1.1000 1.2141 0.8 1.8760 2.1272 1.2 2.7704 3.1799 1.6 3.7026 4.2835 2.0 4.5596 5.3055 𝑡 𝑖 𝑤 𝑖 𝑦(𝑡 𝑖 ) Euler’s Method 𝑦 ′ =𝑓 𝑡,𝑦 𝑎≤ 𝑡 ≤𝑏, 𝑦(𝑎) =𝛼 𝑤 𝑖+1 = 𝑤 𝑖 +ℎ𝑓 𝑡 𝑖 , 𝑤 𝑖 𝑤 0 =𝛼
Sec:5.2 EULER’S METHOD 𝑡 𝑖 𝑤 𝑖 𝑦(𝑡 𝑖 ) Example Euler’s Method 𝑦 ′ =𝑦− 𝑡 2 +1 0≤ 𝑡 ≤4, 𝑦(0) = 0.5 Euler’s Method 𝑤 𝑖+1 = 𝑤 𝑖 +ℎ 𝑤 𝑖 − 𝑡 𝑖 2 +1 𝑤 0 = 0.5 𝑡 𝑖 𝑤 𝑖 𝑦(𝑡 𝑖 ) 𝒚(𝒕)= (𝒕+ 𝟏) 𝟐 − 𝟎.𝟓 𝒆 𝒕 𝑻𝒓𝒖𝒆 0.0 0.5000 0.5000 0.4 1.1000 1.2141 0.8 1.8760 2.1272 1.2 2.7704 3.1799 1.6 3.7026 4.2835 2.0 4.5596 5.3055 2.4 5.1834 6.0484 2.8 5.3528 6.2177 3.2 4.7579 5.3737 3.6 2.9651 2.8609 4.0 -0.6329 -2.2991 𝑬𝒖𝒍𝒆𝒓