An exact method for the calculation of certain Titchmarsh-Weyl m-functions