MATH 2250 Differential Equations and Linear Algebra Homework 4 Computing Assignment

advertisement
MATH 2250
Differential Equations and Linear Algebra
Fall Semester, 2008, University of Utah
Homework 4 Computing Assignment
1. Load the MAPLE worksheet from the class web site (which uses Euler’s method to numerically approximate a solution to an initial value
problem), and modify it to handle the initial value problem we did in
class:
dy
= xy, y(1) = 1.
dx
As in class, we are interested in the Euler’s method estimate of the
solution at x = 2 (in other words, an estimate for y(2), where y(x) is
the solution to the initial value problem).
(a) Start using a step size of h = 0.2, or n = 5 steps over the x range
1 to 2. We did this in lecture, and got an estimate of 3.41921 for
y(2). You should get the same result (but with additional decimal
places).
2
(b) We also showed in class that the exact solution is y(x) = e(x −1)/2 .
Use MAPLE to calculate the exact solution for y(2). You will
need to use the “exp()” function.
(c) Next, use MAPLE to calculate the percent error of the estimate. If
yest is your estimate and yexact is the exact value, then the percent
error will be given by
!
yexact − yest
.
100
yexact
(d) Now go back and double the number of steps n (thus halving
the step size h), and re-run the estimate and error calculation,
checking that the error has decreased. Keep doubling n (i.e., run
for n = 5, 10, 20, 40, etc.) until the percent error is below 1%.
Please print out only the final MAPLE worksheet (just the one for the final
value of n from part (d)). It should show the values of n and h you used,
the estimate, the exact value, and the percent error. Please save paper by
showing only the version where the print command is moved after the forloop, so only the final estimate value is shown.
1
Download