hw17_derek_rampal

# hw17_derek_rampal - Derek Rampal HW 17 17 10/20 5.7 232...

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

HW 17 17 10/20 5.7 232 1(a), 2(a) Use the Runge-Kutta method of order 4. Compute the actual values, the absolute errors and the number of significant digits. code: % % Derek Rampal % 17 10/20 5.7 232 1(a), 2(a) % clear; % 1a a1 = 0; b1 = 1; h1 =.2; ival1 = [1;1]; ffun = inline( '[3*y(1)+2*y(2)-(2*t^2+1)*exp(2*t);4*y(1)+y(2)+(t^2+2*t- 4)*exp(2*t)]' , 't' , 'y' ); fact = inline( '[1/3,-1/3,1;1/3,2/3,t^2]*exp([5;-1;2]*t)' , 't' ); [t1,onea] = rk4(ffun,a1,b1,h1,ival1); [m,n] = size(t1); [m1,n1]=size(onea); for i = 1:m oneaact(:,i) = fact(t1(i,1)); for j = 1:m1 [sd(j,i),abserr(j,i),relerr(j,i)] = sigdig(oneaact(j,i),onea(j,i)); end ; end ; [t1';onea] oneaact abserr relerr sd % 2a % y''-2*y'+y=t*exp(t)-t % u1(t)=y(t) % u1'(t)=u2(t)=y'(t) % u2'(t)=y''(t)=t*exp(t)-t+2*y'-y =t*exp(t)-t+2*u2(t)-u1(t) a2 = 0; b2 = 1; h2 = .1; ival2 = [0;0]; gfun = inline( '[y(2);t*exp(t)-t+2*y(2)-y(1)]' , 't' , 'y' ); gact = inline( '1/6*t^3*exp(t)-t*exp(t)+2*exp(t)-t-2' , 't' ); [t2,twoa] = rk4(gfun,a2,b2,h2,ival2);

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.

## This note was uploaded on 09/19/2009 for the course MATH numerical taught by Professor Ford during the Spring '09 term at FAU.

### Page1 / 4

hw17_derek_rampal - Derek Rampal HW 17 17 10/20 5.7 232...

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

View Full Document
Ask a homework question - tutors are online