3 ms·
It's not particularly elegant, is it? You just want to plot the sine function, but first you have to import libraries, declare symbols (with a scary correspond
by enriquto 6y ago
It's not particularly elegant, is it?
You just want to plot the sine function, but first you have to import libraries, declare symbols (with a scary correspondence between strings and variable names), and finally plot the damn function.
- mkl 6y agoI literally always have a Jupyter QtConsole open with one tab having Sympy loaded, and every single letter variable defined as a symbolic variable, and another tab with numpy; this is my constant daily-use calculator. In that context, it really is just "plot(sin(x))". It's not really anything more than having a terminal open with Gnuplot running, and no less elegant. Edit: plus, if I'm plotting with Sympy it's almost certainly something I've calculated symbolically with Sympy, so everything is defined and ready, and it's much more elegant than switching to a separate program. For a one-off "what does function look like?" question, both these tools are far too clunky, and I'd use Desmos or GeoGebra.
- abdullahkhalids 6y agoIf people have to reduce to this hack, why doesn't the language just declare every character string a symbolic variable by default, like Mathematica?
- mkl 6y agoBecause the vast majority of Python programs aren't doing symbolic maths with Sympy. It's not a hack, and it's pretty trivial. I type "a," and press up, and run the line from my command history with all the letters in it. Sympy also has a submodule named abc you can import variables from, but I like defining them as real number variables so I don't get complex answers when they don't make sense. Sympy is just a Python library, and one of the types it defines is symbolic maths variables, so you define Python variables just like with any other library, and then use them.
- enriquto 6y ago> Because the vast majority of Python programs aren't doing symbolic maths with Sympy. And this, my friends, is why mathematicians will never feel at home using Python+libraries. Instead of having a programming environment ideally suited to the needs of math, you need to fit your math to the Procrustean bed of Python syntax.
- williamstein 6y agoSageMath solves these problems.
- tomrod 6y agoExactly. Grandparent commenter is complaining about resolved issues that the community worked out years ago.
- abdullahkhalids 6y agoIt does not. I tried to replicate some symbolic computation code I wrote during my PhD in Mathematica in SageMath, and I just failed to get anywhere despite weeks of trying. I don't think I don't understand SageMath enough.
- tomrod 6y agoEh, it's fine even despite your hyperbole. Applied mathematicians such as myself often use python without complaint. Setting up sympy takes no effort. Plus, #python on freenode.
- abdullahkhalids 6y agoThat is what I wanted to say. The Python scientific ecosystem seems like it is written by programmers for scientists, while Matlab/Mathematica seem like they are written by scientists for scientists.
- nxpnsv 6y agoOne import statement is too much?