Solving ODEs Using Taylor Series ..
Solving ODEs Using Taylor Series ..
Solving ODEs Using Taylor Series ..
20%233, 1994
Pergamon Copyright@1994 Elsevier Science Ltd
Printed in Great Britain. All rights reserved
089%1221/94 $7.00 + 0.00
089%1221(94)00193-6
Y. F. CHANG
4258 Piedmont Mesa Road, Claremont, CA 91711, U.S.A.
G. CORLISS
Department of Mathematics, Marquette University
Milwaukee, WI 53233, U.S.A.
The solution of an initial value problem in ordinary differential equations expanded as a Taylor
series has been given as both a classical and a numerical method for many years. The work of
Sir Isaac Newton contains a four term series expansion for a nonelementary ordinary differential
equation. In 1946, Miller [l] used recurrence relations to compute Taylor series terms for the Airy
integral. Others [2,3] have written translator programs using automatic differentiation to write
object programs for solving ODES. Moore [4] solved ODES, evaluating the Taylor series remainder
term in interval arithmetic to compute a guaranteed enclosure of the solution. Lohner [5] is the
latest of many who have advanced Moore’s ideas for interval enclosures of Taylor series solutions
for ODES. Rall [S] g ives other applications of Taylor series methods.
The philosophy of the Taylor series method is totally different from that of other methods in
the solution of ODES. We use a power series for the solution function that is very long compared
to the usual fourth-order or twelfth-order methods. For an ODE whose solution is f(t), the series
terms for f(t) expanded at the solution point with an arbitrary stepsize h and stored as reduced
derivatives,
F(n + 1) := F(n) 2.
These reduced derivatives are the Taylor series terms. We calculate them up to the 30th term and
beyond. With the long Taylor series, it is then possible to calculate the radius of convergence.
This is the principal departure from other methods. The arbitrary stepsize h is adjusted to an
optimum stepsize after the radius of convergence has been calculated. To properly control the
local truncation error, the optimum stepsize is determined from the series length, the radius
The authors would like to express their gratitude to R. Morris for the initial design and coding of the translator
program, to J. Fauss, D. Lowery and M. Prieto for their work on series analysis, to R. Moore, M. Tabor, J. Weiss for
many helpful suggestions, to R. Stanford, P. Breckheimer and K. Berryman at Jet Propulsion Labs for requesting
user defined functions, and to J. Wright for the many bugs found.
209
210 Y. F.CHANG AND G. CORLISS
of convergence, and the preset error limit. Then, the series terms for f(t) are adjusted from
the arbitrary stepsize h to the actual stepsize h,,, by multiplying F(n + 1) by (h,,ew,h)n. An
exception is made in the solution of stiff problems, where the stepsize is determined by the length
of a polynomial that adequately represents the function. The final step in the solution is the
summation for the analytic continuation.
TAYLOR SERIESALGORITHM:
- Call subroutine RSET, which performs analytic continuation and prints the solution.
A method which uses an infinite Taylor series is A-stable. However, in practice, the series
is truncated to N terms. The characteristic polynomial is p(z, y) = z - C[y(k)/k!]. The real-
valued stability intervals are (-8.8,0), (-12.6,0), and (-16.3,O) for N = 20, 30, and 40 terms,
respectively. Taylor series methods are best suited to solve problems that require high accuracy.
Since very high order derivatives are used in these methods, stiff problems can be solved using
the approximation of a polynomial with a negative exponential.
Under the infinite series method option, the function that represents the primary singularity is
determined to allow the integration stepsize to be much larger than in previous methods. If the
error criterion is less stringent than the accuracy to which the pole can be calculated, then the
integration stepsize can be larger than the radius of convergence because we effectively remove
the primary singularity and increase the radius of convergence.
In Section 2, we describe the domain of applicability and the use of the ATOMFT system for
solving ODES by Taylor series methods. The body of the paper considers applications of Taylor
series techniques. In Section 3, we give numerical experiments on global error propagation.
Examples of single and multi-constraint differential algebraic equations (DAEs) are solved in
Section 4. In Section 5, we apply ATOMFT to linear and nonlinear boundary value problems,
numerical quadrature, and delay differential equations.
2. ATOMFT TRANSLATOR
The ATOMFT system [7-lo] is designed to solve stiff and nonstiff initial value ODE problems
and some classes of DAEs. The latter are control problems; for example, the controlled landing
of the space shuttle through the Earth’s atmosphere without burning up (Section 4). ATOMFT
is simple enough to be used by students, practical enough to be used by engineers, and versatile
enough to be used by research mathematicians.
The source code for the complete ATOMFT system is available from Corliss. The complete
package includes the ATOMFT compiler, its subroutine library RDCV, and a printed User Man-
ual [lo], on which this article is based. The ATOMFT system is portable to any computer that
has a Fortran 77 compiler.
ATOMFT 211
2.1.Applicability
l The ATOMFT method can solve:
- systems of stiff and nonstiff systems of initial value problems in ordinary differential
equations in which
- the highest order derivative of each dependent variable is given explicitly on the left
hand side of an equation,
- whose right hand side has a finite sequence of +, -, *, /, **, EXP, SIN, COS, TAN,
SINH, COSH, TANH, ALOG;
- with any number of user-defined functions nested to any depth.
.
- boundary value problems,
- time delay equations,
- problems which have catastrophic subtractive errors, and
- control problems of whatever size (limited by computer memory), with up to nine
constraint equations, and consistent or inconsistent initial conditions.
l ATOMFT can also solve (with some manual intervention):
- problems with polynomial solutions,
- singular problems which require the application of 1’Hopital’s rule.
The very high order and precise error control used by ATOMFT have enabled it to solve
many problems which cause other methods difficulties. It solves with ease a class of problems
with negative-order singularities, which usual methods solve incorrectly. These are problems
whose right-hand sides do not satisfy the Lipschitz condition. For these problems, ATOMFT will
correctly “fail” to compute a solution.
The ATOMFT compiler supports the solution of ODES in the complex domain [ll]. This
unique capability can be used to explore the structure of the singularities in the complex domain
of nonlinear problems. The information about the location and order of singularities in the
solution provides insight into the behavior of the system. This method has been used to map the
first mathematical natural boundary discovered in the solution of a chaotic dynamical system [12-
141.
The complexity and execution time of ATSPGM depend on the number of functions and on
the number of multiplications in the ODE system, and not on the number of equations in the
ODE system nor on the order of the derivatives involved. There is no penalty for high-order
derivatives.
As with all numerical methods, there is no substitute for insight into the structure of the ODE
system and for the application of clever transformations.
only to convey the flavor and ease-of-use of the ATOMFT system. To use ATOMFT, one should
consult the User Manual [lo] ( available from Corliss) for detailed explanations of the features
and many more examples that we include here.
STEP 0. INSTALLATION. At installation time, ATOMFT is compiled and linked with the For-
tran 77 library to create an executable file, and the runtime library RDCV is created. There are
no system-dependent parameters to be set. Of course, the commands to compile, link, and build
the library must be system-dependent.
STEP 1. EDIT ODEINP. At Step 1, the system of differential equations is stated in a form ac-
ceptable to ATOMFT as illustrated in Example 1. The input file ODEINP specifies for ATOMFT
1. the system of differential equations to be solved,
2. how the initial conditions and the interval of integration are communicated to ATSPGM,
and
3. the commands to control the operation of ATOMFT or to control the execution of AT-
SPGM.
Example1.SimpleODEINP file.
The first block contains the system of differential equations. These equations are processed by
ATOMFT to determine the recursion relations that are written into ATSPGM to generate the
Taylor series for each component of the solution. To enter the differential equations, DIFF(Y,T,N)
denotes the Nth derivative of Y with respect to T. N may range from 0 to 8, inclusively. The
DIFF( , , ) func t ion is used to specify the system of ODES with Fortran-like statements using
standard Fortran operators and functions. ATOMFT compiler processes the data in the first
block to produce a Fortran object program ATSPGM, which is then compiled and executed to
solve the problem. The second, third, and fourth blocks are copied unchanged from ODEINP to
predetermined locations in ATSPGM.
The second block is usually empty, but it can be used to insert nonexecutable Fortran state-
ments at the beginning of ATSPGM.
The third block is used to specify the interval of integration and the initial conditions by
reading them from a data file prepared at Step 5. This is the file DATA opened in Block 3. The
interval of integration is from START to END. END can be less than START for integration
in a negative direction. The initial values (at START) of a dependent variable named y and its
derivatives are assigned to the array Y as follows:
Y(1) denotes 9 at START,
Y(2) denotes y’ at START,
Y(3) denotes y” at START, etc.
Thus, in Example 1, two initial conditions Y(1) for y(0) and Y(2) for y’(0) are entered for the
second order differential equation. All other valid Fortran statements may be included in Block 3
ATOMFT 213
to be copied into ATSPGM, ss shown in Example 1 by the WRITE statement to echo the input.
The third block may also be used to change the default values of method-controlling variables.
The fourth block is usually empty. It may be used to insert statements into ATSPGM at the
end of each integration step.
STEP 2. RUN ATOMFT. At Step 2, ATOMFT (A) reads the first block from ODEINP,
(B) analyzes the differential equations, (C) generates the ATSPGM program, and (D) copies the
second, third, and fourth blocks from ODEINP directly into ATSPGM. The User Manual [lo]
includes the complete ATSPGM for Example 1.
In the normal usage of the ATOMFT system, it is not necessary for the user to inspect the
code in ATSPGM. However, in the event of an error or if some small changes are desired, the
user can edit ATSPGM by hand.
STEPS 3 AND 4. COMPILE AND LINK ATSPGM. At Steps 3 and 4, the ATSPGM program is
compiled using any suitable Fortran 77 compiler and linked with the runtime library RDCV to
produce an executable module.
STEP 5. PREPARE THE DATA. The recommended manner to supply the initial conditions, the
interval of integration, and control parameters is to read them from a data file which you prepare
at Step 5. The format of this data file is completely under your control as shown by Example 1.
Step 5 may be done at any time before Step 6, or it may be omitted completely if the input data
is hard-wired into input Block 3 of ODEINP.
STEP 6. RUN ATSPGM. At Step 6, the given problem is solved. Every component of the
equations is expanded in a Taylor series, and the solution point is moved forward by analytic
continuation. ATSPGM may read the data file prepared at Step 5 and writes the solution results.
The exact content, format, and location of the solution results depend on the data in ODEINP
prepared at Step 1.
Now that we have discussed the ATOMFT system for solving ODES using Taylor series tech-
niques, we turn for the rest of this paper to applications to which ATOMFT has been put.
The absolute errors in the solution of this problem are shown in Figure 1. The horizontal scale is
time from zero to t = 50. The vertical scale is the logarithm of the absolute error, log 1ftrue- fcalcj.
The upper curve in Figure 1 is the global error in the solution by DVERK (a Runge-Kutta
method) with a tolerance of lo- lo. The bottom curve is the result from ATOMFT with the same
error limit. The “true” values used for comparison are calculated using an extended-precision
arithmetic.
The global error from ATOMFT is much smaller than the global error from DVERK for the
same error limit. This is indicative of the superior error control under ATOMFT. The propagation
of the global error over time can be seen by examining the plot for the DVERK results. Since
214 Y. F. CHANG AND G. CORLISS
-11 :
ATOMFT takes very large integration steps, there are too few points for analysis. The tops of
the global error plot are on the line for the square of the time. The magnitude of the global error
for nonlinear periodic oscillation increases quadratically with time.
To study the cyclical behavior, we plot the phase diagrams for this problem. Nonlinear prob-
lems have distinctively shaped phase diagrams. The phase diagram usually shown is that for
f’ vs. f. We are going to plot the “derivative” phase diagram for f” vs. f’ in Figure 2 because
the cyclical component of the global error has a phase diagram with the same shape as the de-
rivative phase diagram. It is shaped like a fan, and the points progress clockwise as the time
advances.
Figure 3 is the global error phase diagram for data from the ATOMFT solution. This phase
diagram has a very similar shape as the phase diagram for f” vs. f’ in Figure 2. The exception
is that the error phase diagram in Figure 3 increases in size on each revolution as dictated by
the quadratically growing propagation. This similarity in the two shapes signifies that the global
error is proportional to the derivative of the solution. We cannot prove this conclusion; we only
offer the evidence. This similarity is found in all of the examples that we have examined, including
chaotic systems.
We continue this study of global errors by comparing the solutions to two problems, a two-body
problem and a chaotic problem. The two-body problem has a period of 27r. The initial values
for z, Y, g, and 2 are determined from the eccentricity of the orbit, e = 9.
&a:
==-i, x(0) = 1 - e,
(1)
d2Y Y
dt2 = --a’ Y(9) = 9,
Chaotic dynamical problems are particularly difficult to solve numerically. Many chaotic problems
have singularities in the complex plane that form natural boundaries [12-141. Our example is the
ATOMFT 215
c f’
‘;,
\
\.
.:
‘.. :’
,’
-.. ._ _. *
:
/.’ ,.:,: :
,,..-:‘<‘A
., ‘. ‘. .,
-12.‘
0 time 95
Henon-Heiles problem
d2x
-@ = -x - 2xy, z(O) = -0.3225, s’(0) = 0.24943,
d2y
-@ = -y -x2 + y2, y(0) = -0.3532, y’(0) = 0.29403.
The twobody problem and the Henon-Heiles problem have oscillations with about the same
period, 2n. This allows for a direct comparison of the global error propagation in the two
solutions. The Henon-Heiles problem has singularities that are three time units from the real
axis. The two-body problem has singularities that are only 0.03 time units from the real axis.
The distance of a singularity from the real axis is directly related to the radius of convergence.
Therefore, the two-body problem requires stepsizes that are about one hundred times smaller
than the Henon-Heiles problem. We show in Figure 4 the global errors for problems (1) and (2).
The vertical scale is the logarithm of the error, and the horizontal scale is from t = 0 to t = 95.
These results are obtained from DVERK with a tolerance of 10-l’. The Henon-Heiles results
are marked by small dots, while the two-body problem results are marked by larger dots. The
global error in the two-body solution is very large beginning with the first revolution, while the
global error in the Henon-Heiles solution is quite small during the first few revolutions. As the
numerical solutions progress to longer times, we observe that the global error in the two-body
solution propagates as the square of time, and the global error in the Henon-Heiles solution grows
exponentially with time. The exponential propagation is the characteristic of a chaotic problem.
We begin with a very simple DAE example, a weight at location (2, y) on a string of unit length
suspended from the ceiling.
d2X
- = -xX(t), x(0) = sin(l.2), x’(0) = 0,
dt2
(3)
d2y
s= -YX@) - 91 y(0) = -cos(l.2), Y’(0) = 0,
condition = x * x + y * y - 1 = 0.
The gravitational force is g, and X(t) is the unknown tension in the string. The algebraic con-
straint equation is the “condition” that the string does not stretch. There is a direct cause and
effect relationship between the unknown string tension A(t) condition and the constant string
length. At each solution step, the string length is maintained constant by adjusting the unknown
tension A(t).
To use the ATOMFT system to solve a DAE, the user is required to assign specific names to
two variables. First, the unknown variable in the ODE, X(t) in this example, must be named
FNTCND. The name stands for the function related to the condition. Second in the algebraic
equation (3), the lefthand side must be named CNDITN. The condition must be equal to zero,
CNDITN = 0.
Example2.ODEINP file to ATOMFT for the simple
pendulum.
COPTION DUMF=I
DIFF(X,T,P)= - FNTCND(T)*X
DIFF(Y,T,2)= - FNTCND(T)*Y- 32.2
CNDITN = X*X + Y*Y - I
$
$
START = 0.0
END = 1.0
X(i) = SIN(I.2)
C Y(l) given here is purposelyinconsistent.
Y(i) = -0.5
C Let SEEK find the right initialvalues,with
C X(1) being exact and Y(i) not exact.
X(30) = 1.0
Y(30) = 0.0
$
$
There are two things to note in the ODEINP in Example 2. First, the starting position of the
pendulum is at the extremum of its swing, where both the x and y velocities are zero. At the
starting point, Y(1) = y(0) = - cos(l.2). We have purposely entered an inconsistent initial value
for y(0) = -l/2 to illustrate the power of ATOMFT. Second, the 30th terms of all the dependent
variables (here z and y) must be assigned initial values of 0 or 1 in the third input block. The
X(30) = 1 indicates that the initial value for x is exact. The Y(30) = 0 indicates that the initial
value for y must be adjusted to achieve consistency.
Solution for the simple pendulum.
The ATOMFT algorithm adjusts all of the dependent variables under the control of the sub-
routine SEEK. This is accomplished with reverse communication, where portions of the main
program are inside SEEK’s iteration loops. In the partial solution given above, SEEK finds the
consistent initial value for y(0) = -cos(l.2) = -0.326358. Also, SEEK maintains the solution
on-track by adjusting for consistency whenever the solution wandered off by more than machine
error.
We shall now solve a DAE problem that is much more complicated than the simple pendulum.
This is a space shuttle landing problem described in [15]. The object is to land the space shuttle
without burning up in the Earth’s atmosphere. The unknown variable FNTCND in this problem
is the bank angle of the space shuttle. It appears in the ODES for GAMMA and A. The control
equation involves a cubic function of the relative speed v, -ve of the space shuttle and the amount
of drag.
Example3.The spaceshuttle
problem.
COPTION DOUBLE,DUMP=l
DIFF(XI,T,l) vR*COS(CAMMA)*SIN(A)/(R*COS(AMBDA))
DIFF(HIGH,T,l) VR*SIN(CAMMA)
DIFF(AMBDA,T,l) VR*COS(CAMMA)*COS(A)/R
DIFF(VR.T.1) -DRAG - G*SIN(GAMMA)- OMGSQ*R*COS(AMBDA)*
A (SINUMBDA)*COS(A)*COS(GAMMA) - COS(AMBDA)*SIN(GAMMA))
DIFF(GAMMA,T,l)= ALIFT*COS(FNTCND(T))/VR + COS(GAMMA)*(VR*VR/
A R-G)/VR + 2*OMEGA*COS(AMBDA)*SIN(A) + OMGSQ*R*COS(AMBDA)*
B (SINUMBDA)*COS(A)*SIN(GAMMA) + COS(AMBDA)*COS(GAMMA))/VR
DIFF(A,T,l) = ALIFT*SIN(FNTCND(T))/(VR*COS(GAMMA))
+ VR*
A COS(GAMMA)*SIN(A)*TAN(AMBDA)/R - 2*OMEGA*(COSUMBDA)*COS(A)*
B TANCGAMMA)- SIN(AMBDA))+ OMGSQ*R*COS(AMBDA)*SIN(AMBDA)*
C SIN(A)/(VR*COS(GAMMA))
R = HIGH + 20902900.
GSQR = l.l86445918E+8/R
G = GSQR*GSQR
OMEGA = 7.29211585E-5
OMGSQ = OMEGA*OMEGA
FORCE = l345*2.37780208E-03*VR*VR*EXP(-HIGH/2.38E4)
ALIFT = 8.769230769E-l*FORCE/5964.496499824
DRAG = 8.246153846E-l*FORCE/5964.496499824
CNDITN = CO + Cl*DVR + C2*DVR*DVR+ CS*DVR*DVR*DVR- DRAG
CO = 3.974960446019
Cl = -1.448947694635E-2
c2 = -2.156171551995E-5
c3 = -l.O8960950729lE-8
DVR = VR - VO
DEGRAD = 3.14159265358979/180.
vo = 1.1
ATOMFT 219
$
$
START = 332.868734542DO
END = 419.868734542130
AMBDA(i) = 3.20417885Di*DEGRAD
GAMMA(l)= -7.49986488D-l*DECRAD
XI(l) = 1.77718047DZ*DEGRAD
A(l) = 6.27883367Dl*DEGRAD
HIGH(l) = 2.64039328D5
vR(l) = 2.43170798D4
vo = WI)
vR(30) = 1
AMBDA(30)= 0
GAMMA(30)= 0
X1(30) =o
A(301 = 0
HIGH(30) = 0
$
9
The initial conditions given in Example 3 are taken from [15]. They do not have sufficient
accuracy for the ATOMFT standard double precision error limit of 1Zdecimal digits. Therefore,
ATOMFT does not accept the initial values as given. In the solution output listed below, all the
initial values except xi and V, are adjusted by DSEEK. The differential equations specifying the
space shuttle problem were stated in reference [15] as first-order equations. This does not imply
a derivative offset equal to one in the ATOMFT solution [16]. The derivative offset of a control
problem is defined to be the difference between the order of the FNTCND Taylor terms and the
order of the related CNDITN Taylor terms. The derivative offset is usually equal to the order of
the ODE, the correct order of the ODE for the scientific problem and not an artificially written
ODE. The equations of motion are second-order ODES.
Solution
forthespace
shuttle
problem.
Step number 0 at T = 3.32868735D+02
XI 3.10176506036403D+00
HIGH 2.64039328000000D+05
AMSDA 5.59234707552655D-01
VR 2.43170798000000D+04
GAMMA -1.30897335610689D-02
A l.O9586320726579D+OO
The exact solutions to this linear DAE problem are x1 = sin(t), 22 = cos(t), x3 = et, and
x4 =e -'. Thus, the consistent initial conditions at t = 0 are x1 = 0, 22 = 1, x3 = 1, and x4 = 1.
The input to ATOMFT for this example is given in Example 4, where we have specified the
consistent initial conditions. The complete solution given by ATOMFT for this example yields
values in agreement with the exact solution.
Example 4. The linear constraint problem.
The ATOMFT system has the capability to solve DAE problems with as many as nine con-
straints. For a single constraint DAE problem, the unknown function FNTCND and CNDITN
are used by ATOMFT to solve the problem. With multi-constraint DAEs, we introduce the
following pairs: FNTCND with CNDITN, FNTCNZ with CNDIT2, etc. Each FNTCNx has its
corresponding CNDITx.
1. zi and yr are the horizontal and vertical positions of the left end of the cross bar one-third
down from the ceiling.
2. 22 and ~2 are the positions of the right end of the cross bar one-third down from the ceiling.
3. 5s and ys are the positions of the weight of the left pendulum.
4. x4 and y4 are the positions of the weight of the right pendulum.
5. AL1 = 1 is the top one-third length of the string.
6. AL3 = 2 is the bottom two-thirds length of the string.
7. BAR= 2 is the length of the cross bar.
8. RM= 10 is the ratio of the mass of the weights of the pendula divided by the mass of the
cross bar connecting the two strings.
With multiple constraints, it is very important that the ODES, the FNTCNx’s, and the CN-
DITx’s are given in the correct order. ATOMFT must be able to perform the sorting of the
equations and variables. The proper input ODEINP file for the coupled pendula is given in
c+ -----la
c------
-----> ~
<:I: _
____-----
__
_->
=zzr---
-___
cr---
---1,
d__
===rr------
------_ __
~_r .____------ ---I===-
--.-----___
I .Yj ==a
Figure 5. Coupled pendula. Figure 6. The swinging weights of the coupled pendula.
222 Y. F. CHANG AND G. CORLISS
Example 5. FNTCND is the tension in the string between the ceiling and 21, FNTCN2 is the
tension in the string between the ceiling and 22, FNTCNS is the tension in the solid cross bar,
FNTCN4 is the tension in the string between zi and x3, and FNTCN5 is the tension in the string
between 2s and x4. The five CNDITx = 0 equations are assigned to the corresponding strings
or cross bar.
The coupled pendula problem has been solved in double precision over a very long duration
of time, fifteen seconds. This is done to observe the stability of the transferring of the energy
between the two pendula. The solution obtained is stable and periodic over the entire fifteen
seconds. This clearly indicates that the Taylor series solution is complete, correct, accurate, and
stable for multiple-constraint problems.
COPTION DOUBLE,DUMP=I
DIFF(Xi,T,2)= - FNTCND(T)*Xi+ FiM*FDX31 + FNTCN2(T)
DIFF(Yl,T,P)= - FNTCND(T)*YI+ RM*FDY31 - 32.2
DIFF(X2,T,2)= - FNTCNS(T)*(XZ- BAR) + RM*FDX42 - FNTCNS(T)
DIFF(YZ,T,P)= - FNTCNB(T)*Y2+ FiM*FDY42 - 32.2
DIFF(X3,T,2)= - FDX31
DIFF(Y3,T,2)= - FDY31 - 32.2
DIFF(X4.T.2)- - FDX42
DIFF(YI,T,S)= - FDY42 - 32.2
FDx31 = FNTCN4(T)*(X3- Xl>
FDY31 = FNTCNII(T)*(Y3- Yl>
FDX42 = FNTCN5(T)*(X4- X2)
FDY42 = FNTCN5(T)*(Y4- Y2)
AL1 = 1.0
AL3 = 2.0
BAR = 2.0
RH = 10.
CNDITN = X1*X1 + Yl*Yl - ALl*ALI
CNDITZ = (X2 - BAR) - Xl
CNDITB = (X2 - BAR)*(X2 - BAR) + Y2*Y2 - ALl*ALl
CNDIT4 = (X3 - X1)*(X3 - Xl> + (Y3 - Yl)*(Y3 - Yl> - AL3*AL3
CNDIT5 = (X4 - X2)*(X4 - X2) + (Y4 - YZ)*(Y4 - Y2) - AL3*AL3
$
$
NSTFPS = 400
START = O.DO
END = 15.DO
X1(1> = 0.298275DO
Yl(l) = -0.95448DO
X2(1) = Xl(l) + BAR
Y2(1) = Yl(1)
X3(1) = Xl(I)
Y3(1) = Yl(I) - AL3
X4(1) = X2(1) + DSQRT(AL3)
Y4(1) = Y2(1) - DSQRT(AL3)
X1(30) = 1
X2(30) = 1
X3(30) = 1
X4(30) = 1
:
5. OTHER APPLICATIONS OF ATOMFT
In this section, we will discuss some applications of the Taylor series method for problems that
are outside of the usual class of ODES. ATOMFT can be applied to boundary value problems, the
evaluation of integrals (quadrature), and delay differential equations. There can be many other
ATOMFT 223
applications of the ATOMFT system. If you find any interesting examples, please communicate
with the authors.
We introduce a new Taylor series algorithm that can solve linear boundary value ODES without
iteration. A linear problem is defined here as a problem that has a solution function that is entire.
This class of boundary value problems can be solved in Taylor series form; ATOMFT is not
needed here. On the other hand, the solutions of nonlinear boundary value problems do require
iterations; so, ATOMFT is needed for nonlinear problems. We give detailed solution examples
of both linear and nonlinear boundary value problems.
Another application of ATOMFT is the evaluation of integrals of complicated functions. Since
the ATOMFT system can generate a program code for any function, we can use it to perform
numerical integration of both simple and complicated functions. In fact, by direct comparison,
the ATOMFT method of quadrature is considerably faster than QAGS from QUADPACK [18],
for the integral of a Bessel function.
We complete this section by solving a sample delay differential equation. The ATOMFT system
is particularly good in the solution of a delay problem, because of the very large stepsizes that it
can take. As a consequence, we are required to save only a minimum amount of previous data,
just enough to reach back to the delayed time step. In our example, this can be just a single
step. This sample delay problem has two time delays.
Solutions which are entire (they have no singularities in the finite plane) can be found without
using iteration. Entire solutions are characterized by infinite radii of convergence. It can be
shown that all problems, including boundary value problems, with entire solutions can be solved
in Taylor series form. Since the radius of convergence is infinite for linear problems, the Taylor
series solution (in theory) can cover the entire domain of the problem in a single step. Linear
systems of ODES can be solved quickly and accurately by the ATOMFT system, However, we
will not use the ATOMFT system at first.
An example of a general second-order linear ODE can be written as
d2y=
z yet, on [0, l] with y(0) = 1, y(1) = 10.
The reduced derivatives for the exponential w(t) = et at t = 0 are W(i) = l/(i - l)!, and they
satisfy the general recursion relation
k-2
k-2 Y(k - 1 - i)
Y(k)(k-l)(k-2)=CW(i)*Y(k-l-i)=~ (i_1), . (5)
i=l
The Y-series is the general solution to the problem. Since the problem is linear, we can apply
the principle of superposition and define the solution as the sum of two separate functions, a
known u(t), and an unknown u(t). Then, the terms for the A-series and U-series must sum to the
Y-series, Y(k) = A(k) + U(k). Starting with the known boundary condition at t = 0, y(0) = 1,
we have A(1) = Y(1) = 1, and U(1) = 0. A(1) is completely known (equal to one). U (1) is
completely unknown, so it is set equal to zero. Since the first derivative of y is unknown, the
second terms of A and U are
A(2) is completely unknown; so it is set equal to zero. U(2) is known (equal to the guess G).
224 Y. F. CHANG AND G. CORLISS
Both the A-series terms and the U-series terms obey the general recursion relation (4) because
they are both solutions of the same problem. They satisfy
The sum of all the A-series terms is a(l) = 1.8210821. Similarly, using u(2) = guess = G, the
U-series must satisfy the same recursion relation,
so G = 6.2604255. Indeed, having this value for the derivative of y at t = 0, we can solve this
problem as an initial value problem. The result for y at t = 1 is found to be exactly 10.
We have described the manual Taylor series solution for a boundary value linear problem. We
now implement this solution using the ATOMFT system. It is necessary to solve the problem (4)
twice; once for the auxiliary function a(t), and once for the auxiliary function u(t). The value
for the missing initial condition, y’(0) = G, is then solved just as in equation (6). The ODEINP
file for this problem is given in Example 6. The solution for the guess = G is easily obtained.
This example of a linear boundary value problem is necessarily a simple one so that we may
describe the noniterative Taylor series solution in complete detail. Since ATOMFT can handle
problems with any degree of complexity, it is therefore possible to solve all linear boundary value
problems with almost equal ease. The main things to remember are (1) the use of two identical
ODES, one each for the known and unknown variables, and (2) the initial conditions for the
known and unknown are exactly skewed. When one variable is equal to one, the other variable
is equal to zero and visa versa. The complete ATOMFT output for this problem is the message,
“The initial slope is 6.2604263+00.” Use this to solve for y(t).
COPTION DUMP=1
DIFF(A,T,2) = A*EXP(T)
DIFF(U,T,S) = U*FXP(T)
$
$
START = 0.0
END = 1.0
A(1) = 1.0
U(2) = 1.0
MPRINT = 0
$
c = (10.0 - A(l))/U(l)
wMTE(*,101) G
101 FORMAT(’ The initial slope is’,lPE14.6)
STOP
$
ATOMFT 225
When a boundary value problem is nonlinear, ATOMFT usually yields a solution with efficiency
and very high accuracy. Of course, with nonlinear problems, there is always the question of
existence of the solution. In those instances when the solution has either a sharp spike or a
boundary layer behavior, ATOMFT has difficulties just as other numerical methods have.
In 1966, Leavitt proposed that two-point boundary value problems could be solved using a
two-dimensional Taylor series, where the first dimension contains the power series of the solution
with respect to the independent variable, and the second dimension has the solution function
expanded in powers of the unknown initial condition. In 1971, Chang wrote a compiler called
ATSBVP based on this idea. The two-dimensional Taylor series were 20x20; 20 terms in the
normal series, and 20 terms in powers of the unknown. It was used successfully to solve boundary
value problems. In 1976, Corliss questioned the efficiency of the two-dimensional Taylor series
technique, “Is it cost effective to carry the solution in powers of the unknown initial condition all
the way to 20 terms?” He analyzed the situation and concluded that the most efficient method
for solving boundary value problems should contain only the terms up to the second power of the
unknown initial condition, a third-order method. His analysis also showed that a second-order
method such as Newton’s iteration is only 15 percent less efficient than the third-order method.
Upon learning of these results, Chang abandoned work on the ATSBVP compiler.
In previous versions of ATOMFT, we had recommended the variational technique plus Newton
iteration to solve boundary value problems. Here, we illustrate the ease of use of standard shooting
techniques in the context of Taylor series algorithms. Shooting algorithms do not necessarily
require the differentiation of the ODES, and can be quite good at detecting the nonexistence of
solutions.
We introduce a new approach to shooting algorithms. We solve the system of ODES with a
first guess for the unknown initial condition. Successive guesses are produced automatically by
the subroutine BVP. It is called to process the iterations, which are performed on the calculated
results at the far boundary in following manner. Upon completion of the first solution, the second
guess is the first guess plus ten percent. Upon completion of the second solution, the third guess
is calculated from a straight-line fit. After the third solution, the fourth guess is calculated
by a parabolic fit. Then, each succeeding solution yields an ever higher-order fit for the next
guess. Our algorithm requires finding the roots of successively longer polynomials for each guess.
This is handled easily by the RTPOLY algorithm within BVP. RTPOLY is a Taylor series based
algorithm to solve for all the roots of any polynomial. It is very fast, and very powerful. It has
solved polynomials as large as degree 8,000.
To activate our algorithm in ATOMFT for two-point boundary value problems, one only needs
to insert a ‘CALL BVP’ in the fourth data block of ODEINP.
IF(KFNDFC .NE. 2) GO TO 25
CALL BVP(KOUNT,VALUE,BVAL,GUESS.IPASS,BPASS),
where KOUNT is the number of iterations attempted, VALUE is the name of the variable that
is to match the boundary value BVAL, and GUESS is the current guess.
This problem will be solved as an initial value problem starting at t = 0. We will use a first trial
G = 1.0 for the unknown slope.
226 Y.F. CHANG AND G. CORLISS
Example7.ODEINP file
fora simple
boundary
value
problem.
COPTION DUMP=1
DIFF(Y,T,P)= - EXP(Y)
8
8
C This is the desired boundaryvalue.
BVAL = 1.3
GUESS = 1.0
C The iterationDO-loop.
DO 28 KK=l,lO
C The initial H must be reset here.
H= 1.414
START = 0.0
END = 1.0
Y(i) = 1.0
Y(2) = GUESS
HPRINT = 1
8
IF(KENDFC .NE. 2) GO TO 25
CALL BVP(KK,Y(l),BVAL,GDESS,IPASS,flPASS)
8
Solution
toExample7.
For trial I, next guess = 5.000000E-01 For trial 5, next guess = 2.784599E+OO
ATOMFT also works well if the boundary conditions are complicated functions of y and y’ at
the boundaries. The User Manual [lo] contains examples.
COPTION DUHP=l
DIFF(X.T.2)= - DBAG*DIFF(X,T,i)
DIFF(Y,T,2)= - DBAG*DIFF(Y,T,l)- 32.3
DRAG = COEF*VEL
VEL = SCjRT(DIFF(X,T,l)*DIFF(X,T,l)
+ DIFF(Y.T.l)*DIFF(Y,T,l))
COEF = 3.E-5
8
8
ATOMFT 227
BVAL = 45000.0
C The first guess for the angle.
GUESS = 0.2
DO 28 KK=l,lO
H= 1.414
START = 0.0
C Make time long enough to hit target.
END = 70.0
MPRINT = 2
X(l) = 0.0
Y(l) = 0.0
X(2) = 3ooo.o*cos(GuEss)
Y(2) = 3000.O*SIN(GUESS)
$
c Locate the time when the cannonballhits the ground.
CALL ZEBOT(Y,O.O.TMPV,NAMES,IPASS,RPASS)
IF(LBUN .NB. 0) GO TO 25
KENDFG = 2
CALL BVP(KK.X(l),BVAL,GUESS,IPASS,RPASS)
$
The muzzle velocity is 3,000 feet per second, the drag force is proportional to the square of the
velocity with a coefficient of 3.E-5. We use a value of GUESS = 0.2 for the unknown elevation
angle of the cannon. The solution is stopped by calling ZEROT which finds the time at which
the cannonball hits the ground (y = 0). At that time, the value of X(1) is the distance the
cannonball has traveled.
A synopsis of the cannonball solution is listed below. Only the final solution values at impact
are shown. The target is hit with six digit accuracy in five iteration loops. The cannon barrel
should be set at an angle of 0.266918 radians to hit a target exactly at 45,000.0 feet.
of the cannonball
Solution problem.
For trial 4, next guess = 2.6694573-01
qb - qa = abf(T)dx. 6-9
J
Since the constant C in equation (8) is arbitrary, we can let either qa or Qb = 0 when we solve
equation (9) by applying our algorithm. Differentiating both sides of equation (8), we have
Since equation (10) is an ordinary differential equation, we can use any ODE solver to evaluate
the definite integral of equation (9). If we let q. = 0, then we need the value for f(a) as an
initial condition. For a simple function such as f(x) = sin(x)2, the function call for a typical
Runge-Kutta type ODE solver would be as follows.
SUBROUTINEFUNC(T,A,ADOT)
DIMENSIONA(I),ADOT(l)
DUMMY = A(1)
F = SIN(T)*SIN(T)
ADOT = F
BETUBN
END
Of course, the lower and upper limits of integration must be specified in the driver program.
For ATOMFT, the input data for this integral listed in Example 9. For a = 0.2 and b = 1.0,
ATOMFT yields q = 0.27003.
Example9.Simplequadrature.
COPTION DWlP=I
DIFF(Q.X.1)= SIN(X)*SIN(X)
$
$
A = 0.2
B = 1.0
START = A
END = B
Q(i) = 0.0
$
$
When the integral is not of a function that is tabulated or can be easily calculated, it is very
difficult to perform the integration using the usual quadrature routines, such as QAGS. Then,
the simplicity of our algorithm for evaluating the integral is evident. Consider the example
Jo1
f(d2 dx,
ATOMFT 229
d2f
s=-f&- 4f f 3 with f(0) = -0.045, f’(0) = 0.25.
The usual numerical integration methods will have a great deal of difficulty with this example,
because the function f(z) is not tabulated. (As we will show later, even for a Bessel function,
which is tabulated, our algorithm is much faster than QAGS.) The ODEINP file for the evaluation
of this integral by the ATOMFT system is listed in Example 10. The calculation yields q =
0.0103192.
Example10.A nonlinear
integrand.
COPTION DUMP=1
DIFF(F,X,O)= - DIFF(F,X,i)*F- F
DIFF(Q,X,I)= F*F
$
$
START = 0.0
END = 1.0
F(l) = - 0.045
F(2) = 0.25
Q(l) = 0.0
MPRINT -1
$
$
An example of an integrand involving Bessel functions was given to us because it was evaluated
very slowly by QAGS. Let f(r) = JO(T) - &(r) + 0.06(&(r) - Yz(r)), a linear combination of
Bessel functions of the first and second kinds. We evaluate
,:f(r)2
J. r dr.
Example11.Integral
ofa Bessel
function.
COPTION DODBLB,DUMP=l
C The Bessel equationsfor J (firstkind) and Y (secondkind).
DIFF(BBSJ,R,2)= BBSJ/RSQ- BBSJ - DIFF(BBSJ,Fl,i)/R
DIFF(BBSY,R,2)- BBSY/RSQ- BESY - DIFF(BESY,R,l)/R
RSQ = R*R
C The rest of this data is for the integral.
AW = 6.D-2
P = P*DIFF(BESJ.R,l) + 2*AMlJ*DIFF(BBSY,R,i)
DIFF(q,R,l)= - P*P*R
$
S
KTRDCV-1
START = 5.DO
END = 0.4DO
C The first two series terms of the Bessel functionsat STARTIS.
BBSJ(I) = -3.27579137591466D-01
BESJ(2) = -1.12080943796045D-01
BESY(I) = 1.47863143398317D-01
BBSY(2) = -3.38090253950026D-01
$
The Bessel functions of the first and second kinds are calculated from the Bessel equation using
the starting values at T = 5, because there is a singularity at T = 0. We need the first two terms
of the Bessel functions J and Y at r = 5 for the initial conditions.
230 Y. F. CHANG AND G. CORLISS
Although Bessel functions are tabulated, and there are programs to perform their evaluations,
QAGS is very slow in this integration. The evaluation of this integral by a Runge-Kutta ODE
solver (DVERK) is five times faster than QAGS. The ATOMFT evaluation of this integral is
19 times faster than QAGS. Our algorithm is very easy to apply, and it is very fast.
of the Bessel
Solution function
integral.
An ODE with time delay requires that the solution results from earlier times be available for
inclusion in the calculations at the current time. This means that the earlier results must be
stored and ready for recall. For ATOMFT, this can be done with ease. Since the ATOMFT
solution takes very large stepsizes, it is necessary to save only a few of the previous results. For
many simple delay problems, only a single step needs to be saved. We will describe the solution
of a problem with two time delays, where many more previous data must be saved.
While using ATOMFT to solve delay problems, it is important to remember that Taylor series
are used in this method. The Taylor series to be saved contains information about the solution at
a previous time, with a specific expansion stepsize. It is therefore necessary that the expansion
stepsize be maintained constant throughout the entire solution. Otherwise, the Taylor series
saved will not be usable for inclusion in subsequent calculations. Alternatively, one could achieve
a variable stepsize by storing the Taylor series with the stepsize used to generate it and re-
evaluating the series at intermediate points as necessary. For our example delay problem, the
radius of convergence is much larger than the stepsize, so a constant stepsize can be maintained
easily.
When there is a single time delay which is smaller than the time step, the ATOMFT solution
needs to save the solution at one previous step. We do this by adding a simple replacement
statement. We illustrate this with the following example.
We need to save and recall the Taylor series for the solution f(t) at an earlier time, f(t - T). We
introduce an additional variable FTMTAU to hold the saved data. Then, a simple replacement
statement FTMTAU = F accomplishes this task when a stepsize equal to TAU is used. The
Taylor series stored in FTMTAU is exactly that from the previous step in the solution.
When the stepsize cannot be equal to the time delay because the radius of convergence is small,
or because of some other constraint, we must then introduce more than one additional variable.
For example, if this problem had required the inclusion of f(t - 37), we would add three variables
as follows.
FMBTAU = FM2TAU
FMlTAU = FMTAU
FMTAU = F
ATOMFT 231
They must be processed in exactly the order given. This processing order is necessary for the
proper transfer of the stored data from F to FM3TAU in three separate steps as the solution of
the problem progresses forward. We write the first two replacement statements as derivatives of
order zero.
DIFF (FM3TAU.T, 0) = FMZTAU
DIFF WMPTAU, T, 0) = FMTAU
FMTAU-F
We will now solve a delay problem with two time delays. In this problem, the first time delay
variable is p(t - i), and the second time delay variable is r(t - 6i). We need to add one variable
for ~(t - i), and six variables for r(t - 6i). Note the seven additional variables and their positions
in Example 12.
l
=P(t - i) - fc r(0) = 0,
>
dp
- = 20r(t - Si) - ;p, p(0) = 0.
dt
Example 12. Delay differential equation.
COPTION DUMP-1
DIFF(RNA,T,l)= 15 - O.O15*PTMI- 0.5*RNA
DIFF(P,T,I)= 2O*RTM61- 0.6*P
PTMI = P
DIFF(RTMGI,T,O)= RIM51
DIFF(RTM51,T.O)= RTM41
DIFF(RTM41,T.O)= RTM31
DIFF(RTM31,T.O)= RTM21
DIFF(RTM2I.T.O)= RTMI
RTMI = RNA
$
$
START = 0.0
END - 20.0
H= 10.0
$
C Move the next line to between
RNEW = 1.0
C the calls for RDCV andRSET.
RADIUS = 10.0
$
The statement H = 10.0 and the statement RADIUS = 10.0 are required to maintain a constant
Taylor series expansion stepsize. This stepsize is a little smaller than the radius of convergence.
We chose it to avoid underflow and overflow. The ATOMFT is not completely automatic. We
must manually edit one line in the ATSPGM object program produced by ATOMFT. The state-
ment HNEW = 1.0must be manually moved to above the statement at Fortran label 24. The
resulting code should appear as follows.
CALL RDCV0MPV,NAMRS,IPASS,RPASS)
RNIIW= 1.0
24 CALL RSET0'MPV,NARRS,IPASS,RPASS)l
The reasonisthat we must maintaina constantstepsize equal to the smallertime delay.This
isthe unitof time that the solution can step forward. It must do so in order to keep the saved
solution data in their proper positions. HNEW is the step that the ATOMFT solution takes, and
the smaller delay time is i = 1. Therefore, HNEW must be equal to 1. Normally, HNEW is the
output of the RDCV subroutine, which makes HNEW a fraction of the radius of convergence.
We are thus overriding the normal output. The solution results for this example delay problem
is listed below. Noticethatp(t) iszerountil the seventhtime step.
232 Y. F. CHANGANDG. CORLISS
,. _#....,.___,.1
Step number 0 at T = O.OOOOOE+OO Step number 8 at T I
o.VVVvVE+VU
This completes our discussion of delay problems. It is not possible to cover the many dif-
ferent types of delay problems in this article. If you encounter any interesting problem, please
communicate with the authors.
CONCLUSIONS
Taylor series methods are powerful, accurate, and flexible tools for attacking many types of
problems in scientific computation involving ordinary differential equations. The ATOMFT
software and User Manual are available from George Corliss (Address on by-line, or e-msil-
georgec@mscs .mu. edu).
REFERENCES
1. J.C.P. Miller, The Airy integral, In Brit. Asso. Adu. Sci. Math. Tables, Volume B, Cambridge Press, (1946).
2. D. Barton, I.M. Willem, and R.V.M. Zahar, The automatic solution of ordinary differential equations by the
method of Taylor series, Comput. J. 14, 243-248 (1971).
3. H.J. Halin, The applicability of Taylor series methods in simulation, In Proc. 1983 Summer Computer
Simulation Conf, July 19-13, Vancouver, BC, (1983).
4. RE. Moore, Interval Analysis, Prentice-Hall, Englewood Cliffs, NJ, (1966).
5. R.J. Lohner, Enclosing the solutions of ordinary initial and boundary value problems, In Computer Arith-
metic, Scientific Computation, and Programming Languages, (Edited by E. Kaucher, U. Kuliih, and Ch. Ull-
rich), pp. 255-286, Teubner, Stuttgart, (1987).
6. L.B. Rail, Automatic differentiation: Techniques and applications, Spr&ger Lecture Notes in Computer
Science, Vol. 120, Springer-Verlag, Berlin, (1981).
7. Y.F. Chang, Automatic solution of differential equations, In Constructive and Computational Methods
for Diflerential and Integral Equations, Springer Lecture Notea in Math., (Edited by D.L. Colton and
R.P. Gilbert), Vol. 430, pp. 61-94, Springer-Verlag, New York, (1974).
a. Y.F. Chang and G. Corliss, Solving ordinary differential equations using Taylor series, ACM T+uns. Math.
Soft 8, 114-144 (1982).
9. Y.F. Chang, The ATOMCC Toolbox, BYTE, 215-224 (April 1986).
10. Y.F. Chang, ATOMFT USER MANUAL, Veraion 3.11, (March 1993).
11. G. Corliss, Integrating ODBs in the complex plane-Pole vaulting, Ma#a. Comp. 35, 1181-1189 (1980).
12. Y.F. Chang, M. Tabor, J. Weiss, and G. Corliss, On the analytic structure of the Henon-Heilee system, Phys.
L&t. 8SA, 211-213 (1981).
13. Y.F. Chang, M. Tabor, and J. Weiss, Analytic structure of the Henon-Heiles Hamiltonian in integrable and
nonintegrable regions, J. Math. Phya. 23 (4) 531-538 (1982).
14. Y.F. Chang, J.M. Greene, M. Tabor, and J. Weiss, The analytic structure of dynamical systems and
self-similar natural boundaries, Physica 8D, 183-207 (1983).
15. K.E. Brenan, Numerical simulation of trajectory prescribed path control problems by the backward differen-
tiation formulas, IEEE lens Automatic Control, AC-31 3 (1986).
16. Y.F. Chang and G. Corllss, Solving control problems with multiple constraints, In Proc. 13th ZMACS World
Congress, (Edited by R. Vichnevetshi and J.J.H. Miller), pp. 1331-1332, (1991).
17. K.E. Brenan and L.R. Petaold, The Numerical Solution of Higher Zndea Differential/Algebraic Equations by
Implicit Runge-Kutta Methods, Lawrence Livermore National Laboratory, Preprint UCRL-95905, (December
1986).
ATOMFT 233
18. FL Pieaeene,E. deDoncker-Kapenga, C.W. Uberhuber, and D.K. Kahaner, QUADPACK: A subroutine pack-
age for automatic integration, In Springer Series on Comp. Math., No. 1, Springer-Verlag, New York, (1983).
19. G. Corliee and Y.F. Chang, G-Stop facility in ATOMFT, a Taylor series ODE solver, In Computational
ODE, (Edited by S.O. Fatunla), pp. 37-77, University of Benin, Benin-City, Nigeria, (1990).
20. K.W. Berryman, R.H. Stanford, and P.J. Breckheimer, The ATOMFT integrator: Using Taylor eeriea to
solve ordinary differential equations, AIAA J. 88-@17-CP, 55 (1988).
21. Y.F. Chang, J. Fauss, M. Prieto and G. Corlise, Convergence analysis of compound Taylor series, In Pro-
ceedings of the Seventh Conference on Numerical Mathematics and Computing, pp. 129-152, University of
Manitoba, (1978).
22. Y.F. Chang and G. Corlii, Ratio-like and recurrence relation tests for convergence of series, J. Inst. Math.
Appl. 25, 349-359 (1980).
23. G. Corlii and D. Lowery, Choosing a stepsize for Taylor series methods for solving ODES, J. Comput. Appl.
Math. 3, 251-256 (1977).