Certain aspects of generating fractals (distance estimation, finding critical
points of a function, Newton's method) requires that we are able to calculate
the *differential* of a function. If your mathematical education stopped
at the age of 16, you probably won't have learned calculus at all and the very
word "calculus", if it means anything at all to you, means "some kind of advanced
maths that I could never grasp in a million years". Poppycock! You can learn
calculus if you have the mathematical education of a twelve year old. If you're
American, replace "maths" with "math". It's the same thing.

Getting anywhere in carpentry is impossible until you understand the concept
of "wood grain". Your progress as a musician stops until you learn to read music.
Similarly, your progress in *any* scientific study is limited until you learn calculus.
Don't believe me? What differentiates psychology from shamanism is statistics, the
ability to distinguish between significant results and chance results and *that*
requires calculus. In actual fact, you probably *have* learned calculus.
You may dimly remember from some long-ago science lesson Newton's equations of motion,
linking displacement, *s*, initial velocity, *u*, acceleration,
*a*, final velocity, *v* and time, *t*:

v = u + at s = ut + ½at^{2}v^{2}= u^{2}+ 2as

You then learned these by rote, applied them in an end-of-year test and promptly
forgot about them. What your physics teacher almost certainly failed to mention
was that all these equations could be derived from scratch if only you knew
that velocity was the rate of change of displacement with respect to time and
that acceleration was the rate of change of velocity with respect to time. It's
no coincidence that the discoverer of these equations of motion and the inventor
of calculus were the same person: Isaac Newton (pace, Leibniz fans: I know he *also*
invented calculus). Without the mathematical
tool, he couldn't have made the world-changing discoveries.

We'll see how to differentiate a simple function from first principles. This is the bit where you'll need the maths education of a twelve year old. Let's take a simple function:

y = x^{2}

If we add a little bit to *x*, written as *∆x*, *y*
will also change by a little bit, *∆y*. But the small change in *y*
won't be the same as the small change in *x* because *y*≠*x*. We
write down the equation as:

y + ∆y = (x + ∆x)^{2}

Expanding the brackets (twelve year old maths) gives us:

y + ∆y = x^{2}+ 2x∆x + ∆x^{2}

Subtracting *y* from both sides gives us the size of the
change in *y*:

∆y = 2x∆x + ∆x^{2}

Dividing both sides by *∆x* gives us the little change in *y*
with respect to a little change in *x*:

∆y / ∆x = 2x + ∆x

Note that the first term in the right-hand side does not depend on *∆x*.
Now here comes the magic bit. If we let *∆x* shrink to nothing at all, the
left-hand side doesn't become infinity because *∆y* is also shrinking to
nothing. What *does* happen is that the annoying *∆x* on the right-hand
side disappears. What we are left with is the *instantaneous rate of change*
of *y* with respect to *x*. For this, we replace *∆* with *d*
and obtain the differential of *y* = *x*^{2}:

dy/dx = 2x

Visually, we can picture this as taking a ray at right angles to the graph of a function
at a point and then drawing a straight line at right angles to the ray. This line
is called the *tangent* and its slope is the same as the value of the
differential at the point. With larger deltas, the tangent is only an approximation
of the slope.

Without too much difficulty, we can differentiate *y* = *x*^{3}:

y = x^{3}y + ∆y = (x + ∆x)^{3}= x^{3}+ 3x^{2}∆x + 3x∆x^{2}+ ∆x^{3}∴ ∆y = 3x^{2}∆x + 3x∆x^{2}+ ∆x^{3}∆y / ∆x = 3x^{2}+ 3x∆x + ∆x^{2}

Letting *∆y* and *∆x* shrink to nothing so that only the first term
in the right-hand side remains leaves us with:

dy/dx = 3x^{2}

Without forcing ourselves through the tedium of differentiating the fourth power
we can already see the pattern that gives the general rule for differentiating a
function of the form *x ^{n}*:

dx^{n}--- = nx^{n-1}dx

Remember that velocity is the differential of displacement with respect to time
and that acceleration is the differential of velocity? This means that acceleration
is the differential of the differential of displacement with respect to time, or the
second differential for short. To do this, we just apply the same differential
rules to the differential function. We also use a slightly different notation.
This means that we have the general formula for the second differential of functions
of the form *x ^{n}*:

d^{2}x^{n}---- = n(n-1)x^{n-2}dx^{2}

Should we need to, we can do this repeatedly to get the third differential, fourth differential, etc.

In principle, we can differentiate any differentiable function from first principles,
but this is sufficiently tedious that it makes sense to take advantage of the hard
work of others and simply to look up the
differential in a table. These days, of course, we can also use a tool like *Mathematica*
to spit out the function we're looking for.

This is a shorthand notation for first, second, etc. differentials that is a lot more convenient to use than the notation I've been using so far. It simply uses the 'ʹ' (prime) character:

f(x), fʹ(x), fʹʹ(x), fʹʹʹ(x), f^{(4)}(x), etc.

This is just differentiation in reverse. When we integrate a function we end
up with the function that, if differentiated, would give us the function we
started with. From the general form above, we can derive the general formula
for integrating functions of the form *x ^{n}*:

∫x^{n}dx = x^{n+1}/ (n+1)

This rule doesn't work when *n* = -1. No
x^{n} function will produce 1/x as its differential because the differential
of x^{0} (i.e. 1) is 0. The integral of 1/x is log_{e}(x).

The '∫' thing is just an old printing character for 's'. We visualize the
operation as summing all the infinitely thin lines under the graph of the function
which is where the notation comes from. We can see that this is the case if
we consider the function *y* = *x*. The graph of the function
is a half a square of sides *x* which gives us the area under the graph
as ½*x*^{2}. You should also be able to figure out where Newton's
equations of motion come from - they are the results of integrating velocity and/or
acceleration.

A one-way function is something that is easy to do one way but (close to) impossible
to do the other. For example, you can multiply two prime numbers very easily, even
if they're large, but finding *which* two prime numbers were multiplied together
to produce a given number (prime factorization) is astonishingly hard. Differentiation
is the same: we can do it easily enough but doing it backwards to integrate is
often astonishingly difficult. Therefore, we'll generally use tables of integrals
(or even numeric methods) to integrate a function.

When *f*(x) is a combination of two other functions, *p*(x) and
*q*(x), there are rules to how we obtain the differential of the combined
function. If you're interested and not too easily bored, you can derive these
from first principles but deriving the quotient rule, in particular, is tedious
in the extreme. So I'll just give you the rules.

In the examples that follow, we'll be using the differentials of sin(*x*)
and *x*^{2} which are cos(*x*) and 2*x* respectively.

(p(x) + q(x))ʹ = pʹ(x) + qʹ(x) (sin(x) + x^{2})ʹ = cos(x) + 2x

(p(x)q(x))ʹ = pʹ(x)q(x) + p(x)qʹ(x) (x^{2}·sin(x))ʹ = 2x·sin(x) + x^{2}·cos(x)

(p(x) / q(x))ʹ = (pʹ(x)q(x) - p(x)qʹ(x)) / q(x)^{2}(sin(x) / x^{2})ʹ = (cos(x)·x^{2}- 2x·sin(x)) / x^{4}

p(q(x))ʹ = pʹ(q(x))·q'(x) (sin(x^{2}))ʹ = 2x·cos(x^{2})

The chain rule is important for our purposes, since we apply it to calculate
the cumulative differential of *f*(z) for boundary tracing.

There you go: that's all the calculus required to generate fractals.

Back to the index