Working 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…
SymPy: Symbolic Mathematics in Python
51–60 of 137 posts
Re: SymPy: Symbolic Mathematics in Python
#52I use SymPy as my calculator with https://github.com/idanpa/calcpy
This looks perfect. I've found native sympy to be a little cumbersome to use.
How do I speed up the start time for it - any ideas? Recompile it with PyPy or similar?
Re: SymPy: Symbolic Mathematics in Python
#53Working 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…
Have you considered using jax? you can efficiently compute the jacobian (even using the gpu if you want) without leaving python at all. The api is also numpy compatible!
Re: SymPy: Symbolic Mathematics in Python
#54Working 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…
Why are you calculating the Jacobian symbolically? AFAIK, for complex cases, the numerical Jacobian is often faster / more numerically stable.
Re: SymPy: Symbolic Mathematics in Python
#55Working 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've used SymPy in a very similar way, in my case it was some nasty derivatives that were needed for some orbital mechanics calculations. First write down the equations, then let SymPy do the laborious math part and turn the output into C code. I'm guessing this is why you don't see a lot of SymPy projects in the wild. It was used for some intermediate calculations, and the results were turned into the product's code…
Re: SymPy: Symbolic Mathematics in Python
#56Re: SymPy: Symbolic Mathematics in Python
#57Re: SymPy: Symbolic Mathematics in Python
#58Working 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…
Re: SymPy: Symbolic Mathematics in Python
#59Earlier quoted context omitted.
I've used SymPy in a very similar way, in my case it was some nasty derivatives that were needed for some orbital mechanics calculations. First write down the equations, then let SymPy do the laborious math part and turn the output into C code. I'm guessing this is why you don't see a lot of SymPy projects in the wild. It was used for some intermediate calculations, and the results were turned into the product's code…
There might be a better way, but my habit is to include the symbolic code as a comment in the C. I've thanked myself for doing this.
Re: SymPy: Symbolic Mathematics in Python
#60Working 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…
Why are you calculating the Jacobian symbolically? AFAIK, for complex cases, the numerical Jacobian is often faster / more numerically stable.