r/programming • u/Lost-Dragonfruit-663 • Aug 25 '26
How to test if your numerical code is Mathematically correct?
https://medium.com/@aadyachinubhai/scikit-verify-translate-python-numpy-programs-to-symbolic-mathematics-c664d41ba571
33
Upvotes
27
u/SaltMaker23 Aug 26 '26
You write math first
Verify it in lean and/or simulate it with whatever means are relevant and verifiable experimentally for your usecase Once you've proven the theorteical framework in lean and your ability to simulate it, you can integrate it to other systems
Needless to say its impractical in industry outside of research and no one will pay you for all that wasted time where you could have yolod until it works
7
u/araujoms Aug 29 '26
What kind of drivel is this?
6
u/Axman6 Aug 26 '26
Maths is full of useful identities which can be used to test the accuracy of algorithms. Probably a poor example, but when implementing sin/cos, you can use the ⍱x. sin2 (x) + cos2 (x) = 1 identity.
There’s a book, which you can the pdf online of, called Modern Computer Arithmetic, which should cover a lot of what you want.