Harsh,
If the sensors are stationary, then over the long term (many seconds) the gyro has no effect on the 9-axis yaw computation. The reason for this is that the accelerometer and magnetometer provide the only steady state orientation information. The 9-axis algorithm will always converge back to the eCompass solution if the sensors are not moving.
For 6-axis accel+gyro, gyro offset WILL affect yaw, especially in the case of stationary sensors. That is because there is no steady state truth to keep the algorithm properly aligned about the Z-axis. That shortcoming in the 6-axis solution is why the 9-axis one exists.
As to equations ... It's not that simple. Both Kalman filters are optimized to compute device orientation relative to the global frame. All calculations are done using quaternion math. Rotation matrices and roll/pitch/yaw are extracted from the orientation quaternion. If you really want to know that math, it is fully described in the app notes packaged with the sensor fusion library. You will quickly see it is far beyond the scope of a community posting.
Regards,
Mike