7
$\begingroup$

Topic- Numerical Approximations

$\endgroup$
1
10
$\begingroup$

Difference approximations of derivatives can be used in the numerical solution of ordinary and partial differential equations.

Consider a function that is smooth in some neighborhood of a point $x$. We can approximate the derivatives using values of the function at speicified mesh points. If the mesh spacing is $h$ the mesh points are $...,x-3h,x-2h,x-h,x,x+h,x+2h,x+3h,...$ Using Taylor's theorem we have

$$f(x+h) = f(x) + f'(x)h + \frac1{2}f''(\xi_2)h^2.$$

The forward difference approximation is

$$f'(x) \approx \frac{f(x+h)-f(x)}{h} $$

and the truncation error is $O(h)$.

The central difference approximation is more accurate for smooth functions. Extending the Taylor approximation as

$$f(x+h) = f(x) + f'(x)h + \frac1{2}f''(x)h^2 +\frac1{6}f'''(\xi_3)h^3,\\f(x-h) = f(x) - f'(x)h + \frac1{2}f''(x)h^2 -\frac1{6}f'''(\xi'_3)h^3\\$$

$$f'(x) \approx \frac{f(x+h)-f(x-h)}{2h} $$

and the truncation error is $O(h^2)$.

Since the central difference approximation is superior to the forward difference approximation in terms of truncation error, why would it not always be the preferred choice? In some cases, for example convection-diffusion equations, central differencing of convective terms can lead to numerical instabilities and poor resolution of steep gradients (artificial dispersion).

$\endgroup$
1
  • 1
    $\begingroup$ You mean the local truncation error is $O(h^3)$ while the global error or order of the method is 2. $\endgroup$
    – Aditya P
    Feb 23 '20 at 18:57
5
$\begingroup$

Even though I feel like this question needs some improvement, I'm going to give a short answer. We use finite difference (such as central difference) methods to approximate derivatives, which in turn usually are used to solve differential equation (approximately).

Recall one definition of the derivative is $$f'(x)=\lim\limits_{h\rightarrow 0}\frac{f(x+h)-f(x)}{h} $$ this means that $$f'(x)\approx\frac{f(x+h)-f(x)}{h} $$ when $h$ is a very small real number. This is usually called the forward difference approximation. The reason for the word forward is that we use the two function values of the points $x$ and the next, a step forward, $x+h$. Similarly, we can approximate derivatives using a point as the central point, i.e. if $x$ is our central point we use $x-h$ and $x+h$. The central difference approximation is then $$f'(x)\approx\frac{f(x+h)-f(x-h)}{2h}.$$

$\endgroup$
3
$\begingroup$

Suppose you have a discrete approximation, y, to a function, $f(x)$, which is in principle continuous but for which you only have some selection of data points: $y_i = f(x_i)$, where $x_i$ may or may not be equally spaced. (This happens all the time when you're trying, for example, to numerically evaluate an ODE or some such.)

Because $f(x)$ is continuous, it makes sense to ask what its derivative $f'(x)$ is. Of course, you won't be able to get the value of the derivative at every value of x on which its defined, because you don't know enough, but let's further suppose that you'll be happy with an approximation to $f'(x)$ that's about as precise as what you started with for $f(x)$. How to make the approximation?

Answer: Abuse of the definition of the derivative. Recall that we may define $f'(x) = \lim_{\epsilon \to 0} \frac{f(x + \epsilon) - f(x - \epsilon)}{2\epsilon}$\, where the numerator consists of two points on either side of the point at which to evaluate the derivative, and the denominator is the distance between the two points. Analytically, we take this distance to be infinitesimally small, but if all we have is a set of data points that describe f(x), we can't do that -- we can only take points that are next to each other and use those. Fortunately, if your data points' x values are close enough together, you can plug them into the formula and expect reasonably good approximation anyway; to wit, if the distance between $x_i$ and $x_{i+1}$ is, say, h, then we can take

$f'(x_i + \frac{h}{2}) \approx \frac{f(x_{i+1}) - f(x_{i})}{h}$.

This is the central difference formula -- it gives an approximation for the value of the derivative at a point midway between ("central" to) each contiguous pair of points in the data.

So, why use it? Well, if you do the same thing to $f'(x)$, you'll get $f''(x)$ at each data point, which will be really nice if you're dealing with a second order ODE.

Astute readers (wiseacres) may have noted that there is not a unique derivative formula; you can use $f'(x) = \lim_{\epsilon \to 0} \frac{f(x + \epsilon) - f(x)}{\epsilon}$ instead, in which case you get approximations to the derivatives at each grid point instead of at points halfway between the data points. And that seems useful. The problem is that you can't use your last (rightmost) data point with this scheme (which may or may not be problematic depending on your boundary conditions).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.