{"id":20500263,"url":"https://github.com/ohno/roughlyrational.jl","last_synced_at":"2026-03-06T08:32:35.521Z","repository":{"id":156627800,"uuid":"562155210","full_name":"ohno/RoughlyRational.jl","owner":"ohno","description":null,"archived":false,"fork":false,"pushed_at":"2022-11-07T03:51:11.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-05T19:35:31.994Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ohno.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-05T13:33:16.000Z","updated_at":"2022-11-05T13:33:28.000Z","dependencies_parsed_at":"2024-07-30T17:21:52.659Z","dependency_job_id":null,"html_url":"https://github.com/ohno/RoughlyRational.jl","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ohno/RoughlyRational.jl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohno%2FRoughlyRational.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohno%2FRoughlyRational.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohno%2FRoughlyRational.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohno%2FRoughlyRational.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ohno","download_url":"https://codeload.github.com/ohno/RoughlyRational.jl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohno%2FRoughlyRational.jl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30167962,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T07:56:45.623Z","status":"ssl_error","status_checked_at":"2026-03-06T07:55:55.621Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T18:20:20.621Z","updated_at":"2026-03-06T08:32:35.493Z","avatar_url":"https://github.com/ohno.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RoughlyRational.jl\n\n[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://ohno.github.io/RoughlyRational.jl/stable/)\n[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://ohno.github.io/RoughlyRational.jl/dev/)\n[![Build Status](https://travis-ci.com/ohno/RoughlyRational.jl.svg?branch=main)](https://travis-ci.com/ohno/RoughlyRational.jl)\n[![Coverage](https://codecov.io/gh/ohno/RoughlyRational.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ohno/RoughlyRational.jl)\n[![Coverage](https://coveralls.io/repos/github/ohno/RoughlyRational.jl/badge.svg?branch=main)](https://coveralls.io/github/ohno/RoughlyRational.jl?branch=main)\n\n\n## Installation\n\nFor the first time only, run the following code in your Jupyter Notebook:\n\n```julia\nusing Pkg\nPkg.add(path=\"https://github.com/ohno/RoughlyRational.jl\")\n```\n\nor use `add` upon Pkg REPL:\n\n```julia\n]\nadd https://github.com/ohno/RoughlyRational.jl\n```\n\n## Usage\n\nTo use this package, run the following code in your Jupyter Notebook or code:\n\n```julia\nusing RoughlyRational\n```\n\n`maybeinteger(x)` and `RoughlyRational(x)` are available.\n\n\n## Examples\n\n`maybeinteger(x)` can determine whether `x` is an integer or not, more roughly than `isinteger(x)`:\n\n```julia\njulia\u003e x = sin(2π)\n-2.4492935982947064e-16\n\njulia\u003e isinteger(x)\nfalse\n\njulia\u003e maybeinteger(x)\ntrue\n```\n\n`roughlyRational` can convert `x` to a rational number more roughly than `Rational(x)`:\n\n```julia\njulia\u003e Rational(0.499999)\n9007181240342483//18014398509481984\n\njulia\u003e roughlyRational(0.499999)\n1//2\n```\n\nSeveral packages allow to display Legendre polynomials:\n\n```julia\n# using Pkg\n# Pkg.add(\"SpecialPolynomials\")\n# Pkg.add(\"Polynomials\")\n# Pkg.add(path=\"https://github.com/ohno/RoughlyRational.jl\")\n# Pkg.add(\"SimplePolynomials\")\n# Pkg.add(\"LaTeXStrings\")\n# Pkg.add(\"Latexify\")\nusing SpecialPolynomials\nusing Polynomials\nusing RoughlyRational\nusing SimplePolynomials\nusing LaTeXStrings\nusing Latexify\n\nfor n in 0:15\n    p = basis(Legendre, n)\n    q = convert(Polynomial, p)\n    r = roughlyRational.(q.coeffs)\n    s = SimplePolynomial(r...)\n    latexstring(\"P_{$n}(x) = \", latexify(\"$s\", env=:raw, cdot=false)) |\u003e display\nend\n```\n\n```math\n\\begin{align}\nP_{0}(x) \u0026= 1 \\\\\nP_{1}(x) \u0026= x \\\\\nP_{2}(x) \u0026= \\frac{-1}{2} + \\frac{3}{2} x^{2} \\\\\nP_{3}(x) \u0026= \\frac{-3}{2} x + \\frac{5}{2} x^{3} \\\\\nP_{4}(x) \u0026= \\frac{3}{8} - \\frac{15}{4} x^{2} + \\frac{35}{8} x^{4} \\\\\nP_{5}(x) \u0026= \\frac{15}{8} x - \\frac{35}{4} x^{3} + \\frac{63}{8} x^{5} \\\\\nP_{6}(x) \u0026= \\frac{-5}{16} + \\frac{105}{16} x^{2} - \\frac{315}{16} x^{4} + \\frac{231}{16} x^{6} \\\\\nP_{7}(x) \u0026= \\frac{-35}{16} x + \\frac{315}{16} x^{3} - \\frac{693}{16} x^{5} + \\frac{429}{16} x^{7} \\\\\nP_{8}(x) \u0026= \\frac{35}{128} - \\frac{315}{32} x^{2} + \\frac{3465}{64} x^{4} - \\frac{3003}{32} x^{6} + \\frac{6435}{128} x^{8} \\\\\nP_{9}(x) \u0026= \\frac{315}{128} x - \\frac{1155}{32} x^{3} + \\frac{9009}{64} x^{5} - \\frac{6435}{32} x^{7} + \\frac{12155}{128} x^{9} \\\\\n\u0026\\vdots\n\\end{align}\n```\n\n`Rational(Float32(x))` replaces `roughlyRational(x)` but has an error:\n\n```julia\n# using SpecialPolynomials\n# using Polynomials\n# using Latexify\n# using LaTeXStrings\nfor n in 4:4\n    for k in 0:1\n        # derivative of the Laguerre polynomials\n        p = basis(Laguerre{0}, n)\n        p = convert(Polynomial, p)\n        p = derivative(p,k)\n        p = Rational.(Float32.(p.coeffs))\n        p = SimplePolynomial(p...)\n        latexstring(\"L_n^k(x) = \", latexify(\"p\", env=:raw, cdot=false)) |\u003e display\n        # Conversion from generalized Laguerre polynomials\n        p = basis(Laguerre{k}, n-k)\n        p = convert(Polynomial, p) * (-1)^k\n        p = Rational.(Float32.(p.coeffs))\n        p = SimplePolynomial(p...)\n        latexstring(\"L_n^k(x) = \", latexify(\"p\", env=:raw, cdot=false)) |\u003e display\n    end\nend\n```\n\n```math\n\\begin{align}\nL_4^0(x) \u0026= \\frac{1}{1} - \\frac{4}{1} x + \\frac{3}{1} x^{2} - \\frac{11184811}{16777216} x^{3} + \\frac{11184811}{268435456} x^{4} \\\\\nL_4^0(x) \u0026= \\frac{1}{1} - \\frac{4}{1} x + \\frac{3}{1} x^{2} - \\frac{11184811}{16777216} x^{3} + \\frac{11184811}{268435456} x^{4} \\\\\nL_4^1(x) \u0026= \\frac{-4}{1} + \\frac{6}{1} x - \\frac{2}{1} x^{2} + \\frac{11184811}{67108864} x^{3} \\\\\nL_4^1(x) \u0026= \\frac{-4}{1} + \\frac{6}{1} x - \\frac{2}{1} x^{2} + \\frac{11184811}{67108864} x^{3} \\\\\n\u0026\\vdots\n\\end{align}\n```\n\n`roughlyRational(x)` solves this problem.\n\n```julia\n# using SpecialPolynomials\n# using Polynomials\n# using Latexify\n# using LaTeXStrings\nfor n in 4:4\n    for k in 0:1\n        # derivative of the Laguerre polynomials\n        p = basis(Laguerre{0}, n)\n        p = convert(Polynomial, p)\n        p = derivative(p,k)\n        p = roughlyRational.(p.coeffs)\n        p = SimplePolynomial(p...)\n        latexstring(\"L_n^k(x) = \", latexify(\"p\", env=:raw, cdot=false)) |\u003e display\n        # Conversion from generalized Laguerre polynomials\n        p = basis(Laguerre{k}, n-k)\n        p = convert(Polynomial, p) * (-1)^k\n        p = roughlyRational.(p.coeffs)\n        p = SimplePolynomial(p...)\n        latexstring(\"L_n^k(x) = \", latexify(\"p\", env=:raw, cdot=false)) |\u003e display\n    end\nend\n```\n\n\n```math\n\\begin{align}\nL_4^0(x) \u0026= \\frac{1}{1} - \\frac{4}{1} x + \\frac{3}{1} x^{2} - \\frac{2}{3} x^{3} + \\frac{1}{24} x^{4} \\\\\nL_4^0(x) \u0026= \\frac{1}{1} - \\frac{4}{1} x + \\frac{3}{1} x^{2} - \\frac{2}{3} x^{3} + \\frac{1}{24} x^{4} \\\\\nL_4^1(x) \u0026= \\frac{-4}{1} + \\frac{6}{1} x - \\frac{2}{1} x^{2} + \\frac{1}{6} x^{3} \\\\\nL_4^1(x) \u0026= \\frac{-4}{1} + \\frac{6}{1} x - \\frac{2}{1} x^{2} + \\frac{1}{6} x^{3} \\\\\n\u0026\\vdots\n\\end{align}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fohno%2Froughlyrational.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fohno%2Froughlyrational.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fohno%2Froughlyrational.jl/lists"}