Skip to content

Commit

Permalink
docs: some more tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sr-murthy committed Mar 13, 2024
1 parent cc751da commit f2e4a92
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
11 changes: 5 additions & 6 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
continuedfractions
==================

A simple extension of the Python `fractions <https://docs.python.org/3/library/fractions.html>`_ standard library for working with `continued fractions <https://en.wikipedia.org/wiki/Continued_fraction>`_ as Python objects.
A simple extension of the Python :py:mod:`fractions` standard library for working with `continued fractions <https://en.wikipedia.org/wiki/Continued_fraction>`_ as Python objects.

The ``continuedfractions`` package is designed to:

- make it easy to construct continued fractions as Python objects
- explore their key properties, such as elements/coefficients,
convergents, segments, remainders
- operate on them as rationals and instances of the standard library
`fractions.Fraction <https://docs.python.org/3/library/fractions.html#fractions.Fraction>`_
class
- explore their key continued fractions properties, such as elements/coefficients,
convergents, remainders, and other numerical properties etc.
- operate on them fully as rational numbers and instances of the standard library
:py:class:`fractions.Fraction` class

Prelude
-------
Expand Down
4 changes: 3 additions & 1 deletion docs/sources/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Contributing
============

The project homepage is on `GitHub <https://github.com/sr-murthy/continuedfractions>`_.

Contributors and contributions are welcome via pull requests from a fork targeting the parent ``main`` `branch <https://github.com/sr-murthy/continuedfractions/tree/main>`_.

A simple Git workflow, using a feature and/or fix branch created off the ``main`` branch of your fork, is recommended.
Expand Down Expand Up @@ -90,7 +92,7 @@ The CI/CD pipelines are defined in the `CI YML <.github/workflows/ci.yml>`_, and
Versioning and Releases
=======================

The package is currently at version ``0.11.7`` - `semantic versioning <https://semver.org/>`_ is used.
The package is currently at version ``0.11.8`` - `semantic versioning <https://semver.org/>`_ is used.

There is currently no dedicated pipeline for releases - both `GitHub releases <https://github.com/sr-murthy/continuedfractions/releases>`_ and `PyPI packages <https://pypi.org/project/continuedfractions>`_ are published manually, but both have the same version tag.

Expand Down
6 changes: 3 additions & 3 deletions docs/sources/creating-continued-fractions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Then we can iteratively construct more accurate :py:class:`~continuedfractions.c
...
With the first 10 elements of the complete sequence of elements of the continued fraction representation of :math:`\sqrt{2}` we have obtained an approximation that is accurate to :math:`6` decimal places. We'd ideally like to have as few elements as possible in our :py:class:`~continuedfractions.continuedfraction.ContinuedFraction` approximation of :math:`\sqrt{2}` for a desired level of accuracy, but this partly depends on how fast the partial, finite continued fractions represented by the chosen sequences of elements in our approximations are converging to the true value of :math:`\sqrt{2}` - these partial, finite continued fractions in a continued fraction representation are called convergents, and will be discussed in more detail later on.
With the first 10 elements of the complete sequence of elements of the continued fraction representation of :math:`\sqrt{2}` we have obtained an approximation that is accurate to :math:`6` decimal places in the fractional part. We'd ideally like to have as few elements as possible in our :py:class:`~continuedfractions.continuedfraction.ContinuedFraction` approximation of :math:`\sqrt{2}` for a desired level of accuracy, but this partly depends on how fast the partial, finite continued fractions represented by the chosen sequences of elements in our approximations are converging to the true value of :math:`\sqrt{2}` - these partial, finite continued fractions in a continued fraction representation are called convergents, and will be discussed in more detail later on.

If we use the first 101 elements (the leading 1, plus a tail of 100 2s) we get more accurate results:

Expand All @@ -179,7 +179,7 @@ If we use the first 101 elements (the leading 1, plus a tail of 100 2s) we get m
>>> sqrt2_100 = ContinuedFraction.from_elements(1, *[2] * 100)
ContinuedFraction(228725309250740208744750893347264645481, 161733217200188571081311986634082331709)
>>> sqrt2_100.elements
# -> (1, 2, 2, 2, ..., 2)
# -> (1, 2, 2, 2, ..., 2) where there are `100` 2s after the `1`
>>> sqrt2_100.as_decimal()
Decimal('1.414213562373095048801688724')
Expand Down Expand Up @@ -262,7 +262,7 @@ A number of examples are given below of validation passes and fails.
.. _creating-continued-fractions.negative-continued-fractions:

“Negative” Continued Fractions
------------------------------
==============================

Continued fractions representations for negative numbers are valid, provided we use `Euclidean integer division <https://en.wikipedia.org/wiki/Continued_fraction#Calculating_continued_fraction_representations>`_ to calculate the elements of the representation, by starting with the integer part of the number, and then calculating the remaining elements for the fractional part with the successive quotients and remainders obtained in each division step. For example, :math:`\frac{-415}{93} = \frac{-5 \times 93 + 50}{93}` has the continued fraction representation :math:`[-5; 1, 1, 6, 7]`:

Expand Down
2 changes: 1 addition & 1 deletion docs/sources/exploring-continued-fractions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ The segments of :py:class:`~continuedfractions.continuedfraction.ContinuedFracti
**Note**: Unlike the :math:`k`-order convergents the segments are :py:class:`~continuedfractions.continuedfraction.ContinuedFraction` objects, and can be used as a proxy for the convergents.

A related concept is that of **remainders** of continued fractions, which are (possibly infinite) subsequences of elements of a given continued fraction, starting from a given element, usually the leading element :math:`a_0`. More precisely, we can define the :math:`k`-th remainder :math:`R_k` of a continued fraction :math:`[a_0; a_1,\ldots]` as the continued fraction :math:`[a_k;a_{k + 1},\ldots]`, obtained by "removing" the elements of the :math:`(k - 1)`-st segment :math:`S_{k - 1} = (a_0,a_1,\ldots,a_{k - 1})` from :math:`[a_0; a_1,\ldots]`.
A related concept is that of **remainders** of continued fractions, which are (possibly infinite) subsequences of elements of a given continued fraction, starting from a given element. Generally, we can define the :math:`k`-th remainder :math:`R_k` of a continued fraction :math:`[a_0; a_1,\ldots]` as the continued fraction :math:`[a_k;a_{k + 1},\ldots]`, obtained by "removing" the elements of the :math:`(k - 1)`-st segment :math:`S_{k - 1} = (a_0,a_1,\ldots,a_{k - 1})` from :math:`[a_0; a_1,\ldots]`.

.. math::
Expand Down
10 changes: 5 additions & 5 deletions docs/sources/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Getting Started
===============

The package uses only Python standard libraries, and is supported on Python versions ``3.10``-``3.12``. It is CI-tested on Ubuntu Linux (22.04.3 LTS), Mac OS (12.7.3) and Windows (Windows Server 2022), but should also install on any other platform supporting these Python versions.
This is a `PyPI package <https://pypi.org/project/continuedfractions/>`_ which uses only Python standard libraries, and is supported on Python versions ``3.10``-``3.12``. It is CI-tested on Ubuntu Linux (22.04.3 LTS), Mac OS (12.7.3) and Windows (Windows Server 2022), but should also install on any other platform supporting these Python versions.

.. _getting-started.installation:

Expand Down Expand Up @@ -34,10 +34,10 @@ Package Structure

This is a library of standalone functions, which are summarised below.

- :py:meth:`~continuedfractions.lib.continued_fraction_rational` - generates the (ordered) sequence of elements (coefficients) of a finite, simple continued fraction representation of a given rational number, given as a :py:class:`fractions.Fraction` object. The representation will be unique if the given number is a rational number with an exact binary fractional representation, otherwise it will be approximate.
- :py:meth:`~continuedfractions.lib.continued_fraction_real` - generates the sequence of elements of a finite, simple, continued fraction representation of a real number, given as a single :py:class:`int`, :py:class:`float`, :py:class:`fractions.Fraction`, :py:class:`decimal.Decimal` object, or a pair of integers and/or :py:class:`fractions.Fraction` objects representing the numerator and non-zero denominator, respectively, of the number. The resulting continued fraction representation will be exact for any rational number and which has an exact representation as a binary fraction, otherwise, it will only be approximate. The latter limitation will be addressed in future versions.
- :py:meth:`~continuedfractions.lib.convergent` - returns the ``k``-th convergent (for a positive integer :math:`k`) of a (finite) simple continued fraction representation of a number, from a sequence of its elements; the convergent is returned as a :py:class:`fractions.Fraction` object
- :py:meth:`~continuedfractions.lib.mediant` - returns the ``k``-th left or right mediant of two rational numbers, given as :py:class:`fractions.Fraction` objects
- :py:meth:`~continuedfractions.lib.continued_fraction_rational` - generates the (ordered) sequence of elements (coefficients) of a finite, simple continued fraction representation of a given rational number, given as a :py:class:`fractions.Fraction` object.
- :py:meth:`~continuedfractions.lib.continued_fraction_real` - generates the sequence of elements of a finite, simple, continued fraction representation of a real number, given as a single :py:class:`int`, :py:class:`float`, :py:class:`fractions.Fraction`, :py:class:`decimal.Decimal` object, or an :py:class:`int` pair and/or :py:class:`fractions.Fraction` pair, representing the numerator and non-zero denominator, respectively, of the number.
- :py:meth:`~continuedfractions.lib.convergent` - returns the ``k``-th convergent (for a positive integer :math:`k`) of a (finite) simple continued fraction representation of a number, from a sequence of its elements; the convergent is returned as a :py:class:`fractions.Fraction` object.
- :py:meth:`~continuedfractions.lib.mediant` - returns the ``k``-th left or right mediant of two rational numbers, given as :py:class:`fractions.Fraction` objects; the mediant is returned as a :py:class:`fractions.Fraction` object.

.. _getting-started.package-structure.continuedfractions_continuedfraction:

Expand Down
2 changes: 1 addition & 1 deletion src/continuedfractions/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.11.7"
__version__ = "0.11.8"

0 comments on commit f2e4a92

Please sign in to comment.