SymPy: Symbolic Mathematics in Python
91–100 of 137 posts
Re: SymPy: Symbolic Mathematics in Python
#92Working in the field of robotics, I often have to write big vectors ( usually computed as the result of 3D transformations ) and then compute their Jacobian ( their derivative with respect to several state-variables ), which quickly becomes very nasty equations. I use sympy to (i) compute these big vectors, expressed in a very declarative way, (ii) compute the jacobian and (iii) export the results in C-code, immediat…
You could maybe calculate the Jacobian in C code using automatic differentiation. Might be less C-code, might be less elementary operations done in the C code, and you would not need to be copy-pasting complex symbolically derived formulas from Python to C.
Re: SymPy: Symbolic Mathematics in Python
#93There is a benchmark of Sympy vs Mathematica at https://www.12000.org/my_notes/CAS_integration_tests/reports... The results were Mathematica failed to solve 1,523 problems, Sympy failed to solve 48,529. So it has some catching up to do.
SymPy is open source, mathematica is not. Additionally, SageMath (which depends on SymPy) is the more comparable product (and is open source).
Why does that matter?
Re: SymPy: Symbolic Mathematics in Python
#94Working in the field of robotics, I often have to write big vectors ( usually computed as the result of 3D transformations ) and then compute their Jacobian ( their derivative with respect to several state-variables ), which quickly becomes very nasty equations. I use sympy to (i) compute these big vectors, expressed in a very declarative way, (ii) compute the jacobian and (iii) export the results in C-code, immediat…
> I use sympy to (i) compute these big vectors, expressed in a very declarative way, (ii) compute the jacobian and (iii) export the results in C-code, immediately importable in my code case. You could maybe calculate the Jacobian in C code using automatic differentiation. Might be less C-code, might be less elementary operations done in the C code, and you would not need to be copy-pasting complex symbolically derive…
Re: SymPy: Symbolic Mathematics in Python
#95SymPy is awesome indeed! I've been using it as a teaching tool for many years. IMHO, it's the best option as compared to Mathematica/Maple/etc. because the API functions match exactly the verbs students use when learning math (solve, expand, factor, etc.). Here is a little tutorial for anyone looking to get started: https://minireference.com/static/tutorials/sympy_tutorial.pd... Also available in runnable notebook fo…
The biggest drawback of SymPy is the need to pre-define all your symbols. That makes it more difficult to handle scenarios where you're taking formulas as input because you either need to parse the equation yourself to figure out what variables were used, or have the user manually supply the symbols.
Re: SymPy: Symbolic Mathematics in Python
#96Earlier quoted context omitted.
Do you know why there's such a big difference ? For example, is the way sympy does its job fundamentally flawed ?
It's a running joke that Wolfram is a jobs program for math PhD's. The difference isn't necessarily technical, but the sheer amount of labor that has gone into adding more edge cases and niche use cases. Sympy is great but like most open source, it's created by volunteer maintainers supported by donations. I imagine the difference is even bigger in things like solving ODE's/PDE's.
Nice. The PhDs just need take care their contributions aren't misappropriated. See https://en.m.wikipedia.org/wiki/Rule_110
Re: SymPy: Symbolic Mathematics in Python
#97SymPy is awesome indeed! I've been using it as a teaching tool for many years. IMHO, it's the best option as compared to Mathematica/Maple/etc. because the API functions match exactly the verbs students use when learning math (solve, expand, factor, etc.). Here is a little tutorial for anyone looking to get started: https://minireference.com/static/tutorials/sympy_tutorial.pd... Also available in runnable notebook fo…
The biggest drawback of SymPy is the need to pre-define all your symbols. That makes it more difficult to handle scenarios where you're taking formulas as input because you either need to parse the equation yourself to figure out what variables were used, or have the user manually supply the symbols.
Re: SymPy: Symbolic Mathematics in Python
#98Earlier quoted context omitted.
> I use sympy to (i) compute these big vectors, expressed in a very declarative way, (ii) compute the jacobian and (iii) export the results in C-code, immediately importable in my code case. You could maybe calculate the Jacobian in C code using automatic differentiation. Might be less C-code, might be less elementary operations done in the C code, and you would not need to be copy-pasting complex symbolically derive…
I could be wrong, but I seriously doubt C macros can do this.
Re: SymPy: Symbolic Mathematics in Python
#99I use SymPy as my calculator with https://github.com/idanpa/calcpy
Re: SymPy: Symbolic Mathematics in Python
#100Unfortunately I always found it quite slow compared to Mathematica