This is simply impossible. All measurements have errors, and noise is unavoidable.
A filter can reduce noise and random errors by combining and averaging measurements. For navigational measurements, the Kalman filter is the best but it is very difficult to properly implement. If you want to learn about the theory, I recommend the textbook "Optimal State Estimation" by Dan Simon.
For Arduino code, try RTIMULib. I described how to implement it in this post: https://forum.pololu.com/t/state-of-the-art-ahrs-for-25/8091/1