Lecture 53

IIT Kanpur July 201
20 followers
Oct 22, 2023
Finding the derivative of a function, knowing the values of the function at few discrete
points, is fundamental in the study of computational fluid dynamics.
I hope you understood that by now.
In last few lectures, we have seen that Taylor series analysis can be used to prepare higher
order numerical scheme.
In this lecture, I will emphasize that Taylor series analysis is an useful way to finding
derivatives, in general.
Recall our definitions of numerical differentiation of the function u of x.
We have learned forward, backward, and central differences.
And we know that forward differences are given based on u i plus 1 minus u i by delta x.
If we take the forward difference on two-point stencil, similarly backward difference on
a two-point stencil is u i minus u i minus 1 by delta x.
And central difference is u i plus 1 minus u i minus 1 by twice of delta x.
In this particular course, by and large, we will use first and second derivatives.
But we will use not necessarily ordinary, in fact, mostly we will use partial derivatives.
And the schemes that we will use, we will try to implement mostly in second order, sometimes
maybe first order, but mostly in second order.
And we will see that we can generate schemes based on the available points.
We can generate schemes for derivatives using Taylor series analysis.
Of course, there are other ways of finding derivatives.
And we will discuss one more in upcoming lecture.
But you will see that this Taylor series analysis is the easiest way in general to
find numerical derivatives.
We will illustrate this taking one example.
Let us say we want to generate double derivative of u using three points, u i, i plus 1, and
i plus 2.
Remember that we have generated double derivative of u based on u i, i minus 1, and i plus 1.
We also know how to get first derivative of u based on u i, i plus 1, i plus 2.
Here we are asking for second derivative of u based on i, i plus 1, and i plus 2.
This is just to give an example that any derivative can be found using Taylor series analysis.
However, to find the second derivative, you need at least three points.
To find the first derivative, you need at least two points.
You understand that just one point on a function is not sufficient to get a derivative because
derivative means change.
So you need at least two points to know the change.
And second derivative is change of change.
So you need at least three points to get an idea of change of change.
So here we expand u i plus 1 in Taylor series as u i plus delta x u i prime plus delta x
square by 2 u i double prime, etc.
And u i plus 2 equals u i plus twice delta x u i prime plus twice delta x whole square
by 2 u i double prime, etc.
So if I now write a u i plus b u i plus 1 plus c u i plus 2, we have a u i plus b multiplied
by u i plus 1.
We take this expression from the Taylor series expansion of u i plus 1 plus c multiplied
by u i plus 2 and we take the Taylor series expansion of u i plus 2.
Clubbing up the terms, we have a plus b plus c multiplied by u i plus b plus twice c multiplied
by delta x u i prime plus b plus 4 c delta x square by 2 u i double prime, etc.
As we are trying to express a u i plus b u i plus 1 plus c u i plus 2 as u i double prime,
our goal now is to make a plus b plus c equals 0, b plus twice c into delta x equals 0, and
b plus 4 c into delta x square by 2 equals 1.
From these three equations, we should be able to find these three unknowns a, b, and c.
We find here both a and c are 1 by delta x square and b is minus 2 by delta x square.
b plus 8 c, this is necessary to understand the accuracy of the scheme, is 6 by delta
x square.
That means the coefficient of u i triple prime, that is b plus 8 c into delta x cube
by 6 is actually delta x.
So the truncation error is delta x multiplied by u i triple prime plus additional terms.
Therefore, I can write now u i double prime is equals u i minus twice u i plus 1 plus
u i plus 2 divided by delta x square plus truncation error which has the order of delta x.
So this is a first order accurate scheme.
This is 3 point forward difference scheme for double derivative.
3 point forward difference scheme for single derivative is second order accurate, but
3 point forward difference for double derivative is only first order accurate.
Why do we need this?
Well, sometimes we need double derivative at the left boundary of a system.
And in that case, we can take double derivative only via forward difference.
But we see that this is, this double derivative is only first order accurate.
So we have to live with that.
If we want to make it higher order accurate expression, then we have to bring additional
terms.
If you want higher order accuracy scheme for forward difference double derivative, you
can take u i plus 3 in the mix and try to figure out if we have this expression of u
i double prime equals a0 u i plus a1 u i plus 1 a2 u i plus 2 and a3 u i plus 3, then what
will be this coefficients a0, a1, a2, and a3, and what would be the order of accuracy
of this scheme.
We can certainly expect that it will be at least second order accurate.
So you can try this exercise and see what will happen.
All the discussion that we had so far are contained in the chapter 3 of your textbook.
So this will be a good time to go to your textbook and read this chapter.
That's all for this class.
We'll see you in next lecture.
Thank you.
