Chapter 14 Differential Equations - 2009 - A Guide To Microsoft Excel 2007 For Scientists and Engineers
Chapter 14 Differential Equations - 2009 - A Guide To Microsoft Excel 2007 For Scientists and Engineers
Differential Equations
Differential equations occur in many physical problems. Let us
look at some simple examples.
Consider the simple equation dvIdt =9 for a falling body when air
resistance is ignored. This integrates to give v =gt + c where cis
the integration constant and 9 is a constant of known value. Thus
we do not have a unique solution, since any value of c will satisfy
248 A Guide to Microsoft Excel 2007 for Scientists and Engineers
Exercise 1: Euler's Euler developed a method for finding the approximate solution to
initial value problems. Let the differential equation to be solved
Method have the form of Equation 14.5 and letthe initial value ofy beyo'
Letthe solution (i.e., the integral of Equation 14.5) have the form
of Equation 14.6.
Y = g(x,Y) (14.6)
f(x)
Y'o
Yo
x,
xc .......:..:..:.------ xo Xl
Figure 14.1
From Equation 14.5, we may calculate any value y'I'y'Z' ...,y'n' We
already know the value ofYo - the initial value. Our task is to find
values for YI'Yz, ..·,Yn· Integration of Equation 14.5 from Xo to Xl
yields Equation 14.7.
Xl
Yl = Yo + J !(xo,yo)dx (14.7)
Differential Equations 249
The second term on the right is the area under the curve f(xJl)
between the two x-values. Euler approximated this to the area of
the rectangle defined by y'O,y'l' x o, and Xl' The approximate value
ofy, is then given by Equation 14.8, or by Equation 14.9 when the
x increment is represented by h.
YI = Yo + (Xl - xo)f(xo, Yo) (14.8)
Yl = Yo + hf(xo,Yo) (14.9)
Figure 14.2
(f) Copy the cells B7:D7 down to row 11. This computes the
successive y approximations. Since we shall not be using the
last value of h*f(x,y), delete Dl1.
1.14
1.12
1.10
1.08
1.06
1.04
1.02
1.00
0.98
0 0.1 0.2 0.3 0.4 0.5
Figure 14.3
Exercise 2: The Like the Euler method, the Runge-Kutta methods finds that an
approximation for y is based on the previous value. These
Runge-Kutta Method mathematicians developed a number of algorithms to solve
differential equations. We shall use the fourth-order Runge-Kutta
The fourth-order method is method, the derivation of which is beyond the scope of this book.
sometimes called the The iterative formula is given in Equation 14.12.
Kutta-Simpson formula since, Y n-] = Y n +i(k] +2k2 +2k3 +k4 )
when the right-hand side of k. = hf(xn,yJ
the differential equation is a
k 2 = hf t x; +fh,Yn +fk]) (14.12)
function of xalone, it reduces
to Simpson's 113 rule. k 3 = hf t x; +fh,Yn +fk2 )
k 4 =hf(xn +h'Yn +k3 )
In the next chapter, a
user-defined function is This may look somewhat formidable so let us see how we can put
developed to perform the it into a worksheet. We have seen in Exercise 1 how to evaluate
Runge-Kutta computation. the equivalentto k 1; this is the value of the differential function for
various x- andy-values. The second parameter, k 2, is similar except
that the x-value is incremented by h while the y-value is
incremented by k 1 . Each parameter increments y by a multiple of
the parameter preceding it.
In the previous Exercise we solved dyjdx =xy with the initial value
yeO) = 1 using Euler's method. Here we solve the same problem
using the Runge-Kutta method so that we may compare the
results.
Exercise 3: Solving In the previous Exercise we solved dy/dx =xy. We would need to
make many edits to the worksheet to solve for another equation
with a User-Defined dy/dx =j(x,y). If we put the function jlxy) in a module, we need
Function edit only the module (and the initial value) to change our
worksheet.
In this Exercise we find the values ofy that satisfy the equation
dy/dx = l/(x + y) with the initial valuey(O) = 2. We use x-values
from 0 to 1.0 in increments of 0.2.
Differential Equations 253
(b) On Sheet3 enter the text and values shown inA1:G7 of Figure
14.5. Name the cells C4:C6 using the text in B4:B6.
If your values do not agree with Figure 14.5 you need to check the
function in the module and the formulas on the worksheet
Remember that formulas can be displayed with [Ctrll+[J. To check
the function, move to a blank cell such as A20 and enter
=rkfunc(3,l). This should return the value 0.25.
(h) Now that you have solved one equation, modify the module
sheet and the values in the named cells of the worksheet to
solve the equation dy/d» =x 2 +Y with the initial valuey(l) =
1. Find the value ofy when x = 1.5 using first h = 0.1, then h =
0.01. You will need to extend the worksheet in the second
case. The analytical resultto eight decimal places isy(1.5) =
2.64232762.
Exercise 4: Solving a In this Exercise we apply the equations developed above to solve:
y" =y' + y =sin(x)
Second-Order with boundary conditionsy(O) = 0 andy'(O) = 0
Equation
Our task is to obtain approximate values ofy andy' when x = 1.
With the substitutiony' = u, we get a pair of equations:
y' = u initial value yeO) = 0
u' =sin(x) - y - u initial value u(O) = 0
Figure 14.6
(b) Move to Sheet4 and enter the text and values shown in Al :K6
of Figure 14.6.
(e) The formulas in row A8:C8 are shown here. Those in columns
D to K may be copied from the row above.
A8: =A7+h
B8: =B7+(D7+2*F7+2*H7+J7)/6
C8: =C7+(E7+2*G7+2*I7+K7)/6
D8: =h*C8
(f) Copy row 8 down to row 12 to geta final value ofx = 1.0. The
results should bey(1.0) = 0.119394 andy'(1.0) = 0.307960.
(g) Try other values of h such as 0.1 and 0.05 to see if the
approximations converge. You will need to expand the table
to have x = 1.0 in the final row.
(a) On the same module used for Exercise 4, code the Pend
function
Function Pend(L, angle)
9 = 9.8
Pend = (-giL) * Sin(angle)
End Function
The parentheses aroundg/L help in reading the formula.
Figure 14.7
(e) Make a chart showing how the angle and the velocity vary
with time.
258 A Guide to Microsoft Exce/2007 for Scientists and Engineers
L5E..(]2
1.0E..(]2
>
.5
~ 5.0E-Q3
.:;
O.OE+OO
-S.OE-03
-1.0E-<l2 +---~~-~-~
Figure 14.8
x'(t) = -O.6Jrr2 ~
.J2i A(x)
where ris the radius of the orifice, xis the height of the water
level from the vertex of the cone, and A (x) is the area of cross
section of the tank x units above the orifice. Find the time
when the tank is empty if r = 0.1 feet,g = 32 feet/sec", and the
tank was initially filled with 51211/3 cubic feet of water to a
level of 8 feet
1 M. L. James et aI., Applied
Numerical Methods for 6. *The circuit' shown in the following figure contains a battery
Digital Computation, Harper (E), an inductance (L), and a resistor (R) whose magnitude
& Row, New York, 1977 varies with its temperature and hence with the current
(page 406). passing through it Its resistance can be expressed by R = a +
Differential Equations 259
di
-=---[
E b' 3 a.
--I
dt L L L
R=a+bi 2
Figure 14.9