Two interacting fermions in a one-dimensional harmonic trap: Matching the Bethe ansatz and variational approaches