Presentation is loading. Please wait.

Presentation is loading. Please wait.

MATH-321 In One Slide MATH-321 & MATLAB Command.

Similar presentations


Presentation on theme: "MATH-321 In One Slide MATH-321 & MATLAB Command."— Presentation transcript:

1 MATH-321 In One Slide MATH-321 & MATLAB Command

2 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 .

3 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 ) 𝑔′(𝑥) ≤𝑘 ∀𝑥

4 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) 𝒙 𝟎 −𝐡 𝒙 𝟎 𝒙 𝟎 +𝐡

5 Sec:4.3 Elements of Numerical Integration
The Trapezoidal Rule 𝑎 𝑏 𝑓 𝑥 𝑑𝑥 = 𝒉 𝟐 𝒇 𝒙 𝟎 +𝒇 𝒙 𝟏 − 𝒉 𝟑 𝟏𝟐 𝒇 ′′ 𝝃 ℎ=𝑏−𝑎 Simpson’s Rule 𝑎 𝑏 𝑓 𝑥 𝑑𝑥 = 𝒉 𝟑 𝒇 𝒙 𝟎 +𝟒𝒇 𝒙 𝟏 +𝒇( 𝒙 𝟐 ) − 𝒉 𝟓 𝟗𝟎 𝒇 𝟒 𝝃 ∗ ℎ=(𝑏−𝑎)/2 The midpoint Rule 𝑎 𝑏 𝑥 0 𝒚=𝒇(𝒙) 𝑎 𝑏 𝑓 𝑥 𝑑𝑥 =(𝒃−𝒂)𝒇 𝒂+𝒃 𝟐 + 𝒉 𝟑 𝟑 𝒇 ′′ 𝝃 𝑥 0 =(𝑏+𝑎)/2

6 Sec:5.2 EULER’S METHOD Euler’s Method 𝑤 𝑖+1 = 𝑤 𝑖 +ℎ𝑓 𝑡 𝑖 , 𝑤 𝑖 𝑤 =𝛼

7 Sec:3.3 Divided Differences
Example 𝒙 𝒊 𝒇(𝒙 𝒊 ) 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. 𝒑 𝟑 𝟒 =𝟒𝟖

8 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’’ 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([ ]) 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 x.^3+x+1; quad(f,0,1) Finite-Difference Methods integral(f,0,1) (Ch.11)

9 After EXAM-2

10 Sec:11.3 Finite-Difference Methods for Linear Problems
cq19 Final171 𝒚(𝒙 𝒊+𝟏 )−𝟐𝒚( 𝒙 𝒊 )+ 𝒚(𝒙 𝒊−𝟏 ) 𝒉 𝟐 +𝟑 𝒚(𝒙 𝒊+𝟏 )− 𝒚(𝒙 𝒊−𝟏 ) 𝟐𝒉 2 𝒚 (𝒙 𝒊 ) 2 𝒙 𝒊 +𝟑 𝒘 𝒊+𝟏 −𝟐 𝒘 𝒊 + 𝒘 𝒊−𝟏 𝒉 𝟐 +𝟑 𝒘 𝒊+𝟏 − 𝒘 𝒊−𝟏 𝟐𝒉 −𝟐 𝒘 𝒊 =𝟐 𝒙 𝒊 +𝟑

11 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 𝒙 (𝟐)

12 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 THM: A is strictly diagonally dominant

13 𝑨=𝑳𝑼 𝑳= 𝑼= Sec:6.5 Matrix Factorization LU factorization Find
-2R1+R2R2 -3R2+R3R3 -4R2+R4R4 -4R1+R3R3 -3R1+R4R4 -R3+R4R4 𝑳= 𝑼= Solve 𝑳𝑼𝒙 =[𝟏,𝟏,𝟏,𝟏] 𝑻 𝑨𝒙=𝒃 1 𝑳𝒚=𝒃 𝑳𝑼𝒙=𝒃 2 𝑼𝒙=𝒚

14 𝑼= Sec:6.1 Linear systems of Equations 𝑷= (Pivoting) 𝑷𝑨= -2R1+R2R2
permutation matrix 𝑷= -(4/3)R2+R4R4 𝑷𝑨= (2/3)R3+R4R4 𝑼=

15 3 Cases: Sec:6.1 Linear systems of Equations unique solution
infinite number of solutions no solution

16 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 = 𝒊=𝟏 𝒎 𝒚 𝒊 − 𝒂 𝟎 − 𝒂 𝟏 𝒙 𝒊 𝟐 = 𝒂 𝟎 𝒂 𝟏 𝒂 𝟐 𝑬 𝒂 𝟎 , 𝒂 𝟏 𝝏𝑬 𝝏 𝒂 𝟎 =𝟎 𝝏𝑬 𝝏 𝒂 𝟏 =𝟎 8.7680 𝒂 𝟎 𝒂 𝟏 𝒂 𝟐 = 𝑚 𝒙 𝒊 𝑥 𝑖 𝒙 𝒊 𝑥 𝑖 𝑥 𝑖 𝑥 𝑖 𝑥 𝑖 𝑥 𝑖 𝒂 𝟎 𝒂 𝟏 𝒂 𝟐 = 𝒚 𝒊 𝒙 𝒊 𝒚 𝒊 𝑥 𝑖 2 𝒚 𝒊

17 EXAM-1 and EXAM-2

18 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

19 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 𝒙 𝟐 = 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

20 Sec:6.1 Fixed- Point Iteration
Step 1 Example1 Use simple fixed-point iteration to locate the root of 𝒇 𝒙 = 𝒆 −𝒙 −𝒙 rearranging the function 𝒙= 𝒆 −𝒙   𝒙=𝒈(𝒙)  𝒙 𝒏 Step 2 𝒏 𝒙 𝒊+𝟏 =𝒈( 𝒙 𝒊 ) 𝒙 𝒊+𝟏 = 𝒆 − 𝒙 𝒊   Starting with an initial guess of x0 = 0 𝒙 𝟏 =𝒈 𝒙 𝟎 = 𝒆 −𝟎 =𝟏 𝒙 𝟐 =𝒈 𝒙 𝟏 = 𝒆 −𝟏 = 𝒙 𝟑 =𝒈 𝒙 𝟐 = 𝒆 −𝟎.𝟑𝟔𝟕𝟖𝟕𝟗 = Thus, each iteration brings the estimate closer to the true value of the root:

21 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 )

22 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+1 𝑦 ′ =𝑦− 𝑡 2 +1 0≤ 𝑡 ≤2, 𝑦(0) = 0.5 =1.1 →𝑦(0.4)≈1.1 𝑤 2 = 𝑤 1 +ℎ 𝑤 1 − 𝑡 = − 𝒘 𝟎 𝒘 𝟏 𝒘 𝟐 𝒘 𝟑 𝒘 𝟒 𝒘 𝟓 =1.876 →𝑦(0.8)≈1.876 𝒕 𝟎 𝒕 𝟏 𝒕 𝟐 𝒕 𝟑 𝒕 𝟒 𝒕 𝟓 0.4 0.8 1.2 1.6 2 𝑡 𝑖 𝑤 𝑖 𝑦(𝑡 𝑖 ) Euler’s Method 𝑦 ′ =𝑓 𝑡,𝑦 𝑎≤ 𝑡 ≤𝑏, 𝑦(𝑎) =𝛼 𝑤 𝑖+1 = 𝑤 𝑖 +ℎ𝑓 𝑡 𝑖 , 𝑤 𝑖 𝑤 =𝛼

23 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 𝑡 𝑖 𝑤 𝑖 𝑦(𝑡 𝑖 ) 𝒚(𝒕)= (𝒕+ 𝟏) 𝟐 − 𝟎.𝟓 𝒆 𝒕 𝑻𝒓𝒖𝒆 𝑬𝒖𝒍𝒆𝒓


Download ppt "MATH-321 In One Slide MATH-321 & MATLAB Command."

Similar presentations


Ads by Google