---
title: The complex derivative
heading: A limit that has to agree from every direction
eyebrow: A12 · Lesson 2 · The complex derivative
xp: 40
---

::: hook
The derivative of a complex function is defined exactly as for a real one, the limit of $(f(z + h) - f(z))/h$ as h shrinks to zero. The difference is that h is now complex, so it can approach zero from any direction in the plane, along the real axis, the imaginary axis or a spiral, and the limit must come out the same every way. That's a much stronger demand than in real calculus. Functions that meet it, like polynomials, $e^z$ and $1/z$, have remarkable properties; functions that fail it, like $\bar z$ and $\lvert z\rvert^2$, don't, even though they're perfectly smooth as functions of x and y.
:::

::: play
- Around the point $z_0$ (the dot), a small dashed circle of radius ε; its image under $w = z^2$ is the solid curve around $z_0^2$.
- For small ε, the image is almost exactly a circle of radius $\lvert f'(z_0)\rvert\varepsilon = 2\lvert z_0\rvert\varepsilon$: near any point, the map just scales and rotates. The readouts compare the image's size with that prediction.
- Grow ε and the image distorts away from a circle: the derivative only describes the map near $z_0$.
:::
:::

```sim plot
view: complex
range: 2.5
slider: a = -1.5..1.5 step 0.05 = 1
slider: b = -1.5..1.5 step 0.05 = 0.5
slider: e = 0.02..0.8 step 0.02 = 0.2
curve: a + j*b + e*exp(j*u) | over: u = 0..2*pi | dashed
curve: (a + j*b + e*exp(j*u))^2 | over: u = 0..2*pi
dot: a + j*b | label: z₀
dot: (a + j*b)^2 | label: z₀²
readout: predicted image radius, 2|z₀|ε = 2*abs(a + j*b)*e
readout: image size along real ε = abs((a + j*b + e)^2 - (a + j*b)^2)
```

::: predict
## For $f(z) = \bar z$ (the conjugate), the difference quotient $(f(z + h) - f(z))/h$ equals $\bar h/h$. What is it when h is real, and when h is imaginary?

- [ ] 1 both times
- [x] 1 for real h, −1 for imaginary h
- [ ] 0 both times
- [ ] j for real h, −j for imaginary h

::: reveal
1 for real h ($\bar h = h$) and −1 for imaginary h ($\bar h = -h$). The limit depends on the direction, so it doesn't exist: $\bar z$ has no complex derivative anywhere, even though, as a map, it's just a mirror reflection.
:::
:::

::: nameit
## The definition

$$f'(z) = \lim_{h \to 0} \frac{f(z + h) - f(z)}{h}$$

where h is complex and the limit must be the same whichever way h approaches 0. A function differentiable at every point of an open region is **analytic** (or holomorphic) there.

## The familiar rules still hold

$\frac{d}{dz}z^n = nz^{n-1}$, and the sum, product, quotient and chain rules work as in real calculus; so do $\frac{d}{dz}e^z = e^z$ and $\frac{d}{dz}(1/z) = -1/z^2$ (for $z \ne 0$). Polynomials are analytic everywhere; rational functions everywhere except their poles.

## What the derivative does

Near $z_0$, $f(z_0 + h) \approx f(z_0) + f'(z_0)h$. Multiplying h by the complex number $f'(z_0)$ rotates it by $\arg f'(z_0)$ and scales it by $\lvert f'(z_0)\rvert$. So, in a small enough neighborhood, an analytic map is a rotation and a scaling, the same in every direction, which is why it preserves angles (lesson 1) where $f' \ne 0$.

## Not differentiable

$\bar z$, $\text{Re}\,z$, $\lvert z\rvert$ and $\lvert z\rvert^2$ (except at 0) depend on x and y in a way that can't be written using z alone; their difference quotients depend on the direction of h.
:::

::: example
## Find the derivative of $f(z) = z^3$ at $z_0 = 1 + j$, and what it does to a small neighborhood.

::: solution
1. **Differentiate.**
   $$f'(z) = 3z^2$$
2. **Evaluate at 1 + j.** Since $(1 + j)^2 = 2j$:
   $$\begin{aligned} f'(1 + j) &= 3(2j) \\ &= 6j \end{aligned}$$
3. **Read off the scale and the turn.** A small neighborhood is scaled by $\lvert 6j\rvert = 6$ and rotated by $\arg 6j = 90°$.

**Answer:** $f'(1 + j) = 6j$, so a small neighborhood is stretched 6 times and rotated 90°.
:::
:::

::: example
## Show that $f(z) = \lvert z\rvert^2$ has a derivative only at $z = 0$.

::: solution
1. **Form the difference quotient.** Call it Q:
   $$\begin{aligned} Q &= \frac{\lvert z + h\rvert^2 - \lvert z\rvert^2}{h} \\ &= \frac{z\bar h + \bar z h + h\bar h}{h} \\ &= z\,\frac{\bar h}{h} + \bar z + \bar h \end{aligned}$$
2. **Let h go to 0.** The last term vanishes, but $z\,\bar h/h$ is $z$ for real h and $-z$ for imaginary h.
3. **When the two agree.** They agree only if z = 0, where the derivative is 0.

**Answer:** the limit depends on the direction of h unless z = 0, so $\lvert z\rvert^2$ has a derivative only at the origin, where it is 0.
:::
:::

::: example
## The map $w = \frac{z + 1}{z - 1}$ is a fraction of the same kind as the Smith chart's. What does it do to a tiny neighborhood of $z_0 = 2 + j$?

::: solution
1. **Quotient rule.**
   $$\begin{aligned} f'(z) &= \frac{(z - 1) - (z + 1)}{(z - 1)^2} \\ &= \frac{-2}{(z - 1)^2} \end{aligned}$$
2. **Evaluate at z₀.** Here $z_0 - 1 = 1 + j$, and $(1 + j)^2 = 2j$, so
   $$\begin{aligned} f'(z_0) &= \frac{-2}{2j} \\ &= j \end{aligned}$$
   That gives $\lvert f'\rvert = 1$ and $\arg f' = 90°$.
3. **Where the square lands.**
   $$\begin{aligned} f(z_0) &= \frac{3 + j}{1 + j} \\ &= 2 - j \end{aligned}$$
   A tiny square near $2 + j$ lands near $2 - j$ at the same size, turned a quarter turn counterclockwise.
4. **Other places.** The same map shrinks or stretches other places, since $\lvert f'\rvert$ changes with z.

**Answer:** $f'(z_0) = j$, so a tiny square near $2 + j$ moves to near $2 - j$ at the same size, turned a quarter turn counterclockwise.
:::
:::

::: check
given: a = 1 | 2 | -1; b = 1 | -2 | 3; n = 2 | 3
answer: Re(n*(a + j*b)^(n - 1))
tolerance: 0.5%

## What's the real part of the derivative of $z^{\given{n}}$ at $z = \given{a} + \given{b}j$?

::: right
Right. $nz^{n-1}$ has real part {answer}.
:::

::: misses
- [any] Not yet. $f'(z) = nz^{n-1}$, then take the real part.
:::
:::

::: check
given: a = 0.5 | 1 | 2; b = 0.5 | 1 | 1.5
answer: 2*abs(a + j*b)
tolerance: 0.5%

## By what factor does $w = z^2$ magnify a tiny neighborhood of $z_0 = \given{a} + \given{b}j$?

::: right
Right. $\lvert f'(z_0)\rvert = 2\lvert z_0\rvert$ = {answer}.
:::

::: misses
- [abs(a + j*b)^2] That's how far $z_0^2$ is from the origin; the local scaling is $\lvert f'\rvert$.
- [any] Not yet. $\lvert f'(z_0)\rvert$.
:::
:::

::: check
given: a = 1 | -1 | 0.5; b = 1 | 2 | -1
answer: arg(2*(a + j*b))*180/pi
unit: °
tolerance: 0.5%

## By what angle does $w = z^2$ rotate a tiny neighborhood of $z_0 = \given{a} + \given{b}j$?

::: right
Right. $\arg f'(z_0) = \arg 2z_0$ = {answer}°.
:::

::: misses
- [arg((a + j*b)^2)*180/pi] That's the angle of $z_0^2$; the rotation is the angle of $f'(z_0) = 2z_0$.
- [any] Not yet. $\arg f'(z_0)$.
:::
:::

::: check
given: a = 1 | 2 | -1; b = 0.5 | 3
answer: Re(-1/(a + j*b)^2)
tolerance: 0.5%

## What's the real part of the derivative of $1/z$ at $z = \given{a} + \given{b}j$?

::: right
Right. $-1/z^2$ has real part {answer}.
:::

::: misses
- [Re(1/(a + j*b)^2)] Mind the sign: $\frac{d}{dz}z^{-1} = -z^{-2}$.
- [any] Not yet. $-1/z^2$.
:::
:::

::: check
given: t = 0 | 45 | 90 | 180
answer: Re(exp(-2*j*t*pi/180))
tolerance: 0.001

## For $f(z) = \bar z$, the difference quotient is $\bar h/h$. What's its real part when h approaches 0 along the direction at angle {t}°?

::: right
Right. $\bar h/h = e^{-2j\theta}$, with real part {answer}: it depends on the direction, so there's no derivative.
:::

::: misses
- [any] Not yet. Write $h = re^{j\theta}$; then $\bar h/h = e^{-2j\theta}$.
:::
:::

::: check
kind: choice

## Which of these has a complex derivative at every point?

- [ ] $\bar z$
- [ ] $\lvert z\rvert^2$
- [x] $z^3 - 2z + 5$
- [ ] $\text{Re}\,z$

::: misses
- [1] Its difference quotient is 1 along the real axis and −1 along the imaginary axis.
- [2] Only at z = 0.
- [4] Like $\bar z$, it depends on the direction of h.
:::
:::

::: check
kind: parts
given: a = 1 | 2; b = 0.5 | 1 | 2; c = 1 | 3

## The map $w = z^2 + \given{c}z$ near $z_0 = \given{a} + \given{b}j$.

::: part
answer: sqrt((2*a + c)^2 + 4*b^2)
tolerance: 0.5%

### By what factor does it magnify a tiny neighborhood?

::: misses
- [2*sqrt(a^2 + b^2)] That's for $z^2$ alone; the derivative is $2z_0 + c$.
- [any] $\lvert f'(z_0)\rvert = \lvert 2z_0 + c\rvert$.
:::
:::

::: part
answer: atan(2*b/(2*a + c))*180/pi
unit: °
tolerance: 0.5%

### By what angle does it rotate it?

::: misses
- [atan(b/a)*180/pi] That's the angle of $z_0$; the rotation is the angle of $f'(z_0)$.
- [any] $\arg(2z_0 + c)$.
:::
:::
:::

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

## Differentiate $f(z) = z^3$ at $z_0 = a + jb$.

::: step
answer: 3*(a^2 - b^2)

### What is the real part of $f'(z_0)$?
:::

::: step
answer: 6*a*b

### What is its imaginary part?
:::

::: right
Right. $f' = 3z_0^2 = 3(a^2 - b^2) + 6abj$.
:::
:::

::: explain
## Why is being differentiable a much stronger condition for a complex function than for a real one?

::: model
For a real function, h can only approach zero from the left or the right, so differentiability asks two one-sided limits to agree. For a complex function, h can approach zero from infinitely many directions in the plane, and the difference quotient must tend to the same complex number along all of them. That forces the function to act locally like multiplication by a single complex number, a rotation and a scaling, the same in every direction, which ties u and v together tightly (the Cauchy–Riemann equations, next lesson). Many smooth-looking functions of x and y, like the conjugate, fail it.
:::
:::

::: practice

::: check
given: a = 2 | -1; b = 1 | 3
answer: 2*abs(a + j*b)
tolerance: 0.5%

## Local magnification of $z^2$ at $\given{a} + \given{b}j$?

::: misses
- [any] $2\lvert z_0\rvert$.
:::
:::

::: check
given: a = 1 | 3; b = 2 | -1; n = 3 | 4
answer: Re(n*(a + j*b)^(n - 1))
tolerance: 0.5%

## Real part of $(z^{\given{n}})'$ at $\given{a} + \given{b}j$?

::: misses
- [any] $nz^{n-1}$.
:::
:::

::: check
given: a = 2 | -1; b = 2 | 1
answer: Re(-1/(a + j*b)^2)
tolerance: 0.5%

## Real part of $(1/z)'$ at $\given{a} + \given{b}j$?

::: misses
- [any] $-1/z^2$.
:::
:::
:::
