2 Consider the IVP y2y y0 3 for 0 t 10 The exact solution o

2. Consider the IVP y\'--2y, y(0) = 3 for 0 t 10 The exact solution of the ODE is y 3e2t The goal of this exercise is to visualize how Euler\'s method is related to the slope field of the differ- ential equation. In order to do this we will plot the direction field together with the approximations and the exact solution alize how Euler\'s method is related to the slop (a) To plot the slope field we will use the MATLAB commands meshgrid and quiver. Enter the following commands: % define grid of values in t and y direction % creates 2d matrices of points in the ty-plane % dt-1 for all points % dy = -2*y, this is the ODE % draw arrows (t,y)-(t+dt, trdy) % adjust look -30 : 6:42 t = 0: .45 : 10 ; y = [T,Y]-meshgrid(t,y); dT - ones (size(T)) ; quiver(T,Y,dT, dY) axis tight hold on After running these commands you should get the graph of the slope field (b) Use linspace to generate a vector of 200 t-values between 0 and 10. Evaluate the solution y at these t-values and plot it in black together with the direction field (use \'linewidth\' ,2)

Solution

It is hoped that the following explanation helps:

A differential equation (simplest kind) is a relationship of the form

                                      dy/dx= f(x,y) with y[a]=b, ...........................(1)

This specifies that the solution curve passes through (a,b) and at any point (x,y) , the tangent to the curve is (slope ) has direction dy/dx.

Not all equations (1) admit explicit solutions. Consider, for example,

                                     dy/dx= sin(x2 ) with say y(0)=1....................(2)

One way to understand such equations is to use f(x,y) to draw the direction field (which is known at every point (x,y)) and figure out the curve looking at the shape of the direction field.

In this case,

                           dy/dt =-2y with y(0) =3...................(3)

This is an easy equation , which can be solved directly.

                    dy/y =-2

so              ln y =-2t + arbitrary constant

so                     y= C e-2t

as y                  y(0) =3,

                     C =3

and               y(t) =3 e-2t , the (exact) explicit solution to the problem

What is done in the computer program is explained as follows: Discretize the equation and the coordinate axes (x between 0 and 10-wit 45 equal divisions and y between -36 and 42 ) .

Plot the (direction) or slope field using dy=-2y dt . (quivers are the vectors representing the direction field)

Compare with the actual solution (by graphing it) obtained above.

In this case, the solution 3e-2t is a rapidly decreasing (in fact exponentially ) , so the agreement with the discretized and the actual solution is very close.

 2. Consider the IVP y\'--2y, y(0) = 3 for 0 t 10 The exact solution of the ODE is y 3e2t The goal of this exercise is to visualize how Euler\'s method is relat

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site