{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# main24 - f E1 =(4*fd2-fd1/3 E2 =(4*fd3-fd2/3 E3...

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

% % Derek Rampal % HW 24 - 12/3 11.3 462 4(c, d) % format long; clear; c % Test lin_fin_diff(tt,vv,kk,cc,zz,P,Q,R) % Problem 5 % y''=2y'-y+x*exp(x)-x % a = 0; b = 1; c = 1; d = exp(-10); n = 10; p = @(x) 0; q = @(x) 100; r = @(x) 0; p answer = exp(-10*(.1:.1:1)); fd1 = lin_fin_diff(a,b,c,d,n,p,q,r); f % Seems to work % % For richardson...using book, % E1 = (4*w(h/2)-w(h))/3 % E2 = (4*w(h/4)-w(h/2))/3 % E3 = (16*E2-E1)/15 % % 4c % actual = @(x) (4./x-2./x.^2+log(x)-3/2); solution = actual(1.1:.1:2); s a = 1; b = 2; c = .5; d = log(2); n = 10; p = @(x) -4/x; q = @(x) -2/x.^2; r = @(x) 2*log(x)./x.^2; r fd1 = lin_fin_diff(a,b,c,d,n,p,q,r); f n=20; fd2 = lin_fin_diff(a,b,c,d,n,p,q,r); fd2 = fd2(2:2:20); f n=40; fd3 = lin_fin_diff(a,b,c,d,n,p,q,r); fd3 = fd3(4:4:40);

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: f E1 = (4*fd2-fd1)./3; E2 = (4*fd3-fd2)./3; E3 = (16*E2-E1)./15; E3 = E3(1,1:9) E for i = 1:9 [sigdigs(1,i),t1,t2] = sigdig(solution(1,i),E3(1,i)); end sigdigs s % 4d % actual = @(x) (1/6*x.^3.*exp(x)-5/3*x.*exp(x)+2*exp(x)-x-2); solution = actual(.2:.2:2); s a = 0; b = 2; c = 0; d = -4; n = 10; p = @(x) 2; q = @(x) -1; r = @(x) (x.*exp(x)-x); r fd1 = lin_fin_diff(a,b,c,d,n,p,q,r); f n=20; fd2 = lin_fin_diff(a,b,c,d,n,p,q,r); fd2 = fd2(2:2:20); f n=40; fd3 = lin_fin_diff(a,b,c,d,n,p,q,r); fd3 = fd3(4:4:40); f E1 = (4*fd2-fd1)./3; E2 = (4*fd3-fd2)./3; E3 = (16*E2-E1)./15; E3 = E3(1,1:9) E for i = 1:9 [sigdigs(1,i),t1,t2] = sigdig(solution(1,i),E3(1,i)); end sigdigs...
View Full Document

{[ snackBarMessage ]}