<s>[INST] How do I find complex function knowing its real part and value in zero? For example I have a complex function $f(z)$, $z = x + iy$.
I know that $\operatorname{Re} f(z) = x^3 + 6 x^2 y + A x y^2 - 2 y^3$
and that  $f(0) = 0$.
What should I do to find $f(z)$?
 [/INST] First method: Cauchy-Riemann equations. The function $f$ is assumed analytic. Therefore, there is an open set around zero where it is holomorphic. The Cauchy-Riemann equations write
\begin{equation}
\frac{\partial\, \text{Im} f}{\partial y}(x+\text{i}y) = \frac{\partial\, \text{Re} f}{\partial x}(x+\text{i}y) = 3x^2 + 12xy + Ay^2
\end{equation}
and
\begin{equation}
\frac{\partial\, \text{Im} f}{\partial x}(x+\text{i}y) = -\frac{\partial\, \text{Re} f}{\partial y}(x+\text{i}y) = -6x^2 -2Axy + 6y^2 \, .
\end{equation}
Due to the equality of mixed partials, one has
\begin{equation}
\frac{\partial^2\, \text{Im} f}{\partial y\,\partial x}(x+\text{i}y) = \frac{\partial^2\, \text{Im} f}{\partial x\,\partial y}(x+\text{i}y) \, , \qquad\text{viz.}\qquad A = -3\, .
\end{equation}
Integrating $\partial\text{Im}/\partial y$ with respect to $y$, one obtains
\begin{equation}
\text{Im} f(x+\text{i}y) = 3 x^2 y + 6 x y^2 - y^3 + B(x)\, .
\end{equation}
Then, the expression of $\partial\text{Im}/\partial x$ imposes
\begin{equation}
B'(x) = -6x^2\, ,\qquad\text{i.e.}\qquad B(x) = -2x^3 + C\, ,
\end{equation}
where $C$ is in $\mathbb{R}$. Finally, the condition $f(0) = 0$ yields $C=0$, and
\begin{equation}
\text{Im} f(x+\text{i}y) = -2 x^3 + 3 x^2 y + 6 x y^2 - y^3 \, .
\end{equation}

Second method: Power series. The function $f$ is assumed analytic. Thus, let us look for an expression as a convergent power series in the vicinity of $z=0$:
\begin{equation}
f(z) = \sum_{n=0}^{+\infty} a_n\, z^n \, , \quad\text{for}\quad |z|<R \, ,
\end{equation}
where $(a_n)_{n\in\mathbb{N}}$ is a sequence of complex numbers. If $z=0$, the latter expression yields $f(0)=a_0=0$. If $z\neq 0$, we introduce the polar form $z = r e^{\text{i}\theta}$ with $r$ in $]0,R[$ and $\theta$ in $[0,2\pi[$. On the one hand, the real part of $f(z)$ satisfies
\begin{equation}
\text{Re} f(z) = \sum_{n=1}^\infty \text{Re}(a_n\, z^n) =  \sum_{n=1}^\infty \left(\text{Re}(a_n)\cos(n\theta) - \text{Im}(a_n)\sin(n\theta)\right) r^n \, .
\end{equation}
On the other hand, the real part of $f(z)$ satisfies
\begin{equation}
\text{Re} f(z) = \left(\cos^3\!\theta + 6\cos^2\!\theta\sin\theta + A\cos\theta\sin^2\!\theta - 2\sin^3\!\theta\right) r^3 \, .
\end{equation}
Computing the Fourier series of the $\theta$-dependent factor, it rewrites as
\begin{equation}
\text{Re} f(z) = \left(\frac{A+3}{4}\cos\theta + \frac{1-A}{4}\cos(3\theta) + 2\sin(3\theta)\right) r^3 \, .
\end{equation}
Due to the uniqueness of the expression of $f$, one has
\begin{equation}
\left\lbrace
\begin{array}{l}
A = -3\, ,\\
\text{Re}(a_3) = (1-A)/4 = 1\, ,\\
\text{Im}(a_3) = -2\, ,\\
\text{Re}(a_{n}) = 0 \quad\text{for}\; n\neq 3\, ,\\
\text{Im}(b_{n}) = 0 \quad\text{for all}\; n\, .
\end{array}
\right.
\end{equation}
Finally, the following expression for $f$ is obtained:
\begin{equation}
f(z) = (1-2\text{i}) z^3 \, ,
\end{equation}
with imaginary part
\begin{equation}
\text{Im} f(x+\text{i}y) = -2 x^3 + 3 x^2 y + 6 x y^2 - y^3 \, .
\end{equation}
</s>