Mike,
One other minor problem is that old is not the current value of z (or
> ----- Stuff here to calculate the initial z -----
>
>
> lastZ = z; // tdis initialization
>
> totalDistance = 0.0;
new for Fractint), it is the value at the start of the iteration that
ends with bailing out.