For a one-dimensional conservative system with position depending mass, one deduces consistently a constant of motion, a Lagrangian, and a Hamiltonian for the nonrelativistic case. With these functions, one shows the trajectories on the spaces ( )x p , for a linear position depending mass. For the relativistic case, the Lagrangian and Hamiltonian cannot be given explicitly in general. However, we study the particular system with constant force and mass linear dependence on the position where the Lagrangian can be found explicitly, but the Hamiltonian remains implicit in the constant of motion.