Following Poromenos’ nifty “Hello World!” function, Jan Krueger posted a great explanation for why it works along with a general method for producing a trigonometric function for _any_ string you like:
The magic behind Poromenos’s function is the Fourier theorem: any “mostly” continuous and periodic function can be expressed as a sum of sines and cosines. I’m not going to bore you with the details; suffice to say that this also works for sampled functions, i.e. discrete series of values.
There’s an algorithm called DFT (Discrete Fourier Transform) that takes a series of N complex sample values and generates a corresponding Fourier series which encodes the various sine/cosine coefficients in N complex output values. In the special case of real input values (which is an extremely common case), you can effectively throw away half of these output values and take the remaining N real/imaginary components, do a bit of magic, and end up with coefficients for a function of the form:
f(t) = x0 + x1 cos(t) + x2 sin(t) + x3 cos(2t) + x4 sin(2t) + …
Now, f(2 pi n/N) returns exactly the (n+1)th character of the original string.
Follow the link and you’ll find a nifty C program that will produce a trigonometric function for any string you like.
HOWTO: encode a string into a complicated-looking trigonometric function











I completely dumbfounded one of my coworkers with this today. He tried to work it out in his head for about fifteen minutes before finally giving up and running it.
I never realized it could be used to dumbfound your colleagues, now I will have to start encoding random strings this way
Also, T-shirts of the function are finally available at http://www.cafepress.com/poromenos in various shapes!
// What's Trending
Raspberry Pi Design Contest
Seventeen Sneaky Secret Hides
Ten Tips for Screws and Screwdrivers
10 Things to Connect to Your Raspberry Pi
I Have a (Puzzling) Dream
Sneak Preview: The Wheeled Wonders of Maker Faire
The Oreo Separator Man at Maker Faire
Tribute to Kathreen Ricketson, Founder of Whipup.net
// What's Shared
A better way to slice a pumpkin
DIY Nerf Darts
In the Maker Shed: Minty Boost USB Charger
100 Dollar Store Organization Ideas for Craft Rooms and Beyond
Mad’s Mouse House
Lace Princess Crowns
I Have a (Puzzling) Dream
Play the Rings of a Tree Trunk Like a Record
// Most Commented
DIY Hacks & How To’s: Get Emergency Power from a Phone Line
Resin Casting: Going from CAD to Engineering-Grade Plastic Parts
Ten Tips for Screws and Screwdrivers
Ten Tips for Better Measurement
Makers on TV: Big Brain Theory
Pitches with Prototypes: Solar Tracker
Tool Review: BioLite CampStove
Grow: A Portable CNC Router System