Slope Fields and Numerical Solutions - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

Slope Fields and Numerical Solutions

Description:

Ideal goal: find functions y(t) that satisfy the differential equation ... syntax is very picky: don't expect to guess at it and have it work ... – PowerPoint PPT presentation

Number of Views:67
Avg rating:3.0/5.0
Slides: 20
Provided by: alanab2
Category:

less

Transcript and Presenter's Notes

Title: Slope Fields and Numerical Solutions


1
Slope Fields and Numerical Solutions
  • MATH 224

2
First-Order Differential Equations
  • Form of DE 1st order
  • Ideal goal find functions y(t) that satisfy the
    differential equation
  • Last class slope fields give rough shape of
    curves
  • Can we connect the dots to make a curve?

3
Temperature Example
  • Return to heating and cooling example
  • Look at particular k, Te values

4
Slope Field
5
Wait isn't this easy???
6
Continued
Always check your answer against the original DE!
7
Modeling
  • Writing down model DEs can be almost trivial is
    some cases
  • See some assignment problems
  • Solving those same DEs to find an exact formula
    for y(t) prediction can be difficult or
    impossible (no closed form)
  • Today, we find numerical approximations to the
    exact y(t) functions

8
Back to Slope Fields
  • Slope fields give us an idea for a computer-based
    approximation strategy
  • Computer can compute slopes at any (t,y)
  • Why not approximate curved solution by straight
    line segments, based on calculated slopes?

9
Euler's method
  • Pick starting point, (t, y), and step size, delta
    x
  • Find slope there
  • sub (t, y) into dy/dt formula
  • Follow that slope for delta x
  • Treat new point as new starting point
  • Repeat

10
Graphically
11
Slope Field vs Estimated Curve
  • Both use dy/dt . formula
  • For slope field, compute slopes on a grid to see
    overall shape of solution family
  • For Euler's method, compute slopes only along a
    path to estimate a particular solution

12
Euler's method limitations
  • Accuracy of estimate depends on step size
  • smaller steps means more accurate
  • but longer to compute
  • Euler's method needs very small steps to be
    accurate
  • Can be generalized to more efficient algorithms
  • Runge-Kutta (Section 2.6)
  • We'll jump straight to the good stuff!

13
Adaptive Runge-Kutta Solvers
  • MATLAB has many built in ODE 'solvers'
  • don't give formulas, just give a predicted curve
    based on DE and a starting point
  • predicted solution still has numerical errors in
    addition to any assumptions, simplifications in
    model
  • We'll use ode45 (general-purpose solver)

14
Using ode45
  • You need
  • a function that represents the f(t,y) in
  • an initial y value, y0 where you'll start the
    solution
  • an interval of time you want to predict over,
    t0, tn
  • an error tolerance you'll accept in the estimated
    final y value, y(tn)

15
Example
y0 30 t0 0 tn 48 Define the function
dy/dt f _at_(t, y) -0.05(y5) run the
solver to generate approximate temperature
curve t, y ode45(f, t0, tn, y0, 1e-5)
the actual predicted points, and lines connecting
them plot(t, y, '.-k', 'markersize',
15) title('ODE 45 Prediction for Temp DE')
16
Graph over Slope Field
17
Numerical Solutions (the good)
  • Single solution curve is easy to generate
  • relatively simple MATLAB coding required
  • syntax is very picky don't expect to guess at it
    and have it work
  • Can generate multiple curves by looping over
    different starting points
  • We'll see how same approach works with more than
    just single 1st order DEs

18
Numerical Solutions (the not so good)
  • Solution found is not general
  • can only pick one starting point, not find
    general family of solutions
  • Solution is not a function
  • it's a list of points that approximate the
    function
  • can't take limits, derivatives, modify
    parameters
  • Still, numerical solutions are
  • relatively easy to generate
  • way better than nothing

19
Before next week
  • Try that solving technique on some of the DEs you
    create in the assignment, to see if
  • can generalize MATLAB to other examples
  • predictions make sense in the problem
  • creating DEs is easy
  • numerical solving is easy (with MATLAB), but
    limited
  • Rest of the course solving analytically
Write a Comment
User Comments (0)
About PowerShow.com