Sympy and symbolic differentiation

I am currently porting a code from mathematica to python. As is commonly known, code which is a few tens of lines in a higher level language becomes twice or thrice that in a lower level language. While there are convenience functions in mathematica and python for almost everything imaginable and needed by a student/physicist (except for a theta function!), the one thing that sets mathematica apart from everything else is it's ability to do symbolic math. The fact that the language was built around this (is it?) probably lends to this but nevertheless, it's one of the things that I'm having the toughest time reimplementing in python. I've been working with sympy, picking up the pieces along the way but I've hit a roadblock for the time being. I'm not able to differentiate an expression that contains a theta function! I'll prolly have to rewrite the expressions so that it'd be easier to work in python i.e do sym diff.

The other interesting thing that I've come across is the use of lambda in defining functions. Other than making the code look cleaner and more understandable, it's cleared up a couple of errors I have having in the earlier case, when i was using def to define functions. I am yet to grasp the full power of this but let's see where this takes me.

But in all honesty, implementation based on an algorithm > reimplement based on a code in another language > rewrite other people's code to make things work!

Popular posts from this blog

Animation using GNUPlot

Pandas download statistics, PyPI and Google BigQuery - Daily downloads and downloads by latest version

Adaptive step size Runge-Kutta method