3 Approximating partial derivatives

Earlier, in HELM booklet  31.3, we saw methods for approximating first and second derivatives of a function of one variable. We review some of that material here. If y = y ( x ) then the forward and central difference approximations to the first derivative are:

d y d x y ( x + δ x ) y ( x ) δ x , d y d x y ( x + δ x ) y ( x δ x ) 2 δ x

and the central difference approximation to the second derivative is:

d 2 y d x 2 y ( x + δ x ) 2 y ( x ) + y ( x δ x ) ( δ x ) 2

in which δ x is a small x -increment. The quantity δ x is what we previously referred to as h , but it is now convenient to use a notation which is more closely related to the independent variable (in this case x ). (Examples implementing the difference approximations for derivatives can be found in HELM booklet  31.)

We now return to the subject of this Section, that of partial derivatives. The PDE u t = α u x x involves the first derivative u t and the second derivative 2 u x 2 . We now adapt the ideas used for functions of one variable to the present case involving u = u ( x , t ) .

Let δ t be a small increment of t , then the partial derivative u t may be approximated by:

u t u ( x , t + δ t ) u ( x , t ) δ t

Let δ x be a small increment of x , then the partial derivative 2 u x 2 may be approximated by:

2 u x u ( x + δ x , t ) 2 u ( x , t ) + u ( x δ x , t ) ( δ x ) 2

The two difference approximations above are the ones we will use later in this Section. Example 14 below refers to these and others.

Example 14

Consider the function u defined by

u ( x , t ) = sin ( x 2 + 2 t )

Using increments of δ x = 0.004 and δ t = 0.04 , and working to 8 decimal places, approximate

  1. u x ( 2 , 3 ) with a one-sided forward difference
  2. u x x ( 2 , 3 ) with a central difference
  3. u t ( 2 , 3 ) with a one-sided forward difference
  4. u t ( 2 , 3 ) with a central difference.

Enter your approximate derivatives to 3 decimal places.

Solution

The evaluations of u we will need are u ( x , t ) = 0.54402111 , u ( x + δ x , t ) = 0.55738933 , u ( x δ x , t ) = 0.53054047 , u ( x , t + δ t ) = 0.60933532 , u ( x , t δ t ) = 0 . 47522703 . It follows that

  1. u x ( 2 , 3 ) 0.55738933 + 0.54402111 0.004 = 3.342
  2. u x x ( 2 , 3 ) 0.55738933 + 2 × 0.54402111 0.53054047 0.00 4 2 = 7.026
  3. u t ( 2 , 3 ) 0.60933532 + 0.54402111 0.04 = 1.633
  4. u t ( 2 , 3 ) 0.60933532 + 0.47522703 2 × 0.04 = 1.676

to 3 decimal places. (Workings shown to 8 decimal places.)