How to find real and imaginary parts of complex function I am trying to find the real and imaginary parts of $$f(z)=z^2\cos z-e^{z^3-z}$$ AND directly verify that both are harmonic
and am having lots of trouble. I know f is holomorphic, and I know many identies such as $$\cos(z)=\cos(x)\cosh(y)-i\sin(x)\sinh(y)$$
but no matter how I try to reorganize, I get so many terms all containing different parts and then I am unable to proceed because I am confused. Is this the only way to find the real and imaginary parts? can anyone give advice/help for this?
Update: I have now gotten
$$Re(f(z))=x^2cosxcoshy+2xysinxsinhy-y^2cosxcoshy-e^{x^3-3xy^2-x}cos(3x^{2}y-y^3-y)$$
and
$$Im(f(z))=(-x^2sinxsinhy+2xycosxcoshy+y^2sinxsinhy)-e^{x^3-3xy^2-x}sin(3x^{2}y-y^3-y)$$
but when it comes to verifying harmonic I know I am supposed to check second partial deravatives, but I am having lots of trouble even calculating the first as I am getting so many terms
 A: For the first part, $z^2 = (x^2 - y^2) + 2 i x y$ and $\cos(z)$ is as you say.
Multiply these term-by-term and select the parts without and with $i$.
For the second part, write $z^3 - z = x^3 - 3 xy^2 - x + i (3x^2y - y^3 - y) = u + i v$.  Then
$e^{u+iv} = e^u \cos(v) + i e^u \sin(v)$.
Then put the two parts together.  $\text{Re}(A-B) = \text{Re}(A) - \text{Re}(B)$, and similarly for $\text{Im}$.
A: If you want ALL the calculation (Robert's answer might be ways better, though) here they are:
$$z = x + iy$$
$$z^2 = (x+iy)(x+iy) = x^2 - y^2 + 2ixy$$
$$\cos(z) = \cos(x + iy) = \cos(x)\cos(iy) - \sin(x)\sin(iy) = \cos(x)\cosh(y) - \sin(x)i\sinh(y)$$
$$z^2\cos(z) = (x^2 - y^2 + 2ixy)(\cos(x)\cosh(y) - \sin(x)i\sinh(y)) = [(x^2-y^2)\cos(x)\cosh(y) +2xy\sin(x)\sinh(y)] + i[2xy\cos(x)\cosh(y) + (x^2-y^2)\sin(x)\sinh(y))$$
$$z^3 = z\cdot z^2 = (x+iy)(x^2 - y^2 + 2ixy) = x^3 - xy^2 + 2ix^2y + iyx^2 - iy^3 - 2xy^3 = x^3 - xy^2 - 2xy^3 + i(2x^2y + yx^2 - y^3)$$
$$z^3 - z = x^3 - xy^2 - 2xy^3 + i(2x^2y + yx^2 - y^3) - (x+iy) = x^3 - xy^2 - 2xy^3 -x + i(2x^2y + yx^2 - y^3 - y)$$
$$e^{z^3-z} = e^{x^3 - xy^2 - 2xy^3}\cdot e^{i(2x^2y + yx^2 - y^3)}$$
Now you should be able to separate the real part from the imaginary part!
It's very straightforward!
A: HINT for finding $\Re\left[f(\text{z})\right]$ and $\Im\left[f(\text{z})\right]$:
$$f(\text{z})=\text{z}^2\cos\left(\text{z}\right)-e^{\text{z}^3-\text{z}}$$
Where $\text{z}\in\mathbb{C}$

Now, we get:


*

*$$\text{z}=\Re\left[\text{z}\right]+\Im\left[\text{z}\right]i$$

*$$\text{z}^2=\left(\Re\left[\text{z}\right]+\Im\left[\text{z}\right]i\right)^2=\Re^2\left[\text{z}\right]-\Im^2\left[\text{z}\right]+2\Re\left[\text{z}\right]\Im\left[\text{z}\right]i$$

*$$\text{z}^3=\left(\Re\left[\text{z}\right]+\Im\left[\text{z}\right]i\right)^3=\Re\left[\text{z}\right]\left(\Re^2\left[\text{z}\right]-3\Im^2\left[\text{z}\right]\right)+\Im\left[\text{z}\right]\left(3\Re^2\left[\text{z}\right]-\Im^2\left[\text{z}\right]\right)i$$

*$$\text{z}^3-\text{z}=\text{z}\left(\text{z}^2-1\right)=\Re\left[\text{z}\right]\left(\Re^2\left[\text{z}\right]-3\Im^2\left[\text{z}\right]-1\right)-\Im\left[\text{z}\right]\left(1-3\Re^2\left[\text{z}\right]+\Im^2\left[\text{z}\right]\right)i$$

*$$\cos\left(\text{z}\right)=\cos\left(\Re\left[\text{z}\right]+\Im\left[\text{z}\right]i\right)=\cos\left(\Re\left[\text{z}\right]\right)\cosh\left(\Im\left[\text{z}\right]\right)-\sin\left(\Re\left[\text{z}\right]\right)\sinh\left(\Im\left[\text{z}\right]\right)i$$

*$$e^{\text{z}^3-\text{z}}=e^{\text{z}^3}\cdot e^{-\text{z}}$$

*$$e^{-\text{z}}=e^{-\left(\Re\left[\text{z}\right]+\Im\left[\text{z}\right]i\right)}=e^{-\Re\left[\text{z}\right]}\cdot e^{-\Im\left[\text{z}\right]i}=e^{-\Re\left[\text{z}\right]}\cos\left(\Im\left[\text{z}\right]\right)-e^{-\Re\left[\text{z}\right]}\sin\left(\Im\left[\text{z}\right]\right)$$

*$$e^{\text{z}^3}=e^{\Re\left[\text{z}\right]\left(3\Im^2\left[\text{z}\right]-\Re^2\left[\text{z}\right]\right)}\left(\cos\left(\Im\left[\text{z}\right]\left(3\Re^2\left[\text{z}\right]-\Im^2\left[\text{z}\right]\right)\right)-\sin\left(\Im\left[\text{z}\right]\left(3\Re^2\left[\text{z}\right]-\Im^2\left[\text{z}\right]\right)\right)i\right)$$


And use, when $\text{s}_1\space\wedge\space\text{s}_2\in\mathbb{C}$:


*

*$$\Re\left[\text{s}_1\pm\text{s}_2\right]=\Re\left[\text{s}_1\right]\pm\Re\left[\text{s}_2\right]$$

*$$\Im\left[\text{s}_1\pm\text{s}_2\right]=\Im\left[\text{s}_1\right]\pm\Im\left[\text{s}_2\right]$$

A: No answer has been selected. Can you finish the solution method mapped out by @Alan Turing?
Real part
$$
\begin{align}
%
\text{Re} \left( z^{2} \cos z \right)
&= x^2 \cos (x) \cosh (y)-y^2 \cos (x) \cosh (y)+2 x y \sin (x) \sinh (y) \\
%
\text{Re} \left( -e^{z^{3}-z} \right) 
%
&= -e^{x^3-3 x y^2-x} \cos \left(-3 x^2 y+y^3+y\right)
%
\end{align}
$$
Imaginary part
$$
\begin{align}
%
\text{Im} \left( z^{2} \cos z \right)
&= -x^2 \sin (x) \sinh (y)+y^2 \sin (x) \sinh (y)+2 x y \cos (x) \cosh (y) \\
%
\text{Im} \left( -e^{z^{3}-z} \right) 
%
&= e^{x^3-3 x y^2-x} \sin \left(-3 x^2 y+y^3+y\right)
%
\end{align}
$$
