
1st Assignment: Euler’s Method
MTH 212-DIFFERENTIAL EQUATION-1ST 3 WEEK BLOCK
I am working on this equation:
In the first class of MNE 212, I had difficulties with my first differential equation
I had problems with this equation because of errors I got in matlab so I decided to change my equation to
I used the program called matlab to solve my equation by writing: dsolve (’Dy = -x*(y+1)’, ‘y(0) = .5′, ‘x’). I used the phrase “dsolve” because it is the proper syntek for matlab to solve differential equations. This is the solution matlab gave: ans = -1+3/2 exp(-1/2x^2)
In latex it is viewed like this:
Then I generated a ez-plot graph by typing this equation on maple:
sol1 = dsolve(‘Dy = -x*(y+1)’, ‘y(0) = .5′, ‘x’)
sol1 =
-1+3/2*exp(-1/2*x^2)
>> ezplot(sol1, [-5 5])
DIRECTIONAL FIELD
I then created 2 direction field graphs as shown below to show the changes in the vector fields . I created the direction field by typing in this command on matlab with my equation: dfield7.
Mathlab then generated the graph.

I also generated a mesh grid graph. Which is silimilar to the graph above. The mesh grid helped me pick intervals for the planes. Matlab uses the command quiver, for plotting direction fields in conjunction with meshgrid. In order to generate the mesh grid I had to type in this formula in mathlab:
>> [x,y]=meshgrid(-5:.5:5,-5:.5:5);
>> s=-x.*(y+1);
>> l=sqrt(1+s.^2);
>> quiver(x,y,1./l,s./l,.5), axis tight

EULER’S METHOD
I also used excel and Euler’s Method to create this graph below.
The equation for Euler’s method is . By Using this equation we can get the soltion for
. We are then left with
.
I then put in Excel ,
and y(x)=0.7 then Excel calculated the results and gave me the table below. When i played with the graph it was made clear that a larger
would cause a greater error but a smaller
will give a shorter range.
| x | y |
| 0 | 1 |
| 0.1 | 1 |
| 0.2 | 0.98 |
| 0.3 | 0.9404 |
| 0.4 | 0.882188 |
| 0.5 | 0.80690048 |
| 0.6 | 0.71655546 |
| 0.7 | 0.61356213 |
| 0.8 | 0.50061278 |
| 0.9 | 0.38056376 |
| 1 | 0.25631302 |
| 1.1 | 0.13068172 |
| 1.2 | 0.00630673 |
| 1.3 | -0.1144501 |
| 1.4 | -0.2295716 |
| 1.5 | -0.3374315 |
| 1.6 | -0.4368168 |
| 1.7 | -0.5269261 |
| 1.8 | -0.6073487 |
| 1.9 | -0.6780259 |
| 2 | -0.739201 |
| 2.1 | -0.7913608 |
| 2.2 | -0.835175 |
| 2.3 | -0.8714365 |
| 2.4 | -0.9010061 |
| 2.5 | -0.9247647 |
| 2.6 | -0.9435735 |
| 2.7 | -0.9582444 |
| 2.8 | -0.9695184 |
| 2.9 | -0.9780532 |
| 3 | -0.9844178 |
| 3.1 | -0.9890925 |
| 3.2 | -0.9924738 |
| 3.3 | -0.9948822 |
| 3.4 | -0.9965711 |
| 3.5 | -0.9977369 |
| 3.6 | -0.998529 |
| 3.7 | -0.9990586 |
| 3.8 | -0.9994069 |
| 3.9 | -0.9996323 |
| 4 | -0.9997757 |
| 4.1 | -0.9998654 |
| 4.2 | -0.9999206 |
| 4.3 | -0.9999539 |
| 4.4 | -0.9999737 |
| 4.5 | -0.9999853 |
| 4.6 | -0.9999919 |
| 4.7 | -0.9999956 |
| 4.8 | -0.9999977 |
| 4.9 | -0.9999988 |
| 5 | -0.9999994 |
| 5.1 | -0.9999997 |
| 5.2 | -0.9999998 |
| 5.3 | -0.9999999 |
| 5.4 | -1 |
| 5.5 | -1 |
| 5.6 | -1 |
| 5.7 | -1 |
| 5.8 | -1 |
| 5.9 | -1 |
| 6 | -1![]() |

