Series 4¶
Consider the following mathematical succession:
\(x_0 = 7\)
\(x_1 = 3\)
\(x_{n+1} = \frac{2*x_n+x_{n-1}}{3}\)
It is well know that this succession converges to 4.0.
Implement the following Python function in the series4 module (file series4.py):
- series4(eps, r)¶
such that given
Desa la funció al fitxer series4.py i puja’l a Atenea. Els següents doctests mostren exemples del que ha de fer la funció:
For exemple:
>>> l = series4(0.1, 2) >>> l [7, 3, 4.33, 3.89] >>> l = series4(0.1, 4) >>> l
Doctests are available at the series4-test.txt file.