Presentation is loading. Please wait.

Presentation is loading. Please wait.

ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical.

Similar presentations


Presentation on theme: "ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical."— Presentation transcript:

1 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege.edu Engr/Math/Physics 25 Chp9: ODE’s Numerical Solns

2 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 2 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Learning Goals  List Characteristics of Linear, MultiOrder, NonHomgeneous Ordinary Differential Equations (ODEs)  Solve ANALYTICALLLY, Linear, 2 nd Order, NonHomogeneous, Constant Coefficient ODEs  Use MATLAB to determine Numerical Solutions to Ordinary Differential Equations (ODEs)

3 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 3 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Differential Equations  Ordinary Diff Eqn  Partial Diff Eqn  PDE’s Not Covered in ENGR25 Discussed in More Detail in ENGR45  Examining the ODE, Note that it: is LINEAR → y, dy/dt, d 2 y/dt 2 all raised to Power of 1 2 nd ORDER → Highest Derivative is 2 is NONhomogenous → RHS  0; –i.e., y(t) has a FORCING Fcn f(t) has CONSTANT Coefficients

4 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 4 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Numerical ODE Solution  Today we’ll do some MTH25  We’ll “look under the hood” of NUMERICAL Solutions to ODE’s  The BASIC Game- Plan for even Sophisticated Solvers: Given a STARTING POINT, y(0) Use ODE to find dy/dt at t=0 ESTIMATE y 1 as

5 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 5 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Numerical Solution - 1  Notation  Exact Numerical Method (impossible to achieve) by Forward Steps  Now Consider y n+1 tntn ynyn t n+1 t tt

6 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 6 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Numerical Solution - 2  The diagram at Left shows that the relationship between y n, y n+1 and the CHORD slope y n+1 tntn ynyn t n+1 t tt  The problem with this formula is we canNOT calculate the chord slope exactly We Know Only Δt & y n, but NOT the NEXT Step y n+1 The Analyst Chooses Δt Chord Slope Tangent Slope

7 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 7 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Numerical Solution -3  However, we can calculate the TANGENT slope at any point FROM the differential equation itself  The Basic Concept for all numerical methods for solving ODE’s is to use the TANGENT slope, available from the R.H.S. of the ODE, to approximate the chord slope  Recognize dy/dt as the Tangent Slope

8 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 8 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Euler Method – 1 st Order  Solve 1 st Order ODE with I.C.  ReArranging  Use: [Chord Slope]  [Tangent Slope at start of time step]  Then Start the “Forward March” with Initial Conditions

9 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 9 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Euler Example  Consider 1 st Order ODE with I.C.  Use The Euler Forward-Step Reln  See Next Slide for the 1 st Nine Steps For Δt = 0.1  But from ODE  So In This Example:

10 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 10 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Euler Exmpl Calc ntntn ynyn f n = – y n +1 y n+1 = y n +  t f n 000.0001.0000.100 10.10.1000.9000.190 20.20.1900.8100.271 30.30.2710.7290.344 40.40.3440.6560.410 50.50.4100.5900.469 60.60.4690.5310.522 70.70.5220.4780.570 80.80.5700.4300.613 90.90.6130.3870.651 Plot Slope

11 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 11 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Euler vs Analytical  The Analytical Solution

12 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 12 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Analytical Soln  Let u = −y+1  Then  Sub for y & dy in ODE  Separate Variables  Integrate Both Sides  Recognize LHS as Natural Log  Raise “e” to the power of both sides

13 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 13 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Analytical Soln  And  Thus Soln u(t)  Sub u = 1−y  Now use IC  The Analytical Soln

14 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 14 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Predictor-Corrector - 1  Again Solve 1 st Order ODE with I.C.  Mathematically  This Time Let: Chord slope  average of tangent slopes at start and END of time step  BUT, we do NOT know y n+1 and it appears on the RHS... Avg of the Tangent Slopes at (t n,y n ) & (t n+1,y n+1 )

15 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 15 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Predictor-Corrector - 2  Use Two Steps to estimate y n+1  First → PREDICT*  Use y* in the Avg Calc  Then Correct  Then Start the “Forward March” with the Initial Conditions

16 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 16 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Predictor-Corrector Example  Solve ODE with IC  The Corrector step  The next Step Eqn for dy/dt = f(t,y)= –y+1  Numerical Results on Next Slide

17 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 17 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Predictor-Corrector Example n 000.0001.0000.1000.9000.095 10.10.0950.9050.1860.8150.181 20.20.1810.8190.2630.7370.259 30.30.2590.7410.3330.6670.329 40.40.3290.6710.3960.6040.393 Slope

18 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 18 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Predictor-Corrector  Greatly Improved Accuracy

19 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 19 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods ODE Example:  Euler Solution with ∆t = 0.25  The Solution Table

20 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 20 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Compare Euler vs. ODE45 Euler SolutionODE45 Solution Euler is Much LESS accurate

21 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 21 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Compare Again with ∆t = 0.025 Euler SolutionODE45 Solution Smaller ∆T greatly improves Result

22 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 22 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods MatLAB Code for Euler % Bruce Mayer, PE % ENGR25 * 04Jan11 % file = Euler_ODE_Numerical_Example_1201.m % y0= 37; delt = 0.25; t= [0:delt:10]; n = length(t); yp(1) = y0; % vector/array indices MUST start at 1 tp(1) = 0; for k = 1:(n-1) % fence-post adjustment to start at 0 dydt = 3.9*cos(4.2*yp(k))^2-log(5.1*tp(k)+6); dydtp(k) = dydt % keep track of tangent slope tp(k+1) = tp(k) + delt; dely = delt*dydt delyp(k) = dely yp(k+1) = yp(k) + dely; end plot(tp,yp, 'LineWidth', 3), grid, xlabel('t'),ylabel('y(t) by Euler'),... title('Euler Solution to dy/dt = 3.9cos(4.2y)-ln(5.1t+6)')

23 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 23 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods MatLAB Command Window for ODE45 >> dydtfcn = @(tf,yf) 3.9*(cos(4.2*yf))^2-log(5.1*tf+6); >> [T,Y] = ode45(dydtfcn,[0 10],[37]); >> plot(T,Y, 'LineWidth', 3), grid, xlabel('T by ODE45'), ylabel('Y by ODE45')

24 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 24 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods All Done for Today Carl Runge Carl David Tolmé Runge Born: 1856 in Bremen, Germany Died: 1927 in Göttingen, Germany

25 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 25 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege.edu Engr/Math/Physics 25 Appendix

26 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 26 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods 2 nd Order ODE SUMMARY-1  If NonHomogeneous Then find ANY Particular Solution  Next HOMOGENIZE the ODE  The Soln to the Homog. Eqn Produces the Complementary Solution, y c  Assume y c take this form

27 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 27 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods 2 nd Order ODE SUMMARY-2  Subbing yc = Ae s t into the Homog. Eqn yields the Characteristic Eqn  Find the TWO roots that satisfy the Char Eqn by Quadratic Formula  Check FORM of Roots  If s 1 & s 2 → REAL & UNequal Decaying Contant(s)

28 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 28 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods 2 nd Order ODE SUMMARY-3  If s 1 & s 2 → REAL & Equal, then s 1 = s 2 =s Decaying Line  If s 1 & s 2 → Complex Conjugates then Decaying Sinusoid  Add Particlular & Complementary Solutions to yield the Complete Solution

29 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 29 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods 2 nd Order ODE SUMMARY-4  To Find Constant Sets: (G 1, G 2 ), (m, b), (B 1, B 2 ) Take for COMPLETE solution  Find Number-Values for the constants to complete the solution process Yields 2 eqns in 2 for the 2 Unknown Constants

30 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 30 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Finite Difference Methods - 1  Another way of thinking about numerical methods is in terms of finite differences.  Use the Approximation  And From the Differential Eqn  From these two equations obtain:  Recognize as the Euler Method

31 BMayer@ChabotCollege.edu ENGR-25_Lec-21_Integ_Diff.ppt 31 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Finite Difference Methods - 2  Could make More Accurate by Approximating dy/dt at the Half-Step as the average of the end pts  Recognize as the Predictor-Corrector Method  Then Again Use the ODE to Obtain


Download ppt "ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical."

Similar presentations


Ads by Google