Skip to content

Commit 0703b9c

Browse files
authored
Update adams_bashforth.py
1 parent 729df6c commit 0703b9c

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

maths/numerical_analysis/adams_bashforth.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""
22
Use the Adams-Bashforth methods to solve Ordinary Differential Equations.
33
4-
54
https://en.wikipedia.org/wiki/Linear_multistep_method
65
Author : Ravi Kumar
76
"""
@@ -25,20 +24,18 @@ class AdamsBashforth:
2524
2625
>>> def f(x, y):
2726
... return x + y
27+
>>> AdamsBashforth(f, [0, 0.2, 0.4], [0, 0.2, 1], 0.2, 1) # doctest: +ELLIPSIS
28+
AdamsBashforth(func=..., x_initials=[0, 0.2, 0.4], y_initials=[0, 0.2, 1], step...)
2829
>>> AdamsBashforth(f, [0, 0.2, 1], [0, 0, 0.04], 0.2, 1).step_2()
2930
Traceback (most recent call last):
3031
...
3132
ValueError: The final value of x must be greater than the initial values of x.
3233
33-
>>> def f(x, y):
34-
... return x + y
3534
>>> AdamsBashforth(f, [0, 0.2, 0.3], [0, 0, 0.04], 0.2, 1).step_3()
3635
Traceback (most recent call last):
3736
...
3837
ValueError: x-values must be equally spaced according to step size.
3938
40-
>>> def f(x, y):
41-
... return x
4239
>>> AdamsBashforth(f,[0,0.2,0.4,0.6,0.8],[0,0,0.04,0.128,0.307],-0.2,1).step_5()
4340
Traceback (most recent call last):
4441
...
@@ -73,8 +70,6 @@ def step_2(self) -> np.ndarray:
7370
>>> AdamsBashforth(f, [0, 0.2], [0, 0], 0.2, 1).step_2()
7471
array([0. , 0. , 0.06, 0.16, 0.3 , 0.48])
7572
76-
>>> def f(x, y):
77-
... return (x -y)/2
7873
>>> AdamsBashforth(f, [0, 0.2, 0.4], [0, 0, 0.04], 0.2, 1).step_2()
7974
Traceback (most recent call last):
8075
...
@@ -109,8 +104,6 @@ def step_3(self) -> np.ndarray:
109104
>>> y[3]
110105
0.15533333333333332
111106
112-
>>> def f(x, y):
113-
... return (x -y)/2
114107
>>> AdamsBashforth(f, [0, 0.2], [0, 0], 0.2, 1).step_3()
115108
Traceback (most recent call last):
116109
...
@@ -151,8 +144,6 @@ def step_4(self) -> np.ndarray:
151144
>>> y[5]
152145
0.5771083333333333
153146
154-
>>> def f(x, y):
155-
... return (x -y)/2
156147
>>> AdamsBashforth(f, [0, 0.2, 0.4], [0, 0, 0.04], 0.2, 1).step_4()
157148
Traceback (most recent call last):
158149
...
@@ -196,8 +187,6 @@ def step_5(self) -> np.ndarray:
196187
>>> y[-1]
197188
0.05436839444444452
198189
199-
>>> def f(x, y):
200-
... return (x -y)/2
201190
>>> AdamsBashforth(f, [0, 0.2, 0.4], [0, 0, 0.04], 0.2, 1).step_5()
202191
Traceback (most recent call last):
203192
...

0 commit comments

Comments
 (0)