I\'ve been experimenting with the compass and gyroscope on iPhone 4 and would like some help with an issue I\'m having. I want to compensate for the slowness of the compass
The direction of the yaw axis vector is undefined when in zero gravity (or free fall, or close enough).
In order to do synchronization while in motion, you need to create a filter for your "horizontal" value that has the same lag/delay response characteristics as the magnetic compass. Either that, or wait until motion stops long enough for both values to settle before recalculating the offset.