What’s the angle between two continuous functions?


I want to write about something very cool I learned about in my Linear Algebra class the other day.
Since since the sum of two continuous functions is continuous, and a continuous function multiplied by a scalar is continuous, the set of all continuous functions defined on the domain [a,b] is a vector space.
You can define an inner product [F|G] as the integral of the product F*G from point a to b (This operation has everything it takes to be an inner product). The inner product naturally gives us a norm. ||F|| = sqrt([F|F]), and an angle between functions: [F|G] = cos(theta) * ||F||||G||. The norm gives us a distance ||F-G||.
So now we have distance between functions and angles between functions. That means we can project a function onto another the same way that we can project a vector onto another in R^n. That’s awesome! And potentially useful. =P

(Edit: Yes, it’s useful. You can deduce the Fourier Series by noting that the cosine and sine as basis for this vector space)


Word Challenge cheating program


I have been playing Word Challenge on facebook, it is a very fun game. It made me start playing with anagrams, and I decided to write an anagram-solving program. However, I read about Donald Knuth’s insight that if you sort a word and its anagram alphabetically, it will give the same word.
sergio -> egiors
orgies -> egiors
So, by using a hash table it is pretty easy to find anagrams in constant time. You just have to associate a word made up of ordered letters to a list of all the possible anagrams. You can do it in O(n) by iterating through a dictionary file. There’s no problem to solve when there is already an optimal solution.
I then decided to write a program that finds every possible word that can be formed by a group of letters (Which would be perfect to use if I ever wanted to cheat on Word Challenge. Which of course I never would! =P) .

Continue reading