{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# Lab10 - >> tc(1)=0 yc(1)=1 h=0.05>> for n=1:120...

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

Exercise 1 t(1)=0, y(1)=1, h=0.4 for n=1:5, y(n+1)=y(n)+h*(y(n)+2*t(n)), t(n+1)=t(n)+h, end plot(t,y); a=0:0.04:2; b=3*exp(a)-2*a-2; plot(t,y,'r:p'); hold on; plot(a,b,'g:s'); hold off; tc(1)=0; yc(1)=1; h=0.04; for n=1:50; yc(n+1)=yc(n)+h*(yc(n)+2*tc(n)); tc(n+1)=tc(n)+h; end; plot(t,y,'r:p'); hold on; plot(tc,yc,'b:d'); plot(a,b,'g:s'); hold off; 0 0.5 1 1.5 2 2.5 0 2 4 6 8 10 12 14 16 18 t y Lab 10 - Ex. 1 Previous Approx. New Approx. Exact Soln.

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

View Full Document
Exercise 2 >> t(1)=0; y(1)=1; h=0.5; >> for n=1:12; y(n+1)=y(n)+h*((1/2)*y(n)-2*cos(t(n))); t(n+1)=t(n)+h; end; >> a=0:0.05:6; >> b=(1/5)*exp(a/2)+(4/5)*cos(a)-(8/5)*sin(a);
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: >> tc(1)=0; yc(1)=1; h=0.05; >> for n=1:120; yc(n+1)=yc(n)+h*((1/2)*yc(n)-2*cos(tc(n))); tc(n+1)=tc(n)+h; end; >> plot(t,y,'r:p'); hold on; >> plot(tc,yc,'b:d'); plot(a,b,'g:s'); hold off; 1 2 3 4 5 6-2-1 1 2 3 4 5 6 Lab 10 - Ex. 2 t y Original Approx. New Approx. Exact Soln. Exercise 3 >> [ts,ys]=rk4('horse',[0,6],1,0.05); >> [tr,yr]=eul('horse',[0,6],1,0.05); >> plot(tr,yr,'r:p'); hold on; >> plot(ts,ys,'b:d'); hold off; 1 2 3 4 5 6-2-1 1 2 3 4 5 6 y t Lab 10 - Ex. 3 - f(t,y) = (1/2) y-2 cos t Euler Approx. RK4 Approx....
View Full 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