here is the map function
and here is sensor smoothing
http://www.arduino.cc/playground/main/smooth
I was just thinking that using these with the accelerometer output to control the motors..
I already have code making the motors move according to the accelerometer output but it is jerky as hell and wont stay balanced at all (but the motors do move the right direction.