{"id":21053233,"url":"https://github.com/sqrtneginf/feigenbaum","last_synced_at":"2026-04-09T21:14:58.555Z","repository":{"id":107338635,"uuid":"132804910","full_name":"SqrtNegInf/Feigenbaum","owner":"SqrtNegInf","description":"Obsessing over tiny floating point bug","archived":false,"fork":false,"pushed_at":"2019-04-20T16:12:04.000Z","size":11,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-20T18:44:52.422Z","etag":null,"topics":["fortran","glibc","java","perl","perl6","python"],"latest_commit_sha":null,"homepage":"","language":"Perl 6","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SqrtNegInf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-05-09T19:41:41.000Z","updated_at":"2019-04-20T16:12:05.000Z","dependencies_parsed_at":"2023-04-09T05:32:22.234Z","dependency_job_id":null,"html_url":"https://github.com/SqrtNegInf/Feigenbaum","commit_stats":{"total_commits":17,"total_committers":1,"mean_commits":17.0,"dds":0.0,"last_synced_commit":"9623d43520142b44d67d6823855e734d9e8da87d"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SqrtNegInf%2FFeigenbaum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SqrtNegInf%2FFeigenbaum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SqrtNegInf%2FFeigenbaum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SqrtNegInf%2FFeigenbaum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SqrtNegInf","download_url":"https://codeload.github.com/SqrtNegInf/Feigenbaum/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243497378,"owners_count":20300241,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["fortran","glibc","java","perl","perl6","python"],"created_at":"2024-11-19T16:05:12.233Z","updated_at":"2026-04-09T21:14:58.509Z","avatar_url":"https://github.com/SqrtNegInf.png","language":"Perl 6","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Feigenbaum constant calculation reveals a F.P. bug\n\nThis task was added to RosettaCode\n(http://rosettacode.org/wiki/Feigenbaum_constant_calculation) recently, and\nwhile the code itself is pretty mundane, it revealed a floating point bug.\n\n## The Bug\n\nThe bug is this: for certain floating point values results from 'X × X'\ndiffer from 'X²'. More generally, the answers from the underlying 'power'\noperation can differ from repeated multiplication. This does not jibe with\nwhat I learned in middle school...\n\nSince the Feigenbaum constant calculation is iterative, errors accumulate and \nthe results diverge.\n\n## Bug Hunt\n\nThe bug is present in all these languages:\n\n* C\n* Perl \n* Perl6 (MoarVM)\n* Python\n\nBut not in these:\n\n* Fortran \n* Java\n* Perl6 (JVM)\n* Perl (with Math-GSL)\n\nWhat's the difference? It seems like the languages in the first group use\nthe libc/glibc system/math libraries, while those in the second roll their\nown (correct me if I'm wrong).\n\nBut then it's hard to explain the Sidef results:\n\n* not buggy, despite being built on top of Perl\n* converges more closely to the OEIS limit value than any other code\n\nFiles in this repository are my attempt to reveal the extent of the\nproblem.  Run them on your favorite OS and see what you get.\n\n## Scope\n\nI found the bug to be present in recent versions of OS X, from at least El\nCapitan (10.11) onwards, and it is still there is the latest release.  Snow\nLeopard (10.6.8) pre-dates the bug.\n\nI did **not** find it in Linux, nor in Perl/Cygwin (for Windows 7).\n\n## The Actual Answer is...\n\nThe actual Feigenbaum constant calculation (as per https://oeis.org/A006890) starts off:\n\nδ = 4.6692016091029906 \n\nFORTRAN and Sidef both give 4.6692016062 after 15 iterations, the closest approximation. \nAdditionally, futher iterations remain near this value, but other programs seem to mostly\ndiverge, if iterations are continued.  Turns out, stopping at 15 is a sweet spot before \nthe values being moving farther away from the true answer.\n\n## Moral of the Story\n\nWorking with floating point is like having a pet tiger. Can be interesting,\nbut you can never let your guard down.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqrtneginf%2Ffeigenbaum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsqrtneginf%2Ffeigenbaum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqrtneginf%2Ffeigenbaum/lists"}