Runge-Kutta Method - Mathematica Implementation Part 1

Numerical Methods for Solving Differential Equations

The Runge-Kutta Method

Mathematica Implementation

(continued from last page...)

Recall from the first numerical methods lab that we had managed to create a program for finding numerical solutions of a first order differential equation using Euler's method. The program we created was as follows:

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


    Wolfram Technology at Howard University | Howard University ...   Go ahead and switch to a new Mathematica notebook by clicking on the button at left. Remember that it will take a while to start up! Once it has launched, enter the old Euler program above, (by using Copy and Paste if you wish,) and then come back here again where we'll discuss modifying it.

Notice that I highlighted a couple of locations in the code in red. Let's move on and discuss why...


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.