Project

a new title

#comment

your code is wrong please recheck your results

  • If you see the above plot between the dx vs Error, as you see the value of dx, in starting i.e I mean at dx = pi/10 the central difference error is lesser than the other two schemes
  • but this central difference approximation is having a limit, where after a certain limit, the error is increasing, even the FDS, BDS has the same effect but it was happening when dx is lesser and the increment is also less
  • by the above graph, the FDS, and BDS is use full for having smaller dx than the central difference scheme
  • And when you compare the Error of FDS and BDS, we have FDS higher error than BDS and so BDS can be the better way to find the approximation.
    close allclear allclccentral_difference_fourthorder = zeros(50,50);forword_difference_fourthorder = zeros(50,50);backword_difference_fourthorder = zeros(50,50);Error_Central_difference = zeros(1,11);Error_forword_difference = zeros(1,11);Error_backword_difference = zeros(1,11);% function to derivative is exp(x)*cos(x)x=pi/3;numerical_2nd_derivative = (-2*sin(x)*exp(x));a= [pi/10,pi/20,pi/40,pi/60,pi/80,pi/100,pi/200,pi/400,pi/600,pi/800,pi/1000];for i=[1:1:11];dx = a(i);central_difference_fourthorder(i) = (-(0.0833*(exp(x-2*dx)*cos(x-2*dx)))+(1.333*(exp(x-dx)*cos(x-dx)))-(2.5*exp(x)*cos(x))+(1.333*(exp(x+dx)*cos(x+dx)))-(0.0833*(exp(x+2*dx))*cos(x+2*dx)))/dx^2;forword_difference_fourthorder(i) =((3.75*(exp(x)*cos(x)))-(12.833*(exp(x+dx)*cos(x+dx)))+(17.833*(exp(x+2*dx)*cos(x+2*dx)))-(13*(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;backword_difference_fourthorder(i) =((2.7789*(exp(x)*cos(x)))-(7.9776*(exp(x-dx)*cos(x-dx)))+(8.1219*(exp(x-2*dx)*cos(x-2*dx)))-(3.2886*(exp(x-3*dx)*cos(x-3*dx)))+(0.2276*(exp(x-4*dx)*cos(x-4*dx)))+(0.1378*(exp(x-5*dx)*cos(x-5*dx))))/dx^2;Error_Central_difference(i) = abs(central_difference_fourthorder(i)-numerical_2nd_derivative);Error_forword_difference(i) = abs(forword_difference_fourthorder(i)-numerical_2nd_derivative);Error_backword_difference(i) = abs(backword_difference_fourthorder(i)-numerical_2nd_derivative);endplot(a,Error_Central_difference,a,Error_forword_difference,a,Error_backword_difference)axis([0 0.35 0 0.5])xlabel('dx')ylabel('Error')legend('Error Central difference','Error forword difference','Error backword difference')​
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.