Well, I have a computer architecture exam in six hours and can’t be bothered, so I figured I would realize a lifelong dream of mine, and make a program that prints “Hello world!” using curve fitting techniques. Enlisting the help of a good friend with numerous mathematical papers under his belt (ostensibly because he could not afford a tighter belt), MATLAB and a longing for procrastination, we embarked on this perilous journey. After many, many hours of fitting and discarding data, I can finally present to you my masterpiece.
This function returns the ascii ordinal for each of the letters of “Hello, world!” at each integer position (0, 1, 2, 3 etc). I call it… The “Hello world!” function! A simple Python script shows it in all its glory:
from math import *
def f(x):
return int(round(96.75 + -21.98*cos(x*1.118) + 13.29*sin(x*1.118) + -8.387*cos(2*x*1.118) \
+ 17.94*sin(2*x*1.118) + 1.265*cos(3*x*1.118) + 16.58*sin(3*x*1.118) \
+ 3.988*cos(4*x*1.118) + 8.463*sin(4*x*1.118) + 0.3583*cos(5*x*1.118) \
+ 5.878*sin(5*x*1.118)))
print "".join([chr(f(x)) for x in range(12)])
and that’s it! Just save this as hello.py
and run it, and the phrase
“Hello world!” will be prominently etched upon your screen for future
generations to enjoy. I, along with my friend and colleague, reserve all
rights to this code, which will be coming soon to a scientific
conference near you. I will also be waiting for my Nobel prize
nomination.
In case you are wondering, here are the plot points and the fitted function:
EDIT: My good friend Iain (of “Lasertoast”:http://lasertoast.com/ fame) has sent me this fantastic etching of the curve on stainless steel, so now I’ll try to milk him for all the etchings I can. Drop them a line if you want anything etched, I can guarantee your satisfaction.