# main15 - y =(2*y 4(y 1(y 3 fp = inline(2*y 4(y 1(y 3't'y f...

This preview shows pages 1–2. Sign up to view the full content.

% % Derek Rampal % main15 % 15 10/15 5.2 190 3(c,d), 6(c,d) % clear; format long; f % 3c % ffun = inline('-1*(y+1)*(y+3)','t','y'); fact = inline('-3+2*(1+exp(-2*t))^-1','t'); f yinit = -2; h = .2; a = 0; b = 2; b answer(1,1) = euler(ffun,a,b,yinit,h); actual(1,1) = fact(b); [sigds(1,1),absolute(1,1),relative(1,1)] = sigdig(actual(1,1),answer(1,1)); [ % 3d % gfun = inline('-5*y+5*t^2+2*t','t','y'); gact = inline('x^2+1/3*exp(-5*x)','x'); g yinit2 = 1/3; h2 = .1; a2 = 0; b2 = 1; b answer(2,1) = euler(gfun,a2,b2,yinit2,h2); actual(2,1) = gact(b2); [sigds(2,1),absolute(2,1),relative(2,1)] = sigdig(actual(2,1),answer(2,1)); [ % 6c % original function = y' = -(y+1)(y+3) = -(y^2 +4 y +3)

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % y'' = (2*y+4)*(y+1)*(y+3) % fp = inline('(2*y+4)*(y+1)*(y+3)','t','y'); f answer(3,1) = taylor2(ffun,fp,a,b,yinit,h); actual(3,1) = fact(b); [sigds(3,1),absolute(3,1),relative(3,1)] = sigdig(actual(3,1),answer(3,1)); [ % 6d % original function = y' = -5*y+5*t^2+2*t % y '' = -5*y'+10*t+2 = -5*(-5*y+5*t^2+2*t)+10*t+2 % % fp2 = inline('-5*(-5*y+5*t^2+2*t)+10*t+2','t','y'); f answer(4,1) = taylor2(gfun,fp2,a2,b2,yinit2,h2); actual(4,1) = gact(b2); [sigds(4,1),absolute(4,1),relative(4,1)] = sigdig(actual(4,1),answer(4,1)); [ [actual,answer,absolute,relative,sigds]...
View Full Document

{[ snackBarMessage ]}

### Page1 / 2

main15 - y =(2*y 4(y 1(y 3 fp = inline(2*y 4(y 1(y 3't'y f...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online