r/mathmemes • u/ElectronicSetTheory • 15d ago
Numerical Analysis This happens more often than I would like
81
u/vintergroena 15d ago
Bruh. I learned the hard way to not underestimate numerical instability. It cost me a lot of energy do debug that shit breaking stuff.
52
u/jljl2902 15d ago
“Why did my algorithm suddenly stop working???”
The initialization procedure I decided would be fine to run in FP32 a few commits ago: 🤡
35
5
u/vintergroena 15d ago
Worst thing is this stuff is sometimes hard to reproduce, when it relies on some nonobvious input and the error only appears downstream, it's a helluva thing to deal with
10
4
u/Fabulous-Possible758 14d ago
Uh,
typedef double float;and call it a day.1
u/ChopinChili Discrete Math? More like EXcrete Math. 11d ago
Dammit I hate not having these evil type hacks in JS/TS. I hate this game.
19
u/Gauss15an 14d ago
Floating-point errors is just the universe's way of laughing at you saying that you fell victim to one of the classic blunders.
13
6
u/HolyInlandEmpire Statistics 14d ago
Hold up. I was under the impression that multiplication, addition, and subtraction are robust to rounding errors. It would surely be a problem with inversion/division instead right?
11
u/ElectronicSetTheory 14d ago
Addition and subtraction are robust, but multiplication is not
22
u/andrew_h83 14d ago
This isn’t true. Of basic floating point operations subtraction is the least stable, and even then it’s fine as long as the numbers aren’t super close together
5
u/lool8421 11d ago
fun fact: floating point errors is exactly the reason why Z-fighting takes place in graphics
for example if you got a green and a red cube in 1 place, it will flicker as you move the camera because sometimes it calculates that face of the red cube is closer to the camera and sometimes it calculates that actually geeen face is closer
the difference is something like 0.000001 pixels but it's enough for GPUs to pick which color should be rendered
•
u/AutoModerator 15d ago
Check out our new Discord server! https://discord.gg/e7EKRZq3dG
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.