Friday 12 June 2015

The Best Site on the Internet: Wolfram|Alpha

www.wolframalpha.com




Wednesday night, to wind down after a busy day of Unity, I was playing some Skyrim. I came across a spell (added by a mod called "Apocalypse Spells") that offered a lot of armor, but had a 2% chance to fail every second.

I tried to estimate how long this would last, on average, but that proved to be rather complex and not easy to estimate. I initially thought I could build a quick spreadsheet to do the math, but on a whim I decided to try using Wolfram|Alpha, which I haven't looked at in ages.

Rather than using pictures, I'm going to offer web links, so you can see the results at each stage for yourself.

The journey started with me getting the formula completely wrong, but is still a tale worth telling because of how the site handled it.
  • I initially came up with the nutty idea that the formula was y = 1/(50-x).
  • I noted the asymptote, and was impressed by how well the site handled it. But I didn't want the chart at 50, I wanted it from 0 to 60, the official lifespan of the spell.
  • What I thought I really wanted (though I was wrong) was the area under the curve. So I tried to see if the site could handle integrals.
  • I then realized that the presence of the asymptote (caused by a divide by 0), meant my formula had to be wrong. I realized that I needed to use permutations and combinations--but my grade 10 math was many years ago, so I decided to see if Wolfram|Alpha could explain how they worked.
  • I was impressed! All sorts of functions were available, including ones I wasn't familiar with. Curious as to what a multinomial was (just another name for a polynomial?), I looked it up.
  • Then I saw the chart representing the frequency of the word's usage in history! Wow! Did it have this information on all kinds of words, or just math stuff? So I decided to look up a random, generic word: "fruit".
  • But Wolfram|Alpha figured that I was asking about the concept of fruit itself, rather than the word, "fruit". So it spat out all kinds of nutritional information, averaging all the data it had on different kinds of fruit! Wow! But it did still have information on fruit as a word, so I clicked that.
  • And down half a screen or so was the graph of the word's frequency of usage throughout history. Wild!
  • At this point I decided to get back to the problem at hand, and realized that I needed to invert my problem: I wasn't trying to solve for how often 2% would get selected, but rather how likely it was that the other 98% would get selected consecutively, which is the formula y = (49/50)^x from 0 to 60.
  • Roughly eyeballing the graph, it looked like the spell would last 10 seconds 80% of the time, 35 seconds 50% of the time, and the full 60 seconds 30% of the time.
There's probably a better way of getting these exact values, either by doing the math or by enabling interactivity on the graph (I haven't tried that yet), but this information was sufficient for me to decide if I wanted to use the spell or not.

Also, it's possible I've done my math wrong. Even if I am right, it would be ideal for x to be an integer value rather than a real number. If anybody finds a better way to do this, feel free to put it in a comment. Thanks!

But I've decided that this is now the Best Site on the Internet. The sheer power of its ability to take basic questions and pull data and calculations together in a matter of seconds is staggering. It's definitely a tool I'm going to learn to use more in the future.

No comments:

Post a Comment