News for hackers. Stuff that matters.
Re:A new release for GNU Octave by enriquto on Sunday January 03, 2021 @06:37AM (#25621210)
Sure, but none of these beats gnuplot's uber-elegant "plot sin(x)" syntax :)
Re:A new release for GNU Octave by mkl on Sunday January 03, 2021 @06:42AM (#25621231)
Sympy can do that: plot(sin(x))

This of course works with other symbolic manipulation:

  plot(sin(x).diff())
  plot(sin(x).subs(x, x**2))
Re:A new release for GNU Octave by kergonath on Sunday January 03, 2021 @07:39AM (#25621428)
Yeah, Matplotlib is capable, but it’s heavy and verbose. It’s fine as an API, but the syntax gets in the way very quickly.

My use case is not a scratch pad with one plotting window; it’s dozens of windows with regressions and stuff. Each window is a completely different context; some of them are short lived and some of them are used for weeks. Using as many notebooks is very impractical. For example, seeing where one parameter is going in one calculations is trivial and quicker than starting a notebook and setting it up. Works transparently over ssh, too.

I am more or less fluent in Matplotlib, because I work with people who use it and I need to understand whatever the students are doing (and some of them use Python and some use R, which is a whole other discussion). I just dislike it and don’t use it much for my things. Ultimately, gnuplot’s syntax for regression and complex plots is much more concise.

I any case I think it’s good intellectual hygiene to use several tools regularly, lest you end up stuck in a way of thinking, so I encourage students to try others. It’s also good to have discussions about these things that don’t end up in holy wars; we need to be curious.

Re:A new release for GNU Octave by enriquto on Sunday January 03, 2021 @06:50AM (#25621252)
Can you show the complete code for these snippets to work? I tried

    import sympy
    sympy.plot(sympy.sin(x))
and it says "NameError: name 'x' is not defined"
Re:A new release for GNU Octave by mkl on Sunday January 03, 2021 @06:51AM (#25621254)
You need to tell Python that you want a symbolic variable named x:

  from sympy import *
  x = symbols('x')
  plot(sin(x))
symbols is sympy.symbols.
Re:A new release for GNU Octave by enriquto on Sunday January 03, 2021 @07:02AM (#25621291)
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.

Re:A new release for GNU Octave by mkl on Sunday January 03, 2021 @07:11AM (#25621328)
I 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.

Re:A new release for GNU Octave by abdullahkhalids on Sunday January 03, 2021 @07:51AM (#25621470)
If people have to reduce to this hack, why doesn't the language just declare every character string a symbolic variable by default, like Mathematica?
Re:A new release for GNU Octave by mkl on Sunday January 03, 2021 @08:02AM (#25621524)
Because 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.

Re:A new release for GNU Octave by enriquto on Sunday January 03, 2021 @08:29AM (#25621648)
> 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.

Re:A new release for GNU Octave by abdullahkhalids on Sunday January 03, 2021 @11:13AM (#25622583)
That 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.
Re:A new release for GNU Octave by tomrod on Sunday January 03, 2021 @08:46AM (#25621716)
Eh, 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.
Re:A new release for GNU Octave by williamstein on Sunday January 03, 2021 @08:45AM (#25621709)
SageMath solves these problems.
Re:A new release for GNU Octave by abdullahkhalids on Sunday January 03, 2021 @11:08AM (#25622549)
It 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.
Re:A new release for GNU Octave by tomrod on Sunday January 03, 2021 @08:46AM (#25621722)
Exactly. Grandparent commenter is complaining about resolved issues that the community worked out years ago.
Re:A new release for GNU Octave by nxpnsv on Sunday January 03, 2021 @08:12AM (#25621576)
One import statement is too much?