homework 06 solutions

homework 06 solutions - Section 2.5 19 Use the Matlab code...

• Homework Help
• davidvictor
• 2

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

Section 2.5 19. Use the Matlab code given on page 131 of the textbook. Switch around the f and impeuler functions, like this: function [X,Y]=impeuler(x,y,x1,n) h=(x1-x)/n; X=x; Y=y; for i=1:n k1=f(x,y); k2=f(x+h,y+h*k1); k=(k1+k2)/2; x=x+h; y=y+h*k; X=[X;x]; Y=[Y;y]; end function yp=f(x,y) yp=x+sqrt(y); Save this code into the file impeuler.m . To get an I.E. approximation of, for instance, y (2) with initial value y (0) = 1 and step size h = 0 . 1, type the commands [X,Y]=impeuler(0,1,2,2/0.1); Y(end) at the command line. The result is that y (2) 6 . 4083. 23. Use the same code as in Problem 19, but change the last line to yp=sin(x)+cos(y) . To get an I.E. approximation of, for instance, y (1) with initial value y (0) = 0 and step size h = 0 . 1, type the commands [X,Y]=impeuler(0,0,1,1/0.1); Y(end) at the command line. The result is that y (1) 1 . 2297. Section 2.6 19. Use the Matlab code given on page 142 of the textbook. Switch around the

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

This is the end of the preview. Sign up to access the rest of the document.
• Spring '07
• TERRELL,R
• Math, matlab, Ordered pair, Command pattern, Category theory, Function object

{[ 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