Doing math (integration) with arduino

There is a PID control algorythem someone wrote for the arduino.
http://www.arduino.cc/playground/Code/PIDLibrary
There is the sompler expresso library also.
http://www.arduino.cc/playground/Main/BarebonesPIDForEspresso
I think this is what you are looking for.