Você está na página 1de 14

Chapter Outline

What is finite difference method, and why? Principle of finite difference method The three basic finite difference schemes Application in solution of difference equations

What is finite difference method, and why?


1 As we learned from Chapter 2, many engineering analysis using mathematical

modeling involve solutions of differential equations.

We learned the solution of first order differential equation in Chapter 3 in


the following way:

The solution is:

du ( x) + p( x) u ( x) = g ( x) dx

(3.6)

u ( x) =

1 K F ( x) g ( x) dx + F ( x) F ( x)

(3.7) (3.5)

in which

p ( x ) dx F ( x) = e
d 2u ( x ) du ( x) +a + bu ( x) = 0 2 dx dx

For second order differential equation of the form:


(4.1)

We have the solutions derived for three cases with Case 1 for a2-4b>0, Case 2 for a2-4b<0, And Case 3 for a2-4b =o, as presented in Section 4.1

We are able to derive solutions for these differential equations which we classified to be: LINEAR and HOMOGENEOUS differential equations While many engineering problems can be described by these linear and homogeneous differential equations as we have demonstrated in Chapters 3 and 4, there many other types of engineering problems that can be modeled by NONLINEAR and NONHOMOGENEOUS differential equations in the following distinct forms: Linear DEs u = 1/x u + u = 0, u+2u+ u = 0 Homogeneous DEs u+2u+u=0 u+xu= 0
(source: www.myphysicslab.com)

Nonlinear DEs u + 1/u = 0, u + u2 = 0 u+ Sinx = 0, uu = 1 Nonhomogeneous DEs u+2u+u = Sinx u+xu = x+x2

In the above Tables: the required solution is function u(x), and and

d 2u ( x ) u" = dx 2

u' =

du ( x ) dx

Many advanced engineering analyses involve nonlinear and nonhomogeneous differential equations, and solution of these equations often is beyond the reach by classical methods as presented in Chapters 3 and 4. Numerical solution method such as Finite Difference methods are often the only practical and viable ways to solve these differential equations.

What we will learn in this chapter is the fundamental principle of this method, and the basic formulations for solving ordinary differential equations

Principle of finite difference method


We have learned in Chapter 2 that differential equations are the equations that involve derivatives. Physically, a derivative represents the rate of change of a physical quantity represented by a function with respect to the change of its variable(s):
f(x) x = h, the step size A A A a x 0 a a

Here, the function f(x) is graphically fi+1 Shown, with the function evaluated fi At 3 consecutive variable x:
fi-1

Tangent of f(x) at x = xi f(x)

fi+1 at x = xi+1 fi at x = xi, and fi-1 at x = xi-1 Since xi+1 = x + x, and xi-1 = x x, we will have:
xi-1

x xi+1 x

xi

df ( x ) f f = lim x 0 x dx x
The differential

(9.2) (9.3)

df ( x) f The difference dx x

Equation (9.3) depicts the principle of finite difference. It is important to be aware of the fact that smaller the steps x the closer the values between the differential and difference of the rate change of the function

Three Basic Finite Difference Schemes


There are 3 ways to express differentials of a function f(x):

The forward difference scheme:


f(x) x = h, the step size A A A a x a a

The rate of the change of the function with fi+1 respect to the variable x is accounted for fi between the current value at: fi-1 x = xi and the step forward at x i+1 = x + x Mathematical expression of the derivative of the function f(x) is: 0

Tangent of f(x) at x = xi f(x)

x xi+1 x

xi-1

xi

f i =

df ( x) dx

x = xi

f x

=
x = xi

f i +1 f i f fi f fi = i +1 = i +1 x xi +1 xi h

(9.4)

where h = x = the incremental step size

The forward difference scheme- Contd:


f(x) fi+1 fi fi-1 A a x 0 A x = h, the step size A a a Tangent of f(x) at x = xi f(x)

The derivative of the function at other values of the variable x in the positive direction can be expressed following Equation (9.4) are:

f i +1 = f i + 2
x

x xi+1

f i + 2 f i +1 h f f i+2 , etc. = i +3 h

(9.5)

xi-1

xi

The second order derivative of the function at x can be derived by the following procedure

f x f i f f f f i d df ( x) i i +1 fi = = lim i +1 = i +1 x x dx dx x = xi x0 h
2

f i + 2 f i +1 f i +1 f i f 2 f i +1 + f i h h = = i+2 h h2

(9.6)

The backward difference scheme:


f(x) fi+1 x = h, the step size A A A a x 0 a a Tangent of f(x) at x = xi f(x)

We evaluate the rate of change of the function values between the current step at xi, and the function value at a step back at xi-1, i.e. x = x x. Mathematically, we will have the following:

fi fi-1

x xi+1 x

xi-1

xi

f i = lim

x 0

f i f i 1 f f i 1 f f i 1 f ( x) f ( x x) = lim i = i x 0 x x x h

(9.7)

and the send order derivatives in the form:

2 fi

f i 2 f i 1 + f i 2 h2

(9.8)

The central difference scheme:


The rate of change of function f(x) is accounted for between the step at back at (x-x) and the step ahead of x, i.e. (x+x). From the graphical representation we have:
f(x) fi+1 fi fi-1 A a x 0
f(x) fi+1 fi fi-1 A a x A

x = h, the step size A A a a

Tangent of f(x) at x = xi f(x)

f i

f i +1 f i 1 f f i 1 = i +1 xi +1 xi 1 2h

(9.9)
xi-1

x xi+1 x
Tangent of f(x) at x = xi f(x) a a

The step size in Equation (9.9) is 2h which is big in compromising the accuracy. A more accurate central difference scheme is to reduce the step size in each forward and backward direction by half as show We will have the corresponding expressions: f 1f 1 (9.11)

xi

x = h, the step size A

f i =
f
i+

i+

x xi+1 x

where

1 2

x = f x+ 2

and

1 2

x 0 = f x 2

xi-1

xi

fi-1/2

fi+1/2

Example on using finite difference method solving a differential equation


The differential equation and given conditions:
2 d x(t ) + x(t ) = 0 2 dt

(9.12) (9.13a, b)

with

x ( 0) = 1

and

& x ( 0) = 0

Solution of Equation (9.12) with conditions in Equation (9.13) by classical method is: x(t) = Cos(t) Let us use the forward difference scheme in the solution with:

and

d 2 x(t ) x(t + 2t ) 2 x(t + t ) + x(t ) = d t2 (t ) 2

x(t + t ) x(t ) dx (t ) = dt t

(9.14a) (9.14b)

We are now ready to convert the differential equation in (9.12) into the form of difference equation by substituting the expressions in Equation (9.14b) into Equation (9.12):

x(t + 2t ) 2 x(t + t ) + x(t ) ( t )


2

+ x(t ) = 0

The following recurrence relationship is established by re-arranging the terms in the the above difference equation:

x (t + 2t ) 2 x(t + t ) + [1 + (t ) 2 ] x (t ) = 0

(9.15)

Solution of DE in Equation (9.12) with conditions in Equation (9.13a,b) The recurrence relation:

x (t + 2t ) 2 x (t + t ) + [1 + ( t ) 2 ] x (t ) = 0

(9.15) (9.13a) 9.13b)

with the given conditions: x(0) = 1 and


& x(0 ) = 0 = dx(t ) x(t + t ) x(t ) =0 = dt t =0 t t =0

From the second part of Equation (9.13b), we have the following relationship: x(0 + t ) x(0 ) = 0 x(t ) x(0 ) x(t ) = x(0 ) t Consequently, we have: x(t) = 1

(9.16b)

The recurrence relationship in Equation (9.15) will get us the function values at variable t, with conditions in Equation (9.13a) and (9.16b) as the starting points.

We must choose the step size t for our numerical values of the function x(t). the smaller the step size we choose, the more accurate the numerical values we will get. smaller steps means more computational effort in the solution process.

Let us choose a step size of t = 0.05: The recurrence relation in Equation (9.15) becomes: x(t+0.1) 2x(t+0.05) + 1.0025x(t) = 0 with x(0.05) = 1 from Equation (9.16b) (a)

Now, we are ready to proceed finding the function values at other values of t.

At t = 0 From Equation (a): x(0.1) 2x(0.05) + 1.0025x(0) = 0 But since x(0) =1 in Equation (9.13a), we will get from the above expression: x(0.1) 2 x(0.05) = -1.0025 =1 from Equation (9.16b) Hence x(0.1) = -1.0025 + 2x(0.05) = 0.9975 (c)

- a numerical solution of function xt) at t = 0.1

At t = t+t = 0+0.05 = 0.05 The recurrence relationship in Equation (a) becomes: x(0.05+0.1) 2x(0.05 + 0.05) + 1.0025x(0.05) = 0 or x(0.15) 2 x(0.1) + 1.0025x(0.05) = 0 = 0.9975 from last step in Equation (d) We will have: x(0.15) = 2x0.9975 1.0025x1 = 0.9925 At t = t+t = 0.05+0.05 = 0.1 By substituting t = 0.1 into x(t+0.1) 2x(t+0.05) + 1.0025x(t) = 0, we will get: x(0.2) 2 x(0.15) + 1.0025x(0.1) = 0 = 0.9925 from last step We will have x(0.2) = 2x0.9925 1.0025x0.9975 = 0.9850 Numerical solution of x(0.2) (e) Numerical solution for x(0.15) (d)

The same solution procedure continues. The numerical solution of x(t) obtained by the finite difference method is compared With the exact solution obtained by classical solution in this example as follows: Variable, t 0 0.05 0.10 0.15 0.20 Finite Difference Results 1 1 0.9975 0.9925 0.9850 Exact Values 1 0.999996 0.9950041 0.98877 0.980066 % Error 0 0 0.25 0.38 0.503

Observations:
1) 2) 3) 4) The error of the numerical solution increases with number of steps. These error are referred to as accumulative errors Step size definitely has strong effects on the accuracy of finite difference method Trade-off between step size and computational effort is an issue in any numerical technique such as finite difference method

Você também pode gostar