r/programming • u/Lost-Dragonfruit-663 • 7d ago
How to test if your numerical code is Mathematically correct?
https://medium.com/@aadyachinubhai/scikit-verify-translate-python-numpy-programs-to-symbolic-mathematics-c664d41ba571
34
Upvotes
8
u/araujoms 4d ago
For example, if an existing implementation is GPL licensed, you may be unable to inspect or reuse its source code;
What kind of drivel is this?
4
u/Axman6 6d ago
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.
28
u/SaltMaker23 7d ago
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