{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

hw24_derek_rampal

# hw24_derek_rampal - Derek Rampal HW 24 24 Code Derek Rampal...

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

Derek Rampal HW 24 24 12/3 11.3 462 4(c, d) Code: % % Derek Rampal % HW 24 - 12/3 11.3 462 4(c, d) % format long ; clear; % 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; answer = exp(-10*(.1:.1:1)); fd1 = lin_fin_diff(a,b,c,d,n,p,q,r); % 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); 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; fd1 = lin_fin_diff(a,b,c,d,n,p,q,r); n=20; fd2 = lin_fin_diff(a,b,c,d,n,p,q,r); fd2 = fd2(2:2:20); n=40; fd3 = lin_fin_diff(a,b,c,d,n,p,q,r); fd3 = fd3(4:4:40); E1 = (4*fd2-fd1)./3; E2 = (4*fd3-fd2)./3; E3 = (16*E2-E1)./15

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

View Full Document
for i = 1:9 [sigdigs(1,i),t1,t2] = sigdig(solution(1,i),E3(1,i)); end sigdigs % 4d actual = @(x) (1/6*x.^3.*exp(x)-5/3*x.*exp(x)+2*exp(x)-x-2); solution = actual(.2:.2:2); a = 0; b = 2; c = 0; d = -4; n = 10; p = @(x) 2; q = @(x) -1; r = @(x) (x.*exp(x)-x); fd1 = lin_fin_diff(a,b,c,d,n,p,q,r); n=20; fd2 = lin_fin_diff(a,b,c,d,n,p,q,r); fd2 = fd2(2:2:20); n=40; fd3 = lin_fin_diff(a,b,c,d,n,p,q,r); fd3 = fd3(4:4:40); E1 = (4*fd2-fd1)./3; E2 = (4*fd3-fd2)./3; E3 = (16*E2-E1)./15 for i = 1:9
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern