Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Algebrite, a computer algebra system in JavaScript (algebrite.org)
140 points by davidedc on April 8, 2016 | hide | past | favorite | 30 comments


Very neat! Would you consider adding a TeX() function to format the output strings into LaTeX? This functionality is very useful for someone who needs to present their results.

I'm doing some coursework for my MSc in math, and have taken to using CASs (Maxima, and Yacas via RYacas) to explore/validate my assignment questions/answers. The automatic TeX formatting in those systems has been an essential feature.


Separate Latex libraries already exist, why not simply extend one of those?


There is also a comprehensive mathematical library for JS called math.js [1]. It has no dependencies, supports powerful symbolic computation, as well as many mathematical functions. It implements a useful subset of what one expects a CAS to be able to do.

[1] http://mathjs.org/


I like Math.js a lot. It is (mostly) a numerical library though (apart from units of measurement and the ability to define functions). I'd challenge that it supports "powerful symbolic computation": CAS traditionally solve equations for example, manipulate polynomials, simplify expressions, add/multiply polynomials/vectors/matrices having elements expressed in symbols rather than having values, that sort of things.


I would be interested seeing this coupled with a NLP library and a graphing library if this could be used to make a wolfram-like clone.


There needs to be a javascript flavor/js based language that allows operator overloading...so that there can be something like numpy in javascript. I love js's semantics much more than python's so it'd be great to do quick and dirty numeric stuff in js.


There is: https://kotlinlang.org/docs/reference/operator-overloading.h...

(Kotlin compiles to js or jvm byte code)



It is possible to overload operators in JS through a horrible hack of valueOf():

http://webcache.googleusercontent.com/search?q=cache:DKKZb1P...

Discussion: https://news.ycombinator.com/item?id=8677721


Aren't all numbers in javascript double precision.


There is a boxed 32-bit signed integer type in JavaScript, which can be instantiated by postfixing `| 0` to a number literal or variable of type number. You can also then convert numbers to an unsigned 32-bit integer by postfixing `>>>0`.

But yeah, for normal numeric operations, the default `number` double-precision is default.

That said, typed arrays of all the common types (u8,u16,u32 and their signed analogues) now exist in JS and are very important for performance reasons, particularly with WebGL and Emscripten.

You can also use typed arrays to get a single integer of the type you desire. For example, to convert a -1 to a signed integer, try this in your console:

    (new Uint32Array([-1]))[0]
You can then compare the result to what I mention above:

    -1>>>0
And this one gives what you would expect:

     var i = (new Uint8Array([-1]))[0]
     console.log(i)


You're right, but I guess you're being downvoted because nobody wants to hear it. JavaScript will never get anything like numpy, because it doesn't have integers. Doing mathematics without integers is like driving a car without wheels.



That is a pretty bold statement.

Combine typed arrays with BLAS and you have yourself a numpy (well, kind of). In Node you can move performance-critical code to C++, which does have integers. Browser support of typed arrays is a bit disappointing, but it's getting better.

Disclaimer: I'm developing https://github.com/mateogianolio/vectorious


(I didn't downvote you.) Yes, but it does not make operator overloading any less useful. In fact, I'd argue the opposite. In a language with only doubles you can use overloaded operators not just for matrices, complex numbers, rationals, etc., but to make it relatively painless to work with your own implementation of integers.


That's very cool.

The API seems fairly similar to SymPy. It would be great to have a CAS that can perform simple operations in the browser, and ship more complicated things to a SymPy backend (or another CAS).

http://live.sympy.org/ is great, but do we really need to call the backend for everything?


beat me to it, I develop www.jasymchat.com which is based on Jasymca (http://webuser.hs-furtwangen.de/~dersch/)..I was thinking of porting Jasymca to a Javascript.


I'd love for someone to try and put this into real hardware.

Computers have advanced but calculators haven't.

Calculators are only focused on school kids, not on people who really need to get things done.

I'd love to have octave or scipy on a piece of dedicated hardware.


A Mathematica style program for tablets that could convert handwritten math using common notation into symbolic constructs would be absolutely amazing.



Doesn't Windows do this? Last time I tried it it was amazingly accurate.


Awesome!

Not knowing much about how a CAS is implemented, I'm curious -- what is it that causes the integration demo to take so much longer than the other examples? Does it have to do some kind of search to find the correct sequence of manipulations?


I'm not sure what method this system uses for definite integration, but it is likely one of Simpsons, Gaussian, and Clenshaw-Curtis. These are numerical methods that, for the best accuracy, require lots of steps of evaluation. Depending on the error bounds you want, it could take a while.

Edit: also the nonlinear square root term may cause difficulty.

People might find this interesting: Maple uses Clenshaw Curtis as the default, but will switch dynamically to Gaussian if singularities are detected.


This would be relevant to numerical integration.

However, as it gives as answer some multiple of pi, it must've performed symbolic integration, which also suits the general design of the library better. There are some methods for performing symbolic integration but often trial and error with lookup tables and tricks (substitution etc) is faster.


Yeah, actually using the Risch algorithm is usually a last resort in a lot of CAS' because it's fairly intensive and also will often produce answers in a form very different from what a human would give. It's also famously difficult to implement, so if this library is using it without a thick layer of tricks and heuristics then that's probably where the slowness comes from.


The one that takes the longest is a double integral. That's the volume under a surface rather than the area under a curve. Frankly I don't know if that's any sort of explanation...


Sorta offtopic, but the logo reminds me of http://ich.deanmcnamee.com/pre3d/ , except that one has the cute behavior when you move the mouse.


Close! Your link has the tetrakis cuboctahedron, while TFA has the pentakis dodecahedron. The spinning on mouse is really cool; all logos ought to have that.


The "pentakis dodecahedron" logo is by Felix Koutchinski (as said in credits/links)


This is admittedly a nitpick, but, seriously people: there are no good reasons (although plenty of bad ones) to continue using CoffeeScript. Just write ES6†.

† ES2015 for the super-pedants :-)




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: