Numerical Analysis of the Limit Cycle Behavior by Michael S. Farrell

advertisement
Numerical Analysis of the Limit Cycle Behavior
of the Van der Pol Oscillator
by Michael S. Farrell
for Numerical Analysis for Engineering
MEAE-4960H01
Submitted December 9, 1999
-1-
Table of Contents
Page
List of Units, Symbols and Parameters
2
Introduction
3
Problem Definition and Formulae Derivation
4
Numerical Approach
5
Discussion of Results and Error Analysis
6
Conclusion
9
References
10
Appendix A: Maple Codes (for hardcopy and html)
Appendix B: Maple Data Files (for hardcopy and html)
Appendix C: Report Diskette (for hardcopy only)
Table of Units, Symbols and Parameters
Tube Characteristics
Transconductance (constant)
Saturation voltage (constant)
gm (expressed in mho = 1/ohm)
Vs (expressed in volts)
Circuit Parameters
Inductor (constant)
Capacitance (constant)
Resistance (constant)
Mutual Inductance coefficient
Grid voltage (variable)
L (expressed in henry = weber/ampere)
C (expressed in farad = coulomb/volt)
R (expressed in ohms)
M
eg (expressed in volts)
Bounded Integral over [a,b]
[a,b]
-2-
Introduction
In many cases, the goal of evaluating a physical system lies in the ability to apply
assumptions to deny the nonlinearities of the system to provide a linear model that
resembles the system so that the unknowns can be solved analytically. This goal is
reassuring since the majority of our coursework has been dedicated to solving problems
involving linear, well-behaved systems composed of ideal components. This approach
is satisfactory only if the non-linear behavior of the system is of little importance with
respect to the steady-state result. However, in some instances, the nonlinear properties
of the system present some insight into behavior and stability. This paper will evaluate
the non-linear, limit cycle behavior of the Van der Pol oscillator.
A limit cycle is defined by a second order nonlinear differential equation with an
oscillatory steady-state output in which the amplitude is independent of initial
conditions and dependent on the system parameters. The initial conditions of nonlinear
systems displaying limit cycle behavior may or may not contribute to the frequency of
oscillation. Further, limit cycles cannot occur in linear systems but exist only in
nonlinear systems displaying ‘almost linear’ behavior. Examples of limit cycles in
physical systems include ideal pendulums that display near linear, loss-less oscillations
for small angular deflections and a traffic sign that twists back and forth about the center
of rotation in a steady wind. Stability is obtained when the system parameters lend
themselves to a steady-state periodic solution that forms a closed loop in the phase
plane. For this reason, phase plane or phase trajectory plots are often used to provide a
graphical method of solution for proving limit cycles and illustrating limitations that
hinder stability. The method of developing phase plots for second order differential
equations begins with reducing the system to two first order differential equations. For
example, consider the second order system:
d2y/dt 2 = (t, y, dy/dt)
that is reduced to the following system of equations:
dy/dt = v and
dv/dt = (t, y, dy/dt)
which can be used to form the plot of y versus v. In the case of “free” oscillatory
systems (the greatest potential for limit cycle existence), the term (t, y, dy/dt) does not
include the independent variable of t explicitly. Stability of the system is demonstrated
graphically by ordinary points with phase trajectories spiraling into a stable closed loop
(limit cycle). This effect is manifested by nonlinear, negative damping forces that tend
to increase the amplitude of small velocities, and decrease the amplitude of large
velocities until stability is achieved and the phase plot displays near-harmonic
oscillations. Unstable and half-stable systems are also demonstrated when the phase
trajectories spiral away from the closed loop (unstable) or spiral into and then out of the
closed loop (half-stable). It should be noted that nonlinear systems reduced to first
order equations as shown above are seldom solved explicitly. For this reason, the
solutions are often approximated analytically by trying to linearize the models using
-3-
methods developed by Krylov and Bogoliubov, and Van der Pol. An alternate means,
which provides greater insight to stability, is through use of numerical methods of
solution.
The Van der Pol oscillator (see figure 1) presents an illustration of the existence of
physical systems that may exhibit ‘negatively damped’ periodic behavior. Vibratory
systems such as this oscillator can be self-sustaining, meaning they take energy into the
system rather than losing energy, provided the oscillations are sufficiently small and an
external source is present (a battery in this case) to impart energy into the system. The
non-linear response of the Van der Pol oscillator does not possess an explicit solution,
and therefore will be approximated using the 4th order Runge-Kutta numerical method.
If
M
L
I
R
C
Dummy A.C.
Source, E s
Pentode
Tube
eg
Figure 1. The van der Pol Oscillator
Problem Description and Formulae Derivation
The Van der Pol oscillator is composed of an RLC biased pentode (vacuum tube)
coupled to a feedback loop, via mutual inductance, with a D.C. voltage source. As the
characteristic equations governing the oscillator will show, the values of the circuit
parameters dictate the stability and frequency of the oscillations of the generator. For
the RLC loop, the characteristic equation in terms of the dummy A.C. source voltage
(Es), loop current (i) and feedback current (if) is given by:
Es = L(d i/dt) + Ri + (1/c) (idt) – M(d if/dt)
where the grid voltage is given by:
eg = (1/C) (idt) or i = C eg’ and d i/dt = C eg’’
by substitution, the RLC loop equation becomes:
eg’’ = -(R / L) eg’ – (1 / LC) eg + (1 / LC){ Es + M(d if/dt)}
The pentode's tube characteristics provide the non-linear behavior of the system and are
given by:
-4-
if = gm {1-( eg 2 / 3 Vs2 )} eg
or d if/dt = gm {1-( eg 2 / Vs2 )} eg’
where gm is the transconductance and Vs is the saturation voltage of the pentode. The
above characteristic equations can be combined to form the governing equation we will
explore:
eg’’ – 2 [ 1 -  eg 2} eg’ + 2 eg = 2 Es (forced system)
or eg’’ – 2 [ 1 -  eg 2} eg’ + 2 eg = 0 (unforced system)
where 2 = (M gm - RC) / LC
2 = 1 / LC
 = (M gm) / Vs2 ( M gm - RC)
This result is similar to the differential equations describing vibrations developed by
Balthasar Van der Pol (namesake of the given oscillator) which is of the form:
y’’ - y 2) y’ + y = 0 where   0 for the unforced system above
By inspection, the equation above implies that the damping term y 2) defines the
behavior of the system such that the system exhibits stable harmonic oscillations when
y 2 = 1, is damped and loses energy when y 2 < 1, and is negatively damped when y 2 > 1.
Referring back to the characteristic equations of the unforced oscillator, we see that the
damping term is dependent upon the circuit parameters alone. Therefore, the
parameters of the oscillator of this paper will be selected to provide agreement with Van
der Pol’s equation, which will allow a comparison to be made with the approximate
solution formulated by Van der Pol and several other noted mathematician. To facilitate
the simulation, the Van der Pol oscillator will be represented by the following first order
nonlinear differential equations:
d eg/dt = v
d v/dt = (t, eg , v) = 2 ( 1 -  eg 2) v - 2 eg = ( 1 - eg 2) v - eg
The above equations will be the basis of the simulation in which the only variables will
be the mesh size and the coefficient 

Numerical Approach
There is a wide selection of open and closed form multi-step numerical methods
available to simulate the characteristic equations presented in this problem. Due to the
absence of an explicit solution for error analysis, it is not practical to illustrate the
differences between the methods available. Therefore, the method applied for this
evaluation will be the 4th order Runge-Kutta method. For the purposes of this paper,
Maple V, release 5 software was used with the Maple algorithm of Appendix A. The
algorithm used is defined by the following:
1(t, 1, 2) = d eg/dt = v = 2
-5-
ƒ2(t, 1, 2) = d v/dt = ( 1 - eg 2) v - eg = ( 1 - 12) 2 - 1
where is a constant to be defined during the simulation. The above functions ƒ1 and ƒ2
are used in the Runge-Kutta 4th order method to iterate the solutions of 1 = eg and 2 =
eg’ as follows:
The initial conditions are defined by 1,0 and 2,0, and the mesh size (time step) h is
determined. The new approximations for 1( t=t0 + h) and 2( t=t0 + h) are calculated by
the following weighted approximations:
k1,1
k1,2
= h ƒ1(t, 1, 2) = h 2
= h ƒ2(t, 1, 2) = h( 1 - 12) 2 - 1}
k2,1
k2,2
= h ƒ1(t+h/2, 1 + k1,1/2, 2 + k1,1/2) = h (2 + k1,1/2)
= h ƒ2(t+h/2, 1 + k1,1/2, 2 + k1,1/2)
= h{ 1 - (1 + k1,1/2) 2}(2 + k1,1/2) - (1 + k1,1/2)]
k3,1
k3,2
= h ƒ1(t+h/2, 1 + k2,1/2, 2 + k2,1/2) = h (2 + k2,1/2)
= h ƒ2(t+h/2, 1 + k2,1/2, 2 + k2,1/2)
= h{ 1 - (1 + k2,1/2) 2}(2 + k2,1/2) - (1 + k2,1/2)]
k4,1
k4,2
= h ƒ1(t+h, 1 + k3,1, 2 + k3,1) = h (2 + k3,1)
= h ƒ2(t+h, 1 + k3,1, 2 + k3,1)
= h{ 1 - (1 + k3,1) 2}(2 + k3,1) - (1 + k3,1)]
and the new approximations for 1( t=t0 + h) and 2( t=t0 + h) become:
1( t=t0 + h) = 1( t=t0) + (k1,1 + 2 k2,1 + 2 k3,1 + k4,1) / 6
2( t=t0 + h) = 2( t=t0) + (k1,2 + 2 k2,2 + 2 k3,2 + k4,2) / 6
This process is repeated until the desired stability is reached and the algorithm results
converge, or the results blow up. For the Van der Pol oscillator, the endpoint of the
algorithm is dictated by the graphical results of the phase plot that will either
demonstrate convergence through the presence of a limit cycle, or will become unstable
due to error expansion or a poorly chosen parameter. Typically, programs such as this
one have the stop points in the algorithm defined by a comparison with an explicit
solution (true error) or a comparison with discrete points in which the value of the
function may be known.
Discussion of Results and Error Analysis
The Van der Pol oscillator response was simulated using the algorithm provided
as Appendix A. The oscillator parameters were chosen as previously outlined, with the
only variables being the mesh size h=0.1 and the damping term coefficient These
values were selected to provide suitably slow convergence for a graphical representation
of the limit cycle of the oscillator. The initial conditions imparted on the system were
-6-
arbitrarily selected to provide an illustration of convergence from outside the limit cycle
as shown below:
Figure 2: The phase plot of eg versus eg’ for the Van der Pol oscillator, with step size h=0.1 and  =
0.1 for initial conditions at (5,5)
and from inside the stable limit cycle as shown below:
Figure 3: The phase plot of eg versus eg’ for the Van der Pol oscillator, with step size h=0.1 and
 = 0.1 for initial conditions at (1,1)
-7-
Figure 2 and Figure 3 demonstrate a graphical simulation that appears close to the
function eg = 2 cos t, which is supported by the results of Appendix B.

This result can be compared to the approximation theory developed by Krylov
and Bogoliubov, for differential equations of the form:
d2y/dt 2 +  2 y +  (t, y, dy/dt) = 0 where is a constant
Krylov and Bogoliubov approximated that the solution to the differential equation is of
the form y = r(t) cos ( t), where r(t) and ( t) are functions representing the amplitude
and total phase of the sinusoidal function and the errors are of order 2. The functions 
r(t) and ( t) are obtained from:
dr/dt = () [0,2] (r cos , -r sin ) cos  d = -(r /2)  (r)
d/dt =  + (r) [0,2] (r cos , -r sin ) cos  d =  (r) 1/2
From the equations above, the approximated linear differential equation, for an initial
value r(0) = ro is given as:
d2y/dt 2 +  (ro)dy/dt) +  (ro)y = 0
Krylov and Bogoliubov’s theory for an improved first approximation of the linearized
equation is defined by:
y(t) = r(t) cos ( t) + (2){1/2 (r) + [2,infinity] [ (r) cos k( t) +   (r) sin k( t)]
where:
 (r) = {1/((k2 – 1))} [0,2] (r cos , -r sin ) cos k d for (k=0,2,…)
 (r) = {1/((k2 – 1))}
[0,2] (r cos , -r sin ) sin k dfor (k=0,2,…)
For limit cycles, Krylov and Bogoliubov provided an approximate amplitude rL which is
determined from dr/dt = -(r /2)  (rL) = 0. For Van der Pol’s equation, the improved first
approximation theory results in the following:
dr/dt = (r)(1- (r 2 /4)) and
r(t) = (roe t/2 ) / (1 + 1/4ro 2 (e t –1)) 1/2
Further, the coefficients  (r) and   (r) are all zero except for  (r), so the final
approximation of y(t) by the Krylov and Bogoliubov improved approximation theory is:
y(t) = r(t) cos (t + o) - r3 (t)/32) sin 3(t + o)
This approximation result is an improvement to approximation results of Van der Pol
which is represented by y(t) = 2 cos t. Further, from the above equations, the
approximation for the amplitude rL of the limit cycle occurs when dr/dt = 0 or
-8-
r = rL =2 which will be the basis for the error analysis of the 4th order Runge-Kutta
simulation of the oscillator.
For the simulation data of Appendix B, the peak amplitude of the stable limit
cycle was found by interpolating five data points around the apparent local minima
around t=48.7 seconds using Neville’s Interpolation algorithm of Appendix A, with the
values of t varied until the minima was identified. The point around t=48.7 seconds was
selected based on the apparent graphical convergence to a stable limit cycle (damping
term apparently negligible). The results of the Neville interpolation algorithm, show a
local minima at the point (t=48.299 seconds, eg = -2.00713463). Based on comparison
with Van der Pol’s approximation, the simulation error appears to be approximately
0.0071 over the interval simulated (t = 0 to 50 seconds).
To illustrate the acceptability of the mesh sizes selected, and demonstrate the
acceptable precision of the 4th order Runge-Kutta method, the algorithm of Appendix A
was executed with alternate mesh sizes. In order to compare results, the mesh size of
0.005 was selected as an accurate baseline for comparison (roundoff error assumed
negligible). Further, a five point Neville interpolation was performed for each mesh size
evaluated using the Runge-Kutta algorithm to simulate solutions of eg in the vicinity of
the local minima (t=48.299 seconds) previously found. The results of this exercise is
shown in Table 1 below:
Mesh Size
Time
Minima Amplitude
Iterations
Amplitude error
0.005
0.01
0.02
0.05
0.1
0.2
0.5
48.7299
48.7299
48.7299
48.7299
48.7299
48.7314
48.8200
-2.00713350
-2.00713349
-2.00713351
-2.00713357
-2.00713464
-2.00709943
-2.00446860
9745
4872
2436
974
487
243
97
-----1.0E-8
1.0E-8
7.0E-8
1.1E-6
3.4E-5
2.6E-3
Table 1: Relative error in amplitude for varied mesh size at local minima around t=48.299 seconds of a t=050 second data simulation of the Van der Pol’s equation
As Table 1 demonstrates, the algorithm error approximation for the 4th order RungeKutta method appears less sensitive to truncation error over iterations, and is more
mesh size dependent. Based on the above comparison, the mesh size selected (h=0.1)
appears to provides a satisfactory trade off of precision versus memory (iterations).
Conclusion
This project illustrated the utility of numerical methods in the application of
simulating nonlinear systems. The Runge-Kutta method employed, showed agreement
with the approximate solution to the system and provided data to support the graphical
basis of the simulation. Further, Neville’s interpolation algorithm showed its utility by
allowing values between data points (dictated by mesh size) to be approximated based
on a polynomial approximation to the data. This proved extremely useful in comparing
mesh sizes for suitability. The graphical representation of the oscillator system proved
the existence of limit cycles and their behavior. The plotted graphs showed that system
-9-
stability was achieved regardless of the initial conditions assigned to the system. As
predicted, the simulation results illustrated the nature of limit cycle behavior dictated by
the damping term y 2). Specifically, the oscillator’s damping term forced the
amplitude to decrease for large velocities (eg’ ) and increase for small velocities, until
equilibrium was reached and the limit cycle was formed.
References
Richard Burden and J. Douglas Faires, Numerical Analysis – 6th Edition, Brooks/Cole
Publishing Co., Pacific Grove, CA, c1997
Erwin Kreyszig, Advanced Engineering Mathematics – 5th Edition, John Wiley & Sons,
Canada, c1983
Richard Kolk, Notes in System Dynamics – Existence of Limit Cycles, RPI - Hartford
Graduate Center (unpublished)
J. J. Stoker, Nonlinear Vibrations in Mechanical and Electrical Systems, Interscience
Publishers, Inc., New York, NY, c1950
Granino A. Korn, Ph.D., Mathematical Handbook for Scientists and Engineers, McGraw-Hill
Book Company, New York, NY, c1961
- 10 -
Numerical Analysis of the Limit Cycle Behavior
of the Van der Pol Oscillator
Appendix A: Maple Code Used
- 11 -
The 4th order Runge-Kutta algorithm code was developed to be compatible with Maple
V – release 5 software and was included in the text:
Richard L. Burden and J. Douglas Faires, Numerical Analysis – Sixth Edition,
Brook/Cole Publishing Company, Pacific Grove, CA, c1997
> restart;
> # RUNGE-KUTTA FOR SYSTEMS OF DIFFERENTIAL EQUATIONS ALGORITHM 5.7
> #
> # TO APPROXIMATE THE SOLUTION OF THE MTH-ORDER SYSTEM OF FIRST> # ORDER INITIAL-VALUE PROBLEMS
> #
UJ' = FJ( T, U1, U2, ..., UM ), J = 1, 2, ..., M
> #
A <= T <= B, UJ(A) = ALPHAJ, J = 1, 2, ..., M
> # AT (N+1) EQUALLY SPACED NUMBERS IN THE INTERVAL [A,B].
> #
> # INPUT:
ENDPOINTS A,B; NUMBER OF EQUATIONS M; INITIAL
> #
CONDITIONS ALPHA1, ..., ALPHAM; INTEGER N.
> #
> # OUTPUT: APPROXIMATION WJ TO UJ(T) AT THE (N+1) VALUES OF T.
> alg057 := proc() local OK, M, I, F, A, B, ALPHA, N, FLAG, NAME, OUP,
> H, T, J, W, L, K;
> printf(`This is the Runge-Kutta Method for Systems of m
equations\n`);
> OK := FALSE;
> while OK = FALSE do
> printf(`Input the number of equations\n`);
> M := scanf(`%d`)[1];
> if M <= 0 then
> printf(`Number must be a positive integer\n`);
> else
> OK := TRUE;
> fi;
> od;
> for I from 1 to M do
> printf(`Input the function F[%d](t,y1 ... y%d) in terms of t and y1
> ... y%d\n`, I,M,M);
> printf(`For example: y1-t^2+1`);
> F[I] := scanf(`%a`)[1];
> F[I] := unapply(F[I],t,evaln(y.(1..M)));
> od;
> OK := FALSE;
> while OK = FALSE do
> printf(`Input left and right endpoints separated by blank\n`);
> A := scanf(`%f`)[1];
> B := scanf(`%f`)[1];
> if A >= B then
> printf(`Left endpoint must be less than right endpoint\n`);
> else
> OK := TRUE;
> fi;
> od;
> for I from 1 to M do
> printf(`Input the initial condition alpha[%d]\n`, I);
> ALPHA[I] := scanf(`%f`)[1];
> od;
- 12 -
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
#
>
>
#
>
>
>
#
>
>
>
>
>
#
>
#
>
>
>
#
>
>
>
#
>
>
>
OK := FALSE;
while OK = FALSE do
printf(`Input a positive integer for the number of subintervals\n`);
N := scanf(`%d`)[1];
if N <= 0 then
printf(`Number must be a positive integer\n`);
else
OK := TRUE;
fi;
od;
if OK = TRUE then
printf(`Choice of output method:\n`);
printf(`1. Output to screen\n`);
printf(`2. Output to text file\n`);
printf(`Please enter 1 or 2\n`);
FLAG := scanf(`%d`)[1];
if FLAG = 2 then
printf(`Input the file name in the form - drive:\\name.ext\n`);
printf(`For example
A:\\OUTPUT.DTA\n`);
NAME := scanf(`%s`)[1];
OUP := fopen(NAME,WRITE,TEXT);
else
OUP := default;
fi;
fprintf(OUP, `RUNGE-KUTTA METHOD FOR SYSTEMS OF DIFFERENTIAL
EQUATIONS\n\n`);
fprintf(OUP, `
T`);
for I from 1 to M do
fprintf(OUP, `
W%d`, I);
od;
STEP 1
H := (B-A)/N;
T := A;
STEP 2
for J from 1 to M do
W[J] := ALPHA[J];
od;
STEP 3
fprintf(OUP, `\n%5.3f`, T);
for I from 1 to M do
fprintf(OUP, ` %11.8f`, W[I]);
od;
fprintf(OUP, `\n`);
STEP 4
for L from 1 to N do
STEP 5
for J from 1 to M do
K[1,J] := H*F[J](T,seq(W[i],i=1..M));
od;
STEP 6
for J from 1 to M do
K[2,J] := H*F[J](T+H/2.0,seq(W[i]+K[1,i]/2.0,i=1..M));
od;
STEP 7
for J from 1 to M do
K[3,J] := H*F[J](T+H/2.0,seq(W[i]+K[2,i]/2.0,i=1..M));
od;
- 13 -
# STEP 8
> for J from 1 to M do
> K[4,J] := H*F[J](T+H,seq(W[i]+K[3,i],i=1..M));
> od;
# STEP 9
> for J from 1 to M do
> W[J] := W[J]+(K[1,J]+2.0*K[2,J]+2.0*K[3,J]+K[4,J])/6.0;
> od;
# STEP 10
> T := A+L*H;
# STEP 11
> fprintf(OUP, `%5.3f`, T);
> for I from 1 to M do
> fprintf(OUP, ` %11.8f`, W[I]);
> od;
> fprintf(OUP, `\n`);
> od;
# STEP 12
> if OUP <> default then
> fclose(OUP):
> printf(`Output file %s created sucessfully`,NAME);
> fi;
> fi;
> RETURN(0);
> end;
alg057 := proc () local OK, M, I, F, A, B, ALPHA, N, FLAG, NAME, OUP,
H, T, J, W, L, K; printf(`This is the Runge-Kutta Method for Systems
of m equations\n`); OK := FALSE; while OK = FALSE do printf(`Input
the number of equations\n`); M := scanf(%d)[1]; if M <= 0 then
printf(`Number must be a positive integer\n`) else OK := TRUE fi od;
for I to M do printf(`Input the function F[%d](t,y1 ... y%d) in terms
of t and y1 ... y%d\n`,I,M,M); printf(`For example: y1-t^2+1`); F[I]
:= scanf(%a)[1]; F[I] := unapply(F[I],t,evaln(y.(1 .. M))) od; OK :=
FALSE; while OK = FALSE do printf(`Input left and right endpoints
separated by blank\n`); A := scanf(%f)[1]; B := scanf(%f)[1]; if B <=
A then printf(`Left endpoint must be less than right endpoint\n`) else
OK := TRUE fi od; for I to M do printf(`Input the initial condition
alpha[%d]\n`,I); ALPHA[I] := scanf(%f)[1] od; OK := FALSE; while OK =
FALSE do printf(`Input a positive integer for the number of
subintervals\n`); N := scanf(%d)[1]; if N <= 0 then printf(`Number
must be a positive integer\n`) else OK := TRUE fi od; if OK = TRUE
then printf(`Choice of output method:\n`); printf(`1. Output to
screen\n`); printf(`2. Output to text file\n`); printf(`Please enter 1
or 2\n`); FLAG := scanf(%d)[1]; if FLAG = 2 then printf(`Input the
file name in the form - drive:\\name.ext\n`); printf(`For example
A:\\OUTPUT.DTA\n`); NAME := scanf(%s)[1]; OUP :=
fopen(NAME,WRITE,TEXT) else OUP := default fi;
fprintf(OUP,`RUNGE-KUTTA METHOD FOR SYSTEMS OF DIFFERENTIAL
EQUATIONS\n\n`); fprintf(OUP,`
T`); for I to M do fprintf(OUP,`
W%d`,I) od; H := (B-A)/N; T := A; for J to M do W[J] := ALPHA[J]
od; fprintf(OUP,`\n%5.3f`,T); for I to M do fprintf(OUP,`
%11.8f`,W[I]) od; fprintf(OUP,`\n`); for L to N do for J to M do
K[1,J] := H*F[J](T,seq(W[i],i = 1 .. M)) od; for J to M do K[2,J] :=
H*F[J](T+.5000000000*H,seq(W[i]+.5000000000*K[1,i],i = 1 .. M)) od;
for J to M do K[3,J] :=
H*F[J](T+.5000000000*H,seq(W[i]+.5000000000*K[2,i],i = 1 .. M)) od;
for J to M do K[4,J] := H*F[J](T+H,seq(W[i]+K[3,i],i = 1 .. M)) od;
- 14 -
for J to M do W[J] :=
W[J]+.1666666667*K[1,J]+.3333333334*K[2,J]+.3333333334*K[3,J]+.1666666
667*K[4,J] od; T := A+L*H; fprintf(OUP,`%5.3f`,T); for I to M do
fprintf(OUP,` %11.8f`,W[I]) od; fprintf(OUP,`\n`) od; if OUP <>
default then fclose(OUP); printf(`Output file %s created
sucessfully`,NAME) fi fi; RETURN(0) end
> alg057();
This is the Runge-Kutta Method for Systems of m equations
Input the number of equations
> 2
Input the function F[1](t,y1 ... y2) in terms of t and y1 ... y2
> y2
For example: y1-t^2+1Input the function F[2](t,y1 ... y2) in terms of
t and y1 ... y2
> 0.1*(1-y1^2)*y2-y1
For example: y1-t^2+1Input left and right endpoints separated by blank
> 0 50
Input the initial condition alpha[1]
> 5
Input the initial condition alpha[2]
> 5
Input a positive integer for the number of subintervals
> 500
Choice of output method:
1. Output to screen
2. Output to text file
Please enter 1 or 2
> 2
Input the file name in the form - drive:\name.ext
For example
A:\OUTPUT.DTA
> a:\vdpplot1.DTA
Output file a:\vdpplot1.DTA created sucessfully0
>
The Neville’s Interpolation algorithm code was developed to be compatible with Maple
V – release 5 software and was included in the text:
Richard L. Burden and J. Douglas Faires, Numerical Analysis – Sixth Edition,
Brook/Cole Publishing Company, Pacific Grove, CA, c1997
- 15 -
- 16 -
Download