Kind of on the topic - I know there is a way to calculate a square root without a calculator. Of course you can do it the "brute force" way, but one day my music teacher told be about a better way, but never explained it in detail. Does someone know how to do this?
I don't want to sound smug or anything, but didn't you study it in school? In Spain we learn it in fifth or sixth grade, just after learning the concept of square root. I thought it was basic enough to be studied at about that age in the rest of the world.
The algorithm is a little complicated compared to other things that we study at that age, but it's not really difficult, although most (and I mean MOST) people, even engineers and such, forget it when they don't need it any more. It infuriates me a little that no teacher explained to us why did it work, but that gave me oportunity to "reverse engineer" the method a few years later, and expand it to a generic n-root algorithm.
I don't know, that's why I just talked about "the rest of the world". I'm just surprised that this is not as common as I thought it was. Cultural blindness, I guess.
I'm sorry, that wasn't at all my intention. In any case, I wouldn't be mocking him, but the educational system he studied under (which definitely wouldn't be his fault; to be honest, I've also suffered a quite bad educational system). And I didn't answer him because someone else had done so already in another comment, linking to wikipedia, so I didn't want to be redundant.
We also learned it in, I think, 4th grade or perhaps 5th. This was in the US. And yes, I've also forgotten it. I don't think I ever used the method outside of that lesson.
I guess it's this: if you have a guess G at the square root of N, compute N/G. If G is too large, N/G will be too small and vice versa (well, as long as your initial guess is larger than zero)
Also, G' = (G+N/G)/2 will be a better guess than G.
Absolutely hilarious and amazingly magical method of algorithmically computing square roots. It right shifts a floating point number to essentially divide the exponent component by 2. Then it uses a weird magic number trick to get the correct result. Awesome random programming trivia.