Sie sind auf Seite 1von 5

# Numerical Solutions of Differential Equations

## Want to solve y' = f(x,y) with y(t0) = y0

Euler's Method See Sheet 2 for Improved Euler's Method and Sheet 3 for
x0 = 0 y0 = 2 h= 0.1
x(n) y(n) f(x(n),y(n)) y(n+1)=y(n) + h*f(x(n),y(n)) First step is to adjust the x0, y0, and h values in B4, D4, a
0 2 #VALUE! #VALUE!
0.1 #VALUE! #VALUE! #VALUE! Column A gives the value of the x variable separated by s
0.2 #VALUE! #VALUE! #VALUE!
0.3 #VALUE! #VALUE! #VALUE! Column B gives the value of the y variable computed from
0.4 #VALUE! #VALUE! #VALUE! This value comes from the computation in Column D with
0.5 #VALUE! #VALUE! #VALUE!
0.6 #VALUE! #VALUE! #VALUE! Column C gives the function evaluation using Columns A a
0.7 #VALUE! #VALUE! #VALUE! This is the key step in Euler's method. You click on C6 to
0.8 #VALUE! #VALUE! #VALUE! Next you can go to the Tools on the Menu Bar, then Mac
0.9 #VALUE! #VALUE! #VALUE! Visual Basic Editor (or you can take the shortcut by ente
1 #VALUE! #VALUE! #VALUE! In the Visual Basic Editor, you find the "Public Function f
1.1 #VALUE! #VALUE! #VALUE! match your particular problem.
1.2 #VALUE! #VALUE! #VALUE! Return to the Excel spreadsheet and go to the Insert Me
1.3 #VALUE! #VALUE! #VALUE! Enter OK, and the spreadsheet will change to the solutio
1.4 #VALUE! #VALUE! #VALUE! Euler's Method. (This also updates Sheet 2 for the Impro
1.5 #VALUE! #VALUE! #VALUE!
1.6 #VALUE! #VALUE! #VALUE!
1.7 #VALUE! #VALUE! #VALUE!
1.8 #VALUE! #VALUE! #VALUE!
1.9 #VALUE! #VALUE! #VALUE!
2 #VALUE! #VALUE! #VALUE!
s Method and Sheet 3 for the Exact Solution

and h values in B4, D4, and F4. These change the initial conditions and the stepsize for the problem.

## y variable computed from Euler's method.

putation in Column D with Euler's formula.

## luation using Columns A and B.

method. You click on C6 to highlight that cell.
n the Menu Bar, then Macros, then select the
take the shortcut by entering Alt-F11).
find the "Public Function f(x,y)" and edit it to

## et and go to the Insert Menu and select Function.

t will change to the solution in Column B of
ates Sheet 2 for the Improved Euler's method.)
Want to solve y' = f(x,y) with y(t0) = y0
Improved Euler's Method
x0 = 0 y0 = 2 h= 0.1
x(n) y(n) f(x(n),y(n)) ye y(n+1) = y(n)+(h/2)*(f(x(n),y(n))+f(x(n)+h,ye))
0 2 #VALUE! #VALUE! #VALUE!
0.1 #VALUE! #VALUE! #VALUE! #VALUE! ye = y(n)+hf(x(n),y(n))
0.2 #VALUE! #VALUE! #VALUE! #VALUE!
0.3 #VALUE! #VALUE! #VALUE! #VALUE!
0.4 #VALUE! #VALUE! #VALUE! #VALUE!
0.5 #VALUE! #VALUE! #VALUE! #VALUE!
0.6 #VALUE! #VALUE! #VALUE! #VALUE!
0.7 #VALUE! #VALUE! #VALUE! #VALUE!
0.8 #VALUE! #VALUE! #VALUE! #VALUE!
0.9 #VALUE! #VALUE! #VALUE! #VALUE!
1 #VALUE! #VALUE! #VALUE! #VALUE!
1.1 #VALUE! #VALUE! #VALUE! #VALUE!
1.2 #VALUE! #VALUE! #VALUE! #VALUE!
1.3 #VALUE! #VALUE! #VALUE! #VALUE!
1.4 #VALUE! #VALUE! #VALUE! #VALUE!
1.5 #VALUE! #VALUE! #VALUE! #VALUE!
1.6 #VALUE! #VALUE! #VALUE! #VALUE!
1.7 #VALUE! #VALUE! #VALUE! #VALUE!
1.8 #VALUE! #VALUE! #VALUE! #VALUE!
1.9 #VALUE! #VALUE! #VALUE! #VALUE!
2 #VALUE! #VALUE! #VALUE! #VALUE!
Actual Solution
x y h= 0.1
0 2
0.1 2.0201
0.2 2.081622
0.3 2.188349
0.4 2.347022 80
0.5 2.568051
0.6 2.866659 70
0.7 3.264632
0.8 3.792962
60
0.9 4.495816
1 5.436564 Euler's
1.1 6.706969
50
Imp
1.2 8.441392 Euler
1.3 10.83896 40
Actual
1.4 14.19865
1.5 18.97547 30
1.6 25.87163
1.7 35.98662 20
1.8 51.06744
1.9 73.93211 10
2 109.1963
0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Euler's
Imp
Euler
Actual