Nice article. I totally agree about SymPy making math fun. I used Mathematica a lot in college, but stopped once it wasn’t free to me anymore. Here’s a blog post I made recently showing some fun SymPy calculations. https://www.swied.com/posts/make-a-ringtone-sound/make-a-rin...
SymPy makes math fun again
21–30 of 96 posts
Re: SymPy makes math fun again
#22I 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…
Yes, it's easy. It was always possible, since fortunately none of the Sage library implementation uses the Sage preprocessor. You could always do "sage -python" and you get the Python interpreter that Sage uses, and can import Sage via "import sage.all". Somebody asked me exactly this question at a colloquium talk I gave on Sage yesterday, and here's my answer/demo:
https://youtu.be/dy792FEh1ns?t=1140
In the demo, I use a Jupyter kernel that runs the Python included in Sage-9.8.
Disclaimer: I created the Sage preparser long ago, in order to make Sage more palatable to mathematicians. In particular, it was inspired by audience feedback during a live demo I did at PyCon 2005.
Re: SymPy makes math fun again
#23The 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.
I think I was looking into it at the start of this project, but it looks like it’s symbolic solver can still only handle linear equations, and I’m working with a mess of quadratic inequalities that I wanted to solve symbolically
Re: SymPy makes math fun again
#24what’s nice is that pyodide folks have gotten sympy compiled to web assembly, so it’s a viable browser library too!
Here's a completely separate Python in WebAssembly project I created, which also provides Sympy with "import sympy" being a little faster (1.7s v 1.16s on my laptop): https://cowasm.org/
Re: SymPy makes math fun again
#25Earlier quoted context omitted.
> 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…
> Is it easier to import SageMath from a plain Python script now; with conda repackaging? Yes, it's easy. It was always possible, since fortunately none of the Sage library implementation uses the Sage preprocessor. You could always do "sage -python" and you get the Python interpreter that Sage uses, and can import Sage via "import sage.all". Somebody asked me exactly this question at a colloquium talk I gave on Sage…
I should add that this is an interesting chunk of Python code, and we've always planned to separate it out from Sage as a separate library than could be used with Sympy, etc.
https://github.com/sagemath/sage/blob/52a81cbd161ef4d5895325...
It does a surprising number of little clever things we realized would be a good idea over years, and it has some neat ideas from various Python PEP's like [1..10] that were rejected from Python, but are very useful when expressing mathematics. It's also annoying when you just want to format your code using prettier (say), and you can't because Sage isn't Python. :-(
Re: SymPy makes math fun again
#26I'd like to say that I use it all the time, but I'm too old to be bothered by learn new things at this point. However, I think the Python ecosystem is getting better all the time, and things like SymPy and Mathics give me a lot of hope for the future of technical computing with Python.
Re: SymPy makes math fun again
#27Nice article. I totally agree about SymPy making math fun. I used Mathematica a lot in college, but stopped once it wasn’t free to me anymore. Here’s a blog post I made recently showing some fun SymPy calculations. https://www.swied.com/posts/make-a-ringtone-sound/make-a-rin...
Re: SymPy makes math fun again
#28Earlier quoted context omitted.
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
#29I've solved some Math assignments using SymPy on my sophomore year in uni. One time instead of writing them down to paper (the assignment was like “you have 24 hours to take these 20 integrals”), I've just shown the script I coded to my teacher and got an A. (And I have dropped out the very same year then :-)
Re: SymPy makes math fun again
#30Earlier quoted context omitted.
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.