Example 4. Find the analytic function $w=f(z)$, given its real part $u(x, y)=2 e^{x} \cos y$ and the additional condition $f(0)=2$.
Solution. First method. We have $\frac{\partial u}{\partial x}=2 e^{x} \cos y$. According to the first of the Cauchy-Riemann conditions, it should be $\frac{\partial u}{\partial x}=\frac{\partial v}{\partial y}$, so $\frac{\partial v}{\partial y}=2 e^{x} \cos y$. From this,

$$
v(x, y)=\int 2 e^{x} \cos y d y=2 e^{x} \sin y+\varphi(x)
$$

where the function $\varphi(x)$ is still unknown. Differentiating $v(x, y)$ with respect to $x$ and using the second of the Cauchy-Riemann conditions, we get

$$
2 e^{x} \sin y+\varphi^{\prime}(x)=-\frac{\partial u}{\partial y}=2 e^{x} \sin y
$$

from which $\varphi^{\prime}(x)=0$, and thus $\varphi(x)=C$, where $C=$ const.

Thus, $v(x, y)=2 e^{x} \sin y+C$, and therefore,

$$
f(z)=2 e^{x} \cos y+i\left(2 e^{x} \sin y+C\right)=2 e^{z}+i C
$$

The constant $C$ will be found from the condition $f(0)=2$, i.e., $2 e^{0}+i C=2$; from this, $C=0$. Answer: $f(z)=2 e^{z}$.

Second method. We will use formula (5). In our example, $u(x, y)=2 e^{x} \cos y, z_{0}=0, C_{0}=2$. Thus, by formula (5) we will have $f(z)=$ $2 \cdot 2 e^{z / 2} \cos \frac{z}{2 i}-2$. Using the fact that $\cos \frac{z}{2 i}=\cos \left(-\frac{i z}{2}\right)=\operatorname{ch} \frac{z}{2}$, we finally get $f(z)=2 e^{z}$.