Numerical Methods for Differential Equations
Numerical Methods for Differential Equations
6.4 Applications
Appendices
Appendix A "Investigated Methods"............................................................................................ 32
Appendix B "Examples".................................................................................................................. 33
Conclusion
Bibliografía........................................................................................................................................ 47
Unit VI 'Solution of Differential Equations'
Introduction
dy
2
x 3 12x2 20x 8.5
dx
The numerical solution of ODEs involves two types of error (remember the
chapters 3 and 4)
1. Errors of truncation, or deratization, caused by the nature of the
techniques used to approximate the values of y.
2. Rounding errors, which are the result of the limited number of digits
significant that a computer can retain.
One can obtain certain knowledge about the magnitude and properties of the
truncation error when deriving the Euler method directly from the expansion
from the Taylor series. To do this, note that the differential equation is subject to
integration will be in the form
General:y' f(x,y)
dy
Wherey' ,y x y y they are the independent and dependent variables,
dx
respectively. If the solution (that is, the function that describes the
behavior of y) has continuous derivatives, can be represented by a
expansion of the Taylor series with respect to the initial values xi,yI like in
yi ´´ 2 yi(n) n
y i 1 yi yi ´h h h Rn
2! n!
y (n1)( ) n1
Where: h xi1x yR remaining term, defined as Rn h
i n
(n 1)!
Where is somewhere in the interval ofxia xi 1
This method is based on the same idea as the simple Euler method, but it makes a
refinement in the approach, taking an average of the slopes
of the found tangent lines.
Thus, in the graph we see that the average slope m corresponds to the
pending the bisector line of the tangent line to the curve at the point of
the initial condition and the tangent line to the curve at the point , x1 ,y1
wherey1It is the approximation obtained with the first Euler's formula.
Finally, this bisector is moved parallel to the point of
the initial condition, and the value of this line is considered at the
pointx x1like the improved Euler approximation.
yi 1 yi
f xi,yi f x 1,y 1
i i
0
h Being: yn1 y h nf xn,yn
2
One way to reduce the error of Euler's method could be the inclusion of
higher order terms in the expansion of the Taylor series for its solution.
For example, with the inclusion of the second-order term as follows
equation:
f'(xi,yI)
y i 1 y i f xI,yi h h2
2!
f''(xI,yi)
Ea h3
6
Although the incorporation of higher-order terms is sufficiently
simple to implement in the polynomials, its inclusion is not so trivial when
The ODE is more complicated. In particular, the ODEs that are a function of both the
dependent variable as well as the independent, require differentiation by the
chain rule. For example, the first derivative of f(x,y) it
f x,y f x,y dy
f ´ xi,yi
x y dx
f f dy f f dy
f
x y dx x y dx dy
f´ xi,yi
x y dx
h
yI 1
yI f(xI,yi)
2 2
Then, this predicted value is used to calculate a slope at the midpoint:
yI 1 f x ,yi 1 i 1
2 2 2
yi 1 yi f x ,y h i 1 i 1
2 2
As in the previous section, this procedure can also connect with the
Newton-Cotes integration formulas
The objective of the Runge-Kutta numerical methods is the analysis and solution of
the initial value problems of ordinary differential equations (ODE), these
they are an extension of the Euler method to solve the (ODEs), but with a
order of higher accuracy than this.
Taylor series without requiring the calculation of higher derivatives. There are many
variations, but all can be denoted in the generalized form of the equation
a1k1 a2 k 2 an k n
Note that the k they are recurrence relations. That is,k1appears in the
equation fork 2, which appears in the equation for k 3, etc. As each k is a
functional evaluation, this recurrence causes the methods be efficient
for calculations on computer.
It is possible to conceive several types of Runge-Kutta methods by using different
numbers of terms in the increment function as specified by n.
Note that the first-order Runge-Kutta (RK) method with n 1yes, in fact,
the Euler method.
Once n is chosen, the a, p, and q are evaluated by equating equation 25.28 to the
terms in the Taylor series expansion. Thus, at least for the versions of
lower order, the number of terms n often represents the order of the
approximation. For example, the second-order RK methods use the function
increment with two terms Those second-order methods will be
exact if the solution of the differential equation is quadratic. Moreover, since the
terms withh 3and older ones are eliminated during the derivation, the error of
local truncation is and the global is In subsequent sections
we will develop third and fourth order RK methods For those cases,
global truncation errors are , respectively. y
yI1 y i a1k1 a2 k 2 h
Where:
k1 f xi yI
k2 f xI p1h yi q11k1h
When using the equation, we must determine the values for the constants a1, a2, p1.
y p11. To do this, we recall that the second-order Taylor series for i1in y
terms of y t y f(x,y)
i i it is written as:
f'(x)i,yi) 2
yI1 yi f xi,yi h h ecu. 1
2!
f x,y f x,y dy
f ´ xi,yi
x y dxecu. 2
f x,y f x,y dy h 2
yi 1 yI f xI,yi h
x y dx 2!
The basic strategy that will be highlighted in the Runge-Kutta methods is the use of
of algebraic manipulations to solve the values of which
it causes the equations
yi1 y i a1k1 a2 k 2 h
and the previous ones are equivalent. To do this, we first use a Taylor series to
expand the equation.k 2 f x i p1h yiq11k1hThe Taylor series for a
A function of two variables is defined as:
g g
e x r y s g x,y r s
x y
f f
f xI p1h yi q11k1h f xi,yi p1h q11k1h O h
2
x y
f f
yi1 yi a1hf xi,yi a2 hf xi,yI a2p1h 2 a2 q11h 2f xi,yI
O h3
x y
f f 2
yi1 yi a1f xiyI a 2f xi,yi h a 2p 1
a2 q11f xI,yi h O h
3
x y
a1 a 2 1
1
a1p 2
2
1
a1 q11
2
Since we have three equations with four unknowns, we must assume the value of
one of these unknowns to determine the other three. Suppose we specify
a value for a2. Then the equations can be solved simultaneously.
25.31 to 25.33 to obtain:
Since we can choose a finite number of values for a2, there is a number
interminable of second-order RK methods. Each version could give
exactly the same results if the solution of the ODE were quadratic, linear
or a constant. However, different results are obtained when the
the solution is more complicated. Below we present three of the most
commonly used and preferred:
Heun's method with only corrector (a2 = ½). If we assume that a2 is 1/2, the
Equations (25.34) and (25.35) could be solved for a1 = ½ and p1 = qI 1 = 1. These
parameters, when substituted into the equation (25.30), yield
Where
Note that k1 is the slope at the beginning of the interval and k2 is the one at the end.
consequence, this second-order Runge-Kutta method is indeed the technique
of Heun without iteration.
Where
Where
Thus, the predictor and the corrector have local truncation errors
of, y respectively. This suggests that the predictor is the weak link
in the method, as it has the biggest error. This weakness is significant due to
that the efficiency of the iterative corrector step depends on the accuracy of the
initial prediction. Consequently, one way to improve Heun's method is
through the development of a predictor that has a local error of This is
can be fulfilled by using Euler's method and the slope at, and information
extra from the previous point like in:
yi01 y f(x
i1 y i
2hi ec.2
Predictor:
Portillo Contreras Misael ISC Group 1 Page 17
Unit VI 'Solution of Differential Equations'
Corrector:
Where the superscripts were added to denote that the correction is applied
iteratively from j 1 to obtain refined solutions. Observe
m m
what y i&y i 1 these are the final results of the iterations of the corrector in
los pasos de tiempo anteriores. Las iteraciones son terminadas en cualquier paso
of time based on the stop criterion:
yI1´ y I1
Ea 100% ec. 3
i1
y i
I1
Milne's Method.
The Milne method is the most common of the multiphase methods based on the
Newton-Cotes integration formulas. Use the three-point Newton-Cotes formula.
points like a predictor:
and the closed formula of Newton-Cotes of three points (Simpson's 1/3 rule) as
a corrector:
The predictor and corrector modifiers for the fourth-order Adams method
They can be developed from the formulas and the error coefficients.
dy1
f1(x y1 y 2 yn
dx
dy2
f 2(x y1 y 2 yn
dx
dyn
f n(x y1 y 2 yn
dx
The solution of such a system requires that the n conditions are known.
initials in the initial value of x.
Note.- The methods used for the solutions of these systems of equations are the
used in the previous sections, therefore we will proceed to adjust the step size
directly, of course after having solved the system using one of the methods
seen before
Step size control.
Where h-actual and h-new = current and new step size, ∆actual = accuracy
actual calculated, ∆new = desired accuracy, and a = constant exponent that is
equal to 0.2 when the step size is increased and 0.25 decreases the step size
step.
A more general way to handle those cases is to determine the new ∆ as:
Where E = global tolerance level. Your choice of y-scale will determine then.
how the error has escalated. For example, if y-scale = y, the accuracy will be
managed in terms of fractional relative error. If you now deal with a case
where relative errors are desired constant to a pre-established maximum limit, there exists
a y-scale equal to that limit. A trick suggested by Press et al. To obtain
the constant relative errors except those that cross very close to zero, is:
6.4 Applications
An L reactance of 0.4H, R=300Ω, and a circuit characteristic will be taken into account.
capacitance of .001 F. At the initial time (t=0), the current is 3A and its derivative
(that is, the electric charge) of .5A/s. °C Solution First, this must be transformed
problem in a set of first-order equations. Q will be taken equal to the
derivative of current intensity.
It is important to emphasize that the problem becomes very unstable if higher values are used.
highs for L.
Solution:
It is worth noting that the above scheme is implicit as it is a dense matrix A.
Applying the generic second-order Runge-Kutta formulas to the array of
Butcher anterior falls:
Substituting in the function f by the expression from the example, the following remains
algoritmo de cálculo:
Calculations begin with i=0, t=0, y0=1, that is, the initial value is assumed to be
temporal step value h=0.1. The sequence of the consequent calculations is
summary in the table below.
Solution:
To find an analytical solution to the problem, it is necessary to diagonalize the matrix A.
or decoupling the system of equations through a similar transformation. For
That by substituting the original variables and the initial conditionals, it remains
finally
If y1 is graphed against t, two time scales, t1 and t11, are observed where the
first term of the solution, e-11.1t, remains practically constant at the
long of t1 and then slowly decays in a time interval 0<t11<40.
It is said that the ODE system is stiff when there is an eigenvalue in the matrix.
of the system that contributes almost nothing to the solution, especially regarding the domain of
integration. A stiffness index is defined as follows:
Where |Re|λ|| represents the modulus of the eigenvalue part. Indeed, let it be the
generic method given by the following difference equation, applied to f(t,
y)=ky=y|:
Appendix B "Examples"
One-Step Methods
Euler's Method
dy
2
x 3 12x2 20x 8.5
dx
Heun's method
dy
4e0.8x 0.5y
dc
From x=0 to x=4, with a step size h=1. With the initial condition that
When x=0 then y=2. Obtain the exact solution by integrating analytically.
And compare the results with those obtained by the Heun method.
Solution. First, we need to solve for all the slopes at the beginning of
interval
K i1 f(0,4,6) 0 .5(4) 2
K i2 f(0,4,6) 4 0.3(6) 0.1(4) 1.8
WhereK iit j is the i-th value of the j-th dependent variable. Afterwards,
we must calculate the first values of deyxyy2 at the midpoint:
h 0.5
y1 k1 1 4 (2) 3.5
2 2
h 0.5
y 2 k1 2 6 (1.8) 6.45
2 2
These will be used to calculate the first set of point slopes.
half
These will be used fortterminate the predictions at the end of the interval
y1 k 3.1h 4 1.781250 .5 3.109375
y 2 k 3.2 h 6 1.7151250 .5 6.857563
Which will be used to calculate the slopes at the end of the interval,
k4.1 f 0.5,3.109375,857563 1
.554688
k4.2 f 0.5,3.109375,857563 1.631749
1
y1 (0.5) 4 2 2 1.75 1.78125 1.554688 0.5 3.115234
6
1
y20.5 6 1.8 2 1.75 1.78125 1.631794
0.5 6.857670
6
By proceeding in a similar manner for the remaining steps, one obtains
Solution: The first step in the midpoint method is the use of the equation to
calculate:
Note that such an estimation of the slope is much closer to the value
Average for the interval (4.4375) where the slope at the beginning of the interval (8.5)
that could have been used by the Euler procedure. The slope at the
The midpoint can then be substituted in equation 25.37 to predict.
The calculation is repeated, and the results are summarized in figure 25.14 and table 25.3.
Through the Ralston method, k1 for the first interval is also equal to 8.5
y:
Multi-Step Methods
Which represents a relative percentage error of -5.73%. This error is somewhat more
smaller than the value of -8.18% incurred in the auto-start Heun.
Now, the predictor equation can be applied iteratively to improve.
the solution:
What is superior to the prediction of 12.08260 that was calculated with the method of
Heun original. The first corrector gives 15.76693 and subsequent iterations.
they converge on the same result as obtained with Heun's method
Autostart: 15.30224. As with the previous step, the rate of convergence of
The corrector has been improved due to better initial prediction.
Deduction and analysis of the error of the predictor-corrector formulas. Already
we use graphic concepts to deduce the non-autostart Heun. Now
we will show how the same equations can be mathematically deduced.
This deduction is particularly interesting because it links the ideas of adjustment of
curve, of numerical integration and of the ordinary differential equations. The exercise is also useful because
provide a simple procedure for developing multi-step methods
higher order and estimate its errors.
The left side can be integrated and evaluated using the fundamental theorem:
ec. 4
The equation represents a solution to the ODE if the integral can be evaluated. It is
to say, provides a means to calculate a new value of the variable
dependent based on a previous value of and the differential equation.
The formulas of numerical integration provide a way to do this.
evaluation. For example, the trapezoidal rule can be used to evaluate the integral,
like in:
ec. 5
Where it is the step size. When substituting equation ec.5 into the
equation ec.4 is given:
What is the correction equation for the Heun method? This is based on the
Trapezoidal rule, the truncation error can be taken directly from the table.
2:
ec.6
ec.7
Now, more than using the closed formula from table 2, the first formula in
open integration of Newton-Cotes can be used to evaluate the integral as
en:
ec. 8
Which is called the midpoint method. Substituting equation ec. 8 into the
equation ec.7 is obtained:
ec.9
What is the predictor for the Heun method for no self-starting. Similar to the corrector, the error
local truncation can be taken directly:
ec.10
Where the subscript p designates that this is the error of the predictor.
Thus, the predictor and the corrector for the non-self-starting Heun method have
truncation errors of the same order. In addition to updating the accuracy of
predictor, this fact has additional benefits related to the analysis of
error like himself to elaborate in the next section.
Error estimation: If the predictor and the corrector of a multipoint method are
of the same order, the local truncation error can be estimated during the course
from a calculation. This is a tremendous advantage, as it establishes a criterion for the
step size adjustment.
The local truncation error for the predictor is estimated using equation ec.9.
The estimated error can be combined with the estimate of from predictor step
to give:
ec.11
Using a similar procedure, the estimated error for the corrector can be
combine with the result of the corrector to give
Where is E now among y Now, if you divide the equation by 5 and you
Rearranging the result we have:
ec.12
Note that the right side of equations ec. 6 and ec. 12 are identical, with the
exception of the third derivative argument. If there is no appreciable variation
Regarding the interval in question, we can assume that the right side is equal.
and therefore, the left sides should be equivalent, as in:
ec.13
In =2, the predictor gives 13.44346 and the trajectory gives 15.30224, which is used
to calculate:
Conclusion
Through the previously seen methods, I understand that they are of great help.
in the application of different areas such as electronics and bacteriology
such as probability among others. Therefore, we can say that.
Numerical methods and their applications in their different methods are greatly
help in the life of the engineer as well as the graduate.
Bibliography
Numerical Methods for Engineers; Chapra Steven C. and Canalé Raymond
5th Ed.