
Click on the image to see its parameters.
Tutorial: Fresnel Integral Coloring
Text and Images © 2011
Kerry Mitchell
Introduction
The Fresnel
integrals show up in physics (particularly, optics), and are interesting in
part because they look simple (considering how involved calculus can be), but
aren't easy to evaluate. When taken together, their graphs create the
Cornu spiral:
The points on the curve come from evaluating these equations:

Although the equations don't have simple analytical solutions, they can be
solved numerically, and that's what this coloring does. More precisely, it draws
the graphs that result from evaluating the equations numerically.
Background
The process of evaluating these equations is called integration. Ideally,
this results in formulas. However, this usually isn't possible, so computers are
often used to get answers as numbers. This process, numerical integration,
was one of the first applications of digital computers and can be extremely tricky.
That trickiness is what makes this coloring work, along with some generalizations
of the functions being integrated.
The integrand for the x equation is cos(π/2 t2)
and is sin(π/2 t2) for the y equation. For this
coloring, you can vary the frequencies and exponents independently to any real value.
By default, the frequencies are π/2 for both equations. Changing the frequency
alters the alignment of the sine and cosine functions, giving the graphs a very
different feel. (Click on the images to see the parameters.)
 |
 |
Red: sine 5% higher, cosine 5% lower Green: sine default,
cosine default Blue: sine 5% lower, cosine 5% higher |
Red: sine twice default, cosine default
Blue: sine default, cosine twice default |
A similar thing happens when changing the exponents, which are both set to 2
by default:

Red: sine 2.02, cosine 1.98
Green: sine 2, cosine 2
Blue: sine 1.98, cosine 2.02
In the middle near the bottom, there's black spiral that winds around a point.
That shows how all three lines (in this example) start out similar--their graphs
lie on top of each other. However, fairly quickly, the curves diverge and
each takes its own path.
In the integrals, the upper limit is θ. This value acts describes how long the curve is. In the Cornu spiral graph above, the curve begins at the green dot
and ends up wrapping around the final point (the white hole). Increasing θ
would make the graph longer and it would fill in the hole even more. This graph
is composed of many segments (1024, to be exact). Using more segments makes the
curve smoother, at the expense of memory and calculation time.
The curve's extent (θ) and the number of segments are set together and
indirectly. It turns out that if you were to set θ to get a pleasing shape
and then change the number of segments to make the curve smoother, then basic
shape of the graph would change. However, changing both simultaneously can allow
you to maintain the shape. This is done through a base and a multiple. Given both, then:
- θ, the curve extent, = base × multiple, and
- the number of segments = base2.
In the figure below, all three curves have the same base (41) and different
multiples. The blue curve has the largest multiple and extends furthest out
into the space. With the smallest multiple, the red curve is most confined. In
between, in both multiple and extent, is the green curve.

Red: base 41, multiple 4
Green: base 41, multiple 5
Blue: base 41, multiple 6
To keep the same basic shape and make the graph smoother, keep the multiple the
same and increase the base by a multiple of the square of the multiple. For
example, in this image, all three curves have a multiple of 3 (the default) and
they all have the same basic shape. How do they differ?
- The red curve is the coarsest, as it has only 361 segments (361 =
192 and the base is 19).
- The green curve has a base of 28 and has 784 segments (784 =
282). It has the same shape because 28 - 19 = 9 = 32.
- The blue curve is the smoothest, with 4096 segments (base = 64). The
difference from the red curve's base is 64 - 28 = 36, which is 4 ×
32.
Click on the image to download the parameters. Play with the mulitiplier and base
values to see how they change (or don't change) the image. Notes:
- The "change the base by a multiple of the multiple squared" trick works
when the frequencies are both set to 1 and the powers both set to 2 (the
default settings). It may work with other settings, but you get to find that
out on your own.
- In this image, I've hidden parts of the green curve and blue curves to
show the graphs more clearly. You can control how much of the curve is shown
(without changing it) by adjusting the "first line" and "last line" parameters.
Set them both to 0 to show the entire curve.
Integration is often thought of as adding up a lot of areas (yes, I
know that this is a gross oversimplification, but just go with it). There are
many ways to do that, and changing the integration method will change the graph
you get with this coloring. Three methods are offered:
- Rectangular rule: treat each area as a rectangle;
- Trapezoidal rule: treat each area as a trapezoid; and
- Simpson's rule: each area has a parabola on top.
You choose how much of each method you want to employ by setting its weight. Here
are several examples, each using the default frequencies, powers, multiples, and
bases. In the left image, the red curve is the rectangular rule, green is
trapezoidal, and blue is Simpson's rule. In the right image, the three methods
are combined in differing amounts.
 |
 |
Red: rect. 1, trap. 0, Simp. 0
Green: rect. 0, trap. 1, Simp. 0
Blue: rect. 0, trap. 0, Simp. 1
|
Red: rect. 1, trap. 1, Simp. 1
Green: rect. 1, trap. -1, Simp. (0, 1)
Blue: rect. 3, trap. -2, Simp. (1, 2)
|
To manage the weights:
- Set a method's weight to 0 (both real and imaginary parts) to turn it off.
- If you're only using one method, its weight is irrelevant (so long as it
is not 0).
- The total of the three weights cannot be 0.
Parameters
The parameters are in three groups: those for the functions being integrated,
those for the integration method, and drawing parameters. Where there is "(hint)"
next to the parameter name (in UF, not here), that indicates that some small
modicum of help is available (click on UF's "?" icon and then click in the
entry area for that parameter to see the hint.)
Function Parameters
- cosine frequency: This factor multiplies π/2 to give the actual
frequency used. That is, set this to 1 for the internal calculation to use
the standard frequency of π/2.
- sine frequency: This factor multiplies π/2 to give the actual
frequency used. That is, set this to 1 for the internal calculation to use
the standard frequency of π/2.
- cosine power: The exponent of the cosine function.
- sine power: The exponent of the sine function.
Integration Parameters
Remember that, while any individual weight can be 0, the total of the three
weights added together cannot be 0.
- rectangular weight (Re) and (Im): The real and imaginary parts of the
rectangular rule weight. Set both to 0 to turn off this method.
- trapezoidal weight (Re) and (Im): The real and imaginary parts of the
trapezoidal rule weight. Set both to 0 to turn off this method.
- Simpson weight (Re) and (Im): The real and imaginary parts of the
Simpson's rule weight. Set both to 0 to turn off this method.
Drawing Parameters
- base: Used to determine how many segments are drawn and the extent of
the graph. Must be an integer larger than 1.
- multiple: Used to determine the extent of the graph. Can be any real
value.
- color by: How to render the line. Choose one of:
- outline: Each segment is colored from the inside (index 0) to the edge
(index 399).
- which line: Colors each segment differently.
- line thickness: How thick is segment is drawn.
- first line: The first segment to be drawn. Use 0 to draw them all.
- last line: The last segment to be drawn. Use 0 to draw them all. See "print
last" below.
- speedup threshold: Decrease to draw faster. Be careful to not set too
small, or the curve will appear as a dashed line. See "print longest" below.
- center and scale: Check to rescale the curve so that it will fit into a
square from (-1, -1) to (1, 1). Generally compatible with "Reset Location" on
the Location tab. Unchecking may require zooming out a lot to see the entire
curve.
- print longest: Check to see the length of the longest segment. Set the
speedup threshold largest than this amount to avoid having the curve appear as
a dashed line. You may need to reload the coloring after checking the box if
no values print.
- print last: Check to see the index of the last segment, for use with the
"last line" parameter. You may need to reload the coloring after checking the
box if no values print.
Hints
I consider this to be a special-purpose coloring, and not necessarily conducive
to general fractaling. You are, of course, free to use this coloring however you’d like. However, these hints may help your explorations be more productive.
- This is one of those coloring formulas that does all the work. It was
designed to be used as an outside coloring with the “Pixel” formula in
lkm.ucl.
- The memory required (and rendering time) increase with the square of the
"base" parameter, so tread lightly with large bases.
- You may wish to begin with the "center and scale" box checked, until you
have a design that you like. If you're working with several curves, uncheck
the box to see how they really relate to each other (or don't).
Back
to Tutorials page
Up
to my home page