The Tamm variational principle and its generalization to the scattering amplitude