Problem4_15 - et3=abs(ca-f_1stderiv%Remainder terms(little unclear about this part tser=(et1 et2/2%printing all data fprintf\nTrue

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function problem4_15(x,step) %Problem 4.15 %Application using forward, center and backward difference approximations %step=step size %approximations. f=25*x^3-6*x^2+7*x-88; f_1stderiv=75*x^2-12*x+7; xi=x-step; x2=x+step; f_xi=25*xi^3-6*xi^2+7*xi-88; f_x2=25*x2^3-6*x2^2+7*x2-88; %------------------------------------------------ %Forward difference approx fw=(f_x2-f)/step; et1=abs(fw-f_1stderiv); %------------------------------------------------ %Backward difference approx ba=(f-f_xi)/step; et2=abs(ba-f_1stderiv); %------------------------------------------------ %Centered difference approx ca=(f_x2-f_xi)/(2*step);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: et3=abs(ca-f_1stderiv); %------------------------------------------------%Remainder terms (little unclear about this part) tser=(et1+et2)/2; %------------------------------------------------%printing all data fprintf('\nTrue value:1stderiv_f(2)=%3d\n\n',f_1stderiv); fprintf('Forward:1stderiv_f(2)=%4.1f, error=%3.1f\n\n',fw,et1); fprintf('Backward:1stderiv_f(2)=%4.1f, error=%3.1f\n\n',ba,et2); fprintf('Backward:1stderiv_f(2)=%4.1f, error=%3.1f\n\n',ca,et3); fprintf('Et based on remainder term in Taylor series:\n\nForward: Et= %3.1f\n\n',tser); fprintf('Backward: Et=%3.1f\n\nCentered: Et=%1d\n',tser,et3); end...
View Full Document

This note was uploaded on 09/27/2011 for the course EGM 3344 taught by Professor Raphaelhaftka during the Spring '09 term at University of Florida.

Ask a homework question - tutors are online