7 Cost -v- benefit

At a first reading of this Section, it might be tempting to think that the extra effort involved in using Crank-Nicolson (we have to store a set of simultaneous equations, we have to solve them and we have to do this at every time-step) is enough to make the explicit method the winner in a cost-benefit analysis. But this would be wrong.

In practical problems involving numerical approximations to parabolic problems the explicit method is rarely good enough. The stability constraint ( r 1 2 ) imposes such tiny time-steps that it takes a great deal of time for a computer to produce approximations corresponding to even fairly modest values of t . If efficiency is what matters, then Crank-Nicolson beats the explicit approach, and it is worth the extra initial effort formulating a solver (such as those we saw in HELM booklet  30) for the system of equations.

Exercises
  1. Consider the function u defined by

    u ( x , t ) = x 3 cos ( x t )

    Using increments of δ x = 0.005 and δ t = 0.01 , 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.

    State the approximate derivatives to 3 decimal places.

  2. The temperature u ( x , t ) of a metal bar of length ℓ = 3 at a distance x from one end and at time t is modelled by the partial differential equation

    u t = α u x x ( 0 < x < &ell; , t > 0 )

    It is given that the metal has diffusivity α = 1.6 , that the two ends of the bar are kept at temperature u = 0 and that the initial temperature distribution is

    u ( x , 0 ) = f ( x ) = x ( &ell; x )

    Use the explicit difference scheme with δ x = 0.75 and δ t = 0.08 to approximate u ( x , t ) at t = δ t and t = 2 δ t .

  3. The temperature u ( x , t ) of a metal bar of length &ell; = 1.2 at a distance x from one end and at time t is modelled by the partial differential equation

    u t = α u x x ( 0 < x < &ell; , t > 0 ) .

    It is given that the metal has diffusivity α = 2.25 , that the two ends of the bar are kept at temperature u = 0 and that the initial temperature distribution is

    u ( x , 0 ) = f ( x ) = sin ( π x &ell; )

    Use the Crank-Nicolson difference scheme with δ x = 0.4 and δ t = 0.06 to approximate u ( x , t ) at t = δ t and at t = 2 δ t .

  1. The evaluations of u we will need are u ( x , t ) = 0.41614684 , u ( x + δ x , t ) = 0.43162908 , u ( x δ x , t ) = 0.40095819 , u ( x , t + δ t ) = 0.42521885 , u ( x , t δ t ) = 0 . 40703321 . It follows that
    1. u x ( 1 , 2 ) 0.43162908 + 0.41614684 0.005 = 3.096
    2. u x x ( 1 , 2 ) 0.43162908 + 2 × 0.41614684 0.40095819 0.00 5 2 = 11.744
    3. u t ( 1 , 2 ) 0.42521885 + 0.41614684 0.01 = 0.907
    4. u t ( 1 , 2 ) 0.42521885 + 0.40703321 2 × 0.01 = 0.909

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

  2. In this case r = α 2 δ t ( δ x ) 2 = 0.227556 so that the numerical scheme can be written

    u j n + 1 = u j n + 0.227556 ( u j 1 2 2 u j n + u j + 1 n ) = 0.544889 u j n + 0.227556 ( u j 1 2 + u j + 1 n )

    The first stage is to use the given data to find u j 0

    u 0 0 = 0 from the boundary condition u 1 0 = f ( δ x ) = f ( 0.75 ) = 1.6875 from the initial condition u 2 0 = f ( 2 δ x ) = f ( 1.5 ) = 2.25 from the initial condition u 3 0 = f ( 3 δ x ) = f ( 2.25 ) = 1.6875 from the initial condition u 4 0 = 0 from the boundary condition

    The first timestep will find u j 1 . We note that the boundary condition implies that u 0 1 = u 4 1 = 0 .

    u 1 1 = 0.544889 u 1 0 + 0.227556 ( u 0 0 + u 2 0 ) = 0.544889 × 1.6875 + 0.227556 ( 0 + 2.25 ) = 1.4315 u 2 1 = 0.544889 u 2 0 + 0.227556 ( u 1 0 + u 3 0 ) = 0.544889 × 2.25 + 0.227556 ( 1.688 + 1.688 ) = 1.994 u 3 1 = 0.544889 u 3 0 + 0.227556 ( u 2 0 + u 4 0 ) = 0.544889 × 1.6875 + 0.227556 ( 2.25 + 0 ) = 1.4315

    The second timestep will find u j 2 . First we note that the boundary condition implies that u 0 2 = u 4 2 = 0 .

    u 1 2 = 0.544889 u 1 1 + 0.227556 ( u 0 1 + u 2 1 ) = 0.544889 × 1.4315 + 0.227556 ( 0 + 1.994 ) = 1.233754 u 2 2 = 0.544889 u 2 1 + 0.227556 ( u 1 1 + u 3 1 ) = 0.544889 × 1.994 + 0.227556 ( 1.432 + 1.432 ) = 1.738 u 3 2 = 0.544889 u 3 1 + 0.227556 ( u 2 1 + u 4 1 ) = 0.544889 × 1.4315 + 0.227556 ( 1.994 + 0 ) = 1.233754

    where some quantities have been rounded to 6 decimal places.

  3. In this case r = α δ t ( δ x ) 2 = 0.84375 so that the numerical scheme can be written

    u j n + 1 = u j n + 0.84375 2 ( u j 1 n 2 u j n + u j + 1 n + u j 1 n + 1 2 u j n + 1 + u j + 1 n + 1 )

    Moving the unknowns to the left of the equation we obtain

    0.42188 u j 1 n + 1 + 1.84375 u j n + 1 0.42188 u j + 1 n + 1 = 0.15625 u j n + 0.42188 ( u j 1 n + u j + 1 n )

    The first stage is to use the given data to find u j 0

    u 0 0 = 0 from the boundary condition u 1 0 = f ( δ x ) = f ( 0.4 ) = 0.86603 from the initial condition u 2 0 = f ( 2 δ x ) = f ( 0.8 ) = 0.86603 from the initial condition u 3 0 = 0 from the boundary condition

    The first time-step will find u j 1 . First we note that the boundary condition implies that u 0 1 = u 3 1 = 0 . Two uses of the stencil give

    0.42188 u 0 1 + 1.84375 u 1 1 0.42188 u 2 1 = 0.15625 u 1 0 + 0.42188 ( u 0 0 + u 2 0 ) = 0.50067 0.42188 u 1 1 + 1.84375 u 2 1 0.42188 u 3 1 = 0.15625 u 2 0 + 0.42188 ( u 1 0 + u 3 0 ) = 0.50067

    The implicit nature of this method means that we have to do some extra work to complete the time-step. We must now solve the simultaneous equations

    1.84375 0.42188 0.42188 1.84375 u 1 1 u 2 1 = 0.50067 0.50067

    In this case there are only two unknowns and it is a simple matter to solve the pair of equations to give u 1 1 = 0.35212 and u 2 1 = 0.35212 .

    The second time-step will find u j 2 . First we note that the boundary condition implies that u 0 2 = u 3 2 = 0 . Two uses of the stencil give

    0.42188 u 0 2 + 1.84375 u 1 2 0.42188 u 2 2 = 0.15625 u 1 1 + 0.42188 ( u 0 1 + u 2 1 ) = 0.20357 0.42188 u 1 2 + 1.84375 u 2 2 0.42188 u 3 2 = 0.15625 u 2 1 + 0.42188 ( u 1 1 + u 3 1 ) = 0.20357

    The implicit nature of this method means that we have to do some extra work to complete the time-step. We must now solve the simultaneous equations

    1.84375 0.42188 0.42188 1.84375 u 1 2 u 2 2 = 0.20357 0.20357

    In this case there are only two unknowns and it is a simple matter to solve the pair of equations to give u 1 2 = 0.14317 and u 2 2 = 0.14317 .