Spreading resistance calculations by the variational method