Friday, January 2, 2009

Controlling Chaos

The Butterfly effect, one aspect of Chaos Theory, says "a butterfly's wings might create tiny changes in the atmosphere that may ultimately alter the path of a tornado or delay, accelerate or even prevent the occurrence of a tornado in a certain location." (http://en.wikipedia.org/wiki/Butterfly_effect)

The effect of small details on the resulting answer causes a huge problem of uncertanity and a huge margin of error that limit the prediction capabilities of anys simulation to just a few iterations. Take for example, the equation n = n^2 with a starting n value of 2
2, 4,16,256,65536,4294967296...
If the starting value was to n = 1.99, the sequence would be like...
1.99, 3.9601, 15.68239201, 245.9374192, 60485.21414, 3658461130....

See how that small change resulted in a very large difference??

Suppose that this calculation was conducted as an experiment. We knew the initial value to be something close to 2. After a few "turns" the value was measured to be 60485. I picked a number a bit far from the initial turn so that the change was measurable. Using these 3 pieces of information, 60485, n = n^2, turn = 5, we can find the initial value by simply changing the equation to n = squareroot(n). Using this, we get the sequence
60485, 245.9369838, 15.68237813, 3.960098247, 1.98999956

Ofcourse, there is the problem of loosing data while backtrackign (more chaos....). I'd suggest finding the midpoint between the measured initial value and the calculated initial value to find a better estimation of the initial value.

(2+1.98999956)/2 = 1.99499978.

If we were to use this newly computed value as the starting point, the sequence would look like:

1.99499978, 3.980024122, 15.84059201, 250.9243552, 62963.03202, 3964343401....

Looking back at all three of the sequences and the benefit of this method:

Actual Values: 1.99, 3.9601, 15.68239201, 245.9374192, 60485.21414, 3658461130
Rounded Values: 2, 4, 16, 256, 65536, 4294967296
Re-Adjusted Calculations: 1.99499978, 3.980024122, 15.84059201, 250.9243552, 62963.03202, 3964343401

The difference: (Calculated - Actual value)
Rounded Value: 4294967296 - 3658461130 = 636506166
Re-Adjusted Calculations: 3964343401 - 3658461130= 305882271

The result that readjusted and recalculated for the initial value was 2X as close to the actual value as the one that didn't. Continually readjusting the initial value and re-calculating will, yes, be very process intensive for large sequences. It'd actually make more sense to simply re-start the calculation with the current point in time as the initial value, but tracking back like this will allow you to adjust the measurements to account for the measurement error. In the above example, it was possible to calculate that the difference was +/- 0.01 by subtracting 1.99499978 from 2. This error can then be plugged into the calculations to adjust for the measurement error.