WOLFRAM

Let’s Do It Again

Iteration usually increases complexity. For example, ponder the following “Fractal Maze”. The green lines mark the boundaries of a frame that shows the black paths of a maze. Copies of that frame and the paths are copied inside. With 4 levels of nested frames, it is possible to get from 1 to 8 on the outer frame. When pictures are repeated inside themselves, it’s usually called the Droste effect.

Fractal Maze

Another simple experiment involves rolling a box around, each time toppling it over an edge. Where can the box wind up? “Box Toppling Patterns” shows how complicated moving a box can get.

Box Toppling Patterns

A New Kind of Science discusses what a simple program can do at length. Cellular automata, Turing machines, and substitution systems are some of the simple programs that show interesting behavior when iterated. Here is “Turing Machines with Cyclic Tapes” (Stephen Wolfram and Kovas Boguta).

Turing Machines with Cyclic Tapes

Reduce, Replicate, Rebuild” (Stephen Face) does just that with a single square, and interesting patterns emerge as the simple operations are repeated.

Reduce, Replicate, Rebuild

In “Orbit Diagram of the Logistic Map”, a more classic example of patterns in a repeated figure is shown.

Orbit Diagram of the Logistic Map

So, obviously, when faced with thousands of calculations, using a computer can help a lot. But therein lies a danger. Most textbooks list as a property of logarithms that log(a b)=log(a)+log(b). Most of the time that’s correct, but unfortunately, there is a branch cut with logarithms. For negative integers, logarithms are discontinuous. More pictures are available at “Surface with Branch Cuts” (Yu-Sung Chang) or “The Monodromy Group of an Algebraic Function” (Maxim Rytin).

Plot3D[Im[Log[a + b I]], {a, -1, 1}, {b, -1, 1}]

Many programming languages ignore branch cuts. Mathematica does not have that luxury—when released in 1988, there were various function combinations that could make nonsensical results. Eventually, most of these errors were resolved by being exceedingly careful with branch cuts. For example, here is a correct method for handling the Log function. Thousands of other examples for how to be careful are given at The Wolfram Functions Site. Many of the most crucial functions have been available for a decade now.

Correct method for handling the Log function

If you’re a fan of fractals, you’ve probably seen pictures of the Mandelbrot set and the like. The popular fractals are built on continuous functions, such as x2. When a discontinuous function is used as the basis of a fractal, the result is a chaotic soup of discontinuities, which tends to be ugly to the human eye.

Why do I mention all this? Financial formulas tend to use many mathematical functions that have discontinuities. They can have bifurcations, which are the basis of catastrophe theory. When such a function is iterated outside of a careful program like Mathematica, the results can be meaningless. Making big financial decisions based on something utterly meaningless billions of times a second can be highly dangerous. Here’s a chart of the stock market on May 6, 2010 from Wikipedia.

A chart of the stock market on May 6, 2010

If lives or fortunes depend on the functions you’re combining and iterating, at least make sure that extreme caution went into their construction. Wolfram Research learned the hard way, two decades ago, how combined functions could misbehave. In Mathematica, these dangerous errors have been fixed for a long time. Iterate cautiously.

Download notebook

Comments

Join the discussion

!Please enter your comment (at least 5 characters).

!Please enter your name.

!Please enter a valid email address.

1 comment

  1. Hi Ed,

    I would love to see you elaborate on your last point a bit more. Stock crashes are a fascinating topic. I appreciate your view on such an interesting subject!

    Reply