Slight rounding errors in constants
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 839
- Forks
- 220
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 14
Description
In constants.hpp, I noticed there are some constants that get a small unnecessary rounding error due to how they are defined.
For example, with 64bit precision floating point, we have:
LOG_TWO_PI = LOG_TWO + LOG_PI = 0.6931471805599453 + 1.1447298858494002 =
1.8378770664093453
However, a mathematically more precise value is $\log(2\pi) \approx 1.83787706640934548356065947281123527972279494727556682563430308096553139185$
This is better rounded to the 64bit value
1.8378770664093456
which means the current value has an unnecessary error in the order of E-16.
I guess there could be a similar type of issue for other constants as well.
I suppose this is pretty much negligible for any practical purpose and perhaps one may argue the current implementation is better readable. But my OCD is kinda forcing me to point this out haha
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in constants.hpp by reviewing LOG_TWO_PI and nearby constants for values formed from rounded components. Check which constants differ from their more precisely rounded 64-bit values and define the scope of the correction. Done means the identified constants use the better-rounded values without changing unrelated definitions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100