Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Consider the IVP $$y' = \frac{1}{t^2} - \frac{y}{t} = y^2$$ with $t$ an element of $[1,2]$ and $y(1) = -1$. The exact solution is $y(t) = -1/t$

(a) How can we use Euler's method with $h = 0.05$ to approximate the solution & and compare it to actual values of $y$?

(b) Use answer in part (a), and linear interpolation to approx the following values of $y$ and compare also with actual values:




I'm stuck at the euler setup in part (a), and also, with the portion of comparing errors. Can you work out for one of the values in part (b), so I can get it?

share|cite|improve this question

Here is some pseudo code for (a):

h := 0.05;
// The number of xs minus 1 is the number of steps you'll do:
number_of_xs := length([1: h : 2]) - 1;

y_Euler(0) := -1; // Initialise your array of ys.
for i = 0 to i = (number_of_xs-1) do
  y_Euler(i+1) = y_Euler(i) + h*y_Euler(i)^2;

// Then you want to compute the exact values:
xs := [1: h : 2];
y_exact := -1/xs; // Alternatively, write a for loop.

// Then you want to compute the (local) error:
err := abs(y_Euler - y_exact);

You might want to read about local and global error in the second paragraph here. Hope this helps.

share|cite|improve this answer
Any ideas on how I can do this on Maple? – user87274 Oct 31 '13 at 19:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.