Live data from Hacker News

SymPy: Symbolic Mathematics in Python

sympy.org

31–40 of 137 posts

Re: SymPy: Symbolic Mathematics in Python

#31

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

No, excel is the worst tool for anything.

Re: SymPy: Symbolic Mathematics in Python

#32
post #8

SymPy gets the job done. I typically use it in the SageMath combo library, is that still the way to go or has SymPy advanced to the point that I should be using it on its own?

SageMath looks cool, but the fact that it's a combination of many different existing tools all with their own syntax, and feature overlap, scares me off a bit since it seems like how you do things wouldn't be very internally consistent How does this aspect work out in practice?

In practice it feels like working with three libraries in a trenchcoat. However, as of five years ago it was totally worth it: the killer app for Sage was that it let you describe a problem in SymPy where you have the full power of python for loops, library support, visualization etc; and then solve it with Maxima's more powerful symbolic calculus tools. I'm not up to speed on whether SymPy has caught up to Maxima in terms of being able to solve integrals, differential equations, etc.

Re: SymPy: Symbolic Mathematics in Python

#35
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 format: https://colab.research.google.com/github/minireference/sympy... (read only = http://nbviewer.ipython.org/github/minireference/sympytut_no... )

Last but not least, for anyone interested in trying SymPy without installing anything, there is always the SymPy live shell: https://live.sympy.org/ (runs Python + SymPy in the browser thanks to WebAssembly)

Re: SymPy: Symbolic Mathematics in Python

#37

Is there any GUI for SymPy one could easily use to solve symbolic math like Maple/Maxima/Macsyma?

JupyterLite's default Python-compiled-to-WASM build has NumPy, SciPy, matplotlib, and SymPy installed; so you can do computer algebra with SymPy in a browser tab.

https://JupyterLite.rtfd.io/

https://github.com/jupyterlite/jupyterlite/tree/main/py/jupy... :

> Initial support for interactive visualization libraries such as: altair, bqplot, ipywidgets, matplotlib, and plotly

Re: SymPy: Symbolic Mathematics in Python

#38
post #29
post #25

Earlier quoted context omitted.

Sagemath isn't a python library, it's a collection of packages (of which sympy is one) under a common interface. It is indeed what you would use if you wanted to do real symbolic computation in python, but it's not at the level of Mathematica or Maple. Look, we all love open source, but we aren't doing anybody any favors by pretending the open source alternative is better when it isn't. I would encourage anyone whose…

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 here. Both are popular in different areas.

Re: SymPy: Symbolic Mathematics in Python

#39

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.

Although super interesting, the website you mention is only about integrals...

Re: SymPy: Symbolic Mathematics in Python

#40
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 use of tensor calculations. My go-to tool for that is Maxima, however, it has limited and cumbersome packages for it (see [0]). Now for more sophisticated calculations I resort to SymPy, not necessarily because of better handling of symbolics but because of the abstractions that Python already has. Maybe someday I'll get to read the Principles by Norvig and fix Maxima to suit my needs (if anyone has better references to read Maxima's source code/implementation of tensor computations/symbolic (tensor, geometric) algebra I would be grateful to know).

[0] https://arxiv.org/pdf/cs/0503073.pdf

Post reply on HN