Live data from Hacker News

SymPy: Symbolic Mathematics in Python

sympy.org

81–90 of 137 posts

Re: SymPy: Symbolic Mathematics in Python

#81

Symbolic mathematics is severely underexplored in undergraduate studies, and the little exposure I had was generally tied to proprietary software such as Mathematica and MATLAB. I learned to use it as an imperfect extension of pen-and-paper thinking, and source code for more advanced stuff gets shaky the deeper into abstraction one goes. For example, I work in a field of mathematics/engineering that requires heavy us…

For great justice, does anyone know of any applications (other than Maple) that support WYSIWYG typeset input (not output) like Maple does?

As far as I know, Wolfram/Mathematica, LaTex, SymPy, Jupyter, Sage etc all rely on typewriter text for composing and inputting math. For this (and only this) reason, Maple is the only application that ever resonated with me, because input may be written in the same form it's written by hand, and it's baffling this capability isn't more commonplace. Is this a barrier to anyone else?

Re: SymPy: Symbolic Mathematics in Python

#82
post #46

There 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.

Do you know why there's such a big difference ? For example, is the way sympy does its job fundamentally flawed ?

I mean, literally people with Math PhDs are being paid to work on the product, full-time. And they have a financial incentive to address feedback from customers and try to solve as many problems as possible.

By comparison, open source projects are developed by people with a wide range of knowledge level and commitment, and you simply can't expect the quality to be the same.

I find that discussions on HN often fail to acknowledge that proprietary software is usually extremely good at their domain, and what companies put into UX, support and the development/feedback loop are actually very valuable.

Re: SymPy: Symbolic Mathematics in Python

#83
post #11

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…

Funfact: you can probably JIT compile that using JAX for an easy performance gain.

Re: SymPy: Symbolic Mathematics in Python

#84
post #76

Earlier quoted context omitted.

I doubt there's any sort of fundamental flaw in sympy. Getting more and more solutions is mostly about putting in lots of work to tweak the bag of tricks. There is no universal algorithm for solving integrals. As an open source project depending on volunteers (or is it just the one major author?) I am impressed that sympy does as much as it does.

> There is no universal algorithm for solving integral. Not that I want to dispute this, but depending on what you meant, there is in fact such an algorithm: https://en.wikipedia.org/wiki/Risch_algorithm Though often it is not implemented because it is quite complex (its details covering two thick books) and many of the special cases it covers rarely crop up in the real world, so the effort isn't worth it. The caveat…

That is an excellent caveat, and well cited, thanks.

Re: SymPy: Symbolic Mathematics in Python

#85
post #83
post #11

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…

Funfact: you can probably JIT compile that using JAX for an easy performance gain.

But then they would have to compile the jit-optimized XLA to C. Do you know if that’s straightforwardly doable?

Re: SymPy: Symbolic Mathematics in Python

#86
post #4

Sympy is amazing, but i kinda fail to see whats news about it as its oldest commit is 14 years ago.

Oldest commit was from today: https://github.com/sympy/sympy Where are you getting 14 years from?

You wouldn’t say “my oldest child was born today” in reference to your family of six children born between 2008 and today though.

Re: SymPy: Symbolic Mathematics in Python

#87

Symbolic mathematics is severely underexplored in undergraduate studies, and the little exposure I had was generally tied to proprietary software such as Mathematica and MATLAB. I learned to use it as an imperfect extension of pen-and-paper thinking, and source code for more advanced stuff gets shaky the deeper into abstraction one goes. For example, I work in a field of mathematics/engineering that requires heavy us…

a close friend of mine used to tell me about these production Mathematica Notebooks he'd author at his company Coherence to do all these optical and thermal calculations with. It was a regular workhorse for him.

A very long time ago I used to play around with Derive5 in my youth. It was the most affordable Computer Algebra System (CAS) of the time and I learned to program in that funky one liner programming language where I had to strip all the white space from my editor and always be careful to balance parenthesis. I should dig up those old files and upload them to my github. I've been actually meaning to reimplement those operations in a more modern CAS system and see if I can more densely plot these curves I was studying with some iso-arc-length families of exponentials about the point (0,1).

Re: SymPy: Symbolic Mathematics in Python

#88
post #21
post #11

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…

Why are you calculating the Jacobian symbolically? AFAIK, for complex cases, the numerical Jacobian is often faster / more numerically stable.

The poster is talking about using symbolic math to obtain a closed-form expression for the Jacobian that is then numerically evaluated. This will often be faster and more accurate. For example, if your function is sin(x), then the symbolic math tells you your derivative is cos(x), so you put that expression in your code and compile it. When calling this on the angle x = 0.123, your code then just evaluates numerically cosf(0.123), rather than (sinf(0.124) - sinf(0.122)).

Re: SymPy: Symbolic Mathematics in Python

#89
post #21
post #11

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…

Why are you calculating the Jacobian symbolically? AFAIK, for complex cases, the numerical Jacobian is often faster / more numerically stable.

There are plenty of situations where the scenario goes like this: you first do symbolical calculations. then fill in some of the free variables, your resulting expression will simplify a lot. Then you compile that resulting expression to native code and evaluate the simplified specialized code for a zillion parameter vectors.

Anyway,if your day job needs something like this you're better off using a lisp than python.

Post reply on HN