Thursday, 9 October 2008

"I Don't Get It!"


It was a quote from Augustus De Morgan that started it. "Mr.Ballew" he says, "I don't get it," This was a young man who usually gets it, and when he doesn't he has to scratch the itch to know. The quote was on my board, so I was the logical one to ask.

The quote (actually a slight modification of the true words of De Morgan) said:
Imagine a person with a gift of ridicule . He might say first that a negative quantity has no logarithm; secondly he might add that a negative quantity has no square root; and finally he could comment that the ratio of the first non-existent to the second is the same as the circumference of a circle is to the diameter.
"So tell me what you DO understand." I asked

He explained that he thought the "negative has no logarithm" means that you couldn't take logarithm of a negative because the domain of logarithms was limited to values greater than zero. The teacher "stayed still, and Br'er Fox, he lay low". "And I guess the second part is that you can't take the square root of a negative number."... and now the teacher raises one eyebrow..."Ok, you can, but you don't get a real number, you get an imaginary number"...

As the teacher unfolds his arms, one long sweep brings a finger to slide beneath the last line... and then ... . "Ok, and the ratio of the circumference of a circle to the diameter is Π " .. at last the teacher speaks...."Good." and he walks to the board to pick up a marker.

"I think you have seen this somewhere, even if you were not sure what it meant." and on the board he writes Euler's beautiful result (which Cotes shoud get more credit for); eπ i = -1

The student admits to have seen it, and the teacher negotiates an agreement to accept it, or at least accept that De Morgan believed it was true. "Now let's take the natural log of both sides, and we get..." and he writes,... Π i = ln(-1) Now we are in the part that the teacher loves... the student is hooked.. its art and entertainment and poetry and math all in one... and the clever student sees the first inkling of the result... Pi is waiting on one side... the log of a negative on the other... and then he sees all.....

" Ahhhh," he says, "just divide by i... "... The teacher yeilds the marker, ...passing the torch to a new generation??? ... and feels a pang of envy.....to be so bright and so young... and the young man writes Π = ln(-1) / i..... and then thinking of the quote, rewrites it as

Monday, 6 October 2008

Standard Deviation Computation in One Pass


One more new (to me) item in my explorations of the standard deviation. I came across a one-pass method of computing the sample standard deviation which seems to be exact, not an approximation.

Normally the way we compute the sample standard deviation requires two passes through the data, one where we calculate the mean, then again to find the deviations from the mean to calculate the RMS of the deviations. This method is good for most cases where the data comes to you in a set and complete. But in cases where you have data streaming in constantly, say as from the Hubble telescope or something, having to go back and recalculate the total each time may be time consuming. What is needed is a way to take the old results and produce the new result with the one piece of data added.

I found just such a result at a page From John D Cook He writes, "This better way of computing variance goes back to a 1962 paper by B. P. Welford and is presented in Donald Knuth's Art of Computer Programming Vol 2, page 232, 3rd edition. Although this solution has been known for decades, not enough people know about it. ...It is not obvious that the method is correct even in exact arithmetic. It's even less obvious that the method has superior numerical properties, but it does. The algorithm is as follows.

Initialize M1 = x1 and S1 = 0.

For subsequent x's, use the recurrence formulas

Mk = Mk-1+ (xk - Mk-1)/k

Sk = Sk-1 + (xk - Mk-1)*(xk - Mk).

For 2 ≤ k ≤ n, σ2 = Sk/(n - 1)."
although I think the sigma-squared should be s2 from the values I get and the division by n-1. For those who use the Ti 84 and such calculator, this is an easy program to write, or you may download a program I quickly wrote here. It asks for each x in turn, and reports the running mean and sk after each entry.

Saturday, 4 October 2008

A Nice, but Tough, Problem

Click on images to see higher resolution


This one is for my old teaching friend, Al Harmon, who has asked and answered problems for me and from me for many years... This is a variation of a problem that was on the "Wild About Math" website, adjusted a little to make it more compatible to students at HS level..

If you take a number (let's use 200 for an example) and think of all the ways you could write it as a sum or positive integers... (100+100, or 2 + 105 + 93 or... 1+1+1+.....+1) these are called the partitions of the number. Now if you take all the integers in the partition and multiply them together, which one would give the largest product? Obviously 1+1+1...+1 will not amount to a very large product.... 100* 100 is lots larger, and 66* 67 * 67 is even larger...almost 3 (10 5),... which might make you think... aha...more small numbers is better... so 2100 will be great! ...Well it is better, its about 1.126 (1030 ) which is way larger than the others... but can we make it bigger???... What if we experiment a little with other values we try five, and find 5 40 = about 9 (10 27) .... big, but not as big as 2100 ...

well, what about 4 50... wait, that is exactly the same as 2100 by the exponent laws... so using all twos or all fours gives the same result... and fives yeilds less

Hmmmm..... We can't use all threes, but just for the heck of it, we try using two threes in place of three of the twos... what would 297 (32) give us...... aha... more.... just a little more, but more... about 1.46 (1030)... would more threes help??? would lots of threes help??? We could try using all threes and as many twos as would be left over at the end... 66 threes and 1 two would give us 6.18 (1031) more than any of the others. But Is THAT the largest... how can we convince ourselves that using threes is better than anything else?

Side trip to remember some ideas about logarithms.... remember that if a>b then ln(a) > ln(b) ... bigger numbers have bigger logs...so maximizing the product is the same as maximizing the log of the product.... and when we multiply numbers together, we are adding their logarithms to get the log of the product...[ln (bc)=lln (b) + ln(c)] ... now we can use that to think about how the log of the product changes...each time we use a number from the partition of the value, we add x to the sum, and ln(x) to the ln of the product.. so whatever number has the largest ratio of ln(x)/x will be the best choice to use.... If we graph the function (I used winplot, which is a wonderful FREE software.. ) we see the graph below.

It seems to be highest somewhere between 2 and 3, and a calculus student should be able to figure out that happens when f'(x) = 0, and since the numerator of the derivative is 1- ln(x), we know that will happen when ln(x) = 1, or x=e..... but that is NOT an integer... but we do notice the slope is always positive to the left of x=e, and always negative to the right of x=e, so whichever one of the two adjacent integers is most efficient, will be the most efficient.. we find that ln(3)/3 > ln(2)/2 and our question is answered.

Wednesday, 1 October 2008

Fibonacci's Thumb

One of those things that goes around the internet math groups every now and then, is going around again.... things to do with the Fibonacci sequence. I call them Fibonacci Rules of thumb... Ok, you remember Fibonacci, he introduced the Arabic numbers to the west with his famous book, The Liber Abaci.. and had a problem about rabbits where the number each month was given by 1, 1, 2, 3, 5, 8, 13, 21, etc....... YEAH, the one in the DaVinci Code!

The most common Fibonacci Rule of Thumb is converting between miles and kilometers. Suppose you are zipping along in Canada and the speed limit is in Km/hr, and you wonder..."Gosh, just how fast AM I driving?". So take your speedometer reading in good old miles per hour, and think of the number in the fibonacci sequence nearest this one... suppose you are driving a modest 55 mph.. which just happens to be a number in the sequence. Find the next number in the sequence, in this case 89, and that is a really good estimate of your speed in Km/hr (OK, I think it works out to be more like 88.5, but you get the idea).

So why does that work? The typical conversion is miles = 1.609344 kilometers (I know, I just googled it); and if you take any Fibonacci number, and divide it by the one in front, you get about that number. As the numbers get larger and larger, the ratios get closer and closer to 1.618033989.... so the ratios are pretty close. Of course you could use it for lots of other things, and with a little torture, you can make it work for less usual measures... If you want to know how many seconds (appx) in N years, where N is a Fibonacci number, then you can just take the next Fibonacci number, double it, and multiply by 107... So for example, If you wanted to find the number of seconds in 5 years... the next Fibonacci number is 8... double that to get 16... and now add the seven zeros to get 160,000,000 seconds in five years. You can check that one on your own.

And if you are STILL not convinced, would you be impressed if I told you that for N electrons (where N is a Fibonacci number), you can find the charge in Couloumbs by taking the next Fibonacci number, and multiply by 10-19... NOW THAT IS USEFUL STUFF