Is mistake the word we should be using?

Primary differences?
1) The torus's smaller radius is used for the radius check
2) if radius check is not passed, z*=t instead of z/=t (I don't get nice images for z/=t???)
3) different DE (yeah.... that's important! You get something that resembles Cantor Dust instead of polygonals if you use standard DE)!
4) test1 boolean switch makes it so the SmallerRadius has less of an effect: (test1 + ~20*SmallerRadius) ~~ (!test1 + SmallerRadius).
Use:
1) start out with smaller radius set to 0
2) returnMode (should be called DE_Mode) = 2, 3, or 4 to check out the polygonals- you'll get dust if you set smaller radius to 0 for regular DE
3) Donuts = 4 is a nice one (it does the square shapes)
4) DonutFactor 1.1~1.3
I started to play with your different DE modes. It's amazing how it works. It looks like shapes are not coming from fractal formula but just from errors of distance estimation.
E.g. I got something like on attached image:
With DE calculation built into formula I can't get more than 4 donuts, too. I also had to change from z/=t to z*=t
So the only way to get different number of donuts (not weird shapes) is to use deltaDE algorithm.
You asked how deltaDE works so here is algorithm (pseudocode is better for explanation):
vect3 z0 = ResultOfFractalIterations(z)
float r = length(z0)
vect3 z1 = ResultOfFractalIterations(z + vect3(delta, 0,0))
float r1 = length(z1)
float dr1 = fabs(r1 - r) / delta
vect3 z2 = ResultOfFractalIterations(z + vect3(0, delta, 0))
float r2 = length(z2)
float dr2 = fabs(r2 - r) / delta
vect3 z1 = ResultOfFractalIterations(z + vect3(0, 0, delta))
float r3 = length(z3)
float dr3 = fabs(r3 - r) / delta
double dr = sqrt(dr1*dr1 + dr2*dr2 + dr3*dr3)
distance = 0.5 * r / dr (or distance = 0.5 * r * log(r) / dr for mandelbulbs)
One important remark thing is to calculate z1, z2 and z3 using exactly the same number of iterations as z0
delta must be some very small number. For doubles I use 1e-10. For floats the best is something about 1e-5.
Inside fractal formula we don't need to calculate dr.