Friday, December 26, 2008

Symbolic math

Posted by Danny Tarlow
I've been playing around with sympy, a symbolic math library for Python: http://docs.sympy.org/index.html A lot of work I do involves writing down hairy likelihood functions, taking the partial derivatives, and solving for some update that increases the likelihood. Up until now, I've always done the calculus and algebra by hand. I'm wondering now why I put myself through the tedium. I was never one to use a TI-89 back in high school calculus, but at least then I could justify it to myself by saying I was learning more. But now, sympy seems like it has all the answers. It even has a print feature that will export directly to latex. Is there any downside?

3 comments:

Joseph Turian said...

You should check out Theano. It can do automatic differentation in Python, and optimizes and compiles functions to C. We developed it at the LISA Labo at the University of Montreal (Yoshua Bengio's lab).

Danny Tarlow said...

This looks like a great complement to sympy. One of the shortcomings I've found in sympy is in handling array operations (like large summations needed in machine learning), and (if I'm reading correctly) this appears to be Theano's strength?

Have you ever considered combining it with sympy?

Either way, it sounds very useful. Thanks for the pointer!

A 1-In-100 Blogger said...

I always thought you had a TI-89 (or better) manually installed into your brain at birth. That must have been why, in my mind, you never needed to use a calculator in high school.

If I remember correctly, your calculus teacher was sick one day, but rather than hire a substitute teacher, didn't he just have you teaching the class - a class that you were taking to "learn" math?

It's sort of like you already know the information you're "learning," but because you're a team player and don't want to jump through loops, you go through the motions of re-learning it anyway. I'm guessing you do it just to get other people to think you're really human, or something like that. Yeah, that's it... yep, the smartest guy I've ever known, Danny Tarlow!