5

How can I analyse data stored in Mathematica using Wolfram | Alpha? Here is an example:

I have a list: a = {1, 2, 3, 4, 5}

I can plot it in Mathematica, like this:

enter image description here

But once I try to use Wolfram | Alpha, an error message appears:

enter image description here

How can I perform different types of analyses on Mathematica data using Wolfram | Alpha?

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
Darren Lee
  • 587
  • 4
  • 11

1 Answers1

4

For your specific example, the following does what you want:

= List plot of {1,2,3,4,5}

But in general don't send WolframAlpha inputs as though you're using Mathematica. Just send free-form linguistic input i.e. plain English (or other languages it understands). For example, to plot the Sine function don't type Plot[Sin[x],{x,-3,3}]

just type "plot sin of x from -3 to 3"

Interestingly, if you send the following = a + 2 to WolframAlpha, it returns the correct result, adding 2 to each element of a. But using a in place of the list in the free-form input seems to confuse WolframAlpha.

RunnyKine
  • 33,088
  • 3
  • 109
  • 176
  • 2
    I think the gist of the question is: how can we transfer data present in Mathematica to Wolfram|Alpha? That is, use the variable a directly. (I don't think it's directly possible, at least not without W|A Pro (??)) – Szabolcs Mar 01 '13 at 04:23
  • @Szabolcs see my edit above. It works partially. – RunnyKine Mar 01 '13 at 04:25
  • Interesting observation, and +1 for that! – Szabolcs Mar 01 '13 at 04:25
  • It seems W|A is very quirky: if you give the list a longer name, it'll recognize it: mylist = {1, 2, 4, 8, 20}, = plot mylist. But the plot won't exactly be what you'd expect ... – Szabolcs Mar 01 '13 at 04:43
  • @Szabolcs, yes you're right, that's what I meant by W|A being confused. I got a plot of x^2 instead. – RunnyKine Mar 01 '13 at 04:47
  • @Szabolcs and Runny - When you type =a+2 into Mathematica, it sends it WolframAlpha, interprets it, and (if possible) returns a simple Mathematica expression to generate the result. You can do this whether a is defined in your mathematica session or not. If a is defined, then it will evaluate as normal once back in your Mathematica session. But a was always just "a" as far as WolframAlpha was concerned. – Mark McClure Mar 01 '13 at 04:48
  • @Mark What has always bothered me about W|A is that it doesn't have a reliable syntax. Sometimes it's difficult to guess the right input to get it what I want ... like in this mylist example. The name of the variable influences the result. One other simple example I always wanted to get working but could never figure out is to list countries ordered by annual births per population. It has the data, but the natural language interface seems to make it impossible to get it to do the division (births/population) and the ordering at the same time. – Szabolcs Mar 01 '13 at 04:51
  • 2
    @Szabolcs I'm not sure that W|A has syntax at all - let alone "reliable syntax". :) – Mark McClure Mar 01 '13 at 04:54
  • @MarkMcClure: I don't think what you say about a only being evaluated in your Mathematica session is true: depending on your preference settings ("Internet Connectivity" -> "Wolfram Alpha Settings") there is "session data" sent to the WoframAlpha servers -- and that includes the values of global variables, as can be seen from the "Session Information" dialog that pops up when you set "Mathematica Session Info" to "Ask before sending". As for the syntax issue, I think this is by design: "Free-form natural language input" looks pretty much like the opposite of "reliable syntax" :-) – Albert Retey Mar 01 '13 at 14:30
  • @AlbertRetey Of course, you're absolutely correct that you can generally send session info from Mathematica to W|A via the WolframAlpha commands. My claim is very specific to the input "plot a". The reason is that "plot a" has it's own valid interpretation and this is what the computational code ultimately sees. More examples might illuminate but, obviously, this is taking us a bit far afield from the original question. – Mark McClure Mar 01 '13 at 16:12
  • @MarkMcClure: My point was that the WolframAlpha commands generally send session data, but it's up to the servers interpretation of the free form input whether it makes use of that data. For the a+2 and plot a cases it indeed looks like it doesn't make use of the session data and your interpretation of what happens seems correct. The session data dialog indicates that the value of a is actually sent to the server, but then is ignored. Anyway, I fully agree that this is taking us far away from the original question... – Albert Retey Mar 02 '13 at 00:29