Convergence of a Geometric Series ================================= A `Geometric Series `_ is a series summing the terms of an infinite *geometric sequence* in which the *ratio* of consecutive terms is constant. Thus, the *geometric sequence* is an infinite sequence that starts at an *initial term* and each following term is the result of multiplying the previous one by a fixed ratio. For example, if the initial term is :math:`1.0` and the ratio is :math:`2.0`, the resulting geometric sequence is :math:`1.0, 2.0, 4.0, 8.0, 16.0, ...` and the corresponding *geometric series* is the sum of all these terms is infinite. When the ratio belongs to the :math:`(-1.0, 1.0)` interval, the terms converge to :math:`0.0` and the geometric series is *convergence*, i.e. there is a value :math:`v` after summing the infinitely many terms. For example, if the initial term is :math:`1.0` and the ratio is :math:`1/2`, the resulting geometric sequence is :math:`1.0, 1/2, 1/4, 1/8, ...` and the corresponding *geometric series* is the sum of all these terms that converges to ``2.0``. Our purpose is to compute the *approximated convergence value* of a given geometric series by summing all the terms that are **not neglectible** according to a given tolerance value. A term is to be considered neglectible if its absolute value is smaller than the given tolerance. To that goal please implement the following Python function in the :mod:`gseries_conv` module (:file:`gseries_conv.py` file): .. py:function:: gseries_conv(t0, r, nd) such that **given** - ``t0``, :class:`float` such that ``t0 != 0.0`` - ``r``, :class:`float` such that ``-1.0 < r < 1.0`` - ``nd``, :class:`int` such that ``nd > 0`` **returns** - a :class:`float`, the convergence value (rounded to :math:`4` decimals) of the geometric series starting at ``t0`` with ratio ``r`` and :math:`1/10^d` tolerance. - an :class:`int`, the number of summed terms. For example: .. literalinclude:: gseries_conv.test :language: python3 :start-after: --ini :end-before: --fi They are available at the :download:`gseries_conv.test ` file. .. note:: - Observe that the tolerance is specified but giving the number of decimals. - Using the ``while`` statement is recommended. - The given doctests are not exhaustive.