Live data from Hacker News

SymPy makes math fun again

wordsandbuttons.online

11–20 of 96 posts

Re: SymPy makes math fun again

#11
post #2

The interactive js visualizations are super cool, I didn’t know SymPy could do that Lately I’ve been using SymPy and Pluto.jl together, it’s been great for deriving results and making interactive visualizations for numerical code at the same time

Have you checked out Symbolics.jl? It's a lot like SymPy.jl but with all the niceness of a implementation in native Julia instead of a python binding.

Re: SymPy makes math fun again

#13
I like sagemath. They have integration with sympy, and they also have many features making python simpler when you want to do mathematical things.

There's latex display feature when in notebook. It looks good, can even have symbolical matrices and display them as you would've expected.

It's on par with Wolfram notebook, but you get to program in python instead of some propietary language.

If you got some really long formula, it's easier to see you got it correctly by displaying it symbolically in latex.

They have other things to smooth out the parts of python which are annoying in math, like exponentiation works with ^, and dividing integers returns a rational number instead of floating point or an integer.

Re: SymPy makes math fun again

#14

The fact that you have to declare every single variable makes it a non-starter for me. In Mathematica, I have written calculations that involve dozens of variables. In sympy that will be very annoying.

Just write:

    a, b, c, d, f, g, h, i, j, k, l, m, n, p, q, r, s, t, u, v, w, x, y, z = var('a, b, c, d, f, g, h, i, j, k, l, m, n, p, q, r, s, t, u, v, w, x, y, z')
At the top of your Jupyter notebook, right after your import lines, and copy and paste it everywhere else. It's really not a big deal! You can always redefine these variables to other things later, if you need to.

Mathematica costs $387 for the "home desktop" version, or $194/year for the online version. Pretty steep for anyone doing math as part of their hobby. Maybe it would be fine if math itself is your hobby, but even then I'd rather spend that on books.

Of course this is all moot if you're an academic and your school pays for all the licenses to any software you need.

Re: SymPy makes math fun again

#15
Learning how to derive the taylor series or memorizing the formulas with some rough understanding of how to derive them sounds easier than learning a programming language

Regarding his low exam performance , this is why classes are sometimes graded on a curve. Intro calc. is pretty easy, and the author def. seems smart enough to do well. Likely his class was unusually hard. Sometimes that happens..luck of the draw.

Re: SymPy makes math fun again

#16

The fact that you have to declare every single variable makes it a non-starter for me. In Mathematica, I have written calculations that involve dozens of variables. In sympy that will be very annoying.

You can start a REPL with `isympy -I`, which is an IPython REPL but with some preprocessing magic that wraps any unknown variable into a sympy symbol and any integer into a sympy integer, which makes it closer to Mathematica:

    In [1]: 22/7*foobar
    Out[1]: 
    22⋅fo̅o
    ──────
      7

Re: SymPy makes math fun again

#17
As a mathematician, the least fun I have is when interacting with a CAS. The degree to which one needs to do this tends to be field specific, but the tedium of calculations seen is most undergraduate courses is negligible.

Re: SymPy makes math fun again

#18
post #14

The fact that you have to declare every single variable makes it a non-starter for me. In Mathematica, I have written calculations that involve dozens of variables. In sympy that will be very annoying.

Just write: a, b, c, d, f, g, h, i, j, k, l, m, n, p, q, r, s, t, u, v, w, x, y, z = var('a, b, c, d, f, g, h, i, j, k, l, m, n, p, q, r, s, t, u, v, w, x, y, z') At the top of your Jupyter notebook, right after your import lines, and copy and paste it everywhere else. It's really not a big deal! You can always redefine these variables to other things later, if you need to. Mathematica costs $387 for the "home deskto…

Wolfram Alpha is free alternative for most uses. Good enough for most people.

Re: SymPy makes math fun again

#20

I like sagemath. They have integration with sympy, and they also have many features making python simpler when you want to do mathematical things. There's latex display feature when in notebook. It looks good, can even have symbolical matrices and display them as you would've expected. It's on par with Wolfram notebook, but you get to program in python instead of some propietary language. If you got some really long…

> They have other things to smooth out the parts of python which are annoying in math, like exponentiation works with ^, and dividing integers returns a rational number instead of floating point or an integer.

SageMath also has a multivariate inequality solver IIRC. `*` is repeated multiplication (exponentiation) in Python. If you require preprocessing to translate ^ to *, you don't have valid Python code that'll run with any other interpreter.

Is it easier to import SageMath from a plain Python script now; with conda repackaging?

Type promotion in Python:

   from rational import Rational
   assert Rational(1, 4) / 2 == Rational(1, 8)
Python 2 had a __future__ import to do floatdiv instead of floordiv:

  from __future__ import division
  assert 3 / 2 == 1.5
  assert 3 // 2 == 1
  assert 4 / 2 == 2.0
Python 3 returns floats from ints or decimals IIRC:

   assert 3 / 2 == 1.5
   assert 3.0 / 2 == 1.5
   assert 3 // 2 == 1
   assert 4 / 2 == 2.0
Post reply on HN