AltIMU-10 v4 with arduino

Hi im using the altimu-10 v4 sensor to display pitch and roll on the serial monitor. I obtained an example code which reads the accelerometer and magnetometer giving raw values. I only need the accelerometer data but i am unable to understand where i should apply the mathematical formula to convert acceleration to pitch and roll and display it. Any idea guys?
Ill attach my codes.

Roll angle= [atan2(y_acceleration, sqrt(sq(x_acceleration) + sq(z_acceleration)))] * (360/2pi)

Pitch angle= [atan2(x_acceleration, sqrt(sq(y_acceleration) + sq(z_acceleration)))] * (360/2pi)

Serial.Accelerometer.ino (1.92 KB)

Those formulas aren't quite correct. See this application note: http://www.freescale.com/files/sensors/doc/app_note/AN3461.pdf

I would not recommend starting with the program you attached, although it does approximately what you want. Reason: you won't learn much.