Problem: Find an analytic function $f$ such that $\text{Re}(f) = x^2 - y^2$.
Solution: Let $f(z) = u(x,y) + \iota v(x,y)$. We are given that $u(x,y) = x^2 - y^2$. Since $f$ is analytic, it must satisfy the Cauchy-Riemann equations. So we have \begin{align*} u_x = v_y & \implies 2x = v_y \implies v(x,y) = 2xy + g(x), \end{align*} where $g$ is an arbitrary function of $x$ only. We also have \begin{align*} u_y = -v_x & \implies -2y = -2y + g^\prime (x) \\ & \implies g^\prime (x) = 0 \\ & \implies g(x) = c, \end{align*} where $c$ is an arbitrary constant. Therefore, the function will be \[ f(z) = \left( x^2 - y^2 \right) + \iota \left( 2xy + c \right). \] One particular function will be \[ f(z) = (x^2 - y^2) + \iota 2xy = z^2. \]