Live data from Hacker News

Doing Symbolic Math with SymPy

lwn.net

21–30 of 81 posts

Re: Doing Symbolic Math with SymPy

#21

SymPy's problem is that it is based on an object-oriented language. This results in SymPy (and friends) demanding that users abandon hundreds of years of math notation, to conform to the whims of a programming language. In SymPy you do M.diagonalize(), which makes no sense. The matrix M does not have a property diagonalize. Rather, you should apply a choosen diagonalization algorithm like Diagonalize(M) to produce a…

Sympy is great for people who occasionally need such programs. Any serious mathematician will have his or her preferred software that he uses daily anyway.

Sympy works for people who know programming (not just programmers, but researchers in general) who need to use it occasionally.

Re: Doing Symbolic Math with SymPy

#22

Earlier quoted context omitted.

May be the way mathematicians notate is frankly ambiguous and confusing, and recent decades of programming experience have given good insight into more expressive methods of notation.

> recent decades of programming experience as opposed to recent millennia of mathematical experience?

Let's not pretend math notation has remained constant for millennia.

Re: Doing Symbolic Math with SymPy

#23

Earlier quoted context omitted.

May be the way mathematicians notate is frankly ambiguous and confusing, and recent decades of programming experience have given good insight into more expressive methods of notation.

> recent decades of programming experience as opposed to recent millennia of mathematical experience?

To be fair, the mathematical notation that is familiar to us today is just a few hundred years old.

Re: Doing Symbolic Math with SymPy

#24

Earlier quoted context omitted.

> recent decades of programming experience as opposed to recent millennia of mathematical experience?

Let's not pretend math notation has remained constant for millennia.

Of course it has evolved. But some landmarks of it (e.g., using single letters for "variables") have been used since 2500 years ago. Now I laugh when programmers tell me to be "civilized" and name my matrices with full words.

Re: Doing Symbolic Math with SymPy

#25

SymPy's problem is that it is based on an object-oriented language. This results in SymPy (and friends) demanding that users abandon hundreds of years of math notation, to conform to the whims of a programming language. In SymPy you do M.diagonalize(), which makes no sense. The matrix M does not have a property diagonalize. Rather, you should apply a choosen diagonalization algorithm like Diagonalize(M) to produce a…

This is problem I have with Python in general; that even if you prefer to use it in a functional style, most libraries are written by real Python programmers, and using them will force you to grapple with the object-oriented inversion of common sense ( https://lee-phillips.org/pythonhate/ ). My favorite example is: ','.join(['a', 'b'])

What's wrong with (','.join(['a', 'b']))? If it's the order of arguments, then I want to point out that the order has two big advantages:

* partial application is actually useful: I've actually used (','.join) before, but (lambda sep: sep.join(['a', 'b'])) seems relatively useless. That's why Haskell also uses this order with (intercalate sep listOfStrings).

* it accepts any iterable, rather than just lists.

Re: Doing Symbolic Math with SymPy

#26

SymPy is fantastic and impressive and I am a fan. It however does few things better than the program it is directly trying to compete with, namely Mathematica. This gives me scary flashbacks to the early 'Linux on the desktop' advocates, whose main argument was that it was all 'free' in every sense of the word. As we know now, that simply was not enough to switch the majority of users. Do people see a space where Sym…

It runs on a google colab tab that you can spin up pressing "ctrl-T" in any available computer.

Sure, but if you want fast easy math, it's hard to beat wolfram alpha, where you can just enter something like "solve x^2+5a=y for x" and get the answer right away.

Re: Doing Symbolic Math with SymPy

#27

SymPy is fantastic and impressive and I am a fan. It however does few things better than the program it is directly trying to compete with, namely Mathematica. This gives me scary flashbacks to the early 'Linux on the desktop' advocates, whose main argument was that it was all 'free' in every sense of the word. As we know now, that simply was not enough to switch the majority of users. Do people see a space where Sym…

I use it in Jupyter notebooks for civil and structural engineering calcs. The reason is simple: I can print expressions and manipulate the expression with a guarantee that my calcs conform to the pretty printed ones. This allows non-programmers (senior engineers) to check the work on the engineering side with some additional assurances that the calculation is going to be correct compared to just inputting the expression in python seperately from the pretty printing process.

Re: Doing Symbolic Math with SymPy

#28

SymPy's problem is that it is based on an object-oriented language. This results in SymPy (and friends) demanding that users abandon hundreds of years of math notation, to conform to the whims of a programming language. In SymPy you do M.diagonalize(), which makes no sense. The matrix M does not have a property diagonalize. Rather, you should apply a choosen diagonalization algorithm like Diagonalize(M) to produce a…

> Mathematica wins, and will continue to win, because the language is functional and conforms to how Mathematicians think, rather than how programmers like to code. Or maybe Python "will win" because it conforms to how programmers think, rather than forcing them to think like mathematicians (also, why capitalize "mathematicians" in your sentence?), letting them get their shit done. More importantly, "win" what exactl…

> conforms to how programmers think

Python is an important tool in general, it allows to automate many tasks that otherwise would have to be done manually. I wish more non-programmers knew how to use it.

Re: Doing Symbolic Math with SymPy

#29
post #25

Earlier quoted context omitted.

This is problem I have with Python in general; that even if you prefer to use it in a functional style, most libraries are written by real Python programmers, and using them will force you to grapple with the object-oriented inversion of common sense ( https://lee-phillips.org/pythonhate/ ). My favorite example is: ','.join(['a', 'b'])

What's wrong with (','.join(['a', 'b']))? If it's the order of arguments, then I want to point out that the order has two big advantages: * partial application is actually useful: I've actually used (','.join) before, but (lambda sep: sep.join(['a', 'b'])) seems relatively useless. That's why Haskell also uses this order with (intercalate sep listOfStrings). * it accepts any iterable, rather than just lists.

What strikes me as weird about this is that our intent is to do something to the array of strings, so we are looking for a function that takes this array and transforms it into something else. But we are obligated to invert our intuition here, and write this as if we are doing something to the punctuation that we want to insert between the array elements. It’s backwards, and causes us (me, anyway) to keep forgetting how to use this method. I must have gotten this wrong a dozen times. The sensible way would be something like join(array, separator). That is straightforward, and would be hard to get wrong. It could even be written in a way where the order of arguments didn’t matter, so you wouldn’t even have to remember that. Why is the separator privileged as the implicit first argument of `join`?

I accept that you’ve identified some advantages of the Python version; it’s always possible to find cases where object.method() notation gets you something.

Re: Doing Symbolic Math with SymPy

#30

Earlier quoted context omitted.

> recent decades of programming experience as opposed to recent millennia of mathematical experience?

Let's not pretend math notation has remained constant for millennia.

Exactly, it has been refined over millennia.
Post reply on HN