The Wolfram|Alpha Blog is now part of the Wolfram Blog. Join us there for the latest on Wolfram|Alpha and other Wolfram offerings »
Itai Seggev

Mathematica Becomes a Wolfram|Alpha Interface

December 6, 2010 —
Comments Off

Wolfram|Alpha isn’t just the wolframalpha.com website; it’s a whole range of technologies. While the website may be the most familiar way to access these technologies, there are many potential uses and interfaces for the Wolfram|Alpha technology. We’ve already seen a few. Mobile apps for Google’s Android and Apple’s iOS make Wolfram|Alpha accessible anywhere. Widgets allow users to tap portions of Wolfram|Alpha and bring them into their own webpages. The Wolfram|Alpha API allows programmers to integrate Wolfram|Alpha’s data and computation abilities in their own programs. There are even private custom versions of Wolfram|Alpha used to analyze confidential corporate data.

But now there’s another interface to Wolfram|Alpha, one which brings with it a whole new set of capabilities: Mathematica. With the new Mathematica 8, you can access the Wolfram|Alpha engine directly from within Mathematica. Inside a Mathematica notebook document, just type == at the beginning of a line; you’ll get an orange Spikey icon indicating that Mathematica is ready to perform a Wolfram|Alpha query. Now simply type anything that you would type into the Wolfram|Alpha website. You’ll get back the same results as on the website—and more! Using the full power of the Mathematica software, this interface to Wolfram|Alpha allows new levels of interactivity and detail.

In Mathematica, all graphics can be resized, and three-dimensional graphics can be rotated. Moreover, since Mathematica receives the underlying vector graphic from Wolfram|Alpha and not simply a bit-mapped image, this means that enlarging a graphic provides greater detail instead of a boxy image. For example, let’s look at everyone’s favorite three-dimensional surface, the Mathematica Spikey.

Mathematica Spikey

By simply clicking and dragging, you can rotate the Spikey. To resize, click the resize points on the frame that appear after clicking on the graphic.

Resizing the Spikey in Mathematica

Moreover, if you right-click (or Control-click on a Mac) the graphic, you will get a context menu that allows you to copy the graphic to the clipboard for use in another program, to print it out, or to save it in a variety of file formats, which include PDF, PNG, JPEG, TIFF, and EPS. Again, since Mathematica knows the underlying vector graphic, you can set a large resolution in the saved file to create a high-quality graphic.

The above example shows how you can interact with website results in new ways. However, Wolfram|Alpha knows when the Mathematica interface is being used to access it and can provide new results that are simply not possible on the website. Consider the following query. On the live site, you get a single image of one view of the plot. By doing this inside of Mathematica, you automatically get a resizable and rotatable graphic.

Plot of x sin(xy)

Yet in this case, you get even more features, including sliders for changing the x and y ranges in the plot. You can now zoom in to focus on a particular feature or zoom out to see how the function behaves over a larger area. By setting, for example, xmin and ymin to 0, we see how the function behaves in the first quadrant (the region where both variables are positive).

Plot of sin(xy)

Another key innovation of the Mathematica interface to Wolfram|Alpha is called exposed data. Suppose you wanted to compare the growth of Las Vegas, Nevada and Phoenix, Arizona, two major American cities that have grown tremendously over the last three decades.

Comparing population histories of Las Vegas and Pheonix

Much like on the website, you see a plot of the population histories. But suppose you wanted to know the exact data points that were used to create that plot. On the live site, the best you can do is estimate where the dots are. But in Mathematica 8, you can request them directly. Click the plus sign just to the right of the Log scale button, and select “Formatted data” from the menu that appears.

Requesting formatted data

The following output, a nicely formatted version of the data, will be generated:

Formatted data

If you want to get these data into another program, say, Microsoft Excel, you have a couple of options. One is to select the table with your mouse, right click (Control-click on Macs), and select “Copy As > Plaintext”. This will create a table on the clipboard, free of any Mathematica-specific formatting, which you can paste into your favorite spreadsheet. Another option, which may be more useful if you’re going to do serious data analysis, would be to return to the plus sign menu and requested the Time series data instead. This creates a machine-processable version of the data points.

Machine-processable data points

You can then export this to a Microsoft Excel 2003 spreadsheet named vegas_phoenix_pops.xls using the following command. Each city will have a data table on its own sheet in the resulting spreadsheet. If you wish to use the Microsoft Excel 2007 format, simply replace the .xls extension with the .xlsx extension.

Data in Microsoft Excel format

Several types of exposed data formats are available for different purposes. We’ve just seen two. Number data, Quantity data, and Formula data allow you to quickly extract just those elements from a table. (A quantity is a measurement which includes a number and a unit, like “3 feet”.) Finally, Sound data allows you to extract the sounds that sometimes appear in Wolfram|Alpha results. You can then export these sounds as MIDI files (for musical sounds) or WAV, FLAC, and AIFF files (for more general sounds). Only the types of data that make sense for a particular result are displayed in the plus sign menu. We expect that as more data is integrated into this technology, additional types of exposed data will come into being. Fortunately, the Mathematica client will automatically learn about these new types and reveal them as they become available.

As you can see, Mathematica 8 takes the Wolfram|Alpha experience to a whole new level. From interactivity to manipulation to providing additional information, almost every part of the Wolfram|Alpha technology is enhanced when combined with the new Mathematica. You can purchase or upgrade to Mathematica 8 here, or you can enter Wolfram|Alpha’s Deck the Halls with Facts & Knowledge Holiday Gift-Away for a chance to win a copy of Mathematica 8 Professional. Enjoy!

7 Comments

Until now I have had the impression that the full resources of Mathematica were available to W|A subject to a time limitation because it was free. The first page of this blog does not emphasize enough the enormous increase that comes with using the ‘paid for’ Mathematica API. I suggest that this be given greater emphasis on the first page to encourage the reader to click the contine button.

Posted by Brian Gilbert December 6, 2010 at 3:01 pm

Exposed Data is the best thing since M7! There are many limitations when searching for an economics term like velocity of money. I can only imagine getting my hands on the exposed data on something that takes some calculation, which Alpha will do for me! Thanks for the information!

Posted by Samuel Chen December 7, 2010 at 1:53 am

The opening page for this item has the image of the spikey and underneath its says ‘By clicking on this……’
But clicking on the image has no effect. You have to click ‘continue’ and then it works on the fresh image of the spikey appears. A minor edit should fix it.

Posted by Brian Gilbert December 7, 2010 at 2:24 am

Mathematica has always had more capabilities than W|A.
No limit to query length.
Far more PROGRAMMING ability, beyond the scripting available in a web page.
A more natural math interface with all the symbols (much better than typing Integrate every time)
Significantly larger datasets.
Ability to save interactive notebooks.
etc.

This blog is not about the paid API, which is a web programming interface for W|A. (Wolfram can correct me if necessary.) My understandingis Mathematica has far more capabilities than both the free W|A and the W|A API. For example I’ve seen entire interactive math tutorials explaining derivatives and integrals.

Posted by Nickalh December 7, 2010 at 2:35 am

The mathematica 8 documentation is aaccessible free at
http://reference.wolfram.com/mathematica/guide/Mathematica.html

and a 15 day free trial at
http://www.wolfram.com/mathematica/trial/

Posted by Brian Gilbert December 9, 2010 at 5:01 am

I have been wondering since the day that Wolfram|Alpha came out whether Wolfram would leverage it’s power for use in Mathmatica. Here is the answer.

I think that this is a brilliant development decision.

Posted by reg.doug December 10, 2010 at 6:14 pm

Actually, everything you said here was available with Mathematica user “only”, are actually available to W|A Pro users as well.
If you want to interact with the x sin(xy) wave, you can. You can also move it around in 3D, (assuming you have downloaded the free CDF Player), and you can also change the x&y axis values …
What you have to do for that is only click on the bottom right of the image, on the enable interactivity button.
You can also download the data of the query you made.Yes, and in all those format you want it.

You just have to go with the pro version.

The difference though, is when you ask for multiple object to be plotted, and other neet stuff that Mathematica do that W|A don’t, but you haven`t talk about any of this here.

Everything you bringned up, is doable in the pro version of W|A.

I tested it.

Posted by Sebastien February 15, 2015 at 9:11 pm