In this work, combining the Bethe ansatz approach with the variational principle, we calculate the ground state energy of the relative motion of a system of two fermions with spin up and down interacting via a delta-function potential in a 1D harmonic trap. Our results show good agreement with the analytical solution of the problem, and provide a starting point for the investigation of more complex few-body systems where no exact theoretical solution is available.