0% found this document useful (0 votes)
54 views10 pages

Euler'S Method For Coupled Differential Equations RLC Circuits

This document describes Euler's method and its improved version for numerically solving coupled differential equations, and applies these methods to model RLC circuits. It introduces the basic Euler method, then describes the improved Euler method which uses the average derivative at the midpoint of each time step for higher accuracy. It also introduces the differential equations that describe charge and current in an RLC circuit under both free and forced oscillations. The document concludes by outlining how the Euler methods can be applied to solve the coupled differential equations governing RLC circuits.

Uploaded by

Epic Win
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views10 pages

Euler'S Method For Coupled Differential Equations RLC Circuits

This document describes Euler's method and its improved version for numerically solving coupled differential equations, and applies these methods to model RLC circuits. It introduces the basic Euler method, then describes the improved Euler method which uses the average derivative at the midpoint of each time step for higher accuracy. It also introduces the differential equations that describe charge and current in an RLC circuit under both free and forced oscillations. The document concludes by outlining how the Euler methods can be applied to solve the coupled differential equations governing RLC circuits.

Uploaded by

Epic Win
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Project PHYSNET Physics Bldg.

Michigan State University East Lansing, MI


MISN-0-351
EULERS METHOD FOR
COUPLED DIFFERENTIAL EQUATIONS;
RLC CIRCUITS
q(t)
q(t + t) D
t t + t D t + t D
a
b
c
1
EULERS METHOD FOR COUPLED DIFFERENTIAL EQUATIONS;
RLC CIRCUITS
by
Robert Ehrlich
1. Eulers Method
a. Original Eulers Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
b. Improved Eulers Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
c. The RLC Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
d. Applying the Two Euler Methods to RLC Circuits . . . . . . 4
2. Several Exact Solutions
a. Zero Applied Voltage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
b. Sinusoidal Applied Voltage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
c. Resonance in RLC Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
d. Error Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3. Computer Implementation
a. Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
b. Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4. A Project: Examine Accuracy
a. Accuracy For Free Oscillations . . . . . . . . . . . . . . . . . . . . . . . . . 11
b. Accuracy For Forced Oscillations, Resonances . . . . . . . . . . 12
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
A. Fortran, Basic, C++ Programs. . . . . . . . . . . . . . . . . . . . . . . . 12
2
ID Sheet: MISN-0-351
Title: Eulers Method for Coupled Dierential Equations; RLC
Circuits
Author: R. Ehrlich, Physics Dept., George Mason University, Fairfax, VA
22030; (703)323-2303.
Version: 3/11/2002 Evaluation: Stage 0
Length: 2 hr; 20 pages
Input Skills:
1. Vocabulary: inductor (MISN-0-144).
2. Describe the Euler-method algorithm for solving rst-order dier-
ential equations (MISN-0-350).
Output Skills (Knowledge):
K1. Write an explanation of the improved Euler method for the nu-
merical solution of two coupled rst-order dierential equations of
the form dy
1
/dx = f
1
(y
1
, y
2
, x), dy
2
/dx = f
2
(y
1
, y
2
, x).
Output Skills (Project):
P1. Use the improved Euler method to solve the coupled, rst order
dierential equations for an RLC circuit for free oscillations.
P2. Use the improved Euler method to solve the coupled, rst-order
dierential equations for an RLC circuit for oscillations that are
forced by a sine-wave voltage generator.
External Resources (Required):
1. A computer with BASIC or FORTRAN or C++.
3
THIS IS A DEVELOPMENTAL-STAGE PUBLICATION
OF PROJECT PHYSNET
The goal of our project is to assist a network of educators and scientists in
transferring physics from one person to another. We support manuscript
processing and distribution, along with communication and information
systems. We also work with employers to identify basic scientic skills
as well as physics topics that are needed in science and technology. A
number of our publications are aimed at assisting users in acquiring such
skills.
Our publications are designed: (i) to be updated quickly in response to
eld tests and new scientic developments; (ii) to be used in both class-
room and professional settings; (iii) to show the prerequisite dependen-
cies existing among the various chunks of physics knowledge and skill,
as a guide both to mental organization and to use of the materials; and
(iv) to be adapted quickly to specic user needs ranging from single-skill
instruction to complete custom textbooks.
New authors, reviewers and eld testers are welcome.
PROJECT STAFF
Andrew Schnepp Webmaster
Eugene Kales Graphics
Peter Signell Project Director
ADVISORY COMMITTEE
D. Alan Bromley Yale University
E. Leonard Jossem The Ohio State University
A. A. Strassenburg S. U. N. Y., Stony Brook
Views expressed in a module are those of the module author(s) and are
not necessarily those of other project participants.
c 2002, Peter Signell for Project PHYSNET, Physics-Astronomy Bldg.,
Mich. State Univ., E. Lansing, MI 48824; (517) 355-3784. For our liberal
use policies see:
http://www.physnet.org/home/modules/license.html.
4
MISN-0-351 1
EULERS METHOD FOR
COUPLED DIFFERENTIAL EQUATIONS;
RLC CIRCUITS
by
Robert Ehrlich
1. Eulers Method
1a. Original Eulers Method. The simplest algorithm for the nu-
merical solution of rst-order dierential equations of the form
dq
dt
(t) = f[q(t), t] , (1)
where f is some known function, is based on the Euler method. This
method replaces the dierential equation by a nite dierence equation
through the substitution of
1
dq
dt
(t)
q
t
=
q(t + t) q(t)
t
(2)
into Eq. (1). This approximation is the basis of the original Euler method,
wherein we solve Eq. (2) for q(t + t):
q(t + t) = q(t) +
dq
dt
(t)t (3)
and obtain dq/dt from Eq. (1).
1b. Improved Eulers Method . The basis of the improved Eulers
method is the observation that the right hand side of Eq. (2) is a better
approximation to the derivative dq/dt at the intermediate time t + t/2
than at the time t. This gives:
dq
dt
(t +
1
2
t) =
q(t + t) q(t)
t
. (4)
The reason for this improvement is illustrated in Fig. 1. Equation (4) can
be rearranged to give:
q(t + t) q(t) + t
dq
dt
(t +
1
2
t (5)
1
See Numerical Solutions of Dierential Equations for RC Circuits Using Eulers
Method (MISN-0-350).
5
MISN-0-351 2
q(t)
q(t + t) D
t t + t D t + t D
a
b
c
Figure 1. Graphical basis of the improved Euler method.
The slope of curve (a) is the right side of both Eqs. (2) and
(4), that of curve (b) is the left side of (2), and that of curve
(c) is the left side of (4).It is obvious that (c)s slope is a
better approximation to (a)s slope than is (b)s.
where the derivative at the intermediate time, t + t/2, can be approxi-
mated by the average of the derivatives at times t and t + .
dq
dt
(t +
1
2
t)
1
2
_
dq
dt
(t + t) +
dq
dt
(t)
_
. (6)
Equations (5) and (6) yield the improved Euler equation:
q(t + t) q(t) +
t
2
_
dq
dt
(t) +
dq
dt
(t + t)
_
. (7)
Equation (7) represents a substantial improvement on Eulers original
method given in Eq. (3), but it requires knowledge of dq/dt at time t +t
which, through Eq. (1), requires q(t + t) and that is the very quantity
we are trying to nd! The improved Euler method species that the
required dq/dt at t +t is to be obtained by: (1) getting a crude estimate
of q(t +t) from Eq. (3); and (2) putting that crude estimate into Eq. (1)
to get the required derivative.
6
MISN-0-351 3
1c. The RLC Circuit . In the circuit shown in Fig. 2, an EMF (an
applied voltage V
a
) is connected across the series combination of a switch
S, a resistor R, an inductor L, and a capacitor C. We are interested in
determining how the current in the circuit varies as a function of time
after the switch is closed. Kirchhos second rule, otherwise known as
the loop equation, states that around any closed loop the sum of the
potential drops equals the sum of the EMFs. Applying this rule to the
circuit shown in Fig. 2 after the switch is closed gives:
V
R
+V
L
+V
c
= V
a
. (8)
The voltages across R, L, and C can be expressed in terms of the current
I, its time rate of change dI/dt, and the charge q on the capacitor C:
V
R
= IR; V
L
= L
dI
dt
; V
C
= q/C . (9)
Substitution of Eqs. (9) into (8) yields
L
dI
dt
+IR +q/C = V
a
or:
dI
dt
=
1
L
[V
a
IR q/C] . (10)
In order to nd the current I as a function of time, we must solve Eq. (10)
together with the relation
I =
dq
dt
, (11)
which is the denition of the current owing away from one plate of the
capacitor. This is also the current which ows through the elements R
and L because this is a single loop circuit. Equations (10) and (11) can be
solved using the Euler methods. The two special cases we shall consider
are:
1 Free oscillations of the RLC circuit when V
a
= (applied voltage) = 0;
2 Forced oscillations of the RLC circuit with V
a
= V
0
sin t;
The two rst order dierential equations, Eqs. (10) and (11), can be made
into a single second order dierential equation by dierentiating Eq. (10)
with respect to time and substituting it into Eq. (11). This gives:
L
d
2
I
dt
2
+R
dI
dt
+
I
C
+
dV
a
dt
= 0 . (12)
7
MISN-0-351 4
S
R
L
C
V
a
Figure 2. The RLC series circuit.
Methods other than Eulers must be used to solve the problem in this
form.
2
1d. Applying the Two Euler Methods to RLC Circuits. In the
original Euler method we use the rst order Taylor expansions:
q(t + t) = q(t) +q

(t) t
I(t + t) = I(t) +I

(t) t
(13)
where rst derivatives have been indicated by primes. In the improved
Euler method the derivatives q

(t) and I

(t) in Eq. (13) are replaced by


the average values:
1
2
[q

(t) +q

(t + t)]
and
1
2
[I

(t) +I

(t + t)] .
Note that: I(t) q

(t) dq/dt. The exact sequences of steps followed in


the two Euler methods are shown in Fig. 3. In order to begin the process
we must specify two initial conditions, since there are two rst order
dierential equations (or one second order equation). We shall arbitrarily
assume the initial conditions, I = 0 and q = 1 at time t = 0. We next
calculate values for the charge and current at the next value of the time,
2
See The Runge-Kutta Method for Solving Dierential Equations, (MISN-0-367)
or The Numerov Method for Solving Dierential Equations, Illustrated with the
Damped Driven Oscillator, (MISN-0-39).
8
MISN-0-351 5
initial conditions
' -
1
(V - IR - q/c)
_
L
q 1
I 0
I
old
old
`
`
old a
`
q q + q' t
new old old
`
D
I I + I ' t
new old old
`
D
q q +
t
(q' + q' )
__
2
new old old new
` D
I I +
t
(I ' + I
'
)
__
2
new old old new
` D
I
'
1
(V - I R - q /c)
_
L
new a new new
`
I
n
p
r
o
v
e
d

m
e
t
h
o
d
O
r
i
g
i
n
a
l

m
e
t
h
o
d
Figure 3. Flow diagram for the two Euler methods.
t +t, using the original Eulers method [Eq. (13)], as well as an updated
value for the derivative I

(t + t). For the original Eulers method we


advance the time by t(t t +t), and loop back to repeat the process
(dotted line). In the improved Euler method we compute improved values
for q(t + t) and I(t + t) before completing the loop. Note that it was
necessary to compute the original values for q(t+t) and I(t+t) before
we could get the improved values since the improved values make use of
the derivatives, q

(t+t) I(t+t) and I

(t+t), found from Eq. (10).


2. Several Exact Solutions
2a. Zero Applied Voltage . If the applied voltage V
a
is zero, then in
certain cases free oscillations can occur in the RLC series circuit. If V
a
is taken to be zero for all times, then dV
a
/dt is also zero, in which case
9
MISN-0-351 6
Eq. (12) has the exact solution:
I = I
0
e
(R/2Lt)
sin
0
t , (14)
where

0
=
1

LC
_
1
R
2
C
4L
_
1/2
. (15)
The computer-generated curve of Fig. 4 is the approximate solution
obtained using the improved Eulers method. The gradually decaying
oscillations of the curve agree with the general form of the exact solution,
in which an oscillatory factor, sin
0
t, is multiplied by a damping factor
exp[(R/2 L)t]. As long as R
2
C/4L is much less than one, then Eq. (15)
which gives a value for
0
, reduces to

0

1

LC
;
_
for R << (4L/C)
1/2
_
; (16)
where
0
is 2 times the frequency of the free oscillations. The period T
of the oscillations is given by:
T =
2

0
2

LC . (17)
The appearance of the damping factor e
(R/2L)t
, in Eq. (14), implies that
the envelope i.e., the non-oscillatory curve drawn tangent to the solution
(see the hand-drawn dotted curve in Fig. 4), should fall to a fraction
1/e 0.368 of its initial value after a time
=
2L
R
. (18)
By examining the expressions for
0
in Eq. (16) we see that
0
will be a
real number only if
1
R
2
C
4L
> 0 ,
which therefore requires that:
R < (4L/C)
1/2
. (19)
If R exceeds the critical value
_
4L/C. then
0
becomes imaginary and
the factor sin
0
t is replaced by the exponential of a real number. For
this overdamped case the solution becomes a pure decaying exponential
and no longer oscillates. For this reason, when R has the borderline value,
R =
_
4L/C, the circuit is said to be criticall damped.
10
MISN-0-351 7
T
I
M
E




C
U
R
R
E
N
T
.
0
0
0
0



.
0
0
0
0


.
1
.
0
0
0
0


-
.
2
3
7
5


.
2
.
0
0
0
0


-
.
3
9
3
1


.
3
.
0
0
0
0


-
.
4
3
4
8


.
4
.
0
0
0
0


-
.
3
6
2
7


.
5
.
0
0
0
0


-
.
2
0
5
4


.
6
.
0
0
0
0


-
.
0
1
0
5


.
7
.
0
0
0
0



.
1
6
9
1


.
8
.
0
0
0
0



.
2
8
9
4


.
9
.
0
0
0
0



.
3
5
2
8


.
1
0
.
0
0
0
0



.
2
7
5
7


.
1
1
.
0
0
0
0



.
1
6
0
8


.
1
2
.
0
0
0
0



.
0
1
5
8


.
1
3
.
0
0
0
0


-
.
1
1
9
9


.
1
4
.
0
0
0
0


-
.
2
1
2
8


.
1
5
.
0
0
0
0


-
.
2
4
3
3


.
1
6
.
0
0
0
0


-
.
2
0
9
4


.
1
7
.
0
0
0
0


-
.
1
2
5
4


.
1
8
.
0
0
0
0


-
.
0
1
7
7


.
1
9
.
0
0
0
0



.
0
8
4
7


.
2
0
.
0
0
0
0



.
1
6
5
4


.
2
1
.
0
0
0
0



.
1
8
1
8


.
2
2
.
0
0
0
0



.
1
5
8
9


.
2
3
.
0
0
0
0



.
0
9
7
9


.
2
4
.
0
0
0
0



.
0
1
7
7


.
2
5
.
0
0
0
0


-
.
0
5
9
6


.
2
6
.
0
0
0
0


-
.
1
1
4
7


.
2
7
.
0
0
0
0


-
.
1
3
5
7


.
2
8
.
0
0
0
0


-
.
1
2
0
4


.
2
9
.
0
0
0
0


-
.
0
7
6
1


.
3
0
.
0
0
0
0


-
.
0
1
6
5


.
3
1
.
0
0
0
0



.
0
4
1
7


.
3
2
.
0
0
0
0



.
0
8
4
1


.
3
3
.
0
0
0
0



.
1
0
1
2


.
3
4
.
0
0
0
0



.
0
9
1
2


.
3
5
.
0
0
0
0



.
0
5
9
0


.
3
6
.
0
0
0
0



.
0
1
4
8


.
3
7
.
0
0
0
0


-
.
0
2
9
0


.
3
8
.
0
0
0
0


-
.
0
6
1
5


.
3
9
.
0
0
0
0


-
.
0
7
5
5


.
4
0
.
0
0
0
0


-
.
0
6
9
0


.
4
1
.
0
0
0
0


-
.
0
4
5
7


.
4
2
.
0
0
0
0


-
.
0
1
2
9


.
4
3
.
0
0
0
0



.
0
2
0
1


.
4
4
.
0
0
0
0



.
0
4
5
0


.
4
5
.
0
0
0
0



.
0
5
6
2


.
4
6
.
0
0
0
0



.
0
5
2
2


.
4
7
.
0
0
0
0



.
0
3
5
3


.
4
8
.
0
0
0
0



.
0
1
1
1


.
4
9
.
0
0
0
0


-
.
0
1
3
8


.
5
0
.
0
0
0
0


-
.
0
3
2
8


.
5
1
.
0
0
0
0


-
.
0
4
1
8


.
5
2
.
0
0
0
0


-
.
0
3
9
4


.
5
3
.
0
0
0
0


-
.
0
2
7
2


.
5
4
.
0
0
0
0


-
.
0
0
9
3


. .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
R
=



.
2
0
0
0
0

L
=


2
.
0
0
0
0
0

C
=


2
.
0
0
0
0
0

D
T
=


1
.
0
0
0
0
0

N
=


5
5
.
0
0
0
0
0

V
0
=



.
0
0
0
0
0

W
=



.
0
0
0
0
0

t
1
t
2
t
3
t
4
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 4. Computer output for the free underdamped oscil-
lator (hand-drawn solid line). Also shown is the exponential
damping factor (dashed line), computed directly from its
exact formal expression. The times t
1
,...,t
4
are one period
apart.
2b. Sinusoidal Applied Voltage. If the applied voltage is a sinu-
soidal function of time, then forced oscillations occur in the RLC circuit.
When the applied voltage is given by V
a
= V
0
sin t, then Eq. (12) again
has an exact solution. If the initial conditions are chosen properly, the cur-
rent is a sinusoidal function of time, with the same oscillation frequency
11
MISN-0-351 8
as the applied voltage:
I = I
m
sin(t ) , (20)
I
m
=
V
0
Z
(21)
and the quantity Z is known as the impedance and is given by
Z =
_
R
2
+
_
L
1
C
_
2
_
1/2
. (22)
The quantity appearing in Eq. (20) is the phase shift which is the rela-
tive shift between the sine curves describing the applied voltage and the
current as functions of time; is given by
= tan
1
_
L
1
C
_
R
. (23)
If the initial conditions are chosen arbitrarily, the solution will not have
a purely sinusoidal time dependence. Generally these departures from a
sinusoidal shape occur at times close to t = 0 and then gradually disap-
pear. For this reason such initial departures from a sinusoidal shape are
known as transient currents. They occur whenever the initial conditions
are other than those consistent with the specic solution which is purely
sinusoidal [Eq. (20)]. Figure 5 shows a computer generated solution ob-
tained using the improved Eulers method. The initial conditions used in
this case (q
0
= 1 and I
0
= 0), are such that there evidently is a transient
current present initially. After the transient current dies out, the ampli-
tude and phase of the resulting sine wave should be consistent with that
given by Eq. (21).
2c. Resonance in RLC Circuit . Like any system whose oscillations
are driven by an external source, an RLC circuit can resonate when the os-
cillation frequency of the external source matches the natural frequency
of the circuit. (The natural frequency is the frequency of free oscillations).
At resonance the amplitude of the current has a greater value than for
any other frequency. To nd the frequency at which the amplitude of
the current I
m
= V
0
/Z reaches its maximum, we must nd the frequency
for which Z is a minimum. Since the factor (L1/C)
2
which appears
in Eq. (22) can not be negative, Z will have its smallest possible value
when this factor is zero:
_
L
1
C
_
2
= 0 . (24)
12
MISN-0-351 9
T
I
M
E




C
U
R
R
E
N
T
.
0
0
0
0



.
0
0
0
0


.
2
.
0
0
0
0



.
0
1
4
6


.
4
.
0
0
0
0



.
0
8
9
6


.
6
.
0
0
0
0



.
1
8
1
0


.
8
.
0
0
0
0



.
2
4
4
7


.
1
0
.
0
0
0
0



.
2
4
7
2


.
1
2
.
0
0
0
0



.
1
7
4
1


.
1
4
.
0
0
0
0



.
0
3
3
5


.
1
6
.
0
0
0
0


-
.
1
4
6
4


.
1
8
.
0
0
0
0


-
.
3
2
4
7


.
2
0
.
0
0
0
0


-
.
4
5
8
1


.
2
2
.
0
0
0
0


-
.
5
1
2
5


.
2
4
.
0
0
0
0


-
.
4
7
1
4


.
2
6
.
0
0
0
0


-
.
3
4
1
0


.
2
8
.
0
0
0
0


-
.
1
4
8
6


.
3
0
.
0
0
0
0



.
0
6
3
5


.
3
2
.
0
0
0
0



.
2
4
7
9


.
3
4
.
0
0
0
0



.
3
6
3
8


.
3
6
.
0
0
0
0



.
3
8
6
3


.
3
8
.
0
0
0
0



.
3
1
3
3


.
4
0
.
0
0
0
0



.
1
6
4
9


.
4
2
.
0
0
0
0


-
.
0
2
0
5


.
4
4
.
0
0
0
0


-
.
3
9
6
5


.
4
6
.
0
0
0
0


-
.
3
1
9
2


.
4
8
.
0
0
0
0


-
.
3
5
8
2


.
5
0
.
0
0
0
0


-
.
3
0
4
2


.
5
2
.
0
0
0
0


-
.
1
7
0
8


.
5
4
.
0
0
0
0



.
0
0
8
9


.
5
6
.
0
0
0
0



.
1
9
0
2


.
5
8
.
0
0
0
0



.
3
2
7
8


.
6
0
.
0
0
0
0



.
3
8
7
5


.
6
2
.
0
0
0
0



.
3
5
3
8


.
6
4
.
0
0
0
0



.
2
3
4
4


.
6
6
.
0
0
0
0



.
0
5
8
1


.
6
8
.
0
0
0
0


-
.
1
3
2
6


.
7
0
.
0
0
0
0


-
.
2
9
1
1


.
7
2
.
0
0
0
0


-
.
3
7
9
0


.
7
4
.
0
0
0
0


-
.
3
7
4
9


.
7
6
.
0
0
0
0


-
.
2
7
9
8


.
7
8
.
0
0
0
0


-
.
1
1
7
1


.
8
0
.
0
0
0
0



.
0
7
3
5


.
8
2
.
0
0
0
0



.
2
4
5
3


.
8
4
.
0
0
0
0



.
3
5
6
5


.
8
6
.
0
0
0
0



.
3
7
9
8


.
8
8
.
0
0
0
0



.
3
0
9
8


.
9
0
.
0
0
0
0



.
1
6
3
6


.
9
2
.
0
0
0
0


-
.
0
2
2
9


.
9
4
.
0
0
0
0


-
.
2
0
3
8


.
9
6
.
0
0
0
0


-
.
3
3
4
9


.
9
8
.
0
0
0
0


-
.
3
8
3
9


.
1
0
0
.
0
0
0
0


-
.
3
3
8
9


.
1
0
2
.
0
0
0
0


-
.
2
1
0
8


.
1
0
4
.
0
0
0
0


-
.
0
3
0
9


.
1
0
6
.
0
0
0
0



.
1
5
6
6


.
1
0
8
.
0
0
0
0



.
3
0
6
0


. .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
R
=



.
2
0
0
0
0

L
=


2
.
0
0
0
0
0

C
=


2
.
0
0
0
0
0

D
T
=


1
.
0
0
0
0
0

N
=


5
5
.
0
0
0
0
0

V
0
=



.
0
0
0
0
0

W
=



.
0
0
0
0
0

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure 5. Computer output for V
a
= V
0
sin t, showing
transient current present at times near t = 0. At much later
times the function becomes purely sinusoidal.
Solving Eq. (24) for yields
=
1

LC
. (25)
Note that the resonant frequency given by Eq. (25) is the same as the
approximate frequency of free oscillations, given by Eq. (16). This means
that the circuit shows the greatest response (maximum amplitude cur-
rent), when the applied voltage has a frequency equal to the natural
frequency, i.e., the frequency of free oscillations.
13
MISN-0-351 10
2d. Error Analysis . It is easy to compare the accuracy of the im-
proved and original Euler methods. In the improved Euler method we
nd q(t + t) using Eq. (7) in which the derivative dq/dt(t + t) needs
to be evaluated using the original Euler method, that is:
dq
dt
(t + t) =
dq
dt
(t) + t
d
2
q
dt
2
(t) (26)
Combining Eqs. (7) and (26) yields:
q(t + t) = q(t) + t
dq
dt
(t) +
t
2
2
d
2
q
dt
2
(t) . (27)
This is the correct Taylor expansion for q(t + t) up to terms second
order in t. The size of the t
2
term therefore, represents the dierence
between the original and improved Euler methods. Clearly, the accuracy
of both methods improves as t decreases. In the case of the RLC circuit
there are three time intervals of importance:
1. The period of free oscillations T = 2/
0
, where
0
is given by
Eq. (15).
2. The damping time for free oscillations, = 2L/R.
3. The period of the forced oscillations T = 2/, where is the fre-
quency of the applied voltage: V
a
(t) = V
0
sin t.
In order for either the original or the improved Euler method to give
accurate results, the time step t must be chosen to be small compared
to all three of these times.
3. Computer Implementation
3a. Input. The program
3
rst reads numerical values for the parame-
ters R, L, C, D, N, VO, and W, where
R = resistance
L = inductance
C = capacitance
DT = t (time step)
N = number of time steps
V0 = V
0
(amplitude of applied voltage)
W = (frequency of applied voltage).
3
For BASIC, FORTRAN, and C++ implementations, see this modules Computer
Program Supplement.
14
MISN-0-351 11
After reading the data and setting the initial conditions, the program
proceeds to advance the time in the sequence: 0, t, 2t, 3t, . . . , Nt.
For each new value of the time, it calculates new values of the charge
and current from the old values, using the improved Eulers method. In
addition to printing out a table of numerical values giving the current at
each time, the program also displays a graph of current against time.
3b. Output. The sample output shown in Figs. 4 and 5 were obtained
using two data cards with the following numerical values for the parame-
ters:
R L C DT N V0 W
Fig. 4 0.2 2.0 2.0 1.0 55.0 0.0 0.00
Fig. 5 1.0 8.0 8.0 2.0 55.0 0.7 0.25
In the rst case, since the applied voltage is zero (V0 = 0), and since
the values used for R, L, and C satisfy inequality (19), the solution is a
damped oscillatory one, as previously discussed. In the second case, the
sinusoidally varying applied voltage (V0 = 0), yields a solution which is
also sinusoidal, apart from a transient eect.
4. A Project: Examine Accuracy
4a. Accuracy For Free Oscillations. Run the program using a num-
ber of data sets all of which have V
0
= 0 and various values for the other
parameters. Verify that the inequality (19) must be satised if the solu-
tion is to be an oscillatory one, by using values of R slightly less than and
slightly greater than the value for critical damping. For the oscillatory
solutions, see if their detailed shape agrees with the form of the exact
solution (equation). To verify that the shape of the curve in Fig. 4 is
correct, we may identify the times t
1
, . . . , t
4
at which the current I has
its positive maxima: Reading Fig. 4, for example, we nd:
t
1
t
2
t
3
t
4
current (I) 0.2757 0.1818 0.0912 0.0522
time (t) 10.0000 21.0000 34.0000 46.0000
The time from t
1
to t
4
represents three periods, so we empirically nd
T = (t
4
t
1
)/3 = 12 sec. The theoretical value for the period may be
found using Eq. (15) which yields W = 0.494 and T = 2/ = 12.6 sec.
Carry out a similar analysis for your own data.
15
MISN-0-351 12
4b. Accuracy For Forced Oscillations, Resonances. Run the pro-
gram using a number of data sets with various values for the parameters,
except for VO which is kept at some xed nonzero value. In particular, try
a range of values for W with the other parameters held xed. See if the
maximum amplitude current is observed at the predicted resonant fre-
quency, [Eq. (25)]. Use enough values for W, above and below resonance,
to be able to plot by hand a resonance curve (amplitude of the current
versus frequency). Note, that when you vary W you should also vary DT,
since DT = 0.5/W. This will have the eect of giving the same number of
points per cycle for each run.
Acknowledgments
Preparation of this module was supported in part by the National
Science Foundation, Division of Science Education Development and
Research, through Grant #SED 74-20088 to Michigan State Univer-
sity.
A. Fortran, Basic, C++ Programs
All programs are at
http://www.physnet.org/home/modules/support_programs
which can be navigated to from the home page at
http://www.physnet.org
by following the links: modules support programs, where the pro-
grams are:
m351p1f.for, Fortran;
m351p1b.bas, Basic;
m351p1c.cpp, C++;
lib351.h, needed Library for C++ program;
16
MISN-0-351 ME-1
MODEL EXAM
1. Write an explanation of the improved Euler method for the numerical
solution of two coupled rst-order dierential equations of the form
dy
1
/dx = f
1
(y
1
, y
2
, x), dy
2
/dx = f
2
(y
1
, y
2
, x).
Examinee:
On your computer output sheet(s):
(i) Mark page numbers in the upper right corners of all sheets.
(ii) Label all output, including all axes on all graphs.
On your Exam Answer Sheet(s), for each of the following parts of items
(below this box), show:
(i) a reference to your annotated output; and
(ii) a blank area for grader comments.
When nished, staple together your sheets as usual, but include the origi-
nal of your annotated output sheets just behind the Exam Answer Sheet.
2. Submit the graphical results of your free-oscillation runs using the im-
proved Euler method, with your hand-annotated output demonstrating
that:
a. an oscillatory solution requires Eq. (19) when, done by graphically
displaying the shapes found for R values slightly below and above
the critical value;
b. the period of your oscillatory solution is correct, done by deduc-
ing the value of T from at least 3 periods and comparing to your
computed theoretical value; and
c. the general shape of the solution is correct, done by plotting it.
3. Submit the graphical results of your forced-oscillation runs using the
improved Euler method, with your hand-annotated output succinctly
demonstrating that:
a. your maximum current amplitude occurs at your formula-calculated
resonant frequency (shown on a plot of frequency versus current
amplitude).
17
MISN-0-351 ME-2
b. you properly used the same number of points per wave period for
each run.
INSTRUCTIONS TO GRADER
If the student has submitted copies rather than originals of the computer
output, state that on the exam answer sheet and immediately stop
grading the exam and give it a grade of zero.
Note that the award of points is set up in such a way that a student will
get 50% or less on the exam if the student does only computer work and
no physics.
18
19 20

You might also like