Homework 06 - Section 2.5 19 Use the Matlab code given on page 131 of the textbook Switch around the f and impeuler functions like this

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This homework help was uploaded on 01/21/2008 for the course MATH 2930 taught by Professor Terrell,r during the Spring '07 term at Cornell University (Engineering School).

Page1 / 2

Homework 06 - Section 2.5 19 Use the Matlab code given on page 131 of the textbook Switch around the f and impeuler functions like this

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online