Invariant models in the inversion of gravity and magnetic fields and their derivatives