Mathematica Becomes a Wolfram|Alpha Interface
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.
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.
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.
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).
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.
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.
The following output, a nicely formatted version of the data, will be generated:
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.
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.
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!