Sie sind auf Seite 1von 4

Numerical Solution of Linear Differential Equations

1.2

Euler
0.8 Exact
Mod-Euler-double step size
y

0.6

0.4

0.2

0
0 0.25 0.5 0.75 1 1.25 1.5 1.75 2
x
Prob.: dy/dx=Ay/(1+Bx) ; at x=0, y=1.0 ; Find y vs. x

Sol.: Exact (Analytical) Solution: y=(1+Bx)^(A/B)


w is a dummy name for y

Numerical Solutions:
Let dy/dx=f(x,y) , w be the approximation to y
Step Size: h x0= 0 y0= 1

Euler's method A= -0.9 B= 2


h= 0.1
i x w f(x,y) K=h*f y-exact % Err error

0 0 1 -0.9 -0.09 1 0.00 0


1 0.1 0.91 -0.6825 -0.06825 0.9212 -1.22 -0.011231
2 0.2 0.84175 -0.5411 -0.054113 0.8595 -2.06 -0.017743
3 0.3 0.78764 -0.443 -0.044305 0.8094 -2.68 -0.02173
4 0.4 0.74333 -0.3717 -0.037167 0.7676 -3.16 -0.024254
5 0.5 0.70617 -0.3178 -0.031777 0.732 -3.53 -0.025877
6 0.6 0.67439 -0.2759 -0.027589 0.7013 -3.84 -0.026921
7 0.7 0.6468 -0.2426 -0.024255 0.6744 -4.09 -0.02758
8 0.8 0.62255 -0.2155 -0.02155 0.6505 -4.30 -0.027977
9 0.9 0.601 -0.1932 -0.019318 0.6292 -4.48 -0.02819
10 1 0.58168 -0.1745 -0.01745 0.61 -4.64 -0.028274
11 1.1 0.56423 -0.1587 -0.015869 0.5925 -4.77 -0.028265
12 1.2 0.54836 -0.1452 -0.014515 0.5765 -4.89 -0.028188
13 1.3 0.53384 -0.1335 -0.013346 0.5619 -4.99 -0.028063
14 1.4 0.5205 -0.1233 -0.012328 0.5484 -5.09 -0.027903
15 1.5 0.50817 -0.1143 -0.011434 0.5359 -5.17 -0.027717
16 1.6 0.49674 -0.1064 -0.010644 0.5242 -5.25 -0.027514
17 1.7 0.48609 -0.0994 -0.009943 0.5134 -5.32 -0.027297
18 1.8 0.47615 -0.0932 -0.009316 0.5032 -5.38 -0.027073
19 1.9 0.46683 -0.0875 -0.008753 0.4937 -5.44 -0.026843
20 2 0.45808 -0.0825 -0.008245 0.4847 -5.49 -0.02661
Modified Euler's A= -0.9 B= 2
h= 0.2
i x w K1 K2 y (exact) % Err Err

0 0 1 -0.18 -0.10543 1 0.00 0


1 0.2 0.85729 -0.11022 -0.07471 0.85949 -0.26 -0.00221
2 0.4 0.76482 -0.07648 -0.05632 0.76759 -0.36 -0.00277
3 0.6 0.69842 -0.05714 -0.0444 0.70131 -0.41 -0.00289
4 0.8 0.64765 -0.04484 -0.03617 0.65052 -0.44 -0.00287
5 1 0.60715 -0.03643 -0.03021 0.60995 -0.46 -0.0028
6 1.2 0.57383 -0.03038 -0.02574 0.57655 -0.47 -0.00272
7 1.4 0.54577 -0.02585 -0.02228 0.5484 -0.48 -0.00263
8 1.6 0.5217 -0.02236 -0.01954 0.52425 -0.49 -0.00255
9 1.8 0.50075 -0.01959 -0.01732 0.50322 -0.49 -0.00247
10 2 0.48229 -0.01736 -0.0155 0.48469 -0.49 -0.0024

The step size is TWICE that for Euler method


Most of the computational effort in a method is spent in function evaluations, i.e.,
in evaluating K1, K2, etc. Computing K1, K2, etc., involves finding the value of
the derivative function f(x,y) at a particular point. If in two different methods, the total
number of function evaluations are the same, the total computational effort is also
approximately comparable.
In Huen method, there are two function evaluations per step -compared to only one
in the Euler method. Therefore, if the total number of steps in Huen solution is half that in
Euler method, the total computaion is comparable is the two solutions.
This is achieved by doubling the step size in Huen solution.
Runge-Kutta Method (Order Four)

Sol.. w|o=a
k1=hf(x|i,w|i)
k2=hf(x|i+h/2, w|i+k1/2) w is a dummy name for y
k3=hf(x|i+h/2, w|i+k2/2)
k4=hf(x|(i+1), w|i+k3) A= -0.9 B= 2
w|(i+1)=w|i+(k1+2k2+2k3+k4)/6 h= 0.4
i x w k1 k2 k3 k4 y (exact) % Error

0 0 1 -0.36 -0.210857 -0.230033 -0.153993 1 0


1 0.4 0.767371 -0.153474 -0.113013 -0.116323 -0.090145 0.767587 -0.028065
2 0.8 0.650323 -0.090045 -0.072636 -0.073681 -0.061056 0.650522 -0.030661
3 1.2 0.576367 -0.061027 -0.051712 -0.052154 -0.044933 0.576547 -0.031188
4 1.6 0.524085 -0.044922 -0.039258 -0.039479 -0.034892 0.524249 -0.031346
5 2 0.484537 -0.034887 -0.03114 -0.031264 -0.028134 0.484689 -0.031407
6 2.4 0.453232 -0.028132 -0.0255 -0.025576 -0.023327 0.453375 -0.031433
7 2.8 0.42763 -0.023325 -0.021393 -0.021442 -0.019761 0.427765 -0.031447
8 3.2 0.406171 -0.01976 -0.01829 -0.018324 -0.017027 0.406299 -0.031454
9 3.6 0.387835 -0.017027 -0.015879 -0.015903 -0.014877 0.387957 -0.031458
10 4 0.371924 -0.014877 -0.013959 -0.013977 -0.013149 0.372041 -0.031461

The step size is FOUR times that for Euler method


Runge-Kutta method involves four times as much computation per step when
compared to Euler method. Therefore, if the step size is made four times, the total
compatation in the complete solution remains comparable to that of Euler.

Das könnte Ihnen auch gefallen