---
title: Analytic and harmonic functions
heading: Every analytic function is a two-dimensional field
eyebrow: A12 · Lesson 4 · Analytic and harmonic functions
xp: 40
---

::: hook
Differentiate the Cauchy–Riemann equations once more and they say something remarkable: the real and imaginary parts of an analytic function each satisfy Laplace's equation, the equation of electrostatic potential in charge-free space, of steady heat flow and of ideal fluid flow. Every analytic function is therefore a ready-made two-dimensional field. Its real part is a potential, its imaginary part a flux function whose level curves are the field lines, and the two families of curves cross at right angles. Engineers use this backwards: to solve a 2D field problem, find the analytic function whose parts fit the boundaries.
:::

::: play
- The shading and its contours are the potential $\varphi = \text{Re}\,\Phi$ for $\Phi(z) = z + R^2/z$: a uniform flow, or field, disturbed by a cylinder of radius R at the origin. The curves are streamlines, the level curves of $\psi = \text{Im}\,\Phi$.
- Everywhere, streamlines cross the equipotential contours at right angles, and none enters the cylinder: $\psi = 0$ on its surface.
- Change R: the cylinder grows, and the flow crowds over its top and bottom, where its speed is twice the speed far away.
:::
:::

```sim plot
view: flow
x: x = -3..3
y: y = -2..2
slider: R = 0.3..1.2 step 0.05 = 0.7
shade: x*(1 + R^2/(x^2 + y^2 + 1e-6)) | contours: 16
dx: 1 - R^2*(x^2 - y^2)/((x^2 + y^2)^2 + 1e-6)
dy: -2*R^2*x*y/((x^2 + y^2)^2 + 1e-6)
arrows: none
start: -3, 0.15 | quiet | forward
start: -3, 0.5 | quiet | forward
start: -3, 0.9 | quiet | forward
start: -3, 1.4 | quiet | forward
start: -3, -0.15 | quiet | forward
start: -3, -0.5 | quiet | forward
start: -3, -0.9 | quiet | forward
start: -3, -1.4 | quiet | forward
```

::: predict
## For $f = z^2$, $u = x^2 - y^2$. What's $u_{xx} + u_{yy}$?

- [ ] $4$
- [x] $0$
- [ ] $2x - 2y$
- [ ] $-4$

::: reveal
0: $u_{xx} = 2$ and $u_{yy} = -2$. The real part of every analytic function satisfies Laplace's equation, so it can be a potential in a region with no charge.
:::
:::

::: nameit
## Harmonic functions

If $f = u + jv$ is analytic (with continuous second derivatives, which analytic functions always have), differentiating the Cauchy–Riemann equations gives

$$u_{xx} + u_{yy} = 0, \qquad v_{xx} + v_{yy} = 0$$

u and v are **harmonic**, and v is a **harmonic conjugate** of u. Their level curves cross at right angles wherever $f' \ne 0$, because their gradients are perpendicular: $\nabla u \cdot \nabla v = u_xv_x + u_yv_y = 0$ by the equations.

## The complex potential

A 2D electrostatic field in charge-free space is described by one analytic function $\Phi = \varphi + j\psi$: $\varphi$ is the potential, the curves $\psi$ = constant are the field lines, and the field is $\mathbf E = -\nabla\varphi$, which is $-\overline{\Phi'(z)}$ as a complex number. The difference in ψ between two field lines is the flux between them.

| Field | Φ(z) |
|---|---|
| uniform field E₀ along x | $-E_0 z$ |
| line charge λ at the origin | $-\dfrac{\lambda}{2\pi\varepsilon_0}\ln z$ |
| uniform flow past a cylinder (radius R) | $U\left(z + \dfrac{R^2}{z}\right)$ |

## Finding a harmonic conjugate

Given harmonic u, integrate $v_y = u_x$ in y, then fix the leftover function of x with $v_x = -u_y$.
:::

::: example
## Find a harmonic conjugate of $u = x^2 - y^2 + 2x$.

::: solution
1. **Use the first equation.** $v_y = u_x$, then integrate in y:
   $$\begin{aligned} v_y &= 2x + 2 \\ v &= 2xy + 2y + g(x) \end{aligned}$$
2. **Use the second equation.** $v_x = 2y + g'(x)$ must equal $-u_y = 2y$, so g is a constant.
3. **Put it together.**
   $$v = 2xy + 2y$$
   $$u + jv = z^2 + 2z$$

**Answer:** $v = 2xy + 2y$ (plus any constant), and $u + jv = z^2 + 2z$.
:::
:::

::: example
## In uniform flow U past a cylinder of radius R, how fast does the fluid move at the top of the cylinder?

::: solution
1. **Velocity from the potential.** The velocity is the conjugate of $\Phi'$:
   $$\overline{\Phi'(z)} = U\,\overline{\left(1 - \frac{R^2}{z^2}\right)}$$
2. **Evaluate at the top.** At $z = jR$:
   $$\begin{aligned} 1 - \frac{R^2}{(jR)^2} &= 1 + 1 \\ &= 2 \end{aligned}$$
   so the speed is 2U, twice the free stream, whatever the radius.
3. **The electrostatic version.** The field at the surface of a conducting cylinder in a uniform field E₀ is $2E_0$.

**Answer:** the fluid moves at 2U at the top, twice the free-stream speed, for any radius.
:::
:::

::: example
## A line charge of 1 nC/m lies along the z axis. Its complex potential is $\Phi = -\frac{\lambda}{2\pi\varepsilon_0}\text{Log}\,z$. Find the field at $x = 3$ cm, $y = 4$ cm.

::: solution
1. **Differentiate.**
   $$\Phi' = -\frac{\lambda}{2\pi\varepsilon_0}\cdot\frac1z$$
2. **Field from the potential.**
   $$\begin{aligned} \mathbf E &= -\overline{\Phi'} \\ &= \frac{\lambda}{2\pi\varepsilon_0}\cdot\frac{1}{\bar z} \\ &= \frac{\lambda}{2\pi\varepsilon_0}\cdot\frac{z}{\lvert z\rvert^2} \end{aligned}$$
   That points along z, straight away from the line.
3. **Size.** It is $\frac{\lambda}{2\pi\varepsilon_0 r}$ with $r = 5$ cm, and $\frac{\lambda}{2\pi\varepsilon_0} = 17.98$ V:
   $$\begin{aligned} E &= \frac{17.98}{0.05} \\ &= 359.5\ \text{V/m} \end{aligned}$$
4. **Components.**
   $$\begin{aligned} E_x &= 359.5 \times \frac35 \\ &= 215.7\ \text{V/m} \\ E_y &= 359.5 \times \frac45 \\ &= 287.6\ \text{V/m} \end{aligned}$$
5. **Check.** That matches Gauss's law, and the complex potential gave the direction for free.

**Answer:** the field is 359.5 V/m, pointing straight away from the line: 215.7 V/m along x and 287.6 V/m along y.
:::
:::

::: check
given: a = 1 | 2 | 3; b = 1 | 3
answer: 2*a - 2*b
tolerance: 0

## What's $u_{xx} + u_{yy}$ for $u = \given{a}x^2 - \given{b}y^2$? (Zero means harmonic.)

::: right
Right. {answer}: harmonic only when the two coefficients are equal.
:::

::: misses
- [any] Not yet. $u_{xx} = 2a$ and $u_{yy} = -2b$.
:::
:::

::: check
given: c = 2 | 3 | 5
answer: c
tolerance: 0

## $u = x^2 - y^2 + cx$ with c = {c} has the harmonic conjugate $v = 2xy + ky$. What's k?

::: right
Right. k = {answer}, so $u + jv = z^2 + \given{c}z$.
:::

::: misses
- [any] Not yet. $v_y = u_x = 2x + c$.
:::
:::

::: check
given: E = 100 | 250 | 1000; x = 0.01 | 0.05; y = 0.01 | 0.02
answer: -E*x
unit: V
tolerance: 0.5%

## A uniform field of {E} V/m along x has complex potential $\Phi = -E_0z$. What's the potential at $(\given{x}, \given{y})$ m?

::: right
Right. $\varphi = \text{Re}(-E_0z) = -E_0x$ = {answer} V.
:::

::: misses
- [-E*sqrt(x^2 + y^2)] Only the x part matters: the potential is $-E_0x$.
- [any] Not yet. Take the real part of $-E_0z$.
:::
:::

::: check
given: l = 1 | 5 | 20; r1 = 0.001 | 0.002; r2 = 0.01 | 0.05
answer: l*1e-9/(2*pi*8.854e-12)*ln(r2/r1)
unit: V
tolerance: 0.5%

## A line charge of {l} nC/m has $\varphi = -\frac{\lambda}{2\pi\varepsilon_0}\ln r$. What's the potential difference between radii {r1} m and {r2} m?

::: right
Right. $\frac{\lambda}{2\pi\varepsilon_0}\ln(r_2/r_1)$ = {answer} V.
:::

::: misses
- [l*1e-9/(2*pi*8.854e-12)*log(r2/r1)] Use the natural logarithm.
- [any] Not yet. $\frac{\lambda}{2\pi\varepsilon_0}\ln(r_2/r_1)$.
:::
:::

::: check
given: U = 1 | 2 | 5; R = 0.5 | 1; t = 45 | 60 | 90
answer: U*abs(1 - exp(-2*j*t*pi/180))
tolerance: 0.5%

## Uniform flow U = {U} past a cylinder of radius {R}: $\Phi = U(z + R^2/z)$. What's the speed on the cylinder's surface at angle {t}° from the flow direction?

::: right
Right. $\lvert\Phi'\rvert = U\lvert 1 - e^{-2j\theta}\rvert = 2U\lvert\sin\theta\rvert$ = {answer}.
:::

::: misses
- [U] That's far away; on the surface the flow speeds up or slows down.
- [any] Not yet. $\lvert U(1 - R^2/z^2)\rvert$ at $z = Re^{j\theta}$.
:::
:::

::: check
kind: choice

## The level curves of u and v for an analytic function f cross each other at what angle, where $f' \ne 0$?

- [ ] 45°
- [x] 90°
- [ ] Any angle
- [ ] They never cross

::: misses
- [1] The gradients are perpendicular, so the curves are too.
- [3] The Cauchy–Riemann equations fix it.
- [4] They cross everywhere $f' \ne 0$.
:::
:::

::: check
kind: parts
given: c = 1 | 2; x = 0.5 | 1; y = 1 | 2

## $u = x^3 - 3xy^2 + \given{c}x$ is the real part of an analytic f.

::: part
answer: 3*x^2*y - y^3 + c*y
tolerance: 0.5%

### What is its harmonic conjugate v at $(\given{x}, \given{y})$, taking $v(0, 0) = 0$?

::: misses
- [3*x^2*y - y^3] The cx term contributes cy.
- [any] f is $z^3 + cz$; take its imaginary part.
:::
:::

::: part
answer: sqrt((3*(x^2 - y^2) + c)^2 + 36*x^2*y^2)
tolerance: 0.5%

### What is $\lvert f'\rvert$ there, the size of the gradient of u?

::: misses
- [any] $f' = 3z^2 + c$; take its size.
:::
:::
:::

::: check
kind: derivation
vars: a = -3..3, b = -3..3, x = -2..2, y = -2..2

## $u = ax^2 + bxy - ay^2$ is harmonic. Find a conjugate v with $v(0, 0) = 0$.

::: step
answer: 2*a*x + b*y

### What is $u_x$, which must equal $v_y$?
:::

::: step
answer: 2*a*x*y + b*(y^2 - x^2)/2

### Integrate in y and fix the leftover function of x with $v_x = -u_y$. What is v?
:::

::: right
Right. $v = 2axy + \frac b2(y^2 - x^2)$. Check: $v_x = 2ay - bx = -u_y$.
:::
:::

::: explain
## Why can the real part of any analytic function serve as an electrostatic potential?

::: model
In a region with no charge, the electrostatic potential must satisfy Laplace's equation, $\varphi_{xx} + \varphi_{yy} = 0$ in two dimensions. The Cauchy–Riemann equations make the real part of any analytic function satisfy exactly that: differentiating them gives $u_{xx} = v_{yx}$ and $u_{yy} = -v_{xy}$, which cancel. So every analytic function supplies a valid potential, and its imaginary part supplies the matching field lines, which cross the equipotentials at right angles. Solving a field problem then comes down to finding the analytic function whose potential takes the right values on the conductors.
:::
:::

::: practice

::: check
given: a = 2 | 4; b = 2 | 1
answer: 2*a - 2*b
tolerance: 0

## Laplacian of $\given{a}x^2 - \given{b}y^2$?

::: misses
- [any] $2a - 2b$.
:::
:::

::: check
given: l = 2 | 10; r1 = 0.001; r2 = 0.02 | 0.1
answer: l*1e-9/(2*pi*8.854e-12)*ln(r2/r1)
unit: V
tolerance: 0.5%

## Line charge {l} nC/m: voltage between {r1} m and {r2} m?

::: misses
- [any] $\frac{\lambda}{2\pi\varepsilon_0}\ln(r_2/r_1)$.
:::
:::

::: check
given: U = 3 | 4; t = 45 | 90
answer: 2*U*abs(sin(t*pi/180))
tolerance: 0.5%

## Surface speed at {t}° for flow U = {U} past a cylinder?

::: misses
- [any] $2U\lvert\sin\theta\rvert$.
:::
:::
:::
