AD Series ========= A *mathematical sucsession* :math:`t_1, t_2, ... , t_i, ...` is an infinite sequence of numbers (usually *real*) such that each :math:`t_i` is computed by a formula parameterized to the previous term (or a number of them). The *Mathematical Series* induced by a given math succession is the succession of the incremental sums of the succession's terms. Hence, the series will be :math:`s_1, s_2, ... , s_n, ...` such that :math:`s_1 = t_1` :math:`s_2 = t_1 + t_2` :math:`s_3 = t_1 + t_2 + t_3` ... Let's consider the recursive definition of a mathematical succession parameterized by the real number constants :math:`k`, :math:`a`, and the succession index :math:`i` such that: :math:`t_{1} = a` :math:`t_{i} = {-1}^i * \pi * \frac {k + \sqrt{|t_{i-1}|}} {2*|t_{i-1}|}` Implement the following two Python functions in the module :mod:`ad_series` (file :file:`ad_series.py`). -------------------------------------------------------------------------------------------------------------------- The first function is: .. py:function:: ad_term(k, x, i) such that **given** - ``k``, :class:`float`, is the constant of the above succession - ``x``, :class:`float`, is the value of the :math:`x_{i-1}` term of the above succession - ``i``, :class:`int`, :math:`i > 1`, the index of the term to be calculated **returns** a :class:`float` with the value of the :math:`x_i` term of the succession calculated according to the above definition. For example: .. literalinclude:: ad_term-test.txt :language: python3 :start-after: --ini :end-before: --fi They are available at the :download:`ad_term-test.txt ` file. -------------------------------------------------------------------------------------------------------------------- The second function is: ``ad_sum5``:math:`(k, a)` such that **given** - ``k`` is a :class:`float` with the constant of the succesion - ``a`` is a :class:`float` value of the first term of the succession **returns** a :class:`float` with `s_5` of the series induced by the succession above (in either words, the addition of the first 5 terms of the succession) rounded to 4 decimals. .. note:: Notice that `a` is the first term in the definition and therefore it is part of the 5 terms to be added. For example: .. literalinclude:: ad_sum5-test.txt :language: python3 :start-after: --ini :end-before: --fi .. warning:: This function implementation **must** call the previous function as many times as needed. Doctests for validation are available at the :download:`ad_sum5-test.txt` file.