“Controlled” Versions of the Collatz–Wielandt and Donsker–Varadhan Formulae