Live data from Hacker News

SymPy: Symbolic Mathematics in Python

sympy.org

61–70 of 137 posts

Re: SymPy: Symbolic Mathematics in Python

#61
post #18

Earlier quoted context omitted.

Not sure what you mean with GUI, but you can use it with Jupyter notebooks.

More like writing/clicking math (like in MS Word or some LaTeX editors) that is then converted to SymPy instead of writing stuff in Python directly.

It should be relatively straightforward to build something with Visualequation, latex2sympy, SymPy, and maybe IPython's QTConsole.

https://github.com/daniel-molina/visualequation

https://pypi.org/project/latex2sympy2/

https://ipython.org/ipython-doc/2/interactive/qtconsole.html

Edit: That might be overcomplicating things, there are already better alternatives: https://tex.stackexchange.com/questions/57068/wysiwyg-latex-...

Re: SymPy: Symbolic Mathematics in Python

#62
post #21

Earlier quoted context omitted.

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

I though finite difference differentiation was notoriously unstable.

Perhaps the commenter means something like reverse mode automatic differentiation?

Finite differences does indeed have stability issues, and even if you apply some tricks will only give you about half float precision

Re: SymPy: Symbolic Mathematics in Python

#63

Earlier quoted context omitted.

"Python isn't the best tool for anything, but it's the second best tool for most things."

I thought the role of "second best tool for most things" belonged to Excel

Excel is the most popular GUI framework and programming language in existence. And it underpins accounting divisions around the world!

Re: SymPy: Symbolic Mathematics in Python

#64
post #29

Earlier quoted context omitted.

I'm old enough to have had people tell me the same thing about the Linux kernel vs the Windows kernel. I can do an import sage as the top of any python script. It's a library. And since I get all of python for free it's better than Mathematica.

Your definition of "better" may be wildly different than many. Mathematica is much better in many cases... especially tasks where Mathematica has a built-in function call for something that would be an absolute pain in Python, but worse with respect to price and licensing. I use Python a lot more than Mathematica, but sometimes Mathematica is the best solution. Your windows/Linux analogy is also not very relevant her…

I think the windows linux analogy is pretty apt. especially around the win95/98 days.

Getting some random laptop and figuring out what kernel mods to enable and hope that the specific chipset revision was supported, or maybe a patch available that might work was, in fact, a lot of bullshit to put up with to get, say, sound.

sympy will do a lot. but you're probably going to have to reach for a big book of integrals, or find a friendly mathematician to identify the equation and possible approaches. Mathematica as a paid product has a lot of time and effort spent avoiding resorting to asking for help. Much much more built in.

As an undergrad or a hobbyist you probably want to stay "lower" and slog through the calculations when you're stuck. This is part of the process of understanding. But as a professional, or a more advanced user, screwing around for a week looking for a solution is a waste of time and expertise. Spring the cash, and move forward immediately.

I'm not trying to put words in your mouth, but I think there is some nuance that this maybe helps people understand your point.

"Better" really really depends on where you are and what you're trying to do.

Re: SymPy: Symbolic Mathematics in Python

#66
post #52
post #36

Earlier quoted context omitted.

This looks perfect. I've found native sympy to be a little cumbersome to use.

Same here, I've been slogging through with raw sympy this tool looks great. How do I speed up the start time for it - any ideas? Recompile it with PyPy or similar?

I think PyPy usually has slower startup time. Need to try to defer some of the imports to be done in the background, see how good is the outcome. Feel free to open an issue in github.

Re: SymPy: Symbolic Mathematics in Python

#67
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 ?

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.

Re: SymPy: Symbolic Mathematics in Python

#69

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.

SymPy is open source, mathematica is not.

Additionally, SageMath (which depends on SymPy) is the more comparable product (and is open source).

Re: SymPy: Symbolic Mathematics in Python

#70
post #49

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

Might not handle exactly the difficulties you're having but you can do `from sympy.abc import *`. This will create symbols for pretty much all letters (lower and upper) as well as a bunch of greek symbols (but written out, e.g. "delta").
Post reply on HN