Question: COMPLETE THIS QUESTION USING THIS IN COMMAND WINDOW: clear all; f = @ ( x , y ) 2 * x + y; figure; dirfield

COMPLETE THIS QUESTION USING THIS IN COMMAND WINDOW:
clear all;
f = @(x,y)2*x+y;
figure;
dirfield(f,-3:.3:3,-4:.4:4);hold on;
x =-3:0.1:3;
y1=2*exp(x)-(x+1);
y2=2*x+1;
y3= cos(x);
plot(x,y1,'r');hold on;
plot(x,y2,'g');hold on;
plot(x,y3,'b');hold off;
PLEASE USE THIS GIVEN TO WRITE SCRIPT DIRFIELD:
function dirfield(f,tval,yval)
% dirfield(f, t1:dt:t2, y1:dy:y2)
%
% plot direction field for first order ODE y'= f(t,y)
% using t-values from t1 to t2 with spacing of dt
% using y-values from y1 to t2 with spacing of dy
%
% f is an @ function, or an inline function,
% or the name of an m-file with quotes.
%
% Example: y'=-y^2+ t
% Show direction field for t in [-1,3], y in [-2,2], use
% spacing of .2 for both t and y:
%
% f = @(t,y)-y^2+t;
% dirfield(f,-1:.2:3,-2:.2:2);
[tm,ym]=meshgrid(tval,yval);
dt = tval(2)- tval(1);
dy = yval(2)- yval(1);
fv = vectorize(f);
if isa(f,'function_handle')
fv = eval(fv);
end
yp=feval(fv,tm,ym);
s =1./max(1/dt,abs(yp)./dy)*0.35;
h = ishold;
quiver(tval,yval,s,s.*yp,0,'.r'); hold on;
quiver(tval,yval,-s,-s.*yp,0,'.r');
if h
hold on
else
hold off
end
axis([tval(1)-dt/2,tval(end)+dt/2,yval(1)-dy/2,yval(end)+dy/2])
Question Translation:
Consider the differential equation
dydx=2x+y.
(a) Write the expression of the explicit solution y that passes through (0,-2).
You must show detailed computations in your report.
(b) Write the expression of the explicit solution y that passes through (-1,3).
(c) Write the expression of the explicit solution y that passes through (-2,0).
(d) Define the three solutions you find as y1,y2, and y3 in Project2_Q1.m.
Then use the script to obtain the direction field and plot the solutions in the
direction field. What can you say about the solutions x+? How about
x-?
 COMPLETE THIS QUESTION USING THIS IN COMMAND WINDOW: clear all; f

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!