Graphics Programs Reference
In-Depth Information
Solution Since we use an adaptive method, there is no need to worry about the stable
rangeof h , as we did in Example 7.7. Aslong as wespecifyareasonable tolerance
for the per-step error, the algorithmwill find the appropriate step size. Here are the
commands and the resulting output:
>> [x,y] = runKut5(@fex7
_
7,0,[-9 0],10,0.1);
>> printSol(x,y,4)
>>
x
y1
y2
0.0000e+000 -9.0000e+000
0.0000e+000
9.8941e-002 -8.8461e+000
2.6651e+000
2.1932e-001 -8.4511e+000
3.6653e+000
3.7058e-001 -7.8784e+000
3.8061e+000
5.7229e-001 -7.1338e+000
3.5473e+000
8.6922e-001 -6.1513e+000
3.0745e+000
1.4009e+000 -4.7153e+000
2.3577e+000
2.8558e+000 -2.2783e+000
1.1391e+000
4.3990e+000 -1.0531e+000
5.2656e-001
5.9545e+000 -4.8385e-001
2.4193e-001
7.5596e+000 -2.1685e-001
1.0843e-001
9.1159e+000 -9.9591e-002
4.9794e-002
1.0000e+001 -6.4010e-002
3.2005e-002
The results are in agreement with the analytical solution.
The plots of y and y show every fourth integration step. Note the high density of
points near x
0 where y changes rapidly. As the y -curve becomes smoother, the
distance between the points increases.
=
4.0
2.0
y'
0.0
-2.0
y
-4.0
-6.0
-8.0
-10.0
0.0
2.0
4.0
6.0
8.0
10.0
x
Search WWH ::




Custom Search