Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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:

$y(1.052)$

$y(1.555)$

$y(1.978)$

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|improve this question
add comment

1 Answer

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|improve this answer
    
Any ideas on how I can do this on Maple? –  user87274 Oct 31 '13 at 19:52
add comment

Your Answer

 
discard

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.