Problem Set C

Problem Set C - Problem 7a to find the values at 1 1.5 and...

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

%% Problem 7a % to find the values at 1 1.5 and 3 I had to use ode45 twice because in %order for it to have the correct initial condition it needed to have the %interval start at 2, so I made two intervals; one starting at two % and going down to one and one starting at two and going up to 3 fa = @(t,y)(-exp(y)/(t.*exp(y)-sin(y))); % finding the approximate values [t ya] = ode45(fa, 2 :-.5: 1 , 1.5); [t ya] [t yb] = ode45(fa, 2 : 1 : 4 , 1.5); [t yb] format long ; 1.000000000000000 2.269811843239378 1.500000000000000 1.822765651027438 3.000000000000000 1.045263208334591 %% % Graphing the solution on required interval: Since the initial value is y(2) % the interval that we are evaluating over has to start at 2 so we break the interval that we are solving the differential equation into two intervals that both start at two, one going backwards to .5 and one going forwards to 4 figure hold on ode45(fa , [2 0.5] , 1.5) ode45(fa , [2 4 ] , 1.5) title 'Graph of e^y+ (te^y-sin(y))dy/dt=0 , y(2)=1.5' ; xlabel t ; ylabel y ; hold off 0.5 1 1.5 2 2.5 3 3.5 4 0.5 1 1.5 2 2.5 3 Graph of e y + (te y -sin(y))dy/dt=0 , y(2)=1.5 t y %% 7b % to graph the symbolic solution we repeat the procedure that was done in % problem 6 using dsolve to find the solution of the differential equation % then graphing it on the same graph that was used to graph the approximate % solution from 7a dsolve( 'exp(y)+(t*exp(y)-sin(y))*Dy=0' ) f = @(t,y)t.*exp(y)+cos(y)

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

View Full Document
fa = @(t,y)(-exp(y)/(t.*exp(y)-sin(y))); c=f(2,1.5); [T, Y]= meshgrid(.5:0.1:4, 0:0.1:3); figure hold on contour(T,Y, f(T, Y),[c c], 'k' ) ode45(fa , [2 0.5] , 1.5) ode45(fa , [2 4 ] , 1.5)
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