Euler Method - Using the Method with Mathematica - Part 7

Numerical Methods for Solving Differential Equations

Euler's Method

Using the Method with Mathematica

(continued from last page...)

Instructions for the Exercises

Once again it's time to have you attempt to do some work on your own. The examples that we've already done together should have sufficiently prepared you to tackle these problems. As you work through them, don't cheat yourself by first skipping forward and looking at the solutions. After all, you are supposed to be doing these exercises to enhance your learning, and to prepare yourself for the laboratory exam that you'll take later.

Some of these exercises may be solved exactly using the techniques that you have already learned in the lecture component of this course. If you're feeling ambitious, you might attempt to find the exact solutions to the exercises, where this is possible, and then use these solutions to help you gauge how good the corresponding numerical solutions are, just as we did back in the Introduction.

Use the euler program:

euler[f_,{x_,x0_,xn_},{y_,y0_},steps_]:=

Block[{ xold=x0,
    yold=y0,
    sollist={{x0,y0}},
    x,y,h
  },

  h=N[(xn-x0)/steps];

  Do[ xnew=xold+h;
    ynew=yold+h*(f/.{x->xold,y->yold});
    sollist=Append[sollist,{xnew,ynew}];
    xold=xnew;
    yold=ynew,
    steps
  ];

  Return[sollist]
]

that you entered into Mathematica earlier, to solve each of the initial value problems given in the table below. For each exercise, do the following:

  1. Find the numerical solution, in the form of a list, on the x-interval spanning from the initial condition point up to the specified x-value.

  2. Read this solution list into the solution name specified for the exercise.

  3. Use the number of steps specified.

  4. Redisplay your solution in tidy columns with a command of the form MatrixForm[Solution Name], inserting the appropriate name for the exercise inside the brackets.

  5. Plot your solution using a command of the form ListPlot[Solution Name], inserting the appropriate name for the exercise inside the brackets.

  6. Check your solution and its graph by clicking on the Mathematica Answer button provided. (Only do this once you've tried the problem yourself.)

Exercises

Solution
Name
Differential
Equation
Initial
Condition
Solve
up to
Number
of Steps
Check
Solution
eulerex1 y′ = y y(0) = 1 x = 1 10 Mathematica Logo
eulerex2 y′ = x - y y(0) = 0.5 x = 1 20 Mathematica Icon
eulerex3 y′ = x2+1/y2 y(5) = 1 x = 6 30 Mathematica Icon
eulerex4 y′ = (x - y)2 y(0) = 0.5 x = 0.5 20 Mathematica Icon
eulerex5 y′ = x y + y1/2 y(0) = 1 x = 1 20 Mathematica Icon

If you've finished the above exercises, then you may either return to the beginning of this laboratory, jump to the Table of Contents of all of the differential equations laboratories, or simply quit.

 


Compass If you're lost, impatient, want an overview of this laboratory assignment, or maybe even all three, you can click on the compass button on the left to go to the table of contents for this laboratory assignment.