In this forum post on MSE we were trying to find the imaginary part of an entire function given it's real parte. One of the answers called for this method $$f(z) = 2u\left({z\over 2},-{{iz}\over 2}\right)-u(0,0) \tag{1}$$ which I've never seen before. This caught a lot of attention for the fact that, based on it's definition $$u(x,y):\mathbb{R}^2\rightarrow\mathbb{R}$$ and by using equation $(1)$ we are implying that we can extend the domain of $u(x,y)$ from $\mathbb{R}^2$ to $\mathbb{C}^2$, mainly $$u(z,w):\mathbb{C}^2\rightarrow\mathbb{C}$$ As you can see in the forum post, this started some back and forth between some users, me as well, to try and find some mathematical rigour to equation $(1)$. Because of this I'm now here asking for that so desired mathematical proof: when and why is it possible to extend real-valued function to complex-valued functions? Moreover: when is it possible to apply equation $(1)$ to find an entire function from it's real part?
My approach
I copy here my attempt of an explanation and a sort of proof that I've given even in the comment of the MSE post cited:
The real part of an entire function can be expressed as
$$2u(x,y) = f(x+iy)+\overline{f(x+iy)} = f(x+iy)+\overline{f(\overline{x-iy})} = f(x+iy)+\overline{f}(x-iy)\tag{2}$$
by choosing $$z=x+iy\;\;w=x-iy \Rightarrow x={1\over 2}(z+w)\;\;y={1\over{2i}}(z-w)$$ then $$2u\left({1\over 2}(z+w), {1\over{2i}}(z-w)\right) = f(z)+\overline{f}(w)= f(z)+\overline{f(\overline{w})}\;\;\forall z,w$$
So we can choose $w$ arbitrarily and set it to $w = z_0$ which for the problem given was $z_0=0+i0$, then $$f(z)=2u\left({1\over 2}(z+z_0), {1\over{2i}}(z-z_0)\right)-\overline{f(z_0)} \Rightarrow f(z)=2u\left({1\over 2}z, {1\over{2i}}z\right)-u(0,0)$$
This same proof can be used to find that $$f(z) = 2iv\left({z\over 2},{z\over{2i}}\right)+v(0,0)$$
The problem comes again when substituting in equation $(2)$ for the fact that $z,w\in\mathbb{C}$ and my answer was that the right hand side has sense for every $x$ and $y$,real or complex, such that $x+iy$ and $x-iy$ are in the domain of $f$ which clearly are being $f$ an entire function, so analytic an all $\mathbb{C}$.
Final thoughts
So in the end, I would like some comments by you! If it's possible, I'd love to have a clear and mathematical rigorous explanation.
Best Answer
is the wrong question, it's too general. We can't work with just any extension, we need certain regularity properties. We want a holomorphic extension. Technically, for $f$ defined by $(1)$ to be holomorphic it is not neccessary that $u$ is holomorphic, $z \mapsto u(z/2,-iz/2)$ can be holomorphic even if $(z,w) \mapsto u(z,w)$ isn't. But we can always work with a holomorphic extension.
The local version of the extension question becomes
The answer is "if and only if $u$ is real-analytic". That's clearly necessary, since the Taylor expansion of $\tilde{u}$ about a point in $U$ gives a power series expansion of $u$ about that point by restricting to real arguments. And it is sufficient because the Taylor series of $u$ about a point $p \in U$ converges on some neighbourhood $W_p$ of $p$ in $\mathbb{C}^2$ and thus provides a holomorphic extension of $u\rvert_{W_p \cap \mathbb{R}^2}$ to $W_p$. If we take appropriate $W_p$, say balls or polydisks with centre $p$, then all these extensions fit together and provide a holomorphic extension $\tilde{u}$ with domain $$\bigcup_{p \in U} W_p\,.$$
A global version of the extension question is
The answer to this question is easy too. If such a $\tilde{u}$ exists, its Taylor series (about $0$, say) converges on all of $\mathbb{C}^2$, and thus $u$ has a globally convergent power series expansion. Conversely if $u$ has a power series expansion that converges on all of $\mathbb{R}^2$, this series converges on all of $\mathbb{C}^2$ and thus provides an entire $\tilde{u}$.
Now, if $u \colon \mathbb{R}^2 \to \mathbb{R}$ is real-analytic, it need not be the case that $u$ has a globally convergent series expansion. Take for example $u(x,y) = \frac{1}{1+x^2+y^2}$. Its extension is meromorphic with the nonempty pole set $\{ (z,w) \in \mathbb{C}^2 : z^2 + w^2 = -1\}$.
But, the $u$ we want to extend is not an arbitrary real-analytic function. It is supposed to be the real part of a holomorphic function, and hence it must be harmonic. [Which yields sanity check 1 for such problems: Is the given function harmonic? If it isn't, it cannot be the real (or imaginary) part of a holomorphic function.] And an entire harmonic function has a globally convergent power series representation. (Take the Poisson integral over a sphere of radius $R$ and expand the Poisson kernel into a power series. This shows that the Taylor series about $0$ converges at least on the ball of radius $R$.)
Thus when we're looking for an entire function with a prescribed real part - and the given function is harmonic - the method always works.
The method can fail if we want to find a holomorphic $f \colon \Omega \to \mathbb{C}$ with prescribed real part $u$ when $\Omega \subsetneq \mathbb{C}$, since $(z/2, -iz/2)$ need not belong to the domain of the holomorphic extension $\tilde{u}$ for $z\in \Omega$ in that case.
Ahlfors gives a short discussion of the method in section 1.2 of chapter 2 in his Complex Analysis.