Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is a Numerical Methods question which needs to be answer in Matlab using ru

ID: 3282393 • Letter: T

Question

This is a Numerical Methods question which needs to be answer in Matlab using runnable code which will output an answer. The code must also contain comments.

4. (a) Develop algorithms which, for input discrete data points (zi, f(x)), (T2, f(x2)), (xn, /(xn)), which are assumed to be equally spaced in x, uses second (i) the first and second derivatives at x2, (ii) the first derivatives at x1,... , Xn-2 and second derivatives at x?,... ,2n-3 order estimates to approximate ,xn-1 using a centered finite di]Terence scheme. using a forward finite difference scheme. (iii) the first derivatives at x3 , , Tn and second derivatives at T4, ,.en using a backward finite difference scheme (b) Use each of the algorithms you developed to approximate the velocity and acceleration at t-10 seconds of a moving object with the following recorded positions: Time t (s)02 46 810121416 Position x (m)00.7 1.83.4 5.36.27.3 8.0 8.4

Explanation / Answer

clc;
clear all;
h=2;
t=0:h:16;
x=[0 0.7 1.8 3.4 5.3 6.2 7.3 8 8.4];
n=length(x);
%Central difference
for i=2:n-1
    cfd(i-1)=(x(i+1)-x(i-1))/(2*h);
    csd(i-1)=(x(i+1)-2*x(i)+x(i-1))/h^2;
end
disp('Central differnce')
disp('____________________________________________________________')
disp(' t              Firsrt_derivtive       Second_derivative ')
disp('____________________________________________________________')
for i=1:n-2
fprintf('%f %15f %15f ',t(i+1),cfd(i),csd(i))
end
%Forward differnce
for i=1:n-2
    ffd(i)=(-x(i+2)+4*x(i+1)-3*x(i))/(2*h);
   end
for i=1:n-3
   fsd(i)=(-x(i+3)+4*x(i+2)-5*x(i+1)+2*x(i))/h^2;
end
disp('Forward differnce First derivative')
ffd'
disp('Forward differnce Second derivative')
fsd'
%Backward differnce
for i=3:n
    bfd(i-2)=(x(i-2)-4*x(i-1)+3*x(i))/(2*h);
   end
for i=4:n
   bsd(i-3)=(-x(i-3)+4*x(i-2)-5*x(i-1)+2*x(i))/h^2;
end
disp('Backward differnce First derivative')
bfd'
disp('Backward differnce Second derivative')
bsd'

%%%% Solution %%%

Central differnce
____________________________________________________________
t              Firsrt_derivtive       Second_derivative
____________________________________________________________
2.000000            0.450000             0.100000
4.000000            0.675000             0.125000
6.000000            0.875000             0.075000
8.000000            0.700000            -0.250000
10.000000            0.500000             0.050000
12.000000            0.450000            -0.100000
14.000000            0.275000            -0.075000
Forward differnce First derivative

ans =

   0.250000000000000
   0.425000000000000
   0.725000000000000
   1.200000000000000
   0.400000000000000
   0.649999999999999
   0.425000000000001

Forward differnce Second derivative

ans =

   0.075000000000000
   0.175000000000000
   0.400000000000000
-0.550000000000000
   0.200000000000000
-0.125000000000000

Backward differnce First derivative

ans =

   0.650000000000000
   0.925000000000000
   1.025000000000000
   0.200000000000000
   0.600000000000000
   0.250000000000000
   0.125000000000001

Backward differnce Second derivative

ans =

   0.150000000000000
   0.025000000000000
-0.575000000000000
   0.350000000000000
-0.250000000000000
-0.050000000000000

>>
>>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote