Project

DERIVATION FOR FOURTH ORDER APPROXIMATION OF SECOND DERIVATIVE

DERIVATION FOR FOURTH ORDER APPROXIMATION OF SECOND DERIVATIVE

We take information from4 neighbouring points, these points are all different for all 3 schemes.For backward differencing , the points we take our behind i , ie i-4,i-3,i-2,i-1.

For forward differencing , the points are right of i, that is why it is right side skewed scheme.

The points we take are:i+1,i+2,i+3,i+4

For central differencing, the points are 2 on each side ie, i-2,i-1,i+1,i+2.

Taylor table is written as : f(x+dx)=f(x)+f\'(x)Δx+f\'\'(x)Δx^2/2!+f\'\'\'(x)Δx^3/3!+f\'\'\'\'(x)Δx^4/4!+f\'\'\'\'\'(x)Δx^5/5!+f\'\'\'\'\'\'(x)Δx^6/6!+.......

BACKWARD DIFFERNCING

f\'\'(i)=a*f(i-4)+b*(i-3)+c*f(i-2)+d*f(i-1)+e*f(i)

Opening all the terms acc to the taylor table and writing them column wise as in below table , we get:

we solve all the coffiecients and put all to zero except for term of cofficient of f\'\'(i)*∆x2

Taylor table:

f(i)

(∆x)f\'(i)

∆x2f\'\'(i)

∆x3f\'\'\'(i)

∆x4f\'\'\'\'(i)

a*f(i-4)

a

-4a

16a/2

-64a/6

256a/24

b*f(i-3)

b

-3b

9b/2

-27b/6

81b/24

c*f(i-2)

c

-2c

4c/2

-8c/6

16c/24

d*f(i-1)

d

-d

d/2

-d/6

d/24

e*f(i)

e

0

0

0

0

Sum

0

0

1

0

0

Solving the matrix, GF=E, where G=

1.00000 1.00000 1.00000 1.00000 1.00000
-4.00000 -3.00000 -2.00000 -1.00000 0.00000
8.00000 4.50000 2.00000 0.50000 0.00000
-10.66667 -4.50000 -1.33333 -0.16667 0.00000
10.66667 3.37500 0.66667 0.04167 0.00000

E=

0

0

1

0

0

F=G\\E
F =

0.91667
-4.66667
9.50000
-8.66667
2.91667

Arranging all again in the previous equation , with expanding the taylor equation for all terms , we get only the term of x^2 and x^6. Dividing the whole equation by x^2, we get error of order x^4, that is why the equation is fourth order approximation. hence, f\'\'(x)=(0.91667*f(x-4dx)-4.66667*f(x-3dx)+9.5*f(x-2dx)-8.66667*f(x-dx)+2.91667*f(x))/(dx)^2 is the formula.

The sum of cofficient of term for f\'\'\'\'\'(x)Δx^5/5! is zero but sum of coffiecients collectively for f\'\'\'\'\'\'(x)Δx^6/6! are (0+d/720+64c/720+729b/720+4096a/720) which sums up to 1.3223. Now this term remains only Δx^4 once we divide Δx^2 in the denominator on both side. So the error is of fourth order which means are equation is fourth order accurate. Now this also similarly happens for the forward and the central differncing. So, our equations are fourth order accurate.

Forward differencing:

f\"(i)=a*f(i)+b*f(i+1)+c*f(i+2)+d*f(i+3)+e*f(i+4)

\"\"

D=5x1 matrix having elements,

a=2.91667

b=-8.6667

c=9.50000

d=-4.66667

e=0.91667

we can write the below equation:

f\'\'(x)= (2.91667*f(x)-8.66667*f(x+dx)+9.5*f(x+2*dx)-4.6667*f(x+3*dx)+0.91667*f(x+4*dx))/(dx)^2

Taylor table is shown:

f(i)

(∆x)f\'(i)

∆x2f\'\'(i)

∆x3f\'\'\'(i)

∆x4f\'\'\'\'(i)

a*f(i)

a

0

0

0

0

b*f(i+1)

b

b

b/2

b/6

b/24

c*f(i+2)

c

2c

4c/2

8c/6

16c/24

d*f(i+3)

d

3d

9d/2

27d/6

81d/24

e*f(1+4)

e

4e

16e/2

64e/6

256e/24

Sum

0

0

1

0

0

CENTRAL DIFFERENCING

f\'\'(i)=a*f(i-2)+b*f(i-1)+c*f(i)+d*f(i+1)+e*f(i+2)

we solve all the coffiecients and put all to zero except for term of cofficient of f\'\'(i)*∆x2

Taylor Table:

f(i)

(∆x)f\'(i)

∆x2f\'\'(i)

∆x3f\'\'\'(i)

∆x4f\'\'\'\'(i)

a*f(i-2)

a

-2a

4a/2

-8a/6

16a/24

b*f(i-1)

b

-b

b/2

-b/6

b/24

c*f(i)

c

0

0

0

0

d*f(i+1)

d

d

d/2

d/6

d/24

e*f(i+2)

e

2e

4e/2

8e/6

16e/24

Sum

0

0

1

0

0

f\'\'(x)=-0.083333*(f(x-2*dx))+1.333333*(f(x-dx))-2.5*f(x)+1.333333*f(x+dx))-0.083333*(f(x-2*dx))/(dx)^2

Divinding both sides by first term, we get

f\'\'(x)=-f(x-2*dx)+16*f(x-dx)-30*f(x)+16*f(x+dx)-f(x+2*dx))/12*(dx)^2

\"\"

We assume the values of x and dx=pi/400;

x=pi/3;

error=abs(analytical derivative-numerical derivative)

The code is mentioned as follows:

clear all
close all
clc
graphics_toolkit(\"gnuplot\")
%forward difference scheme
% f\'\'(x)= 2.91667*f(x)-8.66667*f(x+dx)+9.5*f(x+2*dx)-4.66667*f(x+3*dx)+0.91667*f(x+4*dx)

%central difference

%f\'\'(x)=(f(x-2*dx)-16*f(x-dx)+30*f(x)-16*f(x+dx)+f(x+2*dx))/12(dx)^2

%backward differencing
%f\'\'(x)=0.91667*f(x-4*dx)-4.66667*f(x-3*dx)+ 9.5*f(x-2*dx)-8.66667*f(x-dx)+2.91667*f(x)
%solving analytical derivative for f(x)=exp(x)*cos(x)
x=pi/3;
dx=pi/400;
analytical_derivative=-2*exp(x)*sin(x)
term_1=2.91667*exp(x)*cos(x)
term_2=8.66667*exp(x+dx)*cos(x+dx)
term_3=9.5*exp(x+2*dx)*cos(x+2*dx)
term_4=4.66667*exp(x+3*dx)*cos(x+3*dx)
term_5=0.91667*exp(x+4*dx)*cos(x+4*dx)

forward_differencing=(term_1-term_2+term_3-term_4+term_5)/(dx^2)
error_forward=abs(analytical_derivative-forward_differencing)
%central difference
term_6=-1*0.083333*exp(x-(2*dx))*cos(x-(2*dx))
term_7=1.333333*exp(x-dx)*cos(x-dx)
term_8=-1*2.5*exp(x)*cos(x)
term_9=1.333333*exp(x+dx)*cos(x+dx)
term_10=-1*0.083333*exp(x+(2*dx))*cos(x+(2*dx))

central_differencing=((term_6+term_7+term_8+term_9+term_10)/(dx^2))
error_central=abs(analytical_derivative-central_differencing)
%backward differencing=
%f\'\'(x)=0.91667*f(x-4*dx)-4.66667*f(x-3*dx)+ 9.5*f(x-2*dx)-8.66667*f(x-dx)+2.91667*f(x)
term_11=0.91667*exp(x-4*dx)*cos(x-4*dx)
term_12=-4.66667*exp(x-3*dx)*cos(x-3*dx)
term_13=9.5*exp(x-2*dx)*cos(x-2*dx)
term_14=-8.66667*exp(x-dx)*cos(x-dx)
term_15=2.91667*exp(x)*cos(x)
backward_differencing=(term_11+term_12+term_13+term_14+term_15)/(dx^2)
x=pi/3;
error_backward=abs(analytical_derivative-backward_differencing)
plot(x,error_forward,\"color\",\"red\",x,error_central,\"color\",\"black\",x,error_backward,\"color\",\"blue\")
set(gca,\"xlabel\",text(\"string\",\"x value\",\"fontsize\",25))
set(gca,\"ylabel\",text(\"string\",\"error values\",\"fontsize\",25))
grid on
legend(\"red-forward;black-central,blue-backward\")

OBSERVATION: The plot for values of error in octave is shown below. x=pi/3 is the vaue of x

as:\"\"

The bar graph for the values of error is shown below. It shows a better picture of the error values:

\"\"

OBSERVATION: The value of derivatives is:

analytical_derivative = -4.9357

forward_differencing = -4.9358

central_differencing = -4.9358

backward_differencing = -4.9358

1. SO what is different in a right skewed scheme, which is not in a central scheme?

Ans- When we have a skewed scheme, we take information from one direction only ,ie all the backward points or all the forward points and we just have to calulate for the next step, but for the central scheme, we need info from both the directions. In my opinion that approach can take a little more time for computation for equations because here we are not marching in the same direction finding out the value of earlier point. We simultaneously have to take values from the points in both direction.

CONCLUSION: The error is lesser for central difference scheme as compared to forward and backward scheme.The error in backward and forward is almost the same.The information taken in a central scheme is more accurate because the points are more nearby to the main point at which we know the exact value.Here we have arbitarily taken value of x=pi/3, and dx=pi/400 and result will remain the same for any value.

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.

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.