Sequence23 (2 points)¶
We define the following mathematical series:
\[\begin{split}& x_0 = 0.5 \\
& x_i = \frac{1}{i^2 \sqrt{i}} + x_{i-1}, \quad i>0 \\\end{split}\]
Write function sequence23() that takes two values, k and
eps (both float) and returns the summation
(float) of the terms of this series until we reach the first
term which is equal to k with a tolerance eps. This term will not be
included in the summation. We say that two values, \(a\),
\(b\) are equal with a tolerance \(\epsilon\) when they meet
the following condition: \(abs(a-b) < \epsilon\)
Save this function in file sequence23.py.
Examples:
>>> round(sequence23(0.5, 0.1), 2)
0.0
>>> round(sequence23(1.5, 0.1), 1)
0.5
>>> round(sequence23(1.77, 0.01), 3)
5.418
Note
More tests are provided in file test-sequence23.txt.