In my text book I saw that ${|\cosh z|}^2={\cos}^2x+{\sinh}^2y$
But when I tried deriving it myself I got this: $${|\cosh z|}^2={\cos}^2y+{\sinh}^2x$$
See my working below:
$$\cosh z=\frac{1}{2}(e^z+e^{-z})=\frac{1}{2}(e^{x+yi}+e^{-x-yi})=\frac{1}{2}(e^x\cos y+ie^x\sin y+e^{-x}\cos y-ie^{-x}\sin y)$$
Solving further and collecting like terms gives:
$$\frac{1}{2}(e^x+e^{-x})\cos y + \frac{1}{2}(e^x-e^{-x})i\sin y=\cosh x\cos y+i\sinh x\sin y$$
Therefore we can get the square of the absolute value of $\cosh z$
$${|\cosh z|}^2={(\cosh x\cos y)}^2+{(\sinh x\sin y)}^2= {\cos}^2y+{\sinh}^2x$$
Am I wrong or is my textbook wrong? Or are we both right?!
The identity you quote as being the textbook's answer - $|\cosh(x+i y)|^2 = \cos(x)^2 + \sinh(y)^2$ - is false in the case $y=0$ for all $x \not = 0$.
Your identity and proof are correct. It is the case that $|\cosh(x+i y)|^2 = \sinh(x)^2 + \cos(y)^2$.