I apparently wrote this back at the end of May, but never uploaded it here...
I figured out what was wrong with my program. There were two things:
1. I needed to use the output as the new input, instead of sending a set of predetermined points through the function to generate output.
2. I was taking the square root of a number that shouldn't