Series¶
Let’s consider the following mathematical succession parameterized by the real number constants \(k_1, k_2\):
\[x_{i+1} = \left| \frac{k_1 + sin(x_i)}{2*e^{k_2 x_i}} \right|\]
Implement the following Python functions (following the order is recommended) in the module series11 (file series11.py).
The first function is:
For exemple:
>>> x = calc_term(0.1, 0.1, 4.0) >>> x 0.2201 >>> x = calc_term(0.1, 0.1, x) >>> x 0.1557 >>> x = calc_term(0.1, 0.1, x) >>> x 0.1256
Note
Python standard modules such as math may be imported and used.
Doctests are available at the calc_term-test.txt file.
The second function is:
For exemple:
>>> sum3eventerms(0.1, 0.1, 4.0) 4.267 >>> sum3eventerms(0.0, 0.0, 0.0) 0.0 >>> sum3eventerms(-1.0, 1.0, 0.0) 0.384
Note
This function implementation must call the previous function as many times as needed.
Doctests are available at the sum3eventerms-test.txt file.