{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

hw14_derek_rampal - Derek Rampal HW 14 Ford 14 Code Derek...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Derek Rampal HW 14 Ford 14 10/10 4.9 175 3(b,d) Code: % % Derek Rampal % HW14 - main % 3b, 3d % clear; %3b x = [8.1;8.3;8.5;8.7]; f = inline('x*log(x)','x'); fp = inline('log(x)+1','x'); h = .2; threeb(1,1) = ediff3(f,x(1,1),h); threeb(2,1) = mdiff3(f,x(2,1),h); threeb(3,1) = mdiff3(f,x(3,1),h); threeb(4,1) = ediff3(f,x(4,1),-h); for i=1:4 fprime(i,1)=fp(x(i)); [signif(i,1),eabs(i,1),erel(i,1)] = sigdig(fp(x(i,1)),threeb(i,1)); end; [fprime,threeb,eabs,erel,signif] %3a f = inline('2*(log(x))^2+3*sin(x)','x'); fp = inline('4*log(x)/x+3*cos(x)','x'); x= [2;2.1;2.2;2.3]; h=.1; threed(1,1) = ediff3(f,x(1,1),h); threed(2,1) = mdiff3(f,x(2,1),h); threed(3,1) = mdiff3(f,x(3,1),h); threed(4,1) = ediff3(f,x(4,1),-h); for i=1:4 fprime(i,1)=fp(x(i)); [signif(i,1),eabs(i,1),erel(i,1)] = sigdig(fp(x(i,1)),threed(i,1)); end; [fprime,threed,eabs,erel,signif]
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
function fp = ediff3(func,x,h) % % 3 point end point differentiatiion % fp = 1/(2*h)*(-3*func(x)+4*func(x+h)-func(x+2*h)); function fp = mdiff3(func,x,h) % % three point midpoint formula % fp = 1/(2*h)*(func(x+h)-func(x-h)); function [t,Eabs,Erel] = sigdig(p,ph)
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}