Enjoy life. This is not a dress rehearsal, Friedrich Nietzsche.

Definition. Let $D \subseteq \mathbb{R}^2$ be a domain (open and connected set). A function $\phi (x, y): D \to \mathbb{R}$ is said to be $C^2$ on D if $\phi$ and its partial derivatives $\frac{\partial \phi}{\partial x}, \frac{\partial \phi}{\partial y}, \frac{\partial^2 \phi}{\partial x^2}, \frac{\partial^2 \phi}{\partial y^2}$ are all continuous on D. According to this definition, the following conditions are met.
The standard (stronger) meaning of $C^2$ on D requires all partial derivatives up to order 2 — including the mixed partials — to exist and be continuous on D: $\phi, \frac{\partial \phi}{\partial x}, \frac{\partial \phi}{\partial y}, \frac{\partial^2 \phi}{\partial x^2}, \frac{\partial^2 \phi}{\partial y^2}, \frac{\partial^2 \phi}{\partial y \partial x}, \frac{\partial^2 \phi}{\partial x \partial y}$.
Definition. The Laplacian of a function $\phi (x, y)$ is the sum of its unmixed second partial derivatives $\nabla^2 \phi := \frac{\partial^2 \phi}{\partial x^2} + \frac{\partial \phi^2}{\partial y^2} ↭ \nabla^2 \phi := \phi_{xx}+ \phi_{yy}$.
The Laplace’s equation is the condition $\nabla^2 \phi = 0$, i.e., $\frac{\partial^2 \phi}{\partial x^2} + \frac{\partial^2 \phi}{\partial x^2} = 0$.
The standard notations for the Laplacian of a function $\phi (x, y)$ are $\nabla^2 \phi \text{ or } \Delta \phi $. The standard notations for partial derivatives: $\frac{\partial \phi}{\partial x} \text{ or } \phi_x$ for first partials, and for second partials, $\frac{\partial^2 \phi}{\partial x²} \text{ or } \phi_{xx}$. The superscript 2 on the numerator should precede the variable (applies to the differential operator $\partial$) to denote the second derivative; the notation $\frac{\partial^2 \phi}{\partial x^2}$ means “apply $\frac{\partial}{\partial x}$ twice to $\phi$.”
Definition. A real-valued function $\phi (x, y)$ is harmonic on a domain $D \subseteq \mathbb{R}^2$ if it is $C^2$ on D and satisfies Laplace’s equation: $\nabla^2 \phi = \frac{\partial \phi^2}{\partial x^2} + \frac{\partial \phi^2}{\partial y^2} = 0$.
Theorem. Let $f(z) = u(x,y) + iv(x,y)$ be analytic on a domain D (with z = x + iy). Then:
Definition. If u(x, y) is a harmonic function on a domain D, a function v(x, y) is called a harmonic conjugate of u if:
Theorem. Harmonic conjugates yield analytic functions. If u(x, y) is a harmonic function on a domain D and v is a harmonic conjugate of u, then f(z) = u(x, y) + iv(x, y) is analytic on D, where z = x + iy.
Theorem. Existence of Harmonic Conjugates. If $u \in C^2(D)$ is harmonic and D is simply connected, then there exists v with $\frac{\partial u}{\partial x} = \frac{\partial v}{\partial y}$ and $\frac{\partial u}{\partial y} = - \frac{\partial v}{\partial x}$, and $f(z) = u(x, y) + iv(x, y)$ is analytic on D. The conjugate v is unique up to an additive constant.
Theorem. Constant Modulus Implies Constancy. Let $u(x, y)$ be harmonic on a domain $D$, and let $v$ be a harmonic conjugate of $u$. If the function $f(z) = u(x, y) + iv(x, y)$ satisfies $|f(z)| = k$ for all $z \in D$, where $k$ is a constant, then $u$ and $v$ are both constant on $D$.
Proof.
Since v is a harmonic conjugate of u, by the previous Theorem, the function f(z) = u(x, y) + iv(x, y) is analytic on D.
By assumption, $|f(z)| = k$ and this implies that $u^2 + v^2 = k^2$ for all $(x, y) \in D$.
Case 1: $k = 0$. Then, $u^2 + v^2 = 0$, so $u = v = 0$ everywhere — both are constant.
Case 2: $k \neq 0$. As u and v are harmonic (and thus have continuous first-order partial derivatives), we differentiate $u^2 + v^2 = k^2$ with respect to $x$ and $y$ and we get: $2u\frac{\partial u}{\partial x} + 2v\frac{\partial v}{\partial x} = 0$, $2u\frac{\partial u}{\partial y} + 2v\frac{\partial v}{\partial y} = 0$
$2u u_x + 2v v_x = 0, \qquad 2u\,u_y + 2v\,v_y = 0.$
Applying the Cauchy–Riemann equations ($v_x = -u_y$, $v_y = u_x$) and dividing by 2: $\begin{cases} u\,u_x - v\,u_y = 0, \\ u\,u_y + v\,u_x = 0. \end{cases}$
This is a homogeneous linear system in $u_x$ and $u_y$ with coefficient matrix determinant $u^2 + v^2 = k^2 \neq 0$. The only solution is: $u_x = 0 \qquad \text{and} \qquad u_y = 0.$
This is a homogeneous linear system of two equations and two variables, and the determinant of the coefficient matrix is not zero, the system has only one solution; that one solution is the trivial solution.
Since $D$ is connected and $u$ has vanishing partial derivatives, $u$ is constant on $D$. By the Cauchy–Riemann equations, $v_x = -u_y = 0$ and $v_y = u_x = 0$, so $v$ is also constant. $\blacksquare$
Theorem. Zero Derivative Implies Constancy. Let $u(x, y)$ be harmonic on a domain $D$ and $v$ a harmonic conjugate of $u$. If $f'(z) = 0$ for all $z \in D$, where $f(z) = u + iv$, then $u$ and $v$ are both constant on $D$.
Proof.
The function $f = u + iv$ is analytic on $D$ (since $v$ is a harmonic conjugate of $u$). The complex derivative is: $f'(z) = \frac{\partial u}{\partial x} + i\frac{\partial v}{\partial x}.$
If $f'(z) = 0$ for all $z \in D$, then $u_x = 0$ and $v_x = 0$ throughout $D$. By the Cauchy–Riemann equations: $v_y = u_x = 0, \qquad u_y = -v_x = 0.$
All four partial derivatives vanish identically. Since $D$ is connected, both $u$ and $v$ are constant. $\blacksquare$
Both theorems above rely on the following foundational result from multivariable calculus.
Theorem. If $u: D \to \mathbb{R}$ is a differentiable function on a connected domain $D \subseteq \mathbb{R}^n$ such that $\frac{\partial u}{\partial x_i} = 0$ for all $i = 1, 2, \ldots, n$ and all points in $D$, then $u$ is constant on $D$.
The crucial point is that connectedness bridges the gap from local behavior (the function doesn’t change in any small neighborhood) to global behavior (the function has the same value throughout the entire domain).
Step 1: $u$ is locally constant.
If $\nabla u = 0$ at every point, then by the Mean Value Theorem, $u$ is locally constant around each point.
Recall (Mean Value Theorem). If $f: [a, b] \to \mathbb{R}$ is continuous on $[a, b]$ and differentiable on $(a, b)$, then there exists $c \in (a, b)$ such that $f(b) - f(a) = f'(c)(b - a)$.
For any two points $P_1$ and $P_2$ in a small convex neighborhood within $D$:
More precisely, this uses the multivariable Mean Value Theorem: if $u$ is differentiable on a convex set and $\nabla u(\mathbf{c}) = 0$ for all $\mathbf{c}$, then $u(\mathbf{b}) - u(\mathbf{a}) = \nabla u(\mathbf{c}) \cdot (\mathbf{b} - \mathbf{a}) = 0$ for some $\mathbf{c}$ on the segment from $\mathbf{a}$ to $\mathbf{b}$.
Step 2: Global extension via connectedness.
Recall (Connectedness). A topological space $D$ is disconnected if it can be written as $D = U \cup V$ where $U$ and $V$ are disjoint, non-empty, open subsets. If no such decomposition exists, $D$ is connected. In a connected space, the only subsets that are simultaneously open and closed (“clopen”) are $\emptyset$ and $D$ itself. This is precisely why $S = D$: if $S$ were a proper non-empty clopen subset, then $S$ and $D \setminus S$ would disconnect $D$. $\blacksquare$

Exercise. Show that u(x, y) = xy³ -x³y is a harmonic function and find the harmonic conjugate of u(x, y)
First, let’s demonstrate that u(x, y) = xy³ -x³y is indeed a harmonic function.
$\frac{\partial u}{\partial x} = y^3 -3x^2y, \frac{\partial u}{\partial y} = 3xy^2 -x^3, \frac{\partial^2 u}{\partial x^2} = -6xy, \frac{\partial^2 u}{\partial y^2} = 6xy, \frac{\partial^2 u}{\partial x^2} + \frac{\partial^2 u}{\partial y^2} = 0$ at any (x, y) ∈ ℂ. Thus, $u(x,y)=xy^3-x^3y$ is harmonic.
Harmonic conjugate via Cauchy–Riemann. Use the Cauchy–Riemann equations for f=u+iv: $\frac{\partial v}{\partial y} = \frac{\partial u}{\partial x} \text{ (i) } \frac{\partial v}{\partial x} = -\frac{\partial u}{\partial y} \text{ (ii) }$
From (i): $\frac{\partial v}{\partial y} = y^3 -3x^2y$. Integrate $\frac{\partial v}{\partial y}$ with respect to y: $v = \int (y^3 -3x^2y)dy + g(x) = \frac{y^4}{4}-\frac{3x^2y^2}{2}+ g(x)$ where g(x) is a function of x.
From (ii), differentiate v with respect to x and match $\frac{\partial v}{\partial x}$: $-3xy^2 + g'(x) = -3xy^2 +x^3 \leadsto g'(x) = x^3 \leadsto g(x) = \frac{x^4}{4} + C$ where C is a constant of integration.
Therefore, a harmonic conjugate is, $v = \frac{y^4}{4}-\frac{3x^2y^2}{2}+ \frac{x^4}{4} + C$
Exercise. Find an analytic function u + iv given that its imaginary part is v(x, y) = $e^ysin(x)$
Compute the partial derivatives of v(x, y): $\frac{\partial v}{\partial x} = e^ycos(x), \frac{\partial v}{\partial y} = e^ysin(x)$
Check for harmonicity: $\frac{\partial^2 v}{\partial x^2} = -e^ysin(x), \frac{\partial^2 v}{\partial x^2} = e^ysin(x), \nabla^2 v = \frac{\partial^2 v}{\partial x^2} + \frac{\partial^2 v}{\partial y^2} = -e^ysin(x) + e^ysin(x) = 0.$ Use the Cauchy-Riemann equations to find u(x,y): For a function f(z) = u(x, y) + iv(x, y) to be analytic, it must satisfy the Cauchy-Riemann equations: $\frac{\partial v}{\partial y} = \frac{\partial u}{\partial x} \text{ (i) } \frac{\partial v}{\partial x} = -\frac{\partial u}{\partial y} \text{ (ii) }$
From (i): $\frac{\partial u}{\partial x} = e^ysin(x)$. Integrate $\frac{\partial u}{\partial x}$ with respect to x: $u(x, y) = \int (e^ysin(x))dx + g(y) = -e^ycos(x) + g(y)$. Here, g(y) is an arbitrary function of y, arising from the integration.
From (ii) differentiate our expression with respect to y and match $\frac{\partial v}{\partial x}$: $\frac{\partial u}{\partial y} = -e^ycos(x) + g'(y) = -e^ycos(x) \leadsto g'(y) = 0 \leadsto g(y) = C$, so g(y) is a real constant.
Now we have: u(x, y) = $-e^ycos(x) + C$. Thus, the analytic function is: $f(z) = u(x, y) + iv(x, y) = -e^ycos(x) + C + i(e^ysin(x))$.
Or, more compactly: $f(z) = C + e^y(-\cos(x) + i \sin(x)) =[-\cos(x)+i\sin(x)=-e^{-ix}] C + e^y·(-e^{-ix})$. Since $e^y e^{-ix} = e^{y - ix} \leadsto f(z) = C - e^{y - ix}$. Since y -ix = -iz, we conclude: $\boxed{f(z) = C - e^{-iz}}$