Challenge

Week 3.5 - Deriving 4th order approximation of a 2nd order derivative using Taylor Table method

 
AIM:

               To derive the fourth order approximations of a second order derivative using central differencing scheme, skewed right sided difference and skewed left sided difference with the help of taylor table method and to compare the analytical derivative with obtained values for the given function.

Derive the following 4th order approximations of the second-order derivative. 

1. Central difference

2. Skewed right-sided difference

3. Skewed left-sided difference

After deriving these schemes, prove that your skewed schemes are fourth-order accurate i.e the thumb rule given in HINT (ii). 

Once you have done this, write a program in Matlab to evaluate the second-order derivative of the analytical function exp(x)*cos(x) and compare it with the 3 numerical approximations that you have derived.

Provide a plot that compares the absolute error between the above-mentioned schemes

In your own words, describe why a skewed scheme is useful? What can a skewed scheme do that a CD scheme cannot?

 SCHEME DERIVATIONS:

CENTRAL DIFFERENCING SCHEME:

NO OF NODES:

The number of nodes = p+q-1

Where, p is order of derivative.

           q is order of approximations.

The no of nodes = 2+4-1 =>5.

DERIVATION:

To derive a fourth order approximation for the second order derivative,we start with these approximation,
〖∂u〗^2/〖∂x〗^2 =(af(i-2)+bf(i-1)+cf(i)+df(i+1)+ef(i+2))/〖dx〗^2 

taylor series derivation for the above terms,

af(i-2)=af(i-2)  (-2af^' (i)dx)/1!+(4af^'' (i) 〖dx〗^2)/2!+(8af^''' (i) 〖dx〗^3)/3!+(16af''''(i)〖dx〗^4)/4!

Simillarly expand all the terms in the equation (1) and are represented in the form of table using taylor table method.  

〖dx〗^2 〖f 〗^(' ') (x)             f(i)           f ’(i)dx         f ’ ’(i)〖dx〗^2        f ’ ’ ’(i) 〖dx〗^3      f ’ ’ ’ ’(i) 〖dx〗^4  

af(i-2)                  a           -2a               2a               -4a/3                 29/3
bf(i-1)                  b	     -b                b/2             -b/6             b/24
cf(i)		         c	      0                0                 0                   0
df(i+1)		         d            d                d/2             d/6               d/24
ef(i+2)                  e            2e                 2e            4e/3                2e/3
         (∂^2 u)/〖∂x〗^2 =((-0.0833)f(i-2)+(1.333)f(i-1)+(-2.5000)f(i)+(1.3333)f(i+1)+(-0.833)f(i+2))/〖dx〗^2 
      

[█(█(1     1    1     1       1@@-2    -1    0    1   2@2     1/2     0   1/( 2)      2@-4/3     -( 1)/6     0  1/6     4/3@2/3     1/24    0    1/24     2/( 3)@)@)].[█(a@b @c@d@e@f)]=[█(0@0 @1@0@0)]

  

   (∂^2 u)/〖∂x〗^2 =((3.7500)f(i)+(-12.833)f(i+1)+(17.8333)f(i+2)+(-13.0000)f(i+3)+(15.0833)f(i+4)+(-08.333)+f(i+5))/〖dx〗^2 

[█(█(1     1    1     1       1       1@@0   1   2     3     4     5   @0   1/2     4/2     9/2    16/( 2)      25/2@0  1/6     ( 8)/6     27/6   64/6     125/6@0       1/24     16/24    81/24    256/24     625/24@0 1/120  32/120  243/120  1024/120  3125/120@)@)].[█(a@b @c@d@e@f)]=[█(0@0 @1@0@0)]

same as claculation formulas

function Error_central_differencing = fourth_order_central_differencing(x,dx)

% analytic function = exp(x)*cos(x)

% analytic derivative
%f''(x) = -2*exp(x)*sin(x)

analytical_derivative = -2*exp(x)*sin(x);

%numerical derivative
coding

%central differencing
central_differencing = (((-0.0833)*((exp(x-(2*dx)))*(cos(x-(2*dx)))))+((1.3333)*((exp(x-dx))*(cos(x-dx))))-((2.5000)*((exp(x))*(cos(x))))+((1.3333)*((exp(x+dx))*(cos(x+dx))))-((0.0833)*((exp(x+(2*dx)))*(cos(x+(2*dx))))))/(dx^2);

%error
Error_central_differencing = abs(central_differencing- analytical_derivative);
function Error_left_sided_skew = fourth_order_left_sided_skew(x,dx)

% analytic function = exp(x)*cos(x)

% analytic derivative
%f''(x) = -2*exp(x)*sin(x)

analytical_derivative = -2*exp(x)*sin(x);

%numerical derivative

%central differencing
left_sided_skew = (((-0.8333)*((exp(x-(5*dx)))*(cos(x-(5*dx)))))+((5.0833)*((exp(x-(4*dx)))*(cos(x-(4*dx)))))-((13.0000)*((exp(x-(3*dx)))*(cos(x-(3*dx)))))+((17.8333)*((exp(x-(2*dx)))*(cos(x-(2*dx)))))-((12.8333)*((exp(x-dx))*(cos(x-dx))))+((3.7500)*((exp(x))*(cos(x)))))/(dx^2);

%error
Error_left_sided_skew = abs(left_sided_skew- analytical_derivative);

function Error_right_sided_skew = fourth_order_right_sided_skew(x,dx)

% analytic function = exp(x)*cos(x)

% analytic derivative
%f''(x) = -2*exp(x)*sin(x)

analytical_derivative = -2*exp(x)*sin(x);

%numerical derivative

%central differencing
right_sided_skew = (((3.7500)*((exp(x))*(cos(x))))-((12.8333)*((exp(x+dx))*(cos(x+dx))))+((17.8333)*((exp(x+(2*dx)))*(cos(x+(2*dx)))))-((13.0000)*((exp(x+(3*dx)))*(cos(x+(3*dx)))))+((5.0833)*((exp(x+(4*dx)))*(cos(x+(4*dx)))))-((0.8333)*((exp(x+(5*dx)))*(cos(x+(5*dx))))))/(dx^2);

%error
Error_right_sided_skew = abs(right_sided_skew- analytical_derivative);




CONCLUSION:

As seen from the plot, the central differencing scheme has very less error compared to other schemes. Therefore, central differencing is better than other schemes because it uses information from both the sides from the point of consideration to give approximative and accurate values.

As the left and right skewed difference methods uses data only from one side of point of interest it gives less approximative and accurate values about the point.

WHY A SKEWED SCHEME IS USEFUL:

The system which doesn’t contain sufficient information on both side of the point of interest. In such cases we cannot use central differencing scheme so skewed scheme is useful in such cases.

WHAT CAN A SKEWED SCHEME DO THAT A CD SCHEME CANNOT DO:

CDS cannot not be employed at the boundary nodes due to unavailability of right and left nodes at the same time. In such cases the skewed differencing scheme is used.

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.