In the middle of some involved computations, I came across the following expression: $$f(x,y) = \ln (\cosh x + \sinh x\tanh y)$$
where $x,y$ are real numbers. I need to evaluate $f(x,y)$ over a wide range of values of $x,y$. In particular, $x,y$ can get very large (positive or negative). In this case $\sinh x,\tanh y$ may overflow, although the logarithm remains reasonable.
What numerical tricks can I use to evaluate $f(x,y)$ without risk overflow/underflow?
hint
$$f (x,y)=$$ $$\ln (\cosh (x))+\ln (1+\tanh (x)\tanh (y)) $$
with
$$\ln (\cosh (x))=\ln (\frac {e^x+e^{-x}}{2}) $$
$$=\ln (e^x\frac {1+e^{-2x}}{2}) $$ $$=x-\ln (2)+\ln (1+e^{-2x}) $$ $$\approx x-\ln (2)+e^{-2x} $$ for large values of $x$.