One thing I would suggest would be to get rid of all the floating point calculations and use fixed-point integer computation. Virtually everything should be able to be re-factored into a lookup table in PROGMEM. That would be faster and use less RAM.