Answer
$u\left( {x,y} \right)$ is harmonic if ${a^2} = {b^2}$ or $a = \pm b$.
Work Step by Step
We have $u\left( {x,y} \right) = \cos \left( {ax} \right){{\rm{e}}^{by}}$.
1. Take the derivatives with respect to $x$:
${u_x} = - a\sin \left( {ax} \right){{\rm{e}}^{by}}$
${u_{xx}} = - {a^2}\cos \left( {ax} \right){{\rm{e}}^{by}}$
2. Take the derivatives with respect to $y$:
${u_y} = b\cos \left( {ax} \right){{\rm{e}}^{by}}$
${u_{yy}} = {b^2}\cos \left( {ax} \right){{\rm{e}}^{by}}$
The function $u\left( {x,y} \right)$ is harmonic if it satisfies the Laplace equation $\Delta u = 0$:
$\Delta u = {u_{xx}} + {u_{yy}} = 0$
$ - {a^2}\cos \left( {ax} \right){{\rm{e}}^{by}} + {b^2}\cos \left( {ax} \right){{\rm{e}}^{by}} = 0$
$\left( { - {a^2} + {b^2}} \right)\cos \left( {ax} \right){{\rm{e}}^{by}} = 0$
Divide both sides by $\cos \left( {ax} \right){{\rm{e}}^{by}}$ gives $ - {a^2} + {b^2} = 0$
Hence, $u\left( {x,y} \right)$ is harmonic if ${a^2} = {b^2}$ or $a = \pm b$.