{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

hw15_derek_rampal

# hw15_derek_rampal - Derek Rampal HW 15 15 10/15 5.2 190...

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

Derek Rampal 10/14/2008 HW 15 15 10/15 5.2 190 3(c,d), 6(c,d) The formula for f(x) is given in exercise 4. Compute the actual values, the absolute and relative errors and the number of significant digits. Code: % % Derek Rampal % main15 % 15 10/15 5.2 190 3(c,d), 6(c,d) % clear; format long ; % 3c ffun = inline( '-1*(y+1)*(y+3)' , 't' , 'y' ); fact = inline( '-3+2*(1+exp(-2*t))^-1' , 't' ); yinit = -2; h = .2; a = 0; b = 2; 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' ); yinit2 = 1/3; h2 = .1; a2 = 0; b2 = 1; 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) % y'' = (2*y+4)*(y+1)*(y+3) % fp = inline( '(2*y+4)*(y+1)*(y+3)' , 't' , 'y' );

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

View Full Document
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(
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 3

hw15_derek_rampal - Derek Rampal HW 15 15 10/15 5.2 190...

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

View Full Document
Ask a homework question - tutors are online