Numerical Methods For Solving Differential Equations
Numerical Methods For Solving Differential Equations
Professor:
Ing. Édison Martínez Oviedo
UNIVERSITY OF PAMPLONA
ENGINEERING AND ARCHITECTURE
MECHANICAL ENGINEERING
COMPUTATIONAL MECHANICS
PAMPLONA NORTH OF SANTANDER
2018
NUMERICAL METHODS TO SOLVE DIFFERENTIAL EQUATIONS
It is a first-order method and the simplest of the numerical methods, its basic idea is
calculate an approximation to the derivative at xithrough the incremental quotient
Algorithm:
The Euler method is of low precision. These methods are based on the idea of the Euler method.
but with an improvement in the approach
This method allows calculating the slope from an initial point and with this finding a new point.
Applying two derivatives in the interval, at the initial point and the final point.
Algorithm:
we find
yi′= f x(i , andI )
2. We replace the problem data in the predictive equation.
0
yi+1 = yi+ f xi(, andih )
3. Now we evaluate the function again with the
xi+1 y yi0+1= f(xi+1, andi0+1)
4. We replace in the corrective equation
f( xi , yi+) f(xi+1, andI0+1)
yi+1 = yi+ h
2
and we will obtain
yi+1
5. We repeat the procedure until we reach the final value that was given to us.
1.2.2. MIDPOINT METHOD
With the midpoint method or the improved polygon method, we find a slope at the midpoint.
of the interval using a known point
Algorithm:
1. We substitute the problem data into the function they give us by finding
f(xi , andi )
2. We now replace in the equation
h
yi+ 1/ = yi+ f(xi , yi )
2 2
finding the point in
y = yi+ 1/
2
and to find
xi +1 /2
we split our point into two inx
3. We substitute in the equationyi+1 = yi+ f(xi + /,1andi+ ⁄)hand
1 we obtain our next
2 2
point inyi+1
We repeat the procedure until we reach the final value that was given to us.
These methods have more accuracy than the previous ones, characterized because their error has the form:
EIChk
Where C = positive real constant and k = order of the method
All methods use a generalized formula:
yi + 1= yi+ ∅(xi , andi , h)h
1
yesa2= then:
2
1
a1= y p1q11= 1
2
1 1
yi+1 = yi+ ( k1+ k2
2 2
yesa2= 1so:
1
a1= 0p1=11 y = 2
yi+1 = yi+k2 h
2
yesa2= so:
3
1 3
a1= y p1= q11 =
3 4
1 2
yi+1 = yi+ ( k1+ k2 ) h
3 3
Algorithm:
For a number of stages of n=3, one can proceed similarly to the second method.
order. For this case we use the formula:
1
yi+1 = yi+ (k1+ 4k2+k3
6
Where:
k1= f(xi , andi )
1 1
k 2= f(xi+ h, yi+ k1
2 2
k 3= f(xi+ h, yI− k1 h + 2k 2 h)
Algorithm
We find the values of k1, k2y k3
2. We obtain the value of the slope.
3. We now substitute in the equation for y.i+1 finding the point at y=yi+1
4. We repeat the procedure until we reach the final value given to us.
k 4= f(xi+ h, yi+k3 h)
Algorithm
When more accurate results are required, the fifth-order RK method is recommended.
Butcher (1964):
1
yi+1 = yi+ (7k1+ 32k 3+ 12k 4+ 32K5+ 7K6 )h
90
where
Algorithm
The shooting method is based on converting the boundary value problem into a problem of
equivalent initial value. We will have a second degree equation, which we take and the
we express it as two first-order ODEs, then we will obtain a new variable z, which
we will give it an arbitrary initial value, then what we do is integrate the two ODEs of
first order by any of the previous methods, giving us a result which we will compare
whether it approaches or distances itself from the final value given in the exercise. Since this is an approximation, then
we will surely obtain two results, one below and one above the real value, then
what we do is an interpolation between the initial values we take arbitrarily for
z and the result we obtained by integrating the 1st order ODEs. Thus giving us a value for z that we
it will take you right to the exact final value.
Algorithm
We express the 2nd order ODE as two 1st order ones.
We obtain a new variable to which we assign arbitrary initial values.
3. We integrate and when we obtain one value above and another below the final real value.
we interpolate.
The most common alternatives to the shooting method are the finite difference methods, in the
which, the finite divided differences replace the derivatives in the original equation. Thus, a
linear differential equation is transformed into a set of simultaneous algebraic equations,
according to table 1. When we have already replaced the derivatives, it is replaced according to the node which
will give us the equations that we will have to input into a matrix from which we will take the inverse
and will give us the solution to the unknowns.
This method can be applied to partial differential equations in the same way.
First derivative:
f( xi+1 )- fxi−1
( )
f ′ ( xi=
)
2h
Second derivative
Third derivative
-f x( i+3 +) 8f xi+2
( − 13f
) xi+1 (+ 13f)xI−1− 8f( xi-2+) f xi+3( ) ( )
f′′′ x( i=)
8h3
Fourth derivative
′ (x =)
-f x( i+3 +) 12f xi+2
( − 39f
) xi+1 (+ 56f) xi− 39f( xI−1
) − 12f( xI-2+) f xi+3 ( ) ( )
f′′′ I
6h4
Algorithm
The equations are replaced.
2. Then the equations of the nodes are found.
3. They are introduced into a matrix from which we take the inverse and it will give us the results.
Example:
Exercise 27.23 from the book Numerical Methods for Engineers by Chapra 5th edition.
27.23 Use finite differences to solve the differential equation
Ordinary with boundary values. Use 5 nodes see fig. 1
2
+6
2 − ( )
= 0 0= 10 (2) =1With∆x=0.5
Exercise solution.
Node 1
2−2u1+10 2−10
0.5 2
+ 6 −
0.5(2)
1= 0
Solving
Resolving
Node 3
1-2u3 + u2 1− 2
0.5 2
+ 6( )−0.52 3= 0
Resolving
A U B
I -9 10 0 I I u1 I I 20 I
I -2 -9 10 l I u2 I = I 0 I
I 0 -2 -9 i I u3 I I -10 I
d2 x dx
m + m+ kx =0
dt2 dt
dy1
= y2 (x)
dx
dy-2
= yn−1 ( x)
dx
LINEAR DIFFERENTIAL EQUATIONS OF ORDER n
A linear differential equation of order n is a linear expression of the function and its derivatives.
They can be classified as homogeneous (equal to zero) and non-homogeneous (equal to a function of x).
−1
( ) + −1 ( ) +⋯
−1 1( ) + 0( ) =0
−1
+ −1 ( ) +⋯
−1 1( ) + 0( ) = ( )
The points at which fn(x) = 0 are called singular points of the linear equation.
These equations can be described as a relationship whose unknowns are functions of variables.
independent. It is said that a partial differential equation is linear if it is linear in the function
unknown and in all its derivatives, with coefficients that depend only on the variables
independents.
A second-order EDP has the form:
2 2 2
( ,) 2
( , ) + 2B ( ) ( , ) + ( ,) 2
( , ) + ( ,) ( , )
+ ( ,) ( , ) + ( ,) ( ), = ( , )
These equations are used in physical problems such as heat distribution or in dynamics.
of fluids and is defined as:
2 2
2
( , ) + ( , ) = ( ,
2
)
2 2
2
( , ) + ( , ) =0
2
BIBLIOGRAPHY