Heun Method - Mathematica Implementation Part 2

Numerical Methods for Solving Differential Equations

Heun's Method

Mathematica Implementation

(continued fromÌýlast page...)

We will test ourÌýheunÌýprogram by having it create numerical solutions to the same differential equations that we solved using our Euler program in the last lab. Recall that the command-syntax used with your Euler program for this task was:

euler[f,{x,x0,xn},{y,y0},steps]

so for your new program, (since we made no changes to the input format when we adapted it to the Heun method, other than its name,) you would use a command of the form:

heun[f,{x,x0,xn},{y,y0},steps]

Of course, for such a command to work you must have evaluated yourÌýheunÌýprogram during your current session with theÌýMathematicaÌýkernel! Use it 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
heunex1 ²â′Ìý=Ìýy y(0)Ìý=Ìý1 xÌý=Ìý1 10 Mathematica Logo
heunex2 ²â′Ìý=Ìý³æÌý-Ìý²â y(0)Ìý=Ìý0.5 xÌý=Ìý1 20 Mathematica Logo
heunex3 ²â′Ìý=Ìýx2+1/y2 y(5)Ìý=Ìý1 xÌý=Ìý6 30 Mathematica Logo
heunex4 ²â′Ìý=Ìý(³æÌý-Ìý²â)2 y(0)Ìý=Ìý0.5 xÌý=Ìý0.5 20 Mathematica Logo
heunex5 ²â′Ìý=Ìý³æÌý²âÌý+Ìýy1/2 y(0)Ìý=Ìý1 xÌý=Ìý1 20 Mathematica Logo

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.