MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 1 Bruce Mayer, PE Chabot College Mathematics Bruce Mayer, PE Licensed Electrical & Mechanical Engineer Chabot Mathematics §9.4 ODE Analytics
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 2 Bruce Mayer, PE Chabot College Mathematics Review § Any QUESTIONS About §9.3 Differential Equation Applications Any QUESTIONS About HomeWork §9.3 → HW
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 3 Bruce Mayer, PE Chabot College Mathematics §9.4 Learning Goals Analyze solutions of differential equations using slope fields Use Euler’s method for approximating solutions of initial value problems
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 4 Bruce Mayer, PE Chabot College Mathematics Slope Fields Recall that indefinite integration, or AntiDifferentiation, is the process of reverting a function from its derivative. In other words, if we have a derivative, the AntiDerivative allows us to regain the function before it was differentiated – EXCEPT for the CONSTANT, of course. Given the derivative dy / dx = f ‘ ( x ) then solving for y (or f ( x )), produces the General Solution of a Differential Eqn
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 5 Bruce Mayer, PE Chabot College Mathematics Slope Fields AntiDifferentiation (Separate Variables) Example Let: Then Separating the Variables: Now take the AntiDerivative: To Produce the General Solution: This Method Produces an EXACT and SYMBOLIC Solution which is also called an ANALYTICAL Solution
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 6 Bruce Mayer, PE Chabot College Mathematics Slope Fields Slope Fields, on the other hand, provide a Graphical Method for ODE Solution Slope, or Direction, fields basically draw slopes at various CoOrdinates for differing values of C. Example: The Slope Field for ODE
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 7 Bruce Mayer, PE Chabot College Mathematics Slope Fields slope field describes several different parabolas based on varying values of C Slope Field Example: create the slope field for the Ordinary Differential Eequation:
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 8 Bruce Mayer, PE Chabot College Mathematics Slope Fields Note that dy / dx = x / y calculates the slope at any ( x, y ) CoOrdinate point At ( x, y ) = (−2, 2), dy / dx = −2/2 = −1 At ( x, y ) = (−2, 1), dy / dx = −2/1 = −2 At ( x, y ) = (−2, 0), dy / dx = −2/0 = UnDef. And SoOn Produces OutLine of a HYPERBOLA
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 9 Bruce Mayer, PE Chabot College Mathematics Slope Fields Of course this Variable Separable ODE can be easily solved analytically
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 10 Bruce Mayer, PE Chabot College Mathematics Slope Fields Example For the given slope field, sketch two approximate solutions – one of which is passes through(4,2): Solve ODE Analytically using using (4,2) BC Soln
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 11 Bruce Mayer, PE Chabot College Mathematics Slope Field Identification C In order to determine a slope field from a differential equation, we should consider the following: isoclines i) If isoclines (points with the same slope) are along horizontal lines, then DE depends only on y ii) Do you know a slope at a particular point? iii) If we have the same slope along vertical lines, then DE depends only on x iv) Is the slope field sinusoidal? v) What x and y values make the slope 0, 1, or undefined? vi) dy/dx = a( x ± y ) has similar slopes along a diagonal. vii) Can you solve the separable DE? 1. _____ 2. _____ 3. _____ 4. _____ 5. _____ 6. _____ 7. _____ 8. _____ Match the correct DE with its graph: AB C E G D F H H B F D G E A
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 12 Bruce Mayer, PE Chabot College Mathematics Example Demand Slope Field Imagine that the change in fraction of a production facility’s inventory that is demanded, D, each period is given by Where p is the unit price in $k Draw a slope field to approximate a solution assuming a half-stocked (50%) inventory and $2k per item, and then Verify the Slope-Field solution using Separation of Variables. cc
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 13 Bruce Mayer, PE Chabot College Mathematics Example Demand Slope Field SOLUTION: Calculate some Slope Values from
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 14 Bruce Mayer, PE Chabot College Mathematics Example Demand Slope Field An approximate solution passing through (2,0.5) with slope field on the window 0 < x < 3 and 0 < y < 1
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 15 Bruce Mayer, PE Chabot College Mathematics Example Demand Slope Field Find an exact solution to this differential equation using separation of variables: Remove absolute-value and then change signs as inventory demanded satisfies: 0≤ D ≤1
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 16 Bruce Mayer, PE Chabot College Mathematics Example Demand Slope Field Removing ABS Bars Or Now use Boundary Value ($2k/unit,0.5)
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 17 Bruce Mayer, PE Chabot College Mathematics Example Demand Slope Field Graph for This is VERY SIMILAR to the Slope Field Graph Sketched Before
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 18 Bruce Mayer, PE Chabot College Mathematics Numerical ODE Solutions Next We’ll “look under the hood” of NUMERICAL Solutions to ODE’s The BASIC Game- Plan for even the most Sophisticated Solvers: Given a STARTING POINT, y(0) Use ODE to find dy/dt at t=0 ESTIMATE y 1 as
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 19 Bruce Mayer, PE Chabot College Mathematics Numerical Solution - 1 Notation Exact Numerical Method (impossible to achieve) by Forward Steps Now Consider y n+1 tntn ynyn t n+1 t tt
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 20 Bruce Mayer, PE Chabot College Mathematics 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 tt 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
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 21 Bruce Mayer, PE Chabot College Mathematics 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
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 22 Bruce Mayer, PE Chabot College Mathematics Euler Method – 1 st Order ODE 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
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 23 Bruce Mayer, PE Chabot College Mathematics Example Euler Estimate 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:
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 24 Bruce Mayer, PE Chabot College Mathematics Euler Exmple Calc ntntn ynyn f n = – y n +1 y n+1 = y n + t f n Plot Slope
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 25 Bruce Mayer, PE Chabot College Mathematics Euler vs Analytical The Analytical Solution
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 26 Bruce Mayer, PE Chabot College Mathematics 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
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 27 Bruce Mayer, PE Chabot College Mathematics Analytical Soln And Thus Soln u(t) Sub u = 1−y Now use IC The Analytical Soln
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 28 Bruce Mayer, PE Chabot College Mathematics ODE Example: Euler Solution with ∆t = 0.25, y(t=0) = 37 The Solution Table
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 29 Bruce Mayer, PE Chabot College Mathematics Compare Euler vs. ODE45 Euler SolutionODE45 Solution Euler is Much LESS accurate
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 30 Bruce Mayer, PE Chabot College Mathematics Compare Again with ∆t = Euler SolutionODE45 Solution Smaller ∆T greatly improves Result
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 31 Bruce Mayer, PE Chabot College Mathematics 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)')
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 32 Bruce Mayer, PE Chabot College Mathematics MatLAB Command Window for ODE45 >> dydtfcn 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')
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 33 Bruce Mayer, PE Chabot College Mathematics Example Euler Approximation Use four steps of Δt = 0.1 with Euler’s Method to approximate the solution to With I.C. SOLUTION: Make a table of values, keeping track of the current values of t and y, the derivative at that point, and the projected next value.
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 34 Bruce Mayer, PE Chabot College Mathematics Example Euler Approximation Use I.C. to calculate the Initial Slope Use this slope to Project to the NEW value of y n+1 = y n + Δ y : Then the NEW value for y:
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 35 Bruce Mayer, PE Chabot College Mathematics Example Euler Approximation Tabulating the remaining Calculations The table then DEFINES y = f ( t ) Thus, for example, y ( t =0.3) = 1.685
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 36 Bruce Mayer, PE Chabot College Mathematics WhiteBoard Work Problems From §9.4 P32 Population Extinction
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 37 Bruce Mayer, PE Chabot College Mathematics All Done for Today Carl Runge Carl David Tolmé Runge Born: 1856 in Bremen, Germany Died: 1927 in Göttingen, Germany
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 38 Bruce Mayer, PE Chabot College Mathematics Bruce Mayer, PE Licensed Electrical & Mechanical Engineer Chabot Mathematics Appendix –
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 39 Bruce Mayer, PE Chabot College Mathematics
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 40 Bruce Mayer, PE Chabot College Mathematics
MTH16_Lec-14_sec_9-4_ODE_SlopeFields_Euler.pptx 41 Bruce Mayer, PE Chabot College Mathematics