Live data from Hacker News

SymPy: Symbolic Mathematics in Python

sympy.org

71–80 of 137 posts

Re: SymPy: Symbolic Mathematics in Python

#71
post #64

Earlier quoted context omitted.

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, o…

I don't think many question that open source won't eventually be equivalent or better than Mathematica for computational work. It just isn't for a lot of things in 2024. It might be fully reversed in another 5 years. Agreed everyone's view of "best" is different as I said above.

I will say a really nice thing about Mathematica is consistency.

Re: SymPy: Symbolic Mathematics in Python

#73
post #59

Earlier quoted context omitted.

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.

I commit the symbolic code on its own file, in the same commit which adds the c code.

I guess a hypermodern solution would be to produce the parts of the C code with CI/CD from the SymPy Code.

Re: SymPy: Symbolic Mathematics in Python

#76
post #46

Earlier quoted context omitted.

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

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 of Risch's algorithm is that it only "works" if the function you are trying to integrate has an elementary antiderivative. Many of the problems that Mathematica can solve (but SymPy fails at) involved special (i.e. non-elementary) functions.

Re: SymPy: Symbolic Mathematics in Python

#77
post #46

Earlier quoted context omitted.

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

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.

[deleted]

Re: SymPy: Symbolic Mathematics in Python

#79
post #49

Earlier quoted context omitted.

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").

Imagine a scenario where you've got a database of timeseries data, say stock prices. Each price trend is identified by the stock ticker, and your users have an excel spreadsheet of several thousand equations in terms of the stock ticker (e.g. (AAPL-TSLA)/AAPL) and you want to calculate the derivative of each one of those equations with respect to each ticker symbol in each equation before pulling the data.

Obviously you could find a list of every ticker symbol and create a few thousand symbols before parsing, but you don't always have the luxury of a complete/up-to-date list, or doing so might create too many symbol objects and cause performance problems.

Re: SymPy: Symbolic Mathematics in Python

#80
post #25
post #10

Earlier quoted context omitted.

Sagemath is a python library that has more capabilities than Mathematica. If you want to do real symbolic computation in python Sagemath is the only way to do it. That said sympy is quite a cool little library for learning.

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…

Sagemath is a Python library (and a rather large one at that). It's vastly superior to Mathematica and Maple at some things (e.g., number theory and algebraic combinatorics) and inferior at other things (e.g., symbolic integration).
Post reply on HN