Re:Show HN: Advanced Mathematics Library for Node.js and Jav...
by Osmium on Tuesday December 11, 2012 @04:01PM
(#4906786)
Thanks, that's really interesting! I'll check it out next time. Do you see any advantage with this over, e.g., Python w/NumPy?
Re:Show HN: Advanced Mathematics Library for Node.js and Jav...
by Xcelerate on Tuesday December 11, 2012 @04:08PM
(#4906825)
I can't really comment on that actually. For some reason, of all the programming languages I know, I never bothered to learn Python. If you need to make sure your results are 100% accurate then I would recommend a library that has been designed and tested by others, so NumPy would probably be better than creating your own routines. I do really like the clean syntax and support for functional(-ish) programming that CoffeeScript provides though.
This is how easy that is:
(Note: it appears the horizontal scroll bar for this code is hidden by default for OS X browsers.)
This code just takes in a list of coordinates and performs a linear plane regression on them to return the normal vector of the plane. Then if I want the vertical distance between two planes of atoms (these are circular planes that kind of wobble around), then it's just: I left out some details, but you can get the gist of it.