{ "info": { "author": "Matja\u017e Gu\u0161tin", "author_email": "dev@matjaz.it", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Scientific/Engineering :: Mathematics" ], "description": "ContFrac\n===============================================================================\n\nContinued fractions are a representation of numbers expressed as recursive\nsums of integer parts and reciprocals of other numbers. _ContFrac_ is a\npure-Python3 lightweight module to compute and evaluate continued fractions,\nas well as using them to approximate any number. \n\n\nFeatures\n----------------------------------------\n\n- Supports conversion into continued fractions of `int`, `float`,\n `fractions.Fraction` and rational numbers expressed as tuples of 2 integers\n `(numerator, denominator)`, generated iteratively.\n- Computes the convergents of the same data types, generated iteratively.\n- Computes the value of a finite continued fraction.\n- Generates the arithmetical expression as string of a continued fraction.\n\n\nInstallation\n----------------------------------------\n\n```bash\npip install contfrac\n```\n\nor just include the `contfrac.py` file in your project (copy-paste).\n\n\nExample usage\n----------------------------------------\n\n```python\n>>> import contfrac\n>>> value = 415/93 # Express as (415, 93) to avoid rounding continued frac.\n>>> coefficients = list(contfrac.continued_fraction(value))\n>>> print(coefficients)\n[4, 2, 6, 7]\n\n>>> expression = contfrac.arithmetical_expr(coefficients)\n>>> print('Value: {:f} = {:s}'.format(value, expression))\nValue: 4.462366 = 4 + 1/(2 + 1/(6 + 1/(7)))\n\n>>> # The evaluation of a float value from a continued fraction is subject\n>>> # to floating point rounding errors\n>>> eval_value = contfrac.evaluate(coefficients)\n>>> print(eval_value, value) # Visible rounding errors\n4.46236559139785 4.462365591397849\n\n>>> convergents = list(contfrac.convergents(value))\n>>> print(convergents)\n[(4, 1), (9, 2), (58, 13), (415, 93)]\n\n>>> import math\n>>> coefficients = list(contfrac.continued_fraction(math.e, maxlen=10))\n>>> print(coefficients)\n[2, 1, 2, 1, 1, 4, 1, 1, 6, 1]\n\n>>> convergent = contfrac.convergent(math.e, 3) # Low convergent grade\n>>> print(convergent, convergent[0]/convergent[1], math.e)\n(11, 4) 2.75 2.718281828459045\n\n>>> convergent = contfrac.convergent(math.e, 7) # Higher grade = more accurate\n>>> print(convergent, convergent[0]/convergent[1], math.e)\n(193, 71) 2.7183098591549295 2.718281828459045\n```\n\n\nSimilar libraries\n----------------------------------------\n\n- [Continued](https://github.com/MostAwesomeDude/continued), also available\n through `pip` \n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/TheMatjaz/contfrac", "keywords": "continued,fraction,fractions,convergent,rational", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "ContFrac", "package_url": "https://pypi.org/project/ContFrac/", "platform": "", "project_url": "https://pypi.org/project/ContFrac/", "project_urls": { "Homepage": "https://github.com/TheMatjaz/contfrac" }, "release_url": "https://pypi.org/project/ContFrac/1.0.0/", "requires_dist": null, "requires_python": ">=3", "summary": "Continued fractions and convergents", "version": "1.0.0" }, "last_serial": 5138392, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "c42922eb0743603a9ac707e833212457", "sha256": "9522b06413115147618256dae6b21801320cb8d24a274da191f0e57154fb8781" }, "downloads": -1, "filename": "ContFrac-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "c42922eb0743603a9ac707e833212457", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 5781, "upload_time": "2019-04-13T15:24:21", "url": "https://files.pythonhosted.org/packages/67/78/805769b3db8e572bd0ba58f402dea4e2375aec4ec5bbd10e81df65674145/ContFrac-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "065cacb021f610c1f3c91e100ef42b16", "sha256": "e22296506f636ccb8da8142f41ca2dafe275e09b5bbd37df1c77b93e2675ee29" }, "downloads": -1, "filename": "ContFrac-1.0.0.tar.gz", "has_sig": false, "md5_digest": "065cacb021f610c1f3c91e100ef42b16", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 7404, "upload_time": "2019-04-13T15:24:24", "url": "https://files.pythonhosted.org/packages/d4/cf/cecbf51a968313ee6e7ed438005c348e91ad27747f189560e9ff7ba9d9d3/ContFrac-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c42922eb0743603a9ac707e833212457", "sha256": "9522b06413115147618256dae6b21801320cb8d24a274da191f0e57154fb8781" }, "downloads": -1, "filename": "ContFrac-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "c42922eb0743603a9ac707e833212457", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 5781, "upload_time": "2019-04-13T15:24:21", "url": "https://files.pythonhosted.org/packages/67/78/805769b3db8e572bd0ba58f402dea4e2375aec4ec5bbd10e81df65674145/ContFrac-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "065cacb021f610c1f3c91e100ef42b16", "sha256": "e22296506f636ccb8da8142f41ca2dafe275e09b5bbd37df1c77b93e2675ee29" }, "downloads": -1, "filename": "ContFrac-1.0.0.tar.gz", "has_sig": false, "md5_digest": "065cacb021f610c1f3c91e100ef42b16", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 7404, "upload_time": "2019-04-13T15:24:24", "url": "https://files.pythonhosted.org/packages/d4/cf/cecbf51a968313ee6e7ed438005c348e91ad27747f189560e9ff7ba9d9d3/ContFrac-1.0.0.tar.gz" } ] }