views:

132

answers:

4

Are there any libraries knocking around that provide any additional general purpose math functions for Javascript? Say things like sums over a range, derivatives, integrals, etc. I can imagine that many things aren't possible, so even libraries that do rough approximations would be interesting.

Thanks!

Update: As mentioned below, I guess that there aren't any libraries that do what I want to do. In that spirit, I have started on my own library called MathPlus.

+2  A: 

Yes, there is Sylvester, a JavaScript library designed to let you do mathematics with vectors and matrices without having to write lots of loops.

luvieere
Thanks, that's a cool library though I'm not looking to do vector math. Do you know anything that does sums, derivatives, etc like I mentioned in my question?
pr1001
+3  A: 

What are you looking for when you ask for integrals and derivatives? Numerical or symbolic? Indefinite or definite? Single-variable or multivariate? Etc.

It's actually not hard to write a program to do symbolic differentiation, though simplification and display is far from simple (contrary, perhaps, to intuition). Similarly, numerical differentiation and numerical definite integration is simple enough, depending on how much precision you need. (If you need a little it's easy; if you need a fair bit and are doing many operations, you need some serious numerical analysis (math) to make it work; if you need lots of precision you need a bignum library so JS isn't that great.)

'Of course' symbolic integration is extremely difficult in any language. Your best bet in that case would be to query a site like Wolfram|alpha...

If you need clarification or expansion on any of these points, let me know.

Charles
I'm interested in numerical solutions with 'reasonable' precision. Unsurprisingly since I'm looking to use Javascript, my primary interest is visualization within the browser, not scientific calculations (though that'd be cool too!). Specifically, I'm interested in interpolation (e.g. Kriging: http://en.wikipedia.org/wiki/Kriging).
pr1001
A: 

With thanks to Charles and luvieere for their responses, I guess that there aren't any libraries that do what I want to do. In that spirit, I have started on my own library called MathPlus.

pr1001
+1  A: 

I know this is an old question, but it's worth noting that some people have been doing automated conversions of physics libraries over from ActionScript to JS (using eg. Python for the parsing). I'm not saying it's an easy task, but it has to be easier than writing your own math libraries from scratch, so I guess this may be a possibility for some.

Nick Wiggill
Such as? I've developed my MathPlus library a bit, actually adding the vectors and matrices I said I wasn't interested. I've also discovered M8: http://github.com/Kambfhase/m8
pr1001
Box2d. There were others but they've slipped my mind for now. Actually a number of people have done it independently for box2d. If it works for code like that, it's possible for sure.
Nick Wiggill
Cool, thanks, box2Djs looks nice.
pr1001