What are some alternatives to Python library SymPy implemented in Julia?
There is a wrapper:
Is there no native Julia equivalent?
There are, but I don’t know if they are equivalent. E.g.:
https://github.com/jlapeyre/Symata.jl
https://github.com/chakravala/Reduce.jl
Symata.jl
actually relies a lot on sympy for its rewriting and Reduce.jl
is a wrapper around REDUCE
, which is mainly written in Lisp. The closest in pure Julia would most likely be ModelingToolkit.jl, which mainly focuses on rewriting and calculating symbolic derivatives and builds on SymbolicUtils.jl, so it should already be quite fast. That said, it’s still far from feature complete compared to sympy, so I definitely wouldn’t call it a sympy equivalent yet.
I always had an impression that SymPy is so popular in Python world only because Python doesn’t support symbols and expressions as first-class citizens. Julia does. And since symbolic programming is built-in into the language, people tend to create packages for more specific tasks. For example, there are libraries for expression rewriting and simplification (1, 2), calculus (3), Einstein notation (4) and many others. You may get better suggestions if you have such specific tasks in mind.
I’d like to solve the exercises in the book Doing Math with Python using Julia instead of Python.
In my class I also have students doing some of the symbolic calculations programmatically rather than on paper. I use SymPy.jl
, which I actually like using quite a bit more than the underlying Python package. It’s less verbose, and some of the operations do end up being performed by generic algorithms on the Julia side. The Python installation is managed behind the scenes when you add SymPy
, so the dependency on Python shouldn’t be a problem in practice.
Very few languages have a library like SymPy. I think really just Lisp and Python (OK, maybe Java; I don’t know that much about SymJa). The amount of work it takes to built and maintain such a library is enormous, and the payoff is modest compared to lots of other high-investment packages that have been written in pure Julia.
I just renamed this topic from “Julia equivalent of SymPy?” to “Julia alternatives to SymPy?” which I think better expresses what I’m looking for, but may invalidate some of the comments.
Symata.jl depends on sympy (the Python library, not the Julia wrapper). Much of the lower-level stuff in Symata is in Julia, the higher-level stuff, like calculus, calls sympy.
Hi, Modeling Tolkit has no way of simplifying that (except doing it by hand via manual substitution) because
1.5707963267948966 = pi/2
is not true from mathematical (symbolic) point of view. 1. 5707963267948966 is floating point number that is finite, so it can’t represent pi/2 for the purposes of symbolic simplification. Keeping pi//2
as fraction in symbolic form could help but I’m not sure whether Modelling Toolkit has this kind of rule for trigonometric simplification, but it can surely be added in