Problem Set C

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

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

View Full Document Right Arrow Icon

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

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

Unformatted text preview: %% 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) 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],...
View Full Document

This note was uploaded on 06/28/2009 for the course MATH 246H taught by Professor Zheng during the Spring '08 term at Maryland.

Page1 / 8

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

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

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