HOWTO - Encode any string into a trigonometric function
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
Posted by Jason Striegel |
Apr 5, 2008 06:49 PM
Math |
Permalink
| Comments (2)
Recent Entries
- Turn an ATX power supply into a lab PSU
- Second Life on an Apple II
- Nice overview of the YouTube API
- Javascript Super Mario
- Automatic outbound link analytics with jQuery
- Silence your hard drive
- Air on the EeePC
- Relational database using jQuery and HTML tables
- Javascript marker clustering for Google Maps
- Windows Mobile del.icio.us plugin
Comments
Newest comments listed first.
| Posted by: I completely dumbfounded one of my coworkers with this today. on April 8, 2008 at 3:35 PM |
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.
| Posted by: Poromenos on April 16, 2008 at 6:12 PM |
I never realized it could be used to dumbfound your colleagues, now I will have to start encoding random strings this way :P
Also, T-shirts of the function are finally available at http://www.cafepress.com/poromenos in various shapes!
Leave a comment
Bloggers
Welcome to the Hacks Blog!
Categories
- Ajax
- Amazon
- AppleTV
- Astronomy
- BlackBerry
- Blogging
- Body
- Cars
- Cryptography
- Data
- Education
- Electronics
- Energy
- Events
- Excel
- Excerpts
- Firefox
- Flash
- Flickr
- Flying Things
- Food
- Gaming
- Gmail
- Google Earth
- Google Maps
- Government
- Greasemonkey
- Hacks Series
- Hackszine Podcast
- Halo
- Hardware
- Home
- Home Theater
- iPhone
- iPod
- IRC
- iTunes
- Java
- Kindle
- Knoppix
- Language
- LEGO
- Life
- Lifehacker
- Linux
- Linux Desktop
- Linux Multimedia
- Linux Server
- Mac
- Mapping
- Math
- Microsoft Office
- Mind
- Mind Performance
- Mobile Phones
- Music
- MySpace
- MySQL
- NetFlix
- Network Security
- olpc
- OpenOffice
- Outdoor
- Parenting
- PCs
- PDAs
- Perl
- Philosophy
- Photography
- PHP
- Pleo
- Podcast
- Podcasting
- Productivity
- PSP
- Retro Computing
- Retro Gaming
- Science
- Screencasts
- Shopping
- Skype
- Smart Home
- Software Engineering
- Sports
- SQL
- Statistics
- Survival
- TiVo
- Transportation
- Travel
- Ubuntu
- Video
- Virtualization
- Visual Studio
- VoIP
- Web
- Web Site Measurement
- Windows
- Windows Server
- Wireless
- Word
- World
- Xbox
- Yahoo!
- YouTube
Archives
Recent Posts
- Turn an ATX power supply into a lab PSU
- Second Life on an Apple II
- Nice overview of the YouTube API
- Javascript Super Mario
- Automatic outbound link analytics with jQuery
- Silence your hard drive
- Air on the EeePC
- Relational database using jQuery and HTML tables
- Javascript marker clustering for Google Maps
- Windows Mobile del.icio.us plugin
www.flickr.com
|




