 
Summary: Math 308, Matlab assignment 2
due February 12 in class
1. In the initial value problem
dy
dx
= x/y, y(0) = 5,
use Euler's method to compute approximations to y(5) with 1, 5, 50 steps. Note that you will
need to determine the step sizes yourself. Plot the results on one plot. Label the plot and the axes
appropriately.
The syntax is
[x, y] = eul(f, [x0, x1], y0, h)
or
[x, y] = eul(@function, [x0, x1], y0, h)
where f is an inline function or function an Mfile function, [x0, y0] is the initial condition, x1
is the value of x where you want to compute the solution, and h is the (optional) step size. Before
running eul, you will need to create a function f(x, y) = x/y. There are two ways to do this.
You can create an inline function, by typing
>> f = inline('x./y','x','y');
(note the use of vectorized division ./). This is quick, but the function will be erased at the end of
the Matlab session. If you want to use it next time, create an Mfile: edit opens the Matlab editor,
