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

can anyone help me solve this in python 2.7 version please. Don\'t need the grap

ID: 3589718 • Letter: C

Question

can anyone help me solve this in python 2.7 version please. Don't need the graphical help, just need the data.

Consider the function f(x) = x3 2x + 4 on the interval [2, 2] with h = 0.25. Use the forward, backward, and centered finite difference approximations for the first and second derivatives so as to graphically illustrate which approximation is most accurate. Graph all three first-derivative finite difference approximations along with the theoretical, and do the same for the second derivative as well.

Explanation / Answer

%Consider the function f(x)=x^3-2*x+4 on the interval [-2,2] with
h=0.25.
%Use the forward, backward, and centered finite difference
approximations
%for the first and second derivatives so as to graphically illustrate
which
%approximatin is most accurate. Graph all three first-derivative
finite
%difference approximations along with the theoretical, and do the
same for
%the second derivative as well.
function deriv

h=0.25
f(x)=x^3-2*x+4
f'(x)=3*x^2-2 %1st derivative of f(x)
f''(x)=6*x %2nd derivative of f(x)
x2=(-2:.25:2)
x1=x2-h
x3=x2+h
x(i-1)=.25
x(i)=.50
x(i+1)=.75
f'(.25)=(f(x(i+1))-f(x(i)))/h %Forward difference
f'(.25)=(f(x(i))-f(x(i-1)))/h %Backward difference
f'(.25)=(f(x(i+1))-f(x(i-1)))/h %Central difference

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote