Euler Method - Using the Method with Mathematica

Numerical Methods for Solving Differential Equations

Euler's Method

Using the Method with Mathematica

(continued from last page...)

Reminder: the euler program that we've taken so long to analyze looks like this:

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]
]

Copy the program from here and then switch to Mathematica and Paste and execute it. Return here once you have done this. . .

Your output from this command should have been nothing at all! After all, we didn't actually run the euler program, we simply told Mathematica how it works. Let's now move on and try using it.

 


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.