document_2
document_2
Finite Di↵erences
8 f (x+h) f (x)
>
< h + O(h) (Forward Di↵erence)
f (x) f (x h)
f 0 (x) = + O(h) (Backward Di↵erence)
> f (x+h)h f (x h)
:
2h + o(h2 ) (Central Di↵erence)
8 f (x) 2f (x+h)+f (x+2h)
>
< h2 + O(h) (Forward Di↵erence)
00 f (x) 2f (x h)+f (x 2h)
f (x) = h2 + O(h) (Backward Di↵erence)
>
: f (x h) 2f (x)+f (x+h)
h2 + o(h2 ) (Central Di↵erence)
Order of Approximation
• It is worth considering exactly what is meant by the order of accuracy of a discretization approximation.
• As we refine the grid, for any useful scheme, errors associated with the discretization approximation
can be expected to reduce.
• We reach a grid independent solution when any further grid refinement produces no significant di↵er-
ence in the computed solution. At this stage, the discretization errors are small enough that they can
be neglected.
• Note this does not mean a second order solution on one particular grid will always be more accurate
than a first order one (although this will usually be the case for a sufficiently fine grid).
• It does, however, imply that as we refine the grid the error in the higher order scheme goes down more
rapidly, so we expect the higher order scheme to reach a grid independent solution on a coarser grid
than would be required for a lower order scheme.
• It is worth noting that the behaviour described above for a particular scheme can only
be expected on a reasonably fine grid.
The reason for this can be seen from the Taylor series expansion. For example, in the first order backward
di↵erence scheme we have:
fi fi 1 x 00 ( x)2 000
f 0 (xi ) = + f (xi ) f (xi ) + O( x3 )
x 2! 3!
1
Santanu Manna MA 204N: Finite Di↵erence Method
If the first term in the truncation is to be the leading error term, then x has to be small enough so
that:
( x)2 000 x 00
|f (xi )| ⌧ |f (xi )|
3! 2!
Or,
f 00 (xi )
x⌧3
f 000 (xi )
Polynomial Fitting
• The above approximations for the derivatives could also have been derived by fitting a polynomial to
the function f through xi and surrounding points and then di↵erentiating this polynomial to obtain
its gradient.
• The forward and backward di↵erence schemes arise from fitting a first order polynomial through the
points (xi , xi+1 ) and (xi 1 , xi ) respectively.
• The central di↵erence scheme can be obtained by fitting a quadratic curve through the points xi 1 , xi , xi+1 .
Linear Fit:
The first order polynomial:
Quadratic Fit:
The central di↵erence scheme can be obtained by fitting a quadratic curve through the points xi 1 , xi , xi+1 .
The resulting polynomial approximation for function f can be written as:
On a uniform grid:
Then we get:
2
Santanu Manna MA 204N: Finite Di↵erence Method
xfi 1 0 · fi xfi+1
f 0 (xi ) = + +
2( x)2 ( x)2 2( x)2
fi+1 fi 1
) f 0 (xi ) = (5.5)
2 x
Again di↵erentiating eq. (5.4) with respect to x, we get:
One-sided Approximation
The finite di↵erence approximation for first order derivative along the boundary can be obtained by using
forward di↵erence which is first order accurate.
For second order accuracy, we will use a polynomial approach as follows:
Assume that f can be expressed by the polynomial
f = a + bx + cx2 (5.7)
f2 = a + b x + c( x)2
f3 = a + 2b x + c(2 x)2
3
Santanu Manna MA 204N: Finite Di↵erence Method
@u @2u
= ↵ 2, 0 x L, t > 0 (6.1)
@t @x
Suppose Dirichlet boundary conditions are prescribed at both the ends and an initial condition at time
t > 0 as:
u(0, t) = u0 , u(L, t) = uL , u(x, 0) = f (x), 0 x L (6.2)
To solve this problem, we first discretize the domain into regular mesh such that xi = i x; i = 0(1)N
where x0 = 0, xL = N . When the values of ui,j is computed up to t = tj = j t i.e., jth time level, the
values at (j + 1)th time level are computed to give ui,j+1 , i = 1(1)N 1, j = 1, 2, . . .
⌥ Explicit Method:
We discretize equation (6.1) at mesh point (i, j) such that the time derivative is replaced by forward di↵erence
and space derivative is replaced by central di↵erence. We get:
Thus value of ui,j+1 can be computed explicitly. This method is also known as explicit method.
@u @2u
= , 0 x 1, t > 0
@t @x2
With boundary conditions u(0, t) = u(1, t) = 1, and initial conditions
(
1 + 2x, 0 x 1/2
u(x, 0) =
3 2x, 1/2 < x 1
⌅ Use explicit method taking x = 0.2, t = 0.02, and compute up to t = 0.24 up to six decimal places.
4
Santanu Manna MA 204N: Finite Di↵erence Method
Solution: Since the initial temperature u(x, 0) is symmetric and boundary conditions at x = 0 and
x = 1 are also same, the problem is symmetric about x = 0.5. i.e., the temperature at the subsequent times
will also remain symmetric.
The domain is subdivided as:
t 0.02
r= 2
= = 0.5
x 0.04
Putting r = 0.5 in the Explicit formula:
1
ui,j+1 = (ui 1,j + ui+1,j ), i = 1, 2
2
i = 3, 4 can be written by symmetry.
For j = 0,
u0,0 = u5,0 = 1.0, u1,0 = u4,0 = 1.4, u2,0 = u3,0 = 1.8
Computed values are:
For i = 1(1)N 1, gives (N 1) equations in ui,j+1 . This formula is known as Laasonen’s formula.
-r (1-2r) -r
j
1
i 1 i i+1
5
Santanu Manna MA 204N: Finite Di↵erence Method
Crank-Nicolson’s Method:
It is also an implicit scheme. The di↵erence is that the discretization of equation (6.1) is made at the mid-
point of j th and (j + 1)th levels and both the time and space derivatives are replaced by central di↵erence,
i.e.,
✓ ◆
@u 1 ui 1,j 2ui,j + ui+1,j ui 1,j+1 2ui,j+1 + ui+1,j+1
= 2
+ + O( t)2 + O( x)2
@t i,j+ 12 2 ( x) ( x)2
t
Using ( x)2 = r, and neglecting the error terms, we can write the above equation as:
Example:
Find the numerical solution of the heat conduction equation
@u @2u
= , 0 x 1, t > 0
@t @x2
With boundary conditions u(0, t) = u(1, t) = 1 and initial conditions
(
1 + 2x, 0 x 12
u(x, 0) =
3 2x, 12 x 1
Solution: Since the initial temperature u(x, 0) is symmetric and boundary conditions at x = 0 and
x = 1 are also same, so the problem is symmetric about x = 0.5, i.e., the temperature at subsequent times
will also remain symmetric.
Here t = 0.08, r = t/ x2 = 0.08/0.04 = 2, then C-N scheme:
rui 1,j+1 + 2(1 + r)ui,j+1 rui+1,j+1 = rui 1,j + 2(1 r)ui,j + rui+1,j
transforms to:
6
Santanu Manna MA 204N: Finite Di↵erence Method
While finding the solution uD , some errors like rounding/truncation etc., also creep in. So the final
solution is di↵erent from uD , and can be called uC . The error (uD uC ) is called stability error, and if it
tends to zero, then the finite di↵erence scheme is said to be stable.