# Distance Estimate
See mathr.co.uk/de for a bit about distance estimates for fractals.
The formulas are presented here without much commentary so far.
# 1 Distance Estimate
Given \((x, y)\) screenspace pixel coordinates, and fractal formula iterates \((X, Y)\) with subscripts indicating derivatives w.r.t. subscripted variable, then the directional components \((U, V)\) of a distance estimate in pixels are:
\[\begin{aligned} U &= \frac{(Y^2 + X^2) (Y Y_x + X X_x) \log(Y^2 + X^2)}{2 ((Y Y_y + X X_y)^2 + (Y Y_x + X X_x)^2)} \\ V &= -\frac{(Y^2 + X^2) (Y Y_y + X X_y) \log(Y^2 + X^2)}{2 ((Y Y_y + X X_y)^2 + (Y Y_x + X X_x)^2)} \end{aligned}\]
Then
\[|d| = \sqrt{U^2 + V^2} = \frac{(Y^2 + X^2) \log(Y^2 + X^2)}{2 \sqrt{Y^2 Y_y^2 + 2 X Y X_y Y_y + Y^2 Y_x^2 + 2 X Y X_x Y_x + X^2 X_y^2 + X^2 X_x^2}}.\]
# 2 Spatial Derivative Of Distance Estimate
Requires second derivatives of the iterates \(X, Y\).
Derivative of magnitude may be useful for colouring effects:
\[\begin{aligned} |d|_x &= \frac{(Y Y_x + X X_x) (1 + \log(Y^2 + X^2))}{\sqrt{Y^2 Y_y^2 + 2 X Y X_y Y_y + Y^2 Y_x^2 + 2 X Y X_x Y_x + X^2 X_y^2 + X^2 X_x^2}} \\ &- \frac{(2 Y Y_x Y_y^2 + 2 Y^2 Y_{xy} Y_y + 2 X X_y Y_x Y_y + 2 Y X_x X_y Y_y + 2 X Y X_{xy} Y_y + 2 Y^2 Y_x Y_{xx} + 2 X Y X_x Y_{xx} + 2 X Y X_y Y_{xy} + 2 Y Y_x^3 + 2 X X_x Y_x^2 + 2 X Y X_{xx} Y_x + 2 Y X_x^2 Y_x + 2 X X_x X_y^2 + 2 X^2 X_{xy} X_y + 2 X^2 X_x X_{xx} + 2 X X_x^3) (Y^2 + X^2) \log(Y^2 + X^2)}{4 (Y^2 Y_y^2 + 2 X Y X_y Y_y + Y^2 Y_x^2 + 2 X Y X_x Y_x + X^2 X_y^2 + X^2 X_x^2)^{3/2}} \\ |d|_y &= \frac{(Y Y_y + X X_y) (1 + \log(Y^2 + X^2))}{\sqrt{Y^2 Y_y^2 + 2 X Y X_y Y_y + Y^2 Y_x^2 + 2 X Y X_x Y_x + X^2 X_y^2 + X^2 X_x^2}} \\ &- \frac{(2 Y^2 Y_y Y_{yy} + 2 X Y X_y Y_{yy} + 2 Y Y_y^3 + 2 X X_y Y_y^2 + 2 Y Y_x^2 Y_y + 2 X X_x Y_x Y_y + 2 X Y X_{yy} Y_y + 2 Y X_y^2 Y_y + 2 Y^2 Y_x Y_{xy} + 2 X Y X_x Y_{xy} + 2 Y X_x X_y Y_x + 2 X Y X_{xy} Y_x + 2 X^2 X_y X_{yy} + 2 X X_y^3 + 2 X X_x^2 X_y + 2 X^2 X_x X_{xy}) (Y^2 + X^2) \log(Y^2 + X^2)}{4 (Y^2 Y_y^2 + 2 X Y X_y Y_y + Y^2 Y_x^2 + 2 X Y X_x Y_x + X^2 X_y^2 + X^2 X_x^2)^{3/2}} \end{aligned}\]
See: https://www.math.univ-toulouse.fr/~cheritat/wiki-draw/index.php/Mandelbrot_set#Variation.
The derivatives of the directional components might possibly have some use too:
\[\begin{aligned} U_x &= \frac{(Y^2 + X^2) (Y Y_{xx} + (Y_x)^2 + X X_{xx} + (X_x)^2) \log(Y^2 + X^2)}{2 ((Y Y_y + X X_y)^2 + (Y Y_x + X X_x)^2)} \\ &+ \frac{(Y Y_x + X X_x) (2 Y Y_x + 2 X X_x) \log(Y^2 + X^2)}{2 ((Y Y_y + X X_y)^2 + (Y Y_x + X X_x)^2)} \\ &+ \frac{(Y Y_x + X X_x) (2 Y Y_x + 2 X X_x)}{2 ((Y Y_y + X X_y)^2 + (Y Y_x + X X_x)^2)} \\ &- \frac{(Y^2 + X^2) (Y Y_x + X X_x) (2 (Y Y_y + X X_y) (Y_x Y_y + Y Y_{xy} + X_x X_y + X X_{xy}) + 2 (Y Y_x + X X_x) (Y Y_{xx} + (Y_x)^2 + X X_{xx} + (X_x)^2)) \log(Y^2 + X^2)}{2 ((Y Y_y + X X_y)^2 + (Y Y_x + X X_x)^2)^2} \\ U_y &= \frac{(Y^2 + X^2) (Y_x Y_y + Y Y_{xy} + X_x X_y + X X_{xy}) \log(Y^2 + X^2)}{2 ((Y Y_y + X X_y)^2 + (Y Y_x + X X_x)^2)} \\ &+ \frac{(Y Y_x + X X_x) (2 Y Y_y + 2 X X_y) \log(Y^2 + X^2)}{2 ((Y Y_y + X X_y)^2 + (Y Y_x + X X_x)^2)} \\ &+ \frac{(Y Y_x + X X_x) (2 Y Y_y + 2 X X_y)}{2 ((Y Y_y + X X_y)^2 + (Y Y_x + X X_x)^2)} \\ &- \frac{(Y^2 + X^2) (Y Y_x + X X_x) (2 (Y Y_y + X X_y) (Y Y_{yy} + (Y_y)^2 + X X_{yy} + (X_y)^2) + 2 (Y Y_x + X X_x) (Y_x Y_y + Y Y_{xy} + X_x X_y + X X_{xy})) \log(Y^2 + X^2)}{2 ((Y Y_y + X X_y)^2 + (Y Y_x + X X_x)^2)^2} \\ V_x &= \frac{(Y^2 + X^2) (- Y_x Y_y - Y Y_{xy} - X_x X_y - X X_{xy}) \log(Y^2 + X^2)}{2 ((Y Y_y + X X_y)^2 + (Y Y_x + X X_x)^2)} \\ &+ \frac{(2 Y Y_x + 2 X X_x) (- Y Y_y - X X_y) \log(Y^2 + X^2)}{2 ((Y Y_y + X X_y)^2 + (Y Y_x + X X_x)^2)} \\ &+ \frac{(2 Y Y_x + 2 X X_x) (- Y Y_y - X X_y)}{2 ((Y Y_y + X X_y)^2 + (Y Y_x + X X_x)^2)} \\ &- \frac{((Y^2 + X^2) (- Y Y_y - X X_y) (2 (Y Y_y + X X_y) (Y_x Y_y + Y Y_{xy} + X_x X_y + X X_{xy}) + 2 (Y Y_x + X X_x) (Y Y_{xx} + (Y_x)^2 + X X_{xx} + (X_x)^2)) \log(Y^2 + X^2))}{(2 ((Y Y_y + X X_y)^2 + (Y Y_x + X X_x)^2)^2)} \\ V_y &= \frac{(Y^2 + X^2) (( - Y Y_{yy}) - (Y_y)^2 - X X_{yy} - (X_y)^2) \log(Y^2 + X^2)}{2 ((Y Y_y + X X_y)^2 + (Y Y_x + X X_x)^2)} \\ &+ \frac{(- Y Y_y - X X_y) (2 Y Y_y + 2 X X_y) \log(Y^2 + X^2)}{2 ((Y Y_y + X X_y)^2 + (Y Y_x + X X_x)^2)} \\ &+ \frac{(- Y Y_y - X X_y) (2 Y Y_y + 2 X X_y)}{2 ((Y Y_y + X X_y)^2 + (Y Y_x + X X_x)^2)} \\ &- \frac{(Y^2 + X^2) (( - Y Y_y) - X X_y) (2 (Y Y_y + X X_y) (Y Y_{yy} + (Y_y)^2 + X X_{yy} + (X_y)^2) + 2 (Y Y_x + X X_x) (Y_x Y_y + Y Y_{xy} + X_x X_y + X X_{xy})) \log(Y^2 + X^2)}{2 ((Y Y_y + X X_y)^2 + (Y Y_x + X X_x)^2)^2} \end{aligned}\]
# 3 Source
Maxima input was:
X : f(x, y)$
Y : g(x, y)$
dX : X * diff(X, x) + Y * diff(Y, x);
dY : X * diff(X, y) + Y * diff(Y, y);
deX : (X^2 + Y^2) * log(X^2 + Y^2)/2 * dX / (dX^2 + dY^2);
deY : (X^2 + Y^2) * log(X^2 + Y^2)/2 * -dY / (dX^2 + dY^2);
de : radcan(sqrt(deX^2 + deY^2));
diff(de, x);
diff(de, y);
diff(deX, x);
diff(deX, y);
diff(deY, x);
diff(deY, y);
Equations above extracted from output wxMaxima document using a shell script:
cat content.xml |
sed "s|<t[^>]*>||g" |
sed "s|</t>||g" |
tr -d " " |
sed "s|'diff(f(x,y),x,1)|X_x|g" |
sed "s|'diff(f(x,y),y,1)|X_y|g" |
sed "s|'diff(g(x,y),x,1)|Y_x|g" |
sed "s|'diff(g(x,y),y,1)|Y_y|g" |
sed "s|'diff(f(x,y),x,2)|X_{xx}|g" |
sed "s|'diff(f(x,y),x,1,y,1)|X_{xy}|g" |
sed "s|'diff(f(x,y),y,2)|X_{yy}|g" |
sed "s|'diff(g(x,y),x,2)|Y_{xx}|g" |
sed "s|'diff(g(x,y),x,1,y,1)|Y_{xy}|g" |
sed "s|'diff(g(x,y),y,2)|Y_{yy}|g" |
sed "s|f(x,y)|X|g" |
sed "s|g(x,y)|Y|g" |
sed "s|\([+*/-]\)| \1 |g" |
sed "s| [*] | |g" |
sed "s|log|\\\\log|g" |
sed "s|sqrt|\\\\sqrt|g"