I think there must be a formula to calculate the exact position of the Earth taking into account the gravitational attraction of Mars and the Sun. Is it possible with vectors?
Considering the just Sun, Earth, and Mars, this would be a three-body problem. An exact solution for a three-body problem might be interesting mathematically, but if by exact position you mean the real position then you'll need to take into account much more than just Mars. Numerical integration techniques are standard for n-body problems such as the Solar System.