8/13/2019 Ch 10-1.doc
1/30
Chapter 10
Dynamic response using numerical methods
10.1 Numerical methods: introduction
The Euler Method
Consider the model
constrrydt
dy== , (10.1-1)
From the definition of derivative,
ttty
dtdy
+= )(lim0
If the time increment t is chosen small enough, the derivative
can be replaced by the approimate epression
t
tytty
dt
dy
+
)()((10.1-!)
"ssume that the right-hand side of (10.1-1) remains constantover the time interval ),( ttt + , and replace (10.1-1) by the
follo#ing approimation$
)()()(
tryt
tytty=
+
orttrytytty +=+ )()()( (10.1-%)
&his techni'ue for replacing a differential e'uation #ith a
difference e'uation is the uler method.
'uation (10.1-%) can be #ritten in more convenient form as
follo#s. "t the initial time ot , (10.1-%) gives
ttrytytty ooo +=+ )()()(
et ttt o +=1 . &hen
161
8/13/2019 Ch 10-1.doc
2/30
ttrytytty +=+ )()()( 111
&hat is, (10.1-%) is applied successively at the instants kt , #herektt kk +=+1 , and #e can #rite in general
ttrytyty kkk +=+ )()()( 1 (10.1-*)
It is convenient to introduce a time inde k such that
)( kk tyy
=
&hus, (10.1-*) becomes
,...!,1,0,)1(1 =+=+=+ kytrtryyky kkk (10.1-+)In this form, it is easily seen that the continuous variable )(ty
has been represented by the discrete-time variable ky . 'uation
(10.1-+) is a recursion relation or difference e'uation. It can be
solved recursively (se'uentially) at the instants ,...!,1,0=k ,
starting #ith the initial value )( oo tyy = .
In cases #here the subscript notation is inconvenient, the
variable ky is #ritten as )(ky . Care must be taen not to
confuse )(ky #ith )( kty . For ,...!,1,0=k , )(ky represents )(ty at
the values of ,...,, !1 tttt o= In this notation, (10.1-+) becomes
,...!,1,0),()1()1( =+=+ kkytrky (10.1-)ith ra constant, #e can easily solve the original differential
e'uation (10.1-1), so #e really have no need for (10.1-).
/o#ever, this is not the case for a general e'uation of the form
),( vyfy =
(10.1-)
"ssume the right-hand side to be constant over the interval),( 1+kk tt and e'ual to the value )(),(2 kk tvtyf . ith the
approimation (10.1-!), #e have the uler method for (10.1-).
)(),(2)()( 1 kkkk tvtytftyty +=+ (10.1-3)
162
8/13/2019 Ch 10-1.doc
3/30
&his is easily programmed on a computer. &he values of,),(, ttyt
oo and any parameters in the functions f and v must
be read into the program along #ith a stopping criterion.
&he uler method is the simplest algorithm for numerical
solution of a differential e'uation, but it usually gives the least
accurate results.
Example 10.1
Compare the eact solution and the uler method using a step
si4e 1.0=t for
1)0(, ==
ytyy #here 10 t
&he uler algorithm (10.1-3) for this model is
)()1.01()( 1 kkk tytty +=+ (10.1-5)
For this case, the eact solution can be obtained by separating
variables and direct integration. First #e #rite
tdty
dy =
and integrate to obtain
=tty
y
tdty
dy
0
)(
)0(
163
8/13/2019 Ch 10-1.doc
4/30
or
!ln
!)(
)0(
ty
ty
y =
&his can be rearranged as
)!6ep()0()( !tyty =
&he follo#ing table compares the results.kt )( kty
act uler
0.1 1.00+ 1.0000.! 1.0!0 1.010
0.5 1.*55 1.*15
1.0 1.*5 1.+*
&he error in the uler method increases #ith time. It is in error
by 0.+7 in the first step8 by the tenth step, the error is .157.
&he accuracy can be improved by using a smaller value of t
.
164
8/13/2019 Ch 10-1.doc
5/30
Selecting a step size
&hus far, #e have not considered the effect of the 9run time9 of
a numerical method. &his is the time re'uired for the soft#are to
perform the calculations, and it is fre'uently an important factor
in selecting an algorithm. It is difficult to mae a prior
determination of the run time for a given algorithm.
&he process of selecting a proper si4e t begins by considering
the dynamics of the model and ho# fast the input changes #ith
time. " trial value of t is then selected that is small in relation
to these considerations. &he trial solution for the response is
obtained #ith this value. &he step si4e is then reduced
significantly, and the responses are compared. If they agree tothe number of significant figures specified by the analyst, the
correct ans#er is taen to be the last solution. If not, t is again
reduced by a significant factor and the process is repeated until
the solution converges.
In strictly analytical terms, as t approaches 4ero, the solution
of the difference e'uation approaches that of the corresponding
differential e'uation. &his is the reason for using a small t .
&he error produced #hen t is not small enough to representthe differential e'uation accurately is termed truncation error.
/o#ever, numerical considerations as #ell as computer time
re'uire not maing t too small. &he reason is that the effect of
round-off error is greater for smaller t due to the larger
number of iterations re'uired.
165
8/13/2019 Ch 10-1.doc
6/30
10.2 Advanced numerical methods
In light of the large variety of e'uation types that are nonlinear,
it is no #onder that many different numerical methods eist for
solving them. /ere, #e consider t#o methods that are generally
useful. &he first is a so-called predictor-corrector method based
on the uler method but #ith greater accuracy. &he second
method is the :unge-;utta family of algorithms.
Trapezoidal integration
8/13/2019 Ch 10-1.doc
7/30
&he difference bet#een the uler and trape4oidal integration
methods is sho#n in Figure 10.1. &he shaded area represents the
approimation to the integral
+1
)(k
k
t
t
dv
=oth methods use a rectangle of #idth t . &he uler method
taes the height of the rectangle to be )( ktv and approimates
the integral as$
+
=
1
)()(
k
k
t
t
kttvdv
>n the other hand, the trape4oidal method taes the rectangle?s
height as the average value @v of )( ktv and )( 1+ktv andapproimates the integral #ith (10.!-%)
167
8/13/2019 Ch 10-1.doc
8/30
Figure 10.1 Comparison of the uler and trape4oidal integration
approimations. &he shaded area represents the approimation
to the integral. (a) uler. (b) &rape4oidal.
redictor!corrector methods
"s can be seen from Figure 10.1, the uler method can haveserious deficiency in problems, #here the variables are rapidly
changing, because the method assumes the variables are
constant over the time interval t . "s a result, its truncation
error can be sho#n to be the order of !)( t .
>ne #ay of improving the method #ould be by using a better
approimation to the right-hand side of the model
168
8/13/2019 Ch 10-1.doc
9/30
),,( tvyfdt
dy= (10.!-+)
#here v is the input function. &he uler approimation is
[ ]kkkkk ttvtyfttyty ),(),()()( 1 +=+ (10.!-)
8/13/2019 Ch 10-1.doc
10/30
Euler predictor:
),,(1 kkkkk tvyftyx +=+ (10.!-5)
Trapezoidal corrector:
[ ]),,(),,(!
1111 ++++ +
+= kkkkkkkk tvxftvyft
yy (10.!-10)
&his algorithm is sometimes called the modified uler method.
/o#ever, note that any algorithm can be tried as a predictor or a
corrector. &hus many methods can be classified as predictor-corrector, but #e #ill limit our treatment to the modified uler
method. &he truncation error for this method is of the order of%)( t , a significant improvement over the !)( t error of the
basic uler method.
For purposes of comparison #ith the :unge-;utta methods to
follo#, #e can epress the modified uler method as$
),,(1 kkk tvyftg = (10.!-11)
),,( 11! ttvgyftg kkk ++= + (10.!-1!)
)(!
1!11
ggyykk ++=+ (10.!-1%)
170
8/13/2019 Ch 10-1.doc
11/30
Example 10.2
Ase the modified uler method #ith 1.0=t to solve the
e'uation 1)0(, == ytydt
dyup to time 0.1=t .
8/13/2019 Ch 10-1.doc
12/30
replace 1+kx on the right-hand side of that e'uation in order to
get an improved estimate of 1+ky . &his is repeated until the
desired accuracy is achieved8 then the net t interval is treated
the same #ay. /o#ever, this modification obviously increases
the compleity of the programming.
"unge!#utta methods
&he &aylor series representation forms the basis of several
methods for solving differential e'uations, including the :unge-
;utta methods. &he &aylor series may be used to represent the
solution )( tty + in terms of )(ty and its derivatives as follo#s.
...)()(-
1)()(
!
1)()()( %! ++++=+
tyttyttyttytty (10.!-1*)
&he re'uired derivatives are calculated from the differential
e'uation. For an e'uation of the form
),( ytfdtdy = (10.!-1+)
these derivatives are
),()( ytfty =
dt
dfty =
)(
etc.,)(!
!
dt
fdty =
(10.!-1)
#here (10.!-1+) is to be used to epress the derivatives in terms
of only )(ty . If these derivatives can be found, (10.!-1*) can be
used to march for#ard in time. In practice, the high order
derivatives can be difficult to calculate, and the series (10.!-1*)
is truncated at some term. &he number of terms ept in the
series thus determines its accuracy. If terms up to and including
172
8/13/2019 Ch 10-1.doc
13/30
nthderivative of y are retained, the truncation error at each step
is of the order of the first term dropped-namely,
1
11
)C1(
)(
+
++
+
n
nn
dt
yd
n
t
(10.!-1)
sometimes the closed-form epression for the series can be
recogni4ed. For eample, consider the e'uation
0,!
8/13/2019 Ch 10-1.doc
14/30
)(1
)()(
tyta
tytty
=+ (10.!-15)
8/13/2019 Ch 10-1.doc
15/30
8/13/2019 Ch 10-1.doc
16/30
1!1 =+ww (10.!-!+)
!
11 =w
(10.!-!)
!
1! =w (10.!-!)
&hus, the family of second-order :unge-;utta algorithms is
categori4ed by the parameters ),,,( !1 ww , one of #hich can be
chosen independently. &he choice%
!= minimi4es the
truncation error term. For 1= , the :unge-;utta algorithm(10.!-!1)-(10.!-!%) corresponds to the trape4oidal integration
rule if f is a function of only t , and is the same as the
predictor-corrector algorithm (10.!-5)-(10.!-10) for a general),( tyf .
%ourth!order algorithms
&he algorithm is
**%%!!111 gwgwgwgwyy kk ++++=+ (10.!-!3)
)(,2
)(,2
),(
),(
1%%%%%!%%*
1!!!!!%
111!
1
gggyhthfg
ggyhthfg
gyhthfg
ythfg
kk
kk
kk
kk
++++=
+++=
++=
=
(10.!-!5)
Comparison #ith the &aylor series yields eight e'uations for the
ten parameters. &hus, t#o parameters can be chosen in light of
other considerations. &hree common choices are as follo#s.
176
8/13/2019 Ch 10-1.doc
17/30
1.Gill's method. &his choice minimi4es the number of memory
locations re'uired to implement the algorithm and thus is #ell
suited for programmable calculators.
!611
!618!611
18!61
8%6)!611(8%6)!611(8-61
%
%!
%!1
%!*1
+=
==
===
+====
wwww
(10.!-%0)
2.Ralston's method. &his choice minimi4es a bound on the
truncation error.
0+05-+1-.%81+3+5-*.083%!3-*-.%
18*++%!+.08*.0
1113*3.08!0++%+-0.18++1*30--.081*-0!3.0
%!%
%!1
*%!1
===
===
====
wwww
(10.!-%1)
&.lassical method. &his method reduces to
8/13/2019 Ch 10-1.doc
18/30
Example 10.3
Ase the classical :unge-;utta parameter values (10.!-%!) #ith a
step si4e 1.0== th to solve
1.0toup1)0(, ===
tytyy
&he algorithm for the classical parameter value is
)101(0,2
)!
1
!
1(
!
1,
!
12
)!
1,
!
1(
),(
-
1
%
1
%
1
-
1
1%!*
1!%
1!
1
*%!11
gggyhthfg
ggyhthfg
gyhthfg
ythfg
ggggyy
kk
kk
kk
kk
kk
++++=
+++=
++=
=
++++=+
For the given problem, tyf = . For the first iteration,1,0,0 00 === ytk
and
0100+01!+.0)00+01!+.01)(1.00(1.0
00+01!+.0)00+.0!
11)(0+.00(1.0
00+.0)0!
1
1)(0+.00(1.0
0)0(1.0
*
%
!
1
=++=
=++=
=++=
==
g
g
g
g
&hus,
00+01!+!1.1)0100+01!+.0(-
1)00+01!+.0(
%
1)00+.0(
%
10
-
11)1.0(
1 =++++== yy
&his ans#er agrees #ith the eact solution )!6ep( !t . &he rest of
the solution is as follo#s.t 0.1 0.! 0.5 1.0
)(ky 1.00+01!+!1 1.0!0!01%* 1.*55%0!%! 1.*3!100
&he eact solution at 0.1=t , to ten figures, is 1.*3!1!1. &he
numerical solution is correct to seven figures.
178
8/13/2019 Ch 10-1.doc
19/30
10.& Conversion to state varia'le $orm
&here are several #ays of converting a model to state variable
form. If the variables representing the energy storage in the
system are chosen as the state variables, the model must then be
manipulated algebraically to produce the standard state variable
form. &he re'uired algebra is not al#ays obvious. /o#ever, #e
note here that the model
=
)(,,...,,1
1
tvdt
yd
dt
dyytf
dt
ydn
n
n
n
(10.%-1)
#ith the input )(tv can al#ays put into state variable form by
the follo#ing choice of state variables$
1
1
!
1
=
=
=
n
n
ndt
ydx
dt
dyx
yx
(10.%-!)
&he resulting state model is$
[ ])(,,...,,, !1
1
%!
!1
tvxxxtfx
xx
xx
xx
nn
nn
=
=
=
=
(10.%-%)
&he numbering scheme is not uni'ue8 in fact, #e often find thefollo#ing state variable choice$
179
8/13/2019 Ch 10-1.doc
20/30
yy
dt
dyy
dt
ydy
dt
ydy
n
n
n
n
n
n
=
=
=
=
1
!
!
!
1
1
1
(10.%-*)
#hich gives the model
[ ]
1
!%
1!
111 )(,,...,,,
=
=
=
=
nn
nn
yy
yy
yy
tvyyytfy
(10.%-+)
Coupled higher order models
'uation (10.%-1) is some#hat general in that it can be
nonlinear, but it does not cover all cases. For eample, considerthe coupled higher order model
),,,,(1
= zzyytfy (10.%-)
),,,,(!
= zzyytfz (10.%-)
Choose the state variables as$
=
=
=
=
zx
zx
yx
yx
*
%
!
1
(10.%-3)
&hen the state model is$
180
8/13/2019 Ch 10-1.doc
21/30
),,,,(
),,,,(
*%!1!*
*%
*%!11!
!1
xxxxtfx
xx
xxxxtfx
xx
=
=
=
=
(10.%-5)
State e(uations $rom trans$er $unctions
e no# illustrate a method for using the transfer function to
rearrange the diagram so that state variables can be identified.
&he order of the system, and therefore the number of state
variables re'uired, can be found by eamining the denominator
of the transfer functions. If the denominator polynomial is oforder n, then nstate variables are re'uired. Dhysical
considerations (integral causality) can be used to sho# that the
outputs of integration processes )61( s can be chosen as state
variables.
&o illustrate ho# a state model can be derived from a transfer
function, consider the follo#ing first-order model #ith
numerator dynamics$
1
10
)(
)()(
as
!s!
s"
s#sT
+
+== (10.%-10)
#here the input is u and the output is y . Cross-multiplying and
reverting to the time domain, #e obtain
u!u!yay 101 +=+
(10.%-11)
"n alternative #ay of obtaining the differential e'uation is by
dividing the numerator and denominator of (10.%-10) by s .
)(
)(
61
6)(
1
10
s"
s#
sa
s!!sT =
+
+= (10.%-1!)
181
8/13/2019 Ch 10-1.doc
22/30
&he essence of the techni'ue is to obtain a 919 in the
denominator, #hich is then used to isolate )(s# . Cross-
multiplying gives
[ ] )()()(1
)()()()( 0111
01 s"!s#as"!
ss"
s
!s"!s#
s
as# +=++=
&he term multiplying s61 is the input to an integrator8 the
integrator?s output can be selected as a state variable x . &hus,
[ ] [ ])()()(1)()(1)(
)()()(
011111
0
s"!as$as"!s
s#as"!s
s$
s"!s$s#
==
+=
or
u!a!xax )( 0111 +=
(10.%-1%)
u!xy0
+= (10.%-1*)
&he bloc diagram is sho#n in Figure 10.!. Compare (10.%-11)
#ith (10.%-1%), and note that the derivative of the input does not
appear in the latter form.
Figure 10.! &he bloc diagram for (10.%-1%) and (10.%-1*).
182
8/13/2019 Ch 10-1.doc
23/30
Eo#, consider the second-order model for the mechanical
vibration problem. Its transfer function is$
kcsmss%
s$sT
++==
!
1
)(
)()( (10.%-1+)
ivide by !ms to obtain a unity term.
!
!
661
61
)(
)()(
mskmsc
ms
s%
s$sT
++==
Cross-multiply and rearrange to identify the integration
operators.
+=
+=
)()(11
)(1
)(1
)()()(!!
s$m
ks%
mss$
m
c
s
s%ms
s$ms
ks$
ms
cs$
(10.%-1)
efining the state variables as the outputs of the integrators, #esee that
=
+==
)()(11
)(
)()(1
)()(
!
!1
s$m
ks%
mss$
s$s$m
c
ss$s$
or
=
+=
)()(11
)(
)()(1
)(
1!
!11
s$m
ks%
mss$
s$s$m
c
ss$
Figure 10.%a is the bloc diagram derived from these relations.
183
8/13/2019 Ch 10-1.doc
24/30
Figure 10.% &he bloc diagram for the vibration model (10.%-
1+). (a) iagram for the state model (10.%-1) and (10.%-13). (b)
iagram for the state model (10.%-15) and (10.%-!0).
&he corresponding state e'uations in standard form are$
!11 xxm
cx +=
(10.%-1)
fm
xm
kx
11!
+=
(10.%-13)
#here xx =1 .
184
8/13/2019 Ch 10-1.doc
25/30
'uation (10.%-1) can also be arranged as follo#s. et
)()(
)()(
1!
1
ss$s$
sm$s$
=
=
&hen
= )()()(
1)( 1!! s$
m
ks$
m
cs%
ss$
&hese relations give the diagram sho#n in Figure 10.%b. &he
resulting state model #ith mxx =1 is
!1 xx =
(10.%-15)
fxm
cx
m
kx +=
!1! (10.%-!0)
185
8/13/2019 Ch 10-1.doc
26/30
State varia'le models and numerator dynamics
&he general time-invariant model #ith numerator dynamics can
be #ritten as$
01
1
1
01
1
1
...
...
)(
)(
asasasa
!s!s!s!
s&
s#
n
n
n
n
n
n
n
n
++++
++++=
(10.%-!1)
ividing the numerator and denominator byn
nsa gives
nnn
nn
nn
sss
sss
s&
s#
++++
++++=
01
11
1
0
1
1
1
1
...1
...
)(
)(
(10.%-!!)
#here nii a! 6= and nii aa 6= . &his gives
{ }...)()(2)()()( !!1
11
1
00
!
!!
1
11
+++=
++
+
+=
s#s&ss#s&ss&
#'s()s&'s(*+,-......
#'s()s&'s( *+, -
#'s()s+&'s(,-&'s(-#'s(
nnnnn
*n
*
n*n*
nnn
e choose the output of each integrator )61( s to be a state
variable. &hus,
)()(2)(
.
.
.
)()()(2)(
)()()(2)(
)()()(
00
1
%!!
1
!
!11
1
1
1
s#s&ss$
s$s#s&ss$
s$s#s&ss$
s$s&s#
n
nn
nn
n
=
+=
+=
+=
(10.%-!%)
Ase the first e'uation in (10.%-!%) to eliminate G(s) in the
remaining e'uations. &hus,
)()()()(.
.
)()()()()(
)()()()()(
1000
%1!!!!
!11111
s$s&ss$
s$s$s&ss$
s$s$s&ss$
nn
nnnn
nnnn
=
+=
+=
186
8/13/2019 Ch 10-1.doc
27/30
&his gives the differential e'uation set
100
%1!!
!111
!
1
xvx
xxvx
xxvx
n
n
n
n
n
=
+=
+=
(10.%-!*)
#here
niii =
(10.%-!+)
1xvy
n += (10.%-!)
&he original initial conditions of the problem are given in terms
of y , as .),0(),0(),0( etcyyy
'uations (10.%-!*) and (10.%-!) can
be used to find the relation bet#een )0(ix and ),...0(),0(),(
yytv
From (10.%-!), at 0=t $
)0()0()0(1 vyx n= (10.%-!)
"lso, from the first e'uation in (10.%-!*), #e have
vxxx nn 1111!
+= (10.%-!3)
187
8/13/2019 Ch 10-1.doc
28/30
ifferentiating (10.%-!) and substituting gives
vvvyy
vvyvy
vxvyx
nnnn
nnnnn
nnn
111
111
111!
)(
++=
+=
+=
Henerali4ing this procedure and denoting ii dtyd 6 by )(iy gives
the result$
vvvv
yyyx
inin
i
n
i
n
in
i
n
i
i
11
)!(
1
)1(
1
)!(
1
)1(
...2
...
++
+
+++
+++=
(10.%-!5)
#here ni ,...,!,1=
&hus the initial values )0(ix can be found from (10.%-!5) given
the initial values of ),(),( tvty and their derivatives. Interpreting0=t as e'uivalent to = 0t , #e can tae 0...)0()0( ===
vv . In this
case (10.%-!5) gives
)0(...)0()0()0( 1)!(
1
)1(
yyyx ini
n
i
i +
+++= (10.%-%0)
&he transformation to state variable form is summari4ed in
&able 10.1
188
8/13/2019 Ch 10-1.doc
29/30
&able 10.1 " state variable form for numerator dynamics
For eample, consider
-+10
!%
)(
)(!
!
++
++=
ss
ss
s&
s#(10.%-%1)
#here 0for0)(and,)0(,*)0( ===
ttvyy . &he state model (10.%-
!*) and (10.%-!) is$
!11 +.0!+.0 xxvx +=
(10.%-%!)
1! -.01*.0 xvx =
(10.%-%%)
11.0 xvy += (10.%-%*)
&he initial conditions are, from (10.%-%0),
*)0()0(1 == yx (10.%-%+)
189
8/13/2019 Ch 10-1.doc
30/30
5!)0(+.0)0()0(! =+=+=
yyx (10.%-%)
'uations (10.%-%!)-(10.%-%*) are interpreted for 0>t . &hus,
from (10.%-%*)-(10.%-%+), #e see that*)0(1.0)0( ++=+ vy
. If)(tv
is a unit step, then 1)0( =+v and 1.*)0( =+y .