
SymPy Gamma: an open-source, Python-based alternative to Wolfram Alpha - gioi
http://www.sympygamma.com/
======
asmeurer
(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...](http://conference.scipy.org/scipy2013/presentation_detail.php?id=183).
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/](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%...](http://www.sympygamma.com/input/?i=integrate%28sin%28x%29*x%29).
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.

~~~
mkesper
_The important thing to note about SymPy Gamma is that it does only the
mathematics part of WolframAlpha._

Please tell so clearly so you don't get bad credit for non-implemented
features.

------
primitivesuave
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...](http://www.wolframalpha.com/input/?i=I+have+two+apples%2C+Jill+has+three+apples.+How+many+apples+do+we+both+have%3F)

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...](http://www.wolframalpha.com/input/?i=I+have+a+fever+and+a+runny+nose)

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.

~~~
topynate
"I have two mangoes, Jill has three mangoes. How many mangoes do we both
have?"

[http://www.wolframalpha.com/input/?i=I+have+two+mangoes%2C+J...](http://www.wolframalpha.com/input/?i=I+have+two+mangoes%2C+Jill+has+three+mangoes.+How+many+mangoes+do+we+both+have%3F)

Doesn't work, even though Wolfram Alpha knows what mangoes are enough to give
me the nutritional value of three of them as its response instead.

'Oranges' as the noun works quickly. 'Pens' doesn't work at all, so it's
hardly surprising that 'doowats' also fails. Surprisingly, even 'pears' is a
fruit too far.

On the other hand, "I have two apples and one orange, Jill has three oranges.
How many oranges do we both have?" works very well.

So I have to ask, is this just a trick? I mean, did you program it to handle
apples and oranges specifically, without attempting to do any sort of semantic
comprehension? Because this is a big failing of Wolfram Alpha for me. It
'knows' things but it doesn't know them. It knows that a mango has 84 calories
but not that it's countable. Or perhaps it does know that and that knowledge
just doesn't propagate to more complex queries.

~~~
e12e
Yeah, it doesn't appear to be very advanced. I tried:

    
    
       I have two mangoes, Jill has three mangoes. Alan has
       three oranges, and I have two apples and a carrot. How
       many mangoes do we have? How many fruits do we all have?
       How long can we survive?
    

One would think it did some basic parsing, and managed to file away three
oranges and two apples in a parse tree of some kind -- and if those were
associated with "fruits" \-- it should be able to answer?

And if it _were_ able to answer, one might be able to have it hand out advice
on diets ("Give me 30 examples of a 3000 calorie diet featuring no red meat")
and a lot of other things that would be "easy" to answer based on ingesting
some pretty standard databases.

~~~
primitivesuave
I see a couple issues with handling your "30 examples of 3000 calorie diet
with no red meat" query. One is the complexity of finding a subset of all the
food items in the Wolfram Alpha database that add up to around 3000, you could
certainly make an algorithm to do this but all queries time out after a few
seconds so it is likely to fail. The other is that it would have to understand
which foods constitute red meat, which it doesn't (try searching "red meat
food", the only red meat it knows is a movie by that name). Even if it did,
you would need to categorize all foods so the query worked with "3000 calorie
diet with no vegetables" and so on. Obviously if it can solve word problems
about apples but can't solve the same problems about mangoes, computation like
this is far beyond what they will accomplish in many years.

~~~
e12e
Oh, yes, that might have been the "long way 'round" of doing it. I was
alluding at crawling a recipe database (with calories per meal), and filtering
out those with red meat, then doing a random selection. Not very hard at all.

------
techwizrd
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.

------
dekhn
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...](https://code.google.com/p/pymathematic/source/browse/trunk/examples/pyml.py?spec=svn14&r=14)

------
mekane8
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=5+gallons+%2F+12+fl+oz).

[http://www.sympygamma.com/input/?i=how+many+calories+in+a+cu...](http://www.sympygamma.com/input/?i=how+many+calories+in+a+cubic+light+year+of+strawberries)

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

~~~
dmd
Just out of curiosity, why use W|A for unit conversions vs. using Google's
calculator for that?

~~~
capnrefsmmat
Because W|A can tell me that the caloric equivalent of the molasses spilled in
the Boston Molasses Disaster of 1919 is 36 kilotons of TNT:

[http://www.wolframalpha.com/input/?i=%28Calories+in+2300000+...](http://www.wolframalpha.com/input/?i=%28Calories+in+2300000+gallons+of+molasses%29+in+kilotons+of+TNT)
[https://en.wikipedia.org/wiki/Boston_Molasses_Disaster](https://en.wikipedia.org/wiki/Boston_Molasses_Disaster)

So you can do unit conversions with all sorts of weird facts, like the
nutritional content of molasses.

------
roryokane
See also Mathics (try online at [http://mathics.net/;](http://mathics.net/;)
info at [http://mathics.org/](http://mathics.org/)), which wraps SymPy with a
Mathematica-compatible programming language.

------
nathanb
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.

------
zokier
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.

------
frik
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

~~~
mafuyu
Wolfram|Alpha does take boolean, but in the notation that Mathematica likes
(&&, ||, !, etc). You can also write it out in plain english (NOT A OR B,
etc).

I used it to simplify some kmaps for class the other day and it's very nice:
prints out a truth table and various types of minimal forms.

~~~
reeses
"Conventional" boolean operators work as well. Again, I suspect that it
depends on whether a developer has mapped something ToExpression can consume,
either via forms, boxes, or unlocking the function itself. (This would be
consistent with the "throw more mud at it" comment.)

As a Mathematica and WApro user, I find most of the utility in not having to
import random datasets myself. As every researcher, I have a disgusting
library of scripts that often involve curl, groovy, awk, sed, etc., to pull
info into mma. It's nice when that becomes SEP[1].

[http://www.wolframalpha.com/input/?i=+%28x+%E2%88%A8+y%29+%E...](http://www.wolframalpha.com/input/?i=+%28x+%E2%88%A8+y%29+%E2%88%A7+%28x+%E2%88%A8+%C2%ACy%29+%E2%88%A7+%28%C2%ACx+%E2%88%A8+y%29+)

[1] Someone Else's Problem

------
grej
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")

~~~
catchmrbharath
Series are not supported for plotting. Could you please raise a bug at [1].

[https://code.google.com/p/sympy/](https://code.google.com/p/sympy/)

~~~
catchmrbharath
We should be catching the exception though.

------
jrpt
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](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.

------
jessaustin
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.

~~~
aaren
Same on Firefox. I spent a while clicking - it seemed natural.

------
motters
Looks like just a wrapper around a rather limited Google service. Not much
improvement on WA.

------
Glyptodon
Hmm. It doesn't know who Harry Potter is. Much more math based, I guess?

~~~
catchmrbharath
Yes. Its more of a computer algebra system (a mathematica equivalent). Have a
look at [http://sympy.org/en/index.html](http://sympy.org/en/index.html).

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

