Chp9: ODE’s Numerical Solns Engr/Math/Physics 25 Bruce Mayer, PE

advertisement
Engr/Math/Physics 25
Chp9: ODE’s
Numerical Solns
Bruce Mayer, PE
Licensed Electrical & Mechanical Engineer
BMayer@ChabotCollege.edu
Engineering/Math/Physics 25: Computational Methods
1
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Learning Goals
 List Characteristics of Linear,
MultiOrder, NonHomgeneous Ordinary
Differential Equations (ODEs)
 Understand the “Finite-Difference”
concept that is Basis for All Numerical
ODE Solvers
 Use MATLAB to determine Numerical
Solutions to Ordinary Differential
Equations (ODEs)
Engineering/Math/Physics 25: Computational Methods
2
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Differential Equations
 Ordinary Diff Eqn
 Partial Diff Eqn
2 y
y
y
d2y
dy






 x, t 
x
,
t

b
x
,
t

b
y
x
,
t

t   a1 t   a2 yt   f (t ) 2
1
2
2
dt
dt
t
t
x
 PDE’s Not Covered in ENGR25
• Discussed in More Detail in ENGR45
 Examining the ODE, Note that it is:
• LINEAR → y, dy/dt, d2y/dt2 all raised to Power of 1
• 2nd ORDER → Highest Derivative is 2
• NONhomogenous → RHS  0;
– i.e., y(t) has a FORCING Fcn f(t)
• has CONSTANT CoEfficients
Engineering/Math/Physics 25: Computational Methods
3
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Solving 1st Order ODEs - 1
 Given the Simple
ODE with
• No Zero Order
(i.e., “y”) term
• An INITIAL Condition
dy
 2t ; I.C. y 0   7.37
dt
 Can Solve by
SEPARATING the
VARIABLES
 dy

 dt  2t   dt  dy  2tdt
Engineering/Math/Physics 25: Computational Methods
4
 AND Integrating
Both Sides
 dy   2tdt
 Now use the IC in
the Limits of Integ.
  y t 
 t

 y 0 
d  2 
 0
d
• Note the use of
DUMMY VARIABLES of
INTEGRATION
α and β Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Solving 1st Order ODEs - 2
 Integrating
  y t 

 y 0 
1d  2
 t
 0
 
y t 
y 0 7.37
d
 
 
2 t
0
yt   7.37  t  0
2
2
Or yt   t  7.37
2
Engineering/Math/Physics 25: Computational Methods
5
 Separating The
Variables sometimes
works for 1st Order
Eqns
 The Function on the
RHS of the 1st Order
ODE is the
FORCING Function
• Function only of t
• Can be a
CONSTANT
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Solving 1st Order ODEs - 3
 Consider the 1st
Order ODE with a
“Zero” Order Term
and a Forcing Fcn
dy

 y  f t  ;   Const.
dt
 This is the
GENERAL Eqn
 By Theorems of
Linear ODEs Let
Engineering/Math/Physics 25: Computational Methods
6
 yp(t)  ANY Solution to
the General ODE
• Called the
“Particular” Solution
 yc(t)  The Solution to
the General Eqn with
f(t) = 0
• The “Complementary
Solution” or the “Natural”
(UnForced) Response
 i.e., yc is the Soln to the
“Homogenous” Eqn
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
1st Order Response Eqns
 Given yp and yc then the
TOTAL Solution to the
ODE
y t   y p t   yc t 
 Consider the Case
Where the Forcing
Function is a Constant
• f(t) = A
 Now Solve the ODE in
Two Parts for yp & yc

dy p t 
dt
dyc t 

 yc t   0
dt
 For the Particular Soln,
Notice that a
CONSTANT Fits the
Eqn:
y t   K
p
7
1
and
d y p t 

dt
Engineering/Math/Physics 25: Computational Methods
 y p t   A
  d K   0
1
dt
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
1st Order Response Eqns cont
 Sub Into the General
(Particular) Eqn yp and
dyp/dt
 0  K1  A
or
K1  A
 Next, Divide the
Homogeneous Eqn by
·yc to yield (on whtbd)
dyc t  dt 1
 0
yc t 

Engineering/Math/Physics 25: Computational Methods
8
 Next Separate the
Variables & Integrate
 y t  dy t      dt
1
1
c
c
 Recognize LHS as a
Natural Log; so
ln  yc t    t   D
where D  const
 Next Take “e” to
The Power of the
LHS & RHS
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
1st Order Response Eqns cont
 Then
yc t   e t   D  e D e t 
yc t   K 2e t 
  is called the TIME
CONSTANT
 Thus the Solution for a
Constant Forcing Fcn
yt   y p t   yc t 
yt   K1  K 2e
t / 
Engineering/Math/Physics 25: Computational Methods
9
 For This Solution
Examine Extreme
Cases
• t=0
• t→
y0  K1  K 2
yt     K1  K 2e   K1
 The Latter Case is
Called the Steady-State
Response
• All Time-Dependent
Behavior has dissipated
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Higher Order, Linear ODE’s
 The GENERAL Higher Order ODE
dny
d n 1 y
dy
g n t   n t   g n 1 t   n 1 t    g1 t   t   g 0 t   yt   f (t )
dt
dt
dt
• Where the derivative CoEfficients, the gi(t),
may be constants, including Zero
 IF an analytical Solution Exists Then
use the same “linear” methodology as
for the First Order Eqn
ytotal t   yc t   y p t 
Engineering/Math/Physics 25: Computational Methods
10
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Higher Order, Linear ODE’s
 Where as Before
• yc(t) is the solution to Complementary Eqn
dny
d n1 y
dy
g n t   n t   g n1 t   n1 t    g1 t   t   g 0 t   y t   0
dt
dt
dt
• yp(t) is ANY single solution to the FULL,
Orginal Eqn that includes the Force-Fcn
 e.g.:
d 2T r 
r m




U

T
r

Q

e
;  ,U , Q, m  Const
2
dr
Tp  Ae  r m & Tc  e t B1 sin   r   B2 cos  r 
 Ttot r   e t B1 sin   r   B2 cos  r   Ae r m
Const' s   , , B1 , B2 , A from Boundary Conditions (BC' s)
Engineering/Math/Physics 25: Computational Methods
11
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
For More Info On Higher Order
 Hi-Order ODEs usually do NOT have
Analytical solns, except in special cases
• Consider a 2nd order, Linear,
NonHomogenous, Constant CoEfficient
ODE of the form
d2y
dy
t   a1 t   a2 yt   f (t )
2
dt
dt
– ODE’s with these SPECIFIC Characteristics
can ALWAYS be Solved Analytically
 See APPENDIX for more details
 These Methods used in ENGR43
Engineering/Math/Physics 25: Computational Methods
12
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Numerical ODE Solutions
 Today we’ll do some
MTH25
 We’ll “look under the
hood” of
NUMERICAL
Solutions to ODE’s
 The BASIC GamePlan for even the
most Sophisticated
Solvers:
• Given a STARTING
POINT, y(0)
• Use ODE to find the
slope dy/dt at t=0
• ESTIMATE y1 as
dy
y1  y0  t 
dt t 0
Engineering/Math/Physics 25: Computational Methods
13
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Numerical Solution - 1
 Notation
n  Step Number
t  Time Step Length
tn  n  t
 Exact Numerical
Method (impossible
to achieve) by
Forward Steps
yn+1
yn  y t n 
f n  f t n , yn 
yn
 Now Consider slope
dy
 f t , y 
dt
Engineering/Math/Physics 25: Computational Methods
14
tn
t
tn+1
t
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Numerical Solution - 2
yn+1
 The diagram at Left shows
that the relationship between
yn, yn+1 and the CHORD slope
Tangent
Slope
yn
Chord
Slope
tn
t
The Analyst
Chooses Δt
tn+1
y n1  y n
 chord slope
t
 The problem with this formula
is we canNOT calculate the
t
CHORD slope exactly
• We Know Only Δt & yn, but
NOT the NEXT Step yn+1
Engineering/Math/Physics 25: Computational Methods
15
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Numerical Solution -3
 However, we can
calculate the
TANGENT slope at
any point FROM the
differential equation
itself
dy
mn 
 f t n , yn 
dt t  t n
 Recognize dy/dt as
the Tangent Slope
tangent slope  f t , y 
Engineering/Math/Physics 25: Computational Methods
16
 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
yn 1  yn dy

 f t n , yn 
t
dt tn
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Euler Method – 1st Order
 Solve 1st Order ODE
with I.C.
dy
 f (t , y )
dt
y 0   b
 Use: [Chord Slope]
 [Tangent Slope at
start of time step]
yn 1  yn dy

 f t n , yn 
t
dt tn
Engineering/Math/Physics 25: Computational Methods
17
 ReArranging
dy
yn 1  t
 yn
dt t n
or
yn1  yn  t  f n
 Then Start the
“Forward March”
with Initial
Conditions
t0  0
y0  b
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Engineering/Math/Physics 25: Computational Methods
18
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Euler Example
 Consider 1st Order
ODE with I.C.
dy
  y 1
dt
y (0)  0
 Use The Euler
Forward-Step Reln
yn 1  yn  t f n
dy
 yn  t
dt tn
Engineering/Math/Physics 25: Computational Methods
19
 But from ODE
dy
  yn  1
dt t n
 So In This Example:
yn1  yn  t (  yn  1)
 See Next Slide for
the 1st Nine Steps
For Δt = 0.1
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Euler Exmpl Calc
dy
  y  1 t  0.1
dt
tn
yn
fn= – yn+1
yn+1= yn+t∙fn
0
0
0.000
1.000
0.100
1
0.1
0.100
0.900
0.190
2
0.2
0.190
0.810
0.271
3
0.3
0.271
0.729
0.344
4
0.4
0.344
0.656
0.410
5
0.5
0.410
0.590
0.469
6
0.6
0.469
0.531
0.522
7
0.7
0.522
0.478
0.570
8
0.8
0.570
0.430
0.613
9
0.9
0.613
0.387
0.651
n
Slope
Plot
Engineering/Math/Physics 25: Computational Methods
20
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Euler vs Analytical
0.8
 The Analytical
Solution
0.6
y  1 e
y
0.4
Numerical
0.2
Exact
1.25
1
0.75
0.5
0.25
0
0
t
Engineering/Math/Physics 25: Computational Methods
21
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
t
Analytical Soln
dy
  y  1 y t  0   0
dt
 Let u = −y+1
 Integrate Both Sides
 Then
u  1 y
du dy  0  1
dy  du
 Sub for y & dy in
ODE  du
dt
u
du
 Separate
  dt
Variables u
Engineering/Math/Physics 25: Computational Methods
22
du
 u   1dt
 Recognize LHS as
Natural Log
ln u  t  C
 Raise “e” to the
power of both sides
e
ln u
e
t C
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Analytical Soln
dy
  y  1 y t  0   0
dt
 And
 Now use IC
e
e
ln u
u
t  C
C t
 e e  Ke
 Thus Soln u(t)
u  Ke
t
t
0
1  0  Ke
 K 1
 The Analytical Soln
1  y  1 e
t
 Sub u = 1−y
1  y  Ke
t
Engineering/Math/Physics 25: Computational Methods
23
y  1 e
t
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Predictor-Corrector - 1
 Again Solve 1st
 Mathematically
Order ODE with I.C. y  y
n 1
n
 0.5 f (tn , yn )  f (tn 1 , yn 1 )
dy
dt
 f (t , y )
y 0   b
 This Time Let:
Chord slope 
average of tangent
slopes at start and
END of time step
Engineering/Math/Physics 25: Computational Methods
24
t
Avg of the Tangent Slopes
at (tn,yn) & (tn+1,yn+1)
 BUT, we do NOT
know yn+1 and it
appears on the
BOTH sides of the
Eqn...
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Predictor-Corrector - 2
 Use Two Steps to
estimate yn+1
 First → PREDICT*
• Use standard Euler
Method to Predict
y

n 1
y

n 1
y

n 1
 yn  y
 yn  t dy dt n
 yn  t f t n , yn 
yn1  yn  t f n
Engineering/Math/Physics 25: Computational Methods
25
 Then Correct by
using y* in the
Avg Calc

 0.5t  f

y n1 yn  0.5t f tn , yn   f tn1 , yn1
y n1 yn
*

f
n
n 1

 Then Start the
“Forward March”
with the Initial
Conditions
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx

Predictor-Corrector Example
dy
  y 1
dt
 Solve ODE with IC
y (0)  0

yn 1  yn  0.5t f n  f
 The Corrector step
 The next Step Eqn for dy/dt = f(t,y)= –y+1


yn 1  yn  0.5t  yn  1   y
*
n 1

1
 Numerical Results on Next Slide
Engineering/Math/Physics 25: Computational Methods
26
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx

n 1

Predictor-Corrector Example
f  dy dt   y  1
n
tn
yn

yn 1  yn  0.5t f n  f n1
fn
Slope
f n*1
yn 1
Slope
0
0
0.000
1.000
0.100
0.900
0.095
1
0.1
0.095
0.905
0.186
0.815
0.181
2
0.2
0.181
0.819
0.263
0.737
0.259
3
0.3
0.259
0.741
0.333
0.667
0.329
4
0.4
0.329
0.671
0.396
0.604
0.393
Engineering/Math/Physics 25: Computational Methods
27
y n*1
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx

Predictor-Corrector
0.8
 Greatly
Improved
Accuracy
0.6
y
0.4
Exact
0.2
Mod. Euler
t
Engineering/Math/Physics 25: Computational Methods
28
1.25
1
0.75
0.5
0.25
0
0
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
ODE Example:
 Euler Solution with
∆t = 0.25, y(t=0) = 37
Euler Solution to dy/dt = 3.9cos(4.2y)-ln(5.1t+6)
38
36
34
y(t) by Euler
32
30
28
26
24
22
0
1
2
3
4
5
t
6
7
8
9
Engineering/Math/Physics 25: Computational Methods
29
10
dy
 3.9 cos4.2 y   ln 5.1t  6 
dt
 The Solution Table
n
t
y
dy/dt
dely
yn+1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
0
0.25
0.5
0.75
1
1.25
1.5
1.75
2
2.25
2.5
2.75
3
3.25
3.5
3.75
4
4.25
4.5
4.75
5
5.25
5.5
5.75
6
6.25
6.5
6.75
7
7.25
7.5
7.75
8
8.25
8.5
8.75
9
9.25
9.5
9.75
10
37.0000
36.5636
36.9143
36.5769
36.8872
36.5806
36.8418
36.6641
36.9608
36.3357
35.6768
35.2701
35.2882
35.2273
35.3380
35.0526
35.0491
35.0223
34.8909
34.2399
33.9524
33.1997
32.4496
31.6958
30.9492
30.1897
29.4564
28.6710
27.9981
27.1110
26.6745
25.9565
25.3424
25.2245
24.6604
24.6512
24.6268
24.5593
24.2973
23.3007
23.0678
-1.7457
1.4027
-1.3492
1.2410
-1.2264
1.0448
-0.7108
1.1868
-2.5004
-2.6357
-1.6265
0.0722
-0.2436
0.4430
-1.1420
-0.0139
-0.1072
-0.5255
-2.6041
-1.1497
-3.0108
-3.0006
-3.0151
-2.9862
-3.0384
-2.9328
-3.1419
-2.6916
-3.5484
-1.7458
-2.8722
-2.4562
-0.4717
-2.2562
-0.0369
-0.0977
-0.2699
-1.0481
-3.9863
-0.9318
-1.0551
-0.4364
0.3507
-0.3373
0.3103
-0.3066
0.2612
-0.1777
0.2967
-0.6251
-0.6589
-0.4066
0.0181
-0.0609
0.1107
-0.2855
-0.0035
-0.0268
-0.1314
-0.6510
-0.2874
-0.7527
-0.7502
-0.7538
-0.7466
-0.7596
-0.7332
-0.7855
-0.6729
-0.8871
-0.4365
-0.7180
-0.6141
-0.1179
-0.5641
-0.0092
-0.0244
-0.0675
-0.2620
-0.9966
-0.2329
-0.2638
36.5636
36.9143
36.5769
36.8872
36.5806
36.8418
36.6641
36.9608
36.3357
35.6768
35.2701
35.2882
35.2273
35.3380
35.0526
35.0491
35.0223
34.8909
34.2399
33.9524
33.1997
32.4496
31.6958
30.9492
30.1897
29.4564
28.6710
27.9981
27.1110
26.6745
25.9565
25.3424
25.2245
24.6604
24.6512
24.6268
24.5593
24.2973
23.3007
23.0678
22.8040
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Compare Euler vs. ODE45
Euler Solution
ODE45 Solution
Euler Solution to dy/dt = 3.9cos(4.2y)-ln(5.1t+6)
37.5
38
36
37
34
36.5
Y by ODE45
y(t) by Euler
32
30
36
28
35.5
26
35
24
22
0
1
2
3
4
5
t
6
7
8
9
10
34.5
0
1
2
3
4
6
5
T by ODE45
Euler is Much LESS accurate
Engineering/Math/Physics 25: Computational Methods
30
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
7
8
9
10
Compare Again with ∆t = 0.025
Euler Solution
ODE45 Solution
Euler Solution to dy/dt = 3.9cos(4.2y)-ln(5.1t+6)
37.5
37.2
37
37
36.8
Y by ODE45
y(t) by Euler
36.5
36.6
36.4
36
35.5
36.2
35
36
35.8
34.5
0
1
2
3
4
5
t
6
7
8
9
10
0
1
2
3
4
6
5
T by ODE45
Smaller ∆T greatly improves Result
Engineering/Math/Physics 25: Computational Methods
31
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
7
8
9
10
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)')
Engineering/Math/Physics 25: Computational Methods
32
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
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')
Engineering/Math/Physics 25: Computational Methods
33
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
All Done for Today
Carl
Runge
Carl David Tolmé Runge
Born: 1856 in
Bremen, Germany
Engineering/Math/Physics 25: Computational Methods
34
Died: 1927 in
Göttingen, Germany
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Engr/Math/Physics 25
Appendix
f x   2 x  7 x  9 x  6
3
2
Bruce Mayer, PE
Licensed Electrical & Mechanical Engineer
BMayer@ChabotCollege.edu
Engineering/Math/Physics 25: Computational Methods
35
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
2nd Order Linear Equation
 Need Solutions to the
2nd Order ODE
d2y
dy
m 2 (t )  c (t )  ky(t )  f (t )
dt
dt
 As Before The Solution
Should Take This form
y (t )  y p (t )  yc (t )
 Where
• yp  Particular Solution
• yc  Complementary
Solution
Engineering/Math/Physics 25: Computational Methods
36
 If the Forcing Fcn is a
Constant, A, Then
Discern a Particular Soln
A
f (t )  A  y p 
k
 Verify yp
dy p d 2 y p
A
yp  

0
2
k
dt
dt
A
 ky p  k  A
k

 For Any const Forcing
Fcn, f(t) = A
A
y (t )   yc (t )
k
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
The Complementary Solution
 The Complementary
Solution Satisfies the
HOMOGENOUS Eqn
 Look for Solution of this
type
st
y(t )  Ge
 Sub Assumed Solution
d2y
dy
m 2 (t )  c (t )  ky(t )  0
(y = Gest) into the
dt
dt
Homogenous Eqn
 Need yc So That the
st 2
st
st
mGe
s

cGe
s

kGe
0
“0th”, 1st & 2nd
 Canceling Gest
Derivatives Have the
2
SAME FORM so they
ms

cs

k

0
will CANCEL (i.e.,
Divide-Out) in the
 The Above is Called the
Homogeneous Eqn
Characteristic Equation
Engineering/Math/Physics 25: Computational Methods
37
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Complementary Solution cont
 A value for “s” That
SATISFIES the
CHARACTERISTIC
Eqn ensures that Gest is
a SOLUTION to the
Homogeneous Eqn
 Recall the
Homogeneous Eqn
ms  cs  k  0
2
• The Characteristic Eqn
 Solve For s by
Quadratic Eqn
 c  c  4mk

2m
2
s1, 2
d2y
dy
m 2 (t )  c (t )  ky(t )  0  In terms of the
dt
dt
Discriminant γ
 If Gest is indeed a
Solution Then Need
Engineering/Math/Physics 25: Computational Methods
38
s1, 2
c 

2m
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Complementary Solution cont.2
 Given the “Roots” of
the Homogeneous Eqn
s1, 2
c 

2m
 Can Generate STABLE
and UNstable
Responses
• Stable
c
0
2m
• UNstable
c
0
2m
Engineering/Math/Physics 25: Computational Methods
39
 In the Unstable case the
response will grow
exponentially toward ∞
• This is not terribly interesting
 If the Solution is Stable,
need to Consider three
Sets of values for s based
on the sign of γ
• 1. γ > 0 → s1, s2 REAL and
UNequal roots
• 2. γ = 0 → s1 = s2 = s;
ONE REAL root
• 3. γ < 0 → Two roots as
COMPLEX CONJUGATES
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Complementary Soln Cases 1&2
 For the Linear, 2nd Order, Constant Coeff,
2
d
Homogenous Eqn m y (t )  c dy (t )  ky(t )  0
dt 2
dt

By the Methods of MTH4 & ENGR43 Find
Solutions to the ODE by discriminant case:
1. Real & Unequal Roots (Stable for Neg Roots)
yc (t )  A1e  A2 e
s1t
s2t
2. Single Real Root (Stable for Neg Root)
yc (t )   A1  A2t e
Engineering/Math/Physics 25: Computational Methods
40
st
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Complementary Soln Case - 3
3. Complex Conjugate Roots of the form:
s = a ± jω (Stable for Neg a)
yc (t )  A1e

 a  j t
Using the Euler Identity: e
And Collecting Terms find
yc t   e
•
at
 jt
 cos t  j sin t
B1 cos t  B2 sin t 
a, ω, B1, B2 all Constants (a & ω are KNOWN)
Engineering/Math/Physics 25: Computational Methods
41
 A2 e
 a  j t
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
2nd Order Solution
 For the Linear, 2nd
Order, Constant
Coeff, Homogenous
Eqn
d2y
dy
m 2 (t )  c (t )  ky(t )  0
dt
dt

Can Find Solution
based Upon the
nature of the Roots
of the Characteristic
Eqn ms 2  cs  k  0
Engineering/Math/Physics 25: Computational Methods
42
 To Find the Values of
the Constants Need
TWO Initial
Conditions (ICs)
• The ZERO Order IC
yt  0  VALUE
• The 1st Order IC

dy
 y0  VALUE
dt t 0
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Properly Apply Initial conditions
 The IC’s Apply ONLY to the TOTAL
Solution
y (t )  y p (t )  yc (t )
 Many times It’s EASY to forget to add
the PARTICULAR solution BEFORE
applying the IC’s
• Do NOT neglect yp(t) prior to IC’s
Engineering/Math/Physics 25: Computational Methods
43
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
2nd Order ODE Example - 1
 The Homogeneous
Equation
 The Characteristic
Eqn and Roots
2
2
Ch.
Eq.
:
s
 9s  18  0
d y
dy
(t )  9 (t )  18 y (t )  0
2
0  s  3s  6
dt
dt
REAL roots : s  3,  6
 And the IC’s
 Then the Soln Form
y 0 1 2
Given Real &
UnEqual Roots
dy
 17

dt
 y 0 
t 0
2
Engineering/Math/Physics 25: Computational Methods
44
yt   A1e
3t
 A2e
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
6t
2nd Order ODE Example - 2
 From the
Zero Order IC
 Then at t = 0
y0  A1e0  A2e0  0.5
 To Use the 1st Order
IC need to take
Derivative
d
y t   A1e 3t  A2 e 6t
dt
dy

 3 A1e 3t  6 A2 e 6t
dt

Engineering/Math/Physics 25: Computational Methods
45

dy
 17
0
0
 3 A1e  6 A2e 
dt t 0
2
 Now Have 2 Eqns
for A1 & A2
A1  A2  0.5
 3 A1  6 A2  8.5
 Solve w/ MATLAB
BackDivision
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
2nd Order ODE Example - 3
 MATLAB session
 The Response Curve
0.6
>> C = [1,1; -3,-6];
>> b = [0.5; -8.5];
>> A = C\b
A =
-1.8333
2.3333
0.3
0.2
 Or
11 3t 14 6t
y t    e  e ; t  0
6
6
Engineering/Math/Physics 25: Computational Methods
46
Be sure to check
for correct IC’s 
Starting-Value &
Slope
0.4
y(t)
>> A_6 = 6*A
A_6 =
-11.0000
14.0000
0.5
0.1
0
-0.1
-0.2
-0.3
-0.4
0
0.2
0.4
0.6
0.8
1
1.2
1.4
t
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
1.6
1.8
2
2nd Order ODE SuperSUMMARY-1
 See Appendix for FULL Summary
 Find ANY Particular Solution to the
ODE, yp (often a CONSTANT)
 Homogenize ODE → set RHS = 0
 Assume yc = Gest; Sub into ODE
 Find Characteristic Eqn for yc;
a 2nd order Polynomial
Engineering/Math/Physics 25: Computational Methods
47
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
2nd Order ODE SuperSUMMARY-2
 Find Roots to Char Eqn Using
Quadratic Formula (or MATLAB)
 Examine Nature of Roots to Reveal
form of the Eqn for the
Complementary Solution:
• Real & Unequal Roots →
yc = Decaying Constants
• Real & Equal Roots → yc = Decaying Line
• Complex Roots → yc = Decaying Sinusoid
Engineering/Math/Physics 25: Computational Methods
48
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
2nd Order ODE SuperSUMMARY-3
 Then the TOTAL Solution: y = yc + yp
 All TOTAL Solutions for y(t) include 2
Unknown Constants
 Use the Two INITIAL Conditions to
generate two Eqns for the 2 unknowns
st
s t
y

G
e

G
e
 yp
1
2
 Solve the Total
st
mt  b   y p
y

e
Solution for the
 at
B1 cos t  B2 sin t   y p
y

e
2 Unknowns to
Complete the Solution Process
1
Engineering/Math/Physics 25: Computational Methods
49
2
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
2nd Order ODE SUMMARY-1
 If NonHomogeneous
Then find ANY
Particular Solution
 The Soln to the
Homog. Eqn
Produces the
Complementary
d2y
dy
5 2 (t )  7 (t )  3 y (t )  18
Solution, yc
dt
dt

y p  18 / 3  6 (a CONST)  Assume yc take this
 Next HOMOGENIZE
the ODE
2
d y
dy
5 2 (t )  7 (t )  3 y (t )  0
dt
dt
Engineering/Math/Physics 25: Computational Methods
50
form
yc t   Ae st


y c t   sAe

st
y c t   s Ae
2
st
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
2nd Order ODE SUMMARY-2
 Subbing yc = Aest
into the Homog. Eqn
yields the
Characteristic Eqn
5s  7 s  3  0
2
 Find the TWO roots
that satisfy the Char
Eqn by Quadratic
Formula
s1, 2
 If s1 & s2 → REAL &
UNequal
yc t   G1e  G2 e
s1t
• Decaying Contant(s)
 7  72  4  5  3

25
Engineering/Math/Physics 25: Computational Methods
51
 Check FORM of
Roots
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
s 2t
2nd Order ODE SUMMARY-3
 If s1 & s2 → REAL &
Equal, then s1 = s2
=s
st
yc t   e mt  b 
 m, b are constants
• Decaying Line
 If s1 & s2 →
Complex
Conjugates then
yc t   e
 at
 Add Particlular &
Complementary
Solutions to yield
the Complete
Solution
y t   yc  y p
B1 cos t  B2 sin t 
Engineering/Math/Physics 25: Computational Methods
52
• Decaying Sinusoid
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
2nd Order ODE SUMMARY-4
 To Find Constant
 Find Number-Values
Sets: (G1, G2), (m,
for the constants to
b), (B1, B2) Take for
complete the
COMPLETE solution
solution process
y t  0  IC 0  y0

dy
 IC1  y 0
dt t 0
• Yields 2 eqns in 2 for
the 2 Unknown
Constants
Engineering/Math/Physics 25: Computational Methods
53
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Finite Difference Methods - 1
 Another way of
thinking about
numerical methods
is in terms of finite
differences.
 Use the
Approximation
y n 1  yn  dy 
 
t
 dt  n
Engineering/Math/Physics 25: Computational Methods
54
 And From the
Differential Eqn
 dy 
 dt   f (tn , y n )
n
 From these two
equations obtain:
y n 1  y n
 f (t n , y n )
t
 Recognize as the
Euler Method
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Finite Difference Methods - 2
 Could make More Accurate by
Approximating dy/dt at the Half-Step as the
average of the end pts
y n 1  y n  dy 
1   dy 
 dy  
 
       
t
 dt  n  1 2   dt  n  dt  n 1 
2
 Then Again Use the
ODE to Obtain
y n 1  y n 1
  f n  f n 1 
t
2
Engineering/Math/Physics 25: Computational Methods
55
 Recognize as the
Predictor-Corrector
Method
Bruce Mayer, PE
BMayer@ChabotCollege.edu • ENGR-25_Lec-23_ODEs_Euler_Numerical.pptx
Download