**Unformatted text preview:**

MATH 282 MATLAB Assignment 2 First Order Differential Equations Part 2 Qualitative Techniques 1 Understanding the quiver command The quiver command allows us to draw vectors in the plane R2 For instance if we wish to draw the two vectors a 2 3 and b 1 4 and place them at the points 0 0 and 0 1 in R2 then we form the following four matrices 1 The x positions matrix 0 0 2 The y positions matrix 0 1 3 The x components matrix 2 1 4 The y components matrix 3 4 If we type quiver 0 0 0 1 2 1 3 4 in the command window we see Note that MATLAB automatically scales vectors so that they do not overlap To prevent MATLAB from scaling vectors we add a zero to the script We can use the command axis to request that MATLAB draw the vectors and display them on a specific window In this example we draw the vectors A and B and display them on the window 0 x 10 0 y 10 To display a grid simply type grid on We can use the command linewidth to change the width of the vectors in this example we multiply the original length by 1 5 Important Remark To draw a single vector a a1 a2 and place it at the point x x1 x2 type quiver x1 x1 x2 x2 a1 a1 a2 a2 that is we draw the vector a a1 a2 twice 2 Slope Fields Consider the equation dy y t If y t is a solution of the equation then f t y y t represents the slope of the tangent line to the graph of y t at the point t y The following table gives the slopes of the tangent lines at three different points dt t y f t y 1 1 213 1 0 1 4 Think of the vector a b as the position vector of the point a b that is the vector whose tail is the origin and tip the point a b In other words a b is the vector that joins the points 0 0 and a b The vectors 1 2 1 1 and 1 3 are parallel to the tangent lines to the graph of f t y at the points 1 1 1 0 and 1 4 We can use the quiver command to plot the vectors 1 2 1 1 and 1 3 We observe that the vectors have the desired slopes but have different lengths at different points We can scale the vectors by dividing each one of them by its length Li The slope field of our differential equation can be obtained by repeating the same procedure for a large number of points To do this we use the MATLAB commend meshgrid In this example we plot the slope field of the above equation on the domain 4 t 4 3 y 3 We can obtain a better picture by reducing the length of the vectors by half Using the dsolve command we see that the general solution of our equation consists of the family of functions y t t 1 cet The following figure shows the solutions for c 2 1 0 1 2 superimposed on the slope field Example Plot the slop field y t y2 Make sure that use and A special attention should be directed to the second line and the way S was written Exercise B Hunt Consider the critical threshold model for population growth y 2 y y a Find the equilibrium solutions of the differential equation b Draw the slope field and use it to decide which equilibrium solutions are stable and which are unstable y t is stable if solutions that start near y t converge to y t Hint modify T Y meshgrid 4 0 2 4 4 0 2 4 until you obtain c What is the limiting behavior of the solution if the initial population is between 0 and 2 Greater than 2 a desirable slope field d Use dsolve to find the solutions with initial values 1 5 0 3 and 2 1 e Plot the three solutions of part d together with the slope field on the same graph Do the solutions follow the slope field as you expect it to

View Full Document