from Hacker News

SymPy Gamma: an open-source, Python-based alternative to Wolfram Alpha

by gioi on 1/29/14, 5:16 PM with 59 comments

  • by asmeurer on 1/30/14, 1:02 AM

    (I am the lead developer of SymPy)

    The important thing to note about SymPy Gamma is that it does only the mathematics part of WolframAlpha. It's also relatively new. There is no natural language input. There are no non-mathematical capabilities. The syntax should match Python syntax for the most part, though there are extensions to allow things like "sin x" or "x^2" or "2 x". All this will hopefully improve in the future (and pull requests are welcome!).

    Most of the code was written by David Li (who is actually a high school student). You can watch a presentation about it here: http://conference.scipy.org/scipy2013/presentation_detail.ph.... It started out as a "because we can" toy, and it's gotten much better.

    The real benefit of SymPy Gamma over WolframAlpha is that there are no barriers around it, since it's entirely (BSD) open source. For example, if you start computing something interesting and want to try more, you can move to SymPy Live (http://live.sympy.org/) and compute in a more session like environment. Or you can use SymPy locally on your own computer.

    Regarding the comments that wolfram is mostly used for play, I'm not so sure about it. Wolfram is invaluable to students as a calculator. Sure Google can compute 100 * pi, but it falls apart when you try to compute integrate(sin(x) * x, x). When I was in college (which was last year), I saw people use it all the time. It's been very successful in making computer algebra accessible to virtually everyone.

    By the way, probably the best feature of SymPy Gamma right now is the integration steps. See for instance the "integral steps" section of http://www.sympygamma.com/input/?i=integrate%28sin%28x%29*x%.... This is a feature that used to be free at WolframAlpha, and it's extremely useful if you are learning integration in calculus. It doesn't work for all integrals, because not all integrals are computed the way you would by hand.

  • by primitivesuave on 1/29/14, 6:46 PM

    I used to work at Wolfram Research on Wolfram Alpha's backend, and one of the most challenging technical problems we faced was free-form input. Although W|A has by no means perfected this, this is hardly an alternative - queries like "factor the number 100" fail because there is only the beginnings of a free-form transformer. Obviously, the usefulness of being able to answer "factor one hundred" is questionable, but W|A solved it out of Stephen Wolfram's aspiration to be able to "compute everything". Right now, this is just a programming language you can run on the web.

    The other thing is that W|A has trillions of data points and what I am only allowed to describe as the beginnings of a semantic network for inferring relations between them. It was a vastly overcomplicated system that was difficult to work with, so I am quite confident that some day there will be an open-source alternative that anyone can contribute to.

    The other thing to take into account is how this affects the future. Wolfram Research thought they were going to "disrupt the calculator" (I heard this ridiculous statement once at a meeting). In reality, Wolfram Alpha queries are more often for the sake of fun than for the sake of discovery (I know this because there was a big TV in the break room that would keep displaying things that people searched on Wolfram Alpha). Is it really that useful to be able to have a computer give you an answer to "I have two apples, Jill has three apples. How many apples do we both have?"

    http://www.wolframalpha.com/input/?i=I+have+two+apples%2C+Ji...

    Or is it more useful to make something that can take in symptoms of your current ailment and tell you which disease you are most likely to have? Wolfram Alpha does this as well.

    http://www.wolframalpha.com/input/?i=I+have+a+fever+and+a+ru...

    Although the results are difficult to interpret. In my time at Wolfram Research, I was certainly convinced by the idea of knowledge engines and their ultimate emergence, but I think the way this will be accomplished is in more in a Google-esque fashion where their knowledge engine results are displayed alongside a real search algorithm. Best of luck to the people on this project, I hope you make the first step into creating an open source knowledge engine.

  • by techwizrd on 1/29/14, 6:15 PM

    I'm not entirely sure how this works as an alternative to Wolfram Alpha. Much of the value I see in Wolfram Alpha comes from it's highly curated data set and ability to parse natural language into a useful mathematical representation. It brings curated constants and mathematical equations, graphs, and simulations to the general public. On the other hand, this really seems like the SymPy interpreter in a browser.

    I think this would do much better without the comparison to Wolfram Alpha.

  • by dekhn on 1/29/14, 10:46 PM

    Many many many years ago, I wanted to use Mathematica, but I didn't like the language (just the algebra system, plotting, etc).

    I wrote a python bridge, which was actually pretty cool. It's probably the neatest, cleanest, most CS-y code I've written (it converted Python objects to Mathematica objects over MathLink. It integrated with Numeric Python.

    https://code.google.com/p/pymathematic/source/browse/trunk/e...

  • by mekane8 on 1/29/14, 7:01 PM

    Hmmm, my favorite inputs to Wolfram|Alpha are unit conversions. This thing just spews error messages.

    http://www.sympygamma.com/input/?i=5+gallons+%2F+12+fl+oz.

    http://www.sympygamma.com/input/?i=how+many+calories+in+a+cu...

    I wouldn't call it an "alternative" just yet. (And I'm an ex-W|A employee).

  • by roryokane on 1/30/14, 3:33 AM

    See also Mathics (try online at http://mathics.net/; info at http://mathics.org/), which wraps SymPy with a Mathematica-compatible programming language.
  • by nathanb on 1/30/14, 8:01 AM

    I typed "12 c in f", a very simple example of the sort of thing I use wolfram alpha (usually by way of duck duck go) for most often. It choked. I bailed.

    I'm a Linux user. I have bc and units installed. I even have some shell script wrappers to make those utilities actually helpful for casual use. I can open a terminal and calculate expressions and convert units...so long as I ask nicely. The big win for W|A is that it doesn't require me to ask nicely. This is helpful for quick 'n' dirty queries as well as for queries where the work required isn't in doing the calculation so much as reducing the query into a simple expression in the first place.

    In other words, simpygamma solves a problem that by and large doesn't exist.

  • by zokier on 1/29/14, 8:30 PM

    I wonder if any of the stuff developed for Gamma will trickle down (/up?) to ipython. Frankly it is bit surprising that they seem to have developed a new web-interactive system for (augmented) python instead of leveraging the ipython framework.
  • by frik on 1/29/14, 8:01 PM

    SymPy Gamma knows Boolean Logic like (x | y) & (x | ~y) & (~x | y) while Wolfram|Alpha doesn't.

    I would like to see an open source W|A in Julia instead of Python. It could be a great addition to e.g. Wikipedia.org

  • by grej on 1/29/14, 6:15 PM

    This is a great start and thanks for open sourcing this! Although I noticed that some of the plots throw errors (ex. "series(sin(x), x, pi/2")
  • by jrpt on 1/30/14, 4:04 AM

    I once almost started making something I called SymPyScript... think CoffeeScript for SymPy. You'd get the syntax of something like this: http://calculize.com/pickhardt/numerical_derivatives

    But it'd convert to SymPy for evaluation.

    In the end I called it Calculize and evaluated it with JS instead.

  • by jessaustin on 1/29/14, 9:03 PM

    On Chrome 33.0.1750.46, the up-down caret next to the topic headings doesn't respond to a click, even though the cursor indicates that it should. Clicking on the topic heading itself or even around the caret works, but the caret seems the most natural target to me.
  • by motters on 1/30/14, 8:08 AM

    Looks like just a wrapper around a rather limited Google service. Not much improvement on WA.
  • by Glyptodon on 1/29/14, 6:58 PM

    Hmm. It doesn't know who Harry Potter is. Much more math based, I guess?
  • by mrcactu5 on 1/29/14, 6:54 PM

    this is a few steps behind Wolfram Alpha, but at least it's open source