Anisotropic x16 LOD (LOD)

Percentage Accurate: 75.9% → 75.4%
Time: 1.0min
Alternatives: 5
Speedup: N/A×

Specification

?
\[\left(\left(\left(\left(\left(\left(1 \leq w \land w \leq 16384\right) \land \left(1 \leq h \land h \leq 16384\right)\right) \land \left(10^{-20} \leq \left|dX.u\right| \land \left|dX.u\right| \leq 10^{+20}\right)\right) \land \left(10^{-20} \leq \left|dX.v\right| \land \left|dX.v\right| \leq 10^{+20}\right)\right) \land \left(10^{-20} \leq \left|dY.u\right| \land \left|dY.u\right| \leq 10^{+20}\right)\right) \land \left(10^{-20} \leq \left|dY.v\right| \land \left|dY.v\right| \leq 10^{+20}\right)\right) \land maxAniso = 16\]
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left\lfloorh\right\rfloor \cdot dX.v\\ t_1 := \left\lfloorw\right\rfloor \cdot dY.u\\ t_2 := \left\lfloorh\right\rfloor \cdot dY.v\\ t_3 := \left\lfloorw\right\rfloor \cdot dX.u\\ t_4 := \mathsf{max}\left(t\_3 \cdot t\_3 + t\_0 \cdot t\_0, t\_1 \cdot t\_1 + t\_2 \cdot t\_2\right)\\ t_5 := \sqrt{t\_4}\\ t_6 := \left|t\_3 \cdot t\_2 - t\_0 \cdot t\_1\right|\\ \log_{2} \begin{array}{l} \mathbf{if}\;\frac{t\_4}{t\_6} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{t\_5}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_6}{t\_5}\\ \end{array} \end{array} \end{array} \]
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
 :precision binary32
 (let* ((t_0 (* (floor h) dX.v))
        (t_1 (* (floor w) dY.u))
        (t_2 (* (floor h) dY.v))
        (t_3 (* (floor w) dX.u))
        (t_4 (fmax (+ (* t_3 t_3) (* t_0 t_0)) (+ (* t_1 t_1) (* t_2 t_2))))
        (t_5 (sqrt t_4))
        (t_6 (fabs (- (* t_3 t_2) (* t_0 t_1)))))
   (log2
    (if (> (/ t_4 t_6) (floor maxAniso))
      (/ t_5 (floor maxAniso))
      (/ t_6 t_5)))))
float code(float w, float h, float dX_46_u, float dX_46_v, float dY_46_u, float dY_46_v, float maxAniso) {
	float t_0 = floorf(h) * dX_46_v;
	float t_1 = floorf(w) * dY_46_u;
	float t_2 = floorf(h) * dY_46_v;
	float t_3 = floorf(w) * dX_46_u;
	float t_4 = fmaxf(((t_3 * t_3) + (t_0 * t_0)), ((t_1 * t_1) + (t_2 * t_2)));
	float t_5 = sqrtf(t_4);
	float t_6 = fabsf(((t_3 * t_2) - (t_0 * t_1)));
	float tmp;
	if ((t_4 / t_6) > floorf(maxAniso)) {
		tmp = t_5 / floorf(maxAniso);
	} else {
		tmp = t_6 / t_5;
	}
	return log2f(tmp);
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso)
	t_0 = Float32(floor(h) * dX_46_v)
	t_1 = Float32(floor(w) * dY_46_u)
	t_2 = Float32(floor(h) * dY_46_v)
	t_3 = Float32(floor(w) * dX_46_u)
	t_4 = (Float32(Float32(t_3 * t_3) + Float32(t_0 * t_0)) != Float32(Float32(t_3 * t_3) + Float32(t_0 * t_0))) ? Float32(Float32(t_1 * t_1) + Float32(t_2 * t_2)) : ((Float32(Float32(t_1 * t_1) + Float32(t_2 * t_2)) != Float32(Float32(t_1 * t_1) + Float32(t_2 * t_2))) ? Float32(Float32(t_3 * t_3) + Float32(t_0 * t_0)) : max(Float32(Float32(t_3 * t_3) + Float32(t_0 * t_0)), Float32(Float32(t_1 * t_1) + Float32(t_2 * t_2))))
	t_5 = sqrt(t_4)
	t_6 = abs(Float32(Float32(t_3 * t_2) - Float32(t_0 * t_1)))
	tmp = Float32(0.0)
	if (Float32(t_4 / t_6) > floor(maxAniso))
		tmp = Float32(t_5 / floor(maxAniso));
	else
		tmp = Float32(t_6 / t_5);
	end
	return log2(tmp)
end
function tmp_2 = code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso)
	t_0 = floor(h) * dX_46_v;
	t_1 = floor(w) * dY_46_u;
	t_2 = floor(h) * dY_46_v;
	t_3 = floor(w) * dX_46_u;
	t_4 = max(((t_3 * t_3) + (t_0 * t_0)), ((t_1 * t_1) + (t_2 * t_2)));
	t_5 = sqrt(t_4);
	t_6 = abs(((t_3 * t_2) - (t_0 * t_1)));
	tmp = single(0.0);
	if ((t_4 / t_6) > floor(maxAniso))
		tmp = t_5 / floor(maxAniso);
	else
		tmp = t_6 / t_5;
	end
	tmp_2 = log2(tmp);
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left\lfloorh\right\rfloor \cdot dX.v\\
t_1 := \left\lfloorw\right\rfloor \cdot dY.u\\
t_2 := \left\lfloorh\right\rfloor \cdot dY.v\\
t_3 := \left\lfloorw\right\rfloor \cdot dX.u\\
t_4 := \mathsf{max}\left(t\_3 \cdot t\_3 + t\_0 \cdot t\_0, t\_1 \cdot t\_1 + t\_2 \cdot t\_2\right)\\
t_5 := \sqrt{t\_4}\\
t_6 := \left|t\_3 \cdot t\_2 - t\_0 \cdot t\_1\right|\\
\log_{2} \begin{array}{l}
\mathbf{if}\;\frac{t\_4}{t\_6} > \left\lfloormaxAniso\right\rfloor:\\
\;\;\;\;\frac{t\_5}{\left\lfloormaxAniso\right\rfloor}\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_6}{t\_5}\\


\end{array}
\end{array}
\end{array}

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 5 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 75.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left\lfloorh\right\rfloor \cdot dX.v\\ t_1 := \left\lfloorw\right\rfloor \cdot dY.u\\ t_2 := \left\lfloorh\right\rfloor \cdot dY.v\\ t_3 := \left\lfloorw\right\rfloor \cdot dX.u\\ t_4 := \mathsf{max}\left(t\_3 \cdot t\_3 + t\_0 \cdot t\_0, t\_1 \cdot t\_1 + t\_2 \cdot t\_2\right)\\ t_5 := \sqrt{t\_4}\\ t_6 := \left|t\_3 \cdot t\_2 - t\_0 \cdot t\_1\right|\\ \log_{2} \begin{array}{l} \mathbf{if}\;\frac{t\_4}{t\_6} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{t\_5}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_6}{t\_5}\\ \end{array} \end{array} \end{array} \]
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
 :precision binary32
 (let* ((t_0 (* (floor h) dX.v))
        (t_1 (* (floor w) dY.u))
        (t_2 (* (floor h) dY.v))
        (t_3 (* (floor w) dX.u))
        (t_4 (fmax (+ (* t_3 t_3) (* t_0 t_0)) (+ (* t_1 t_1) (* t_2 t_2))))
        (t_5 (sqrt t_4))
        (t_6 (fabs (- (* t_3 t_2) (* t_0 t_1)))))
   (log2
    (if (> (/ t_4 t_6) (floor maxAniso))
      (/ t_5 (floor maxAniso))
      (/ t_6 t_5)))))
float code(float w, float h, float dX_46_u, float dX_46_v, float dY_46_u, float dY_46_v, float maxAniso) {
	float t_0 = floorf(h) * dX_46_v;
	float t_1 = floorf(w) * dY_46_u;
	float t_2 = floorf(h) * dY_46_v;
	float t_3 = floorf(w) * dX_46_u;
	float t_4 = fmaxf(((t_3 * t_3) + (t_0 * t_0)), ((t_1 * t_1) + (t_2 * t_2)));
	float t_5 = sqrtf(t_4);
	float t_6 = fabsf(((t_3 * t_2) - (t_0 * t_1)));
	float tmp;
	if ((t_4 / t_6) > floorf(maxAniso)) {
		tmp = t_5 / floorf(maxAniso);
	} else {
		tmp = t_6 / t_5;
	}
	return log2f(tmp);
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso)
	t_0 = Float32(floor(h) * dX_46_v)
	t_1 = Float32(floor(w) * dY_46_u)
	t_2 = Float32(floor(h) * dY_46_v)
	t_3 = Float32(floor(w) * dX_46_u)
	t_4 = (Float32(Float32(t_3 * t_3) + Float32(t_0 * t_0)) != Float32(Float32(t_3 * t_3) + Float32(t_0 * t_0))) ? Float32(Float32(t_1 * t_1) + Float32(t_2 * t_2)) : ((Float32(Float32(t_1 * t_1) + Float32(t_2 * t_2)) != Float32(Float32(t_1 * t_1) + Float32(t_2 * t_2))) ? Float32(Float32(t_3 * t_3) + Float32(t_0 * t_0)) : max(Float32(Float32(t_3 * t_3) + Float32(t_0 * t_0)), Float32(Float32(t_1 * t_1) + Float32(t_2 * t_2))))
	t_5 = sqrt(t_4)
	t_6 = abs(Float32(Float32(t_3 * t_2) - Float32(t_0 * t_1)))
	tmp = Float32(0.0)
	if (Float32(t_4 / t_6) > floor(maxAniso))
		tmp = Float32(t_5 / floor(maxAniso));
	else
		tmp = Float32(t_6 / t_5);
	end
	return log2(tmp)
end
function tmp_2 = code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso)
	t_0 = floor(h) * dX_46_v;
	t_1 = floor(w) * dY_46_u;
	t_2 = floor(h) * dY_46_v;
	t_3 = floor(w) * dX_46_u;
	t_4 = max(((t_3 * t_3) + (t_0 * t_0)), ((t_1 * t_1) + (t_2 * t_2)));
	t_5 = sqrt(t_4);
	t_6 = abs(((t_3 * t_2) - (t_0 * t_1)));
	tmp = single(0.0);
	if ((t_4 / t_6) > floor(maxAniso))
		tmp = t_5 / floor(maxAniso);
	else
		tmp = t_6 / t_5;
	end
	tmp_2 = log2(tmp);
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left\lfloorh\right\rfloor \cdot dX.v\\
t_1 := \left\lfloorw\right\rfloor \cdot dY.u\\
t_2 := \left\lfloorh\right\rfloor \cdot dY.v\\
t_3 := \left\lfloorw\right\rfloor \cdot dX.u\\
t_4 := \mathsf{max}\left(t\_3 \cdot t\_3 + t\_0 \cdot t\_0, t\_1 \cdot t\_1 + t\_2 \cdot t\_2\right)\\
t_5 := \sqrt{t\_4}\\
t_6 := \left|t\_3 \cdot t\_2 - t\_0 \cdot t\_1\right|\\
\log_{2} \begin{array}{l}
\mathbf{if}\;\frac{t\_4}{t\_6} > \left\lfloormaxAniso\right\rfloor:\\
\;\;\;\;\frac{t\_5}{\left\lfloormaxAniso\right\rfloor}\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_6}{t\_5}\\


\end{array}
\end{array}
\end{array}

Alternative 1: 75.4% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := dX.u \cdot dY.v - dX.v \cdot dY.u\\ t_1 := \left\lfloorh\right\rfloor \cdot dY.v\\ t_2 := dX.v \cdot \left\lfloorh\right\rfloor\\ t_3 := \left\lfloorw\right\rfloor \cdot dY.u\\ t_4 := \mathsf{max}\left({\left(\mathsf{hypot}\left(t\_2, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(t\_1, t\_3\right)\right)}^{2}\right)\\ \log_{2} \begin{array}{l} \mathbf{if}\;\frac{t\_4}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot t\_0\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{t\_4}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left|\left\lfloorh\right\rfloor \cdot \left\lfloorw\right\rfloor\right|, \frac{\left|t\_0\right|}{\sqrt{\mathsf{max}\left({t\_2}^{2}, {\left(\mathsf{hypot}\left(t\_3, t\_1\right)\right)}^{2}\right)}}, 0\right)\\ \end{array} \end{array} \end{array} \]
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
 :precision binary32
 (let* ((t_0 (- (* dX.u dY.v) (* dX.v dY.u)))
        (t_1 (* (floor h) dY.v))
        (t_2 (* dX.v (floor h)))
        (t_3 (* (floor w) dY.u))
        (t_4
         (fmax
          (pow (hypot t_2 (* dX.u (floor w))) 2.0)
          (pow (hypot t_1 t_3) 2.0))))
   (log2
    (if (> (/ t_4 (fabs (* (floor h) (* (floor w) t_0)))) (floor maxAniso))
      (/ (sqrt t_4) (floor maxAniso))
      (fma
       (fabs (* (floor h) (floor w)))
       (/ (fabs t_0) (sqrt (fmax (pow t_2 2.0) (pow (hypot t_3 t_1) 2.0))))
       0.0)))))
float code(float w, float h, float dX_46_u, float dX_46_v, float dY_46_u, float dY_46_v, float maxAniso) {
	float t_0 = (dX_46_u * dY_46_v) - (dX_46_v * dY_46_u);
	float t_1 = floorf(h) * dY_46_v;
	float t_2 = dX_46_v * floorf(h);
	float t_3 = floorf(w) * dY_46_u;
	float t_4 = fmaxf(powf(hypotf(t_2, (dX_46_u * floorf(w))), 2.0f), powf(hypotf(t_1, t_3), 2.0f));
	float tmp;
	if ((t_4 / fabsf((floorf(h) * (floorf(w) * t_0)))) > floorf(maxAniso)) {
		tmp = sqrtf(t_4) / floorf(maxAniso);
	} else {
		tmp = fmaf(fabsf((floorf(h) * floorf(w))), (fabsf(t_0) / sqrtf(fmaxf(powf(t_2, 2.0f), powf(hypotf(t_3, t_1), 2.0f)))), 0.0f);
	}
	return log2f(tmp);
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso)
	t_0 = Float32(Float32(dX_46_u * dY_46_v) - Float32(dX_46_v * dY_46_u))
	t_1 = Float32(floor(h) * dY_46_v)
	t_2 = Float32(dX_46_v * floor(h))
	t_3 = Float32(floor(w) * dY_46_u)
	t_4 = ((hypot(t_2, Float32(dX_46_u * floor(w))) ^ Float32(2.0)) != (hypot(t_2, Float32(dX_46_u * floor(w))) ^ Float32(2.0))) ? (hypot(t_1, t_3) ^ Float32(2.0)) : (((hypot(t_1, t_3) ^ Float32(2.0)) != (hypot(t_1, t_3) ^ Float32(2.0))) ? (hypot(t_2, Float32(dX_46_u * floor(w))) ^ Float32(2.0)) : max((hypot(t_2, Float32(dX_46_u * floor(w))) ^ Float32(2.0)), (hypot(t_1, t_3) ^ Float32(2.0))))
	tmp = Float32(0.0)
	if (Float32(t_4 / abs(Float32(floor(h) * Float32(floor(w) * t_0)))) > floor(maxAniso))
		tmp = Float32(sqrt(t_4) / floor(maxAniso));
	else
		tmp = fma(abs(Float32(floor(h) * floor(w))), Float32(abs(t_0) / sqrt((((t_2 ^ Float32(2.0)) != (t_2 ^ Float32(2.0))) ? (hypot(t_3, t_1) ^ Float32(2.0)) : (((hypot(t_3, t_1) ^ Float32(2.0)) != (hypot(t_3, t_1) ^ Float32(2.0))) ? (t_2 ^ Float32(2.0)) : max((t_2 ^ Float32(2.0)), (hypot(t_3, t_1) ^ Float32(2.0))))))), Float32(0.0));
	end
	return log2(tmp)
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := dX.u \cdot dY.v - dX.v \cdot dY.u\\
t_1 := \left\lfloorh\right\rfloor \cdot dY.v\\
t_2 := dX.v \cdot \left\lfloorh\right\rfloor\\
t_3 := \left\lfloorw\right\rfloor \cdot dY.u\\
t_4 := \mathsf{max}\left({\left(\mathsf{hypot}\left(t\_2, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(t\_1, t\_3\right)\right)}^{2}\right)\\
\log_{2} \begin{array}{l}
\mathbf{if}\;\frac{t\_4}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot t\_0\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\
\;\;\;\;\frac{\sqrt{t\_4}}{\left\lfloormaxAniso\right\rfloor}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left|\left\lfloorh\right\rfloor \cdot \left\lfloorw\right\rfloor\right|, \frac{\left|t\_0\right|}{\sqrt{\mathsf{max}\left({t\_2}^{2}, {\left(\mathsf{hypot}\left(t\_3, t\_1\right)\right)}^{2}\right)}}, 0\right)\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Initial program 77.8%

    \[\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left(\left(\left\lfloorw\right\rfloor \cdot dX.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dX.u\right) + \left(\left\lfloorh\right\rfloor \cdot dX.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dX.v\right), \left(\left\lfloorw\right\rfloor \cdot dY.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right) + \left(\left\lfloorh\right\rfloor \cdot dY.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right)}{\left|\left(\left\lfloorw\right\rfloor \cdot dX.u\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right) - \left(\left\lfloorh\right\rfloor \cdot dX.v\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left(\left(\left\lfloorw\right\rfloor \cdot dX.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dX.u\right) + \left(\left\lfloorh\right\rfloor \cdot dX.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dX.v\right), \left(\left\lfloorw\right\rfloor \cdot dY.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right) + \left(\left\lfloorh\right\rfloor \cdot dY.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left(\left\lfloorw\right\rfloor \cdot dX.u\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right) - \left(\left\lfloorh\right\rfloor \cdot dX.v\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right)\right|}{\sqrt{\mathsf{max}\left(\left(\left\lfloorw\right\rfloor \cdot dX.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dX.u\right) + \left(\left\lfloorh\right\rfloor \cdot dX.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dX.v\right), \left(\left\lfloorw\right\rfloor \cdot dY.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right) + \left(\left\lfloorh\right\rfloor \cdot dY.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right)}}\\ \end{array} \]
  2. Simplified77.8%

    \[\leadsto \color{blue}{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dX.u \cdot dX.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dX.v \cdot dX.v\right)\right)\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dY.u \cdot dY.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left(dY.v \cdot dY.v\right) \cdot \left\lfloorh\right\rfloor\right)\right)\right)}{\left|\left\lfloorw\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dY.v \cdot dX.u - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dX.u \cdot dX.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dX.v \cdot dX.v\right)\right)\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dY.u \cdot dY.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left(dY.v \cdot dY.v\right) \cdot \left\lfloorh\right\rfloor\right)\right)\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left\lfloorw\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dY.v \cdot dX.u - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dX.u \cdot dX.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dX.v \cdot dX.v\right)\right)\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dY.u \cdot dY.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left(dY.v \cdot dY.v\right) \cdot \left\lfloorh\right\rfloor\right)\right)\right)}}\\ \end{array}} \]
  3. Add Preprocessing
  4. Applied egg-rr72.8%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dX.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dX.v\right)}^{2}\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dY.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dY.v\right)}^{2}\right)\right)}{\left|\left(\left\lfloorw\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dX.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dX.v\right)}^{2}\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dY.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dY.v\right)}^{2}\right)\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left(\left\lfloorw\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right|}{\sqrt{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dX.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dX.v\right)}^{2}\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dY.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dY.v\right)}^{2}\right)\right)}}\\ \end{array}\right)} - 1} \]
  5. Simplified77.8%

    \[\leadsto \color{blue}{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array}} \]
  6. Taylor expanded in dX.v around inf 77.8%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left({dX.v}^{2} \cdot {\left(\left\lfloorh\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
  7. Step-by-step derivation
    1. *-commutative77.8%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left({\left(\left\lfloorh\right\rfloor\right)}^{2} \cdot {dX.v}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    2. unpow277.8%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor} \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left(\left(\left\lfloorh\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot {dX.v}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    3. unpow277.8%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left\lfloorh\right\rfloor \cdot \color{blue}{\left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left(\left(\left\lfloorh\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot \left(dX.v \cdot dX.v\right), {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    4. swap-sqr77.8%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left(\left(\left\lfloorh\right\rfloor \cdot dX.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dX.v\right), {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    5. unpow277.8%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left({\left(\left\lfloorh\right\rfloor \cdot dX.v\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    6. *-commutative77.8%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor} \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(dX.v \cdot \left\lfloorh\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
  8. Simplified77.8%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left({\left(dX.v \cdot \left\lfloorh\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
  9. Step-by-step derivation
    1. expm1-log1p-u77.8%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(dX.v \cdot \left\lfloorh\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\right)\right)\\ \end{array} \]
    2. expm1-undefine77.8%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;e^{\mathsf{log1p}\left(\frac{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(dX.v \cdot \left\lfloorh\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\right)} - 1\\ \end{array} \]
    3. *-commutative77.8%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;e^{\mathsf{log1p}\left(\frac{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(\left\lfloorh\right\rfloor \cdot dX.v\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\right)} - 1\\ \end{array} \]
  10. Applied egg-rr77.8%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;e^{\mathsf{log1p}\left(\frac{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(\left\lfloorh\right\rfloor \cdot dX.v\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\right)} - 1\\ \end{array} \]
  11. Simplified78.0%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left|\left\lfloorw\right\rfloor \cdot \left\lfloorh\right\rfloor\right|, \frac{\left|dX.u \cdot dY.v - dX.v \cdot dY.u\right|}{\sqrt{\mathsf{max}\left({\left(dX.v \cdot \left\lfloorh\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dY.u, \left\lfloorh\right\rfloor \cdot dY.v\right)\right)}^{2}\right)}}, 0\right)\\ \end{array} \]
  12. Final simplification78.0%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left|\left\lfloorh\right\rfloor \cdot \left\lfloorw\right\rfloor\right|, \frac{\left|dX.u \cdot dY.v - dX.v \cdot dY.u\right|}{\sqrt{\mathsf{max}\left({\left(dX.v \cdot \left\lfloorh\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dY.u, \left\lfloorh\right\rfloor \cdot dY.v\right)\right)}^{2}\right)}}, 0\right)\\ \end{array} \]
  13. Add Preprocessing

Alternative 2: 75.3% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := dX.v \cdot \left\lfloorh\right\rfloor\\ t_1 := {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\\ t_2 := \mathsf{max}\left({\left(\mathsf{hypot}\left(t\_0, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, t\_1\right)\\ t_3 := \left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|\\ \log \left(e^{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{t\_2}{t\_3} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{t\_2}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_3}{\sqrt{\mathsf{max}\left({t\_0}^{2}, t\_1\right)}}\\ \end{array}}\right) \end{array} \end{array} \]
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
 :precision binary32
 (let* ((t_0 (* dX.v (floor h)))
        (t_1 (pow (hypot (* (floor h) dY.v) (* (floor w) dY.u)) 2.0))
        (t_2 (fmax (pow (hypot t_0 (* dX.u (floor w))) 2.0) t_1))
        (t_3
         (fabs (* (floor h) (* (floor w) (- (* dX.u dY.v) (* dX.v dY.u)))))))
   (log
    (exp
     (log2
      (if (> (/ t_2 t_3) (floor maxAniso))
        (/ (sqrt t_2) (floor maxAniso))
        (/ t_3 (sqrt (fmax (pow t_0 2.0) t_1)))))))))
float code(float w, float h, float dX_46_u, float dX_46_v, float dY_46_u, float dY_46_v, float maxAniso) {
	float t_0 = dX_46_v * floorf(h);
	float t_1 = powf(hypotf((floorf(h) * dY_46_v), (floorf(w) * dY_46_u)), 2.0f);
	float t_2 = fmaxf(powf(hypotf(t_0, (dX_46_u * floorf(w))), 2.0f), t_1);
	float t_3 = fabsf((floorf(h) * (floorf(w) * ((dX_46_u * dY_46_v) - (dX_46_v * dY_46_u)))));
	float tmp;
	if ((t_2 / t_3) > floorf(maxAniso)) {
		tmp = sqrtf(t_2) / floorf(maxAniso);
	} else {
		tmp = t_3 / sqrtf(fmaxf(powf(t_0, 2.0f), t_1));
	}
	return logf(expf(log2f(tmp)));
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso)
	t_0 = Float32(dX_46_v * floor(h))
	t_1 = hypot(Float32(floor(h) * dY_46_v), Float32(floor(w) * dY_46_u)) ^ Float32(2.0)
	t_2 = ((hypot(t_0, Float32(dX_46_u * floor(w))) ^ Float32(2.0)) != (hypot(t_0, Float32(dX_46_u * floor(w))) ^ Float32(2.0))) ? t_1 : ((t_1 != t_1) ? (hypot(t_0, Float32(dX_46_u * floor(w))) ^ Float32(2.0)) : max((hypot(t_0, Float32(dX_46_u * floor(w))) ^ Float32(2.0)), t_1))
	t_3 = abs(Float32(floor(h) * Float32(floor(w) * Float32(Float32(dX_46_u * dY_46_v) - Float32(dX_46_v * dY_46_u)))))
	tmp = Float32(0.0)
	if (Float32(t_2 / t_3) > floor(maxAniso))
		tmp = Float32(sqrt(t_2) / floor(maxAniso));
	else
		tmp = Float32(t_3 / sqrt((((t_0 ^ Float32(2.0)) != (t_0 ^ Float32(2.0))) ? t_1 : ((t_1 != t_1) ? (t_0 ^ Float32(2.0)) : max((t_0 ^ Float32(2.0)), t_1)))));
	end
	return log(exp(log2(tmp)))
end
function tmp_2 = code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso)
	t_0 = dX_46_v * floor(h);
	t_1 = hypot((floor(h) * dY_46_v), (floor(w) * dY_46_u)) ^ single(2.0);
	t_2 = max((hypot(t_0, (dX_46_u * floor(w))) ^ single(2.0)), t_1);
	t_3 = abs((floor(h) * (floor(w) * ((dX_46_u * dY_46_v) - (dX_46_v * dY_46_u)))));
	tmp = single(0.0);
	if ((t_2 / t_3) > floor(maxAniso))
		tmp = sqrt(t_2) / floor(maxAniso);
	else
		tmp = t_3 / sqrt(max((t_0 ^ single(2.0)), t_1));
	end
	tmp_2 = log(exp(log2(tmp)));
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := dX.v \cdot \left\lfloorh\right\rfloor\\
t_1 := {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\\
t_2 := \mathsf{max}\left({\left(\mathsf{hypot}\left(t\_0, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, t\_1\right)\\
t_3 := \left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|\\
\log \left(e^{\log_{2} \begin{array}{l}
\mathbf{if}\;\frac{t\_2}{t\_3} > \left\lfloormaxAniso\right\rfloor:\\
\;\;\;\;\frac{\sqrt{t\_2}}{\left\lfloormaxAniso\right\rfloor}\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_3}{\sqrt{\mathsf{max}\left({t\_0}^{2}, t\_1\right)}}\\


\end{array}}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 77.8%

    \[\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left(\left(\left\lfloorw\right\rfloor \cdot dX.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dX.u\right) + \left(\left\lfloorh\right\rfloor \cdot dX.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dX.v\right), \left(\left\lfloorw\right\rfloor \cdot dY.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right) + \left(\left\lfloorh\right\rfloor \cdot dY.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right)}{\left|\left(\left\lfloorw\right\rfloor \cdot dX.u\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right) - \left(\left\lfloorh\right\rfloor \cdot dX.v\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left(\left(\left\lfloorw\right\rfloor \cdot dX.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dX.u\right) + \left(\left\lfloorh\right\rfloor \cdot dX.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dX.v\right), \left(\left\lfloorw\right\rfloor \cdot dY.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right) + \left(\left\lfloorh\right\rfloor \cdot dY.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left(\left\lfloorw\right\rfloor \cdot dX.u\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right) - \left(\left\lfloorh\right\rfloor \cdot dX.v\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right)\right|}{\sqrt{\mathsf{max}\left(\left(\left\lfloorw\right\rfloor \cdot dX.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dX.u\right) + \left(\left\lfloorh\right\rfloor \cdot dX.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dX.v\right), \left(\left\lfloorw\right\rfloor \cdot dY.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right) + \left(\left\lfloorh\right\rfloor \cdot dY.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right)}}\\ \end{array} \]
  2. Simplified77.8%

    \[\leadsto \color{blue}{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dX.u \cdot dX.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dX.v \cdot dX.v\right)\right)\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dY.u \cdot dY.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left(dY.v \cdot dY.v\right) \cdot \left\lfloorh\right\rfloor\right)\right)\right)}{\left|\left\lfloorw\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dY.v \cdot dX.u - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dX.u \cdot dX.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dX.v \cdot dX.v\right)\right)\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dY.u \cdot dY.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left(dY.v \cdot dY.v\right) \cdot \left\lfloorh\right\rfloor\right)\right)\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left\lfloorw\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dY.v \cdot dX.u - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dX.u \cdot dX.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dX.v \cdot dX.v\right)\right)\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dY.u \cdot dY.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left(dY.v \cdot dY.v\right) \cdot \left\lfloorh\right\rfloor\right)\right)\right)}}\\ \end{array}} \]
  3. Add Preprocessing
  4. Applied egg-rr72.8%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dX.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dX.v\right)}^{2}\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dY.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dY.v\right)}^{2}\right)\right)}{\left|\left(\left\lfloorw\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dX.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dX.v\right)}^{2}\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dY.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dY.v\right)}^{2}\right)\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left(\left\lfloorw\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right|}{\sqrt{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dX.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dX.v\right)}^{2}\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dY.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dY.v\right)}^{2}\right)\right)}}\\ \end{array}\right)} - 1} \]
  5. Simplified77.8%

    \[\leadsto \color{blue}{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array}} \]
  6. Taylor expanded in dX.v around inf 77.8%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left({dX.v}^{2} \cdot {\left(\left\lfloorh\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
  7. Step-by-step derivation
    1. *-commutative77.8%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left({\left(\left\lfloorh\right\rfloor\right)}^{2} \cdot {dX.v}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    2. unpow277.8%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor} \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left(\left(\left\lfloorh\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot {dX.v}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    3. unpow277.8%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left\lfloorh\right\rfloor \cdot \color{blue}{\left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left(\left(\left\lfloorh\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot \left(dX.v \cdot dX.v\right), {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    4. swap-sqr77.8%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left(\left(\left\lfloorh\right\rfloor \cdot dX.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dX.v\right), {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    5. unpow277.8%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left({\left(\left\lfloorh\right\rfloor \cdot dX.v\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    6. *-commutative77.8%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor} \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(dX.v \cdot \left\lfloorh\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
  8. Simplified77.8%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left({\left(dX.v \cdot \left\lfloorh\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
  9. Step-by-step derivation
    1. add-log-exp77.8%

      \[\leadsto \color{blue}{\log \left(e^{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(dX.v \cdot \left\lfloorh\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array}}\right)} \]
  10. Applied egg-rr77.8%

    \[\leadsto \color{blue}{\log \left(e^{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dX.v, \left\lfloorw\right\rfloor \cdot dX.u\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dX.v, \left\lfloorw\right\rfloor \cdot dX.u\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(\left\lfloorh\right\rfloor \cdot dX.v\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array}}\right)} \]
  11. Final simplification77.8%

    \[\leadsto \log \left(e^{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(dX.v \cdot \left\lfloorh\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array}}\right) \]
  12. Add Preprocessing

Alternative 3: 75.3% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\\ t_1 := \left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|\\ t_2 := dX.v \cdot \left\lfloorh\right\rfloor\\ t_3 := \mathsf{max}\left({\left(\mathsf{hypot}\left(t\_2, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, t\_0\right)\\ \log_{2} \begin{array}{l} \mathbf{if}\;\frac{t\_3}{t\_1} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{t\_3}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_1}{\sqrt{\mathsf{max}\left({t\_2}^{2}, t\_0\right)}}\\ \end{array} \end{array} \end{array} \]
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
 :precision binary32
 (let* ((t_0 (pow (hypot (* (floor h) dY.v) (* (floor w) dY.u)) 2.0))
        (t_1
         (fabs (* (floor h) (* (floor w) (- (* dX.u dY.v) (* dX.v dY.u))))))
        (t_2 (* dX.v (floor h)))
        (t_3 (fmax (pow (hypot t_2 (* dX.u (floor w))) 2.0) t_0)))
   (log2
    (if (> (/ t_3 t_1) (floor maxAniso))
      (/ (sqrt t_3) (floor maxAniso))
      (/ t_1 (sqrt (fmax (pow t_2 2.0) t_0)))))))
float code(float w, float h, float dX_46_u, float dX_46_v, float dY_46_u, float dY_46_v, float maxAniso) {
	float t_0 = powf(hypotf((floorf(h) * dY_46_v), (floorf(w) * dY_46_u)), 2.0f);
	float t_1 = fabsf((floorf(h) * (floorf(w) * ((dX_46_u * dY_46_v) - (dX_46_v * dY_46_u)))));
	float t_2 = dX_46_v * floorf(h);
	float t_3 = fmaxf(powf(hypotf(t_2, (dX_46_u * floorf(w))), 2.0f), t_0);
	float tmp;
	if ((t_3 / t_1) > floorf(maxAniso)) {
		tmp = sqrtf(t_3) / floorf(maxAniso);
	} else {
		tmp = t_1 / sqrtf(fmaxf(powf(t_2, 2.0f), t_0));
	}
	return log2f(tmp);
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso)
	t_0 = hypot(Float32(floor(h) * dY_46_v), Float32(floor(w) * dY_46_u)) ^ Float32(2.0)
	t_1 = abs(Float32(floor(h) * Float32(floor(w) * Float32(Float32(dX_46_u * dY_46_v) - Float32(dX_46_v * dY_46_u)))))
	t_2 = Float32(dX_46_v * floor(h))
	t_3 = ((hypot(t_2, Float32(dX_46_u * floor(w))) ^ Float32(2.0)) != (hypot(t_2, Float32(dX_46_u * floor(w))) ^ Float32(2.0))) ? t_0 : ((t_0 != t_0) ? (hypot(t_2, Float32(dX_46_u * floor(w))) ^ Float32(2.0)) : max((hypot(t_2, Float32(dX_46_u * floor(w))) ^ Float32(2.0)), t_0))
	tmp = Float32(0.0)
	if (Float32(t_3 / t_1) > floor(maxAniso))
		tmp = Float32(sqrt(t_3) / floor(maxAniso));
	else
		tmp = Float32(t_1 / sqrt((((t_2 ^ Float32(2.0)) != (t_2 ^ Float32(2.0))) ? t_0 : ((t_0 != t_0) ? (t_2 ^ Float32(2.0)) : max((t_2 ^ Float32(2.0)), t_0)))));
	end
	return log2(tmp)
end
function tmp_2 = code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso)
	t_0 = hypot((floor(h) * dY_46_v), (floor(w) * dY_46_u)) ^ single(2.0);
	t_1 = abs((floor(h) * (floor(w) * ((dX_46_u * dY_46_v) - (dX_46_v * dY_46_u)))));
	t_2 = dX_46_v * floor(h);
	t_3 = max((hypot(t_2, (dX_46_u * floor(w))) ^ single(2.0)), t_0);
	tmp = single(0.0);
	if ((t_3 / t_1) > floor(maxAniso))
		tmp = sqrt(t_3) / floor(maxAniso);
	else
		tmp = t_1 / sqrt(max((t_2 ^ single(2.0)), t_0));
	end
	tmp_2 = log2(tmp);
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\\
t_1 := \left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|\\
t_2 := dX.v \cdot \left\lfloorh\right\rfloor\\
t_3 := \mathsf{max}\left({\left(\mathsf{hypot}\left(t\_2, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, t\_0\right)\\
\log_{2} \begin{array}{l}
\mathbf{if}\;\frac{t\_3}{t\_1} > \left\lfloormaxAniso\right\rfloor:\\
\;\;\;\;\frac{\sqrt{t\_3}}{\left\lfloormaxAniso\right\rfloor}\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{\sqrt{\mathsf{max}\left({t\_2}^{2}, t\_0\right)}}\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Initial program 77.8%

    \[\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left(\left(\left\lfloorw\right\rfloor \cdot dX.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dX.u\right) + \left(\left\lfloorh\right\rfloor \cdot dX.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dX.v\right), \left(\left\lfloorw\right\rfloor \cdot dY.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right) + \left(\left\lfloorh\right\rfloor \cdot dY.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right)}{\left|\left(\left\lfloorw\right\rfloor \cdot dX.u\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right) - \left(\left\lfloorh\right\rfloor \cdot dX.v\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left(\left(\left\lfloorw\right\rfloor \cdot dX.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dX.u\right) + \left(\left\lfloorh\right\rfloor \cdot dX.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dX.v\right), \left(\left\lfloorw\right\rfloor \cdot dY.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right) + \left(\left\lfloorh\right\rfloor \cdot dY.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left(\left\lfloorw\right\rfloor \cdot dX.u\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right) - \left(\left\lfloorh\right\rfloor \cdot dX.v\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right)\right|}{\sqrt{\mathsf{max}\left(\left(\left\lfloorw\right\rfloor \cdot dX.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dX.u\right) + \left(\left\lfloorh\right\rfloor \cdot dX.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dX.v\right), \left(\left\lfloorw\right\rfloor \cdot dY.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right) + \left(\left\lfloorh\right\rfloor \cdot dY.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right)}}\\ \end{array} \]
  2. Simplified77.8%

    \[\leadsto \color{blue}{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dX.u \cdot dX.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dX.v \cdot dX.v\right)\right)\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dY.u \cdot dY.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left(dY.v \cdot dY.v\right) \cdot \left\lfloorh\right\rfloor\right)\right)\right)}{\left|\left\lfloorw\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dY.v \cdot dX.u - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dX.u \cdot dX.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dX.v \cdot dX.v\right)\right)\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dY.u \cdot dY.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left(dY.v \cdot dY.v\right) \cdot \left\lfloorh\right\rfloor\right)\right)\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left\lfloorw\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dY.v \cdot dX.u - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dX.u \cdot dX.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dX.v \cdot dX.v\right)\right)\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dY.u \cdot dY.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left(dY.v \cdot dY.v\right) \cdot \left\lfloorh\right\rfloor\right)\right)\right)}}\\ \end{array}} \]
  3. Add Preprocessing
  4. Applied egg-rr72.8%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dX.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dX.v\right)}^{2}\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dY.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dY.v\right)}^{2}\right)\right)}{\left|\left(\left\lfloorw\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dX.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dX.v\right)}^{2}\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dY.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dY.v\right)}^{2}\right)\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left(\left\lfloorw\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right|}{\sqrt{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dX.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dX.v\right)}^{2}\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dY.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dY.v\right)}^{2}\right)\right)}}\\ \end{array}\right)} - 1} \]
  5. Simplified77.8%

    \[\leadsto \color{blue}{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array}} \]
  6. Taylor expanded in dX.v around inf 77.8%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left({dX.v}^{2} \cdot {\left(\left\lfloorh\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
  7. Step-by-step derivation
    1. *-commutative77.8%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left({\left(\left\lfloorh\right\rfloor\right)}^{2} \cdot {dX.v}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    2. unpow277.8%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor} \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left(\left(\left\lfloorh\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot {dX.v}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    3. unpow277.8%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left\lfloorh\right\rfloor \cdot \color{blue}{\left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left(\left(\left\lfloorh\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot \left(dX.v \cdot dX.v\right), {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    4. swap-sqr77.8%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left(\left(\left\lfloorh\right\rfloor \cdot dX.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dX.v\right), {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    5. unpow277.8%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left({\left(\left\lfloorh\right\rfloor \cdot dX.v\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    6. *-commutative77.8%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor} \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(dX.v \cdot \left\lfloorh\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
  8. Simplified77.8%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left({\left(dX.v \cdot \left\lfloorh\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
  9. Add Preprocessing

Alternative 4: 75.3% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := dX.u \cdot \left\lfloorw\right\rfloor\\ t_1 := {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\\ t_2 := \mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, t\_0\right)\right)}^{2}, t\_1\right)\\ t_3 := \left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|\\ \log_{2} \begin{array}{l} \mathbf{if}\;\frac{t\_2}{t\_3} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{t\_2}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_3}{\sqrt{\mathsf{max}\left({t\_0}^{2}, t\_1\right)}}\\ \end{array} \end{array} \end{array} \]
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
 :precision binary32
 (let* ((t_0 (* dX.u (floor w)))
        (t_1 (pow (hypot (* (floor h) dY.v) (* (floor w) dY.u)) 2.0))
        (t_2 (fmax (pow (hypot (* dX.v (floor h)) t_0) 2.0) t_1))
        (t_3
         (fabs (* (floor h) (* (floor w) (- (* dX.u dY.v) (* dX.v dY.u)))))))
   (log2
    (if (> (/ t_2 t_3) (floor maxAniso))
      (/ (sqrt t_2) (floor maxAniso))
      (/ t_3 (sqrt (fmax (pow t_0 2.0) t_1)))))))
float code(float w, float h, float dX_46_u, float dX_46_v, float dY_46_u, float dY_46_v, float maxAniso) {
	float t_0 = dX_46_u * floorf(w);
	float t_1 = powf(hypotf((floorf(h) * dY_46_v), (floorf(w) * dY_46_u)), 2.0f);
	float t_2 = fmaxf(powf(hypotf((dX_46_v * floorf(h)), t_0), 2.0f), t_1);
	float t_3 = fabsf((floorf(h) * (floorf(w) * ((dX_46_u * dY_46_v) - (dX_46_v * dY_46_u)))));
	float tmp;
	if ((t_2 / t_3) > floorf(maxAniso)) {
		tmp = sqrtf(t_2) / floorf(maxAniso);
	} else {
		tmp = t_3 / sqrtf(fmaxf(powf(t_0, 2.0f), t_1));
	}
	return log2f(tmp);
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso)
	t_0 = Float32(dX_46_u * floor(w))
	t_1 = hypot(Float32(floor(h) * dY_46_v), Float32(floor(w) * dY_46_u)) ^ Float32(2.0)
	t_2 = ((hypot(Float32(dX_46_v * floor(h)), t_0) ^ Float32(2.0)) != (hypot(Float32(dX_46_v * floor(h)), t_0) ^ Float32(2.0))) ? t_1 : ((t_1 != t_1) ? (hypot(Float32(dX_46_v * floor(h)), t_0) ^ Float32(2.0)) : max((hypot(Float32(dX_46_v * floor(h)), t_0) ^ Float32(2.0)), t_1))
	t_3 = abs(Float32(floor(h) * Float32(floor(w) * Float32(Float32(dX_46_u * dY_46_v) - Float32(dX_46_v * dY_46_u)))))
	tmp = Float32(0.0)
	if (Float32(t_2 / t_3) > floor(maxAniso))
		tmp = Float32(sqrt(t_2) / floor(maxAniso));
	else
		tmp = Float32(t_3 / sqrt((((t_0 ^ Float32(2.0)) != (t_0 ^ Float32(2.0))) ? t_1 : ((t_1 != t_1) ? (t_0 ^ Float32(2.0)) : max((t_0 ^ Float32(2.0)), t_1)))));
	end
	return log2(tmp)
end
function tmp_2 = code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso)
	t_0 = dX_46_u * floor(w);
	t_1 = hypot((floor(h) * dY_46_v), (floor(w) * dY_46_u)) ^ single(2.0);
	t_2 = max((hypot((dX_46_v * floor(h)), t_0) ^ single(2.0)), t_1);
	t_3 = abs((floor(h) * (floor(w) * ((dX_46_u * dY_46_v) - (dX_46_v * dY_46_u)))));
	tmp = single(0.0);
	if ((t_2 / t_3) > floor(maxAniso))
		tmp = sqrt(t_2) / floor(maxAniso);
	else
		tmp = t_3 / sqrt(max((t_0 ^ single(2.0)), t_1));
	end
	tmp_2 = log2(tmp);
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := dX.u \cdot \left\lfloorw\right\rfloor\\
t_1 := {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\\
t_2 := \mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, t\_0\right)\right)}^{2}, t\_1\right)\\
t_3 := \left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|\\
\log_{2} \begin{array}{l}
\mathbf{if}\;\frac{t\_2}{t\_3} > \left\lfloormaxAniso\right\rfloor:\\
\;\;\;\;\frac{\sqrt{t\_2}}{\left\lfloormaxAniso\right\rfloor}\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_3}{\sqrt{\mathsf{max}\left({t\_0}^{2}, t\_1\right)}}\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Initial program 77.8%

    \[\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left(\left(\left\lfloorw\right\rfloor \cdot dX.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dX.u\right) + \left(\left\lfloorh\right\rfloor \cdot dX.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dX.v\right), \left(\left\lfloorw\right\rfloor \cdot dY.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right) + \left(\left\lfloorh\right\rfloor \cdot dY.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right)}{\left|\left(\left\lfloorw\right\rfloor \cdot dX.u\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right) - \left(\left\lfloorh\right\rfloor \cdot dX.v\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left(\left(\left\lfloorw\right\rfloor \cdot dX.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dX.u\right) + \left(\left\lfloorh\right\rfloor \cdot dX.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dX.v\right), \left(\left\lfloorw\right\rfloor \cdot dY.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right) + \left(\left\lfloorh\right\rfloor \cdot dY.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left(\left\lfloorw\right\rfloor \cdot dX.u\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right) - \left(\left\lfloorh\right\rfloor \cdot dX.v\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right)\right|}{\sqrt{\mathsf{max}\left(\left(\left\lfloorw\right\rfloor \cdot dX.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dX.u\right) + \left(\left\lfloorh\right\rfloor \cdot dX.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dX.v\right), \left(\left\lfloorw\right\rfloor \cdot dY.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right) + \left(\left\lfloorh\right\rfloor \cdot dY.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right)}}\\ \end{array} \]
  2. Simplified77.8%

    \[\leadsto \color{blue}{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dX.u \cdot dX.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dX.v \cdot dX.v\right)\right)\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dY.u \cdot dY.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left(dY.v \cdot dY.v\right) \cdot \left\lfloorh\right\rfloor\right)\right)\right)}{\left|\left\lfloorw\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dY.v \cdot dX.u - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dX.u \cdot dX.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dX.v \cdot dX.v\right)\right)\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dY.u \cdot dY.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left(dY.v \cdot dY.v\right) \cdot \left\lfloorh\right\rfloor\right)\right)\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left\lfloorw\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dY.v \cdot dX.u - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dX.u \cdot dX.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dX.v \cdot dX.v\right)\right)\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dY.u \cdot dY.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left(dY.v \cdot dY.v\right) \cdot \left\lfloorh\right\rfloor\right)\right)\right)}}\\ \end{array}} \]
  3. Add Preprocessing
  4. Applied egg-rr72.8%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dX.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dX.v\right)}^{2}\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dY.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dY.v\right)}^{2}\right)\right)}{\left|\left(\left\lfloorw\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dX.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dX.v\right)}^{2}\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dY.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dY.v\right)}^{2}\right)\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left(\left\lfloorw\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right|}{\sqrt{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dX.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dX.v\right)}^{2}\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dY.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dY.v\right)}^{2}\right)\right)}}\\ \end{array}\right)} - 1} \]
  5. Simplified77.8%

    \[\leadsto \color{blue}{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array}} \]
  6. Taylor expanded in dX.v around 0 77.2%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left({dX.u}^{2} \cdot {\left(\left\lfloorw\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
  7. Step-by-step derivation
    1. *-commutative77.2%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left({\left(\left\lfloorw\right\rfloor\right)}^{2} \cdot {dX.u}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    2. unpow277.2%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor} \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left(\left(\left\lfloorw\right\rfloor \cdot \left\lfloorw\right\rfloor\right) \cdot {dX.u}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    3. unpow277.2%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left\lfloorh\right\rfloor \cdot \color{blue}{\left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left(\left(\left\lfloorw\right\rfloor \cdot \left\lfloorw\right\rfloor\right) \cdot \left(dX.u \cdot dX.u\right), {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    4. swap-sqr77.2%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left(\left(\left\lfloorw\right\rfloor \cdot dX.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dX.u\right), {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    5. unpow277.2%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left({\left(\left\lfloorw\right\rfloor \cdot dX.u\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    6. *-commutative77.2%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor} \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(dX.u \cdot \left\lfloorw\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
  8. Simplified77.2%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left({\left(dX.u \cdot \left\lfloorw\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
  9. Add Preprocessing

Alternative 5: 68.1% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\\ t_1 := \left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|\\ t_2 := dX.u \cdot \left\lfloorw\right\rfloor\\ t_3 := \mathsf{max}\left({t\_2}^{2}, t\_0\right)\\ \log_{2} \begin{array}{l} \mathbf{if}\;\frac{t\_3}{t\_1} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, t\_2\right)\right)}^{2}, t\_0\right)}\right)\right)}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_1}{\sqrt{t\_3}}\\ \end{array} \end{array} \end{array} \]
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
 :precision binary32
 (let* ((t_0 (pow (hypot (* (floor h) dY.v) (* (floor w) dY.u)) 2.0))
        (t_1
         (fabs (* (floor h) (* (floor w) (- (* dX.u dY.v) (* dX.v dY.u))))))
        (t_2 (* dX.u (floor w)))
        (t_3 (fmax (pow t_2 2.0) t_0)))
   (log2
    (if (> (/ t_3 t_1) (floor maxAniso))
      (/
       (expm1
        (log1p (sqrt (fmax (pow (hypot (* dX.v (floor h)) t_2) 2.0) t_0))))
       (floor maxAniso))
      (/ t_1 (sqrt t_3))))))
float code(float w, float h, float dX_46_u, float dX_46_v, float dY_46_u, float dY_46_v, float maxAniso) {
	float t_0 = powf(hypotf((floorf(h) * dY_46_v), (floorf(w) * dY_46_u)), 2.0f);
	float t_1 = fabsf((floorf(h) * (floorf(w) * ((dX_46_u * dY_46_v) - (dX_46_v * dY_46_u)))));
	float t_2 = dX_46_u * floorf(w);
	float t_3 = fmaxf(powf(t_2, 2.0f), t_0);
	float tmp;
	if ((t_3 / t_1) > floorf(maxAniso)) {
		tmp = expm1f(log1pf(sqrtf(fmaxf(powf(hypotf((dX_46_v * floorf(h)), t_2), 2.0f), t_0)))) / floorf(maxAniso);
	} else {
		tmp = t_1 / sqrtf(t_3);
	}
	return log2f(tmp);
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso)
	t_0 = hypot(Float32(floor(h) * dY_46_v), Float32(floor(w) * dY_46_u)) ^ Float32(2.0)
	t_1 = abs(Float32(floor(h) * Float32(floor(w) * Float32(Float32(dX_46_u * dY_46_v) - Float32(dX_46_v * dY_46_u)))))
	t_2 = Float32(dX_46_u * floor(w))
	t_3 = ((t_2 ^ Float32(2.0)) != (t_2 ^ Float32(2.0))) ? t_0 : ((t_0 != t_0) ? (t_2 ^ Float32(2.0)) : max((t_2 ^ Float32(2.0)), t_0))
	tmp = Float32(0.0)
	if (Float32(t_3 / t_1) > floor(maxAniso))
		tmp = Float32(expm1(log1p(sqrt((((hypot(Float32(dX_46_v * floor(h)), t_2) ^ Float32(2.0)) != (hypot(Float32(dX_46_v * floor(h)), t_2) ^ Float32(2.0))) ? t_0 : ((t_0 != t_0) ? (hypot(Float32(dX_46_v * floor(h)), t_2) ^ Float32(2.0)) : max((hypot(Float32(dX_46_v * floor(h)), t_2) ^ Float32(2.0)), t_0)))))) / floor(maxAniso));
	else
		tmp = Float32(t_1 / sqrt(t_3));
	end
	return log2(tmp)
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\\
t_1 := \left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|\\
t_2 := dX.u \cdot \left\lfloorw\right\rfloor\\
t_3 := \mathsf{max}\left({t\_2}^{2}, t\_0\right)\\
\log_{2} \begin{array}{l}
\mathbf{if}\;\frac{t\_3}{t\_1} > \left\lfloormaxAniso\right\rfloor:\\
\;\;\;\;\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, t\_2\right)\right)}^{2}, t\_0\right)}\right)\right)}{\left\lfloormaxAniso\right\rfloor}\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{\sqrt{t\_3}}\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Initial program 77.8%

    \[\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left(\left(\left\lfloorw\right\rfloor \cdot dX.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dX.u\right) + \left(\left\lfloorh\right\rfloor \cdot dX.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dX.v\right), \left(\left\lfloorw\right\rfloor \cdot dY.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right) + \left(\left\lfloorh\right\rfloor \cdot dY.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right)}{\left|\left(\left\lfloorw\right\rfloor \cdot dX.u\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right) - \left(\left\lfloorh\right\rfloor \cdot dX.v\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left(\left(\left\lfloorw\right\rfloor \cdot dX.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dX.u\right) + \left(\left\lfloorh\right\rfloor \cdot dX.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dX.v\right), \left(\left\lfloorw\right\rfloor \cdot dY.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right) + \left(\left\lfloorh\right\rfloor \cdot dY.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left(\left\lfloorw\right\rfloor \cdot dX.u\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right) - \left(\left\lfloorh\right\rfloor \cdot dX.v\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right)\right|}{\sqrt{\mathsf{max}\left(\left(\left\lfloorw\right\rfloor \cdot dX.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dX.u\right) + \left(\left\lfloorh\right\rfloor \cdot dX.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dX.v\right), \left(\left\lfloorw\right\rfloor \cdot dY.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right) + \left(\left\lfloorh\right\rfloor \cdot dY.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right)}}\\ \end{array} \]
  2. Simplified77.8%

    \[\leadsto \color{blue}{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dX.u \cdot dX.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dX.v \cdot dX.v\right)\right)\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dY.u \cdot dY.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left(dY.v \cdot dY.v\right) \cdot \left\lfloorh\right\rfloor\right)\right)\right)}{\left|\left\lfloorw\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dY.v \cdot dX.u - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dX.u \cdot dX.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dX.v \cdot dX.v\right)\right)\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dY.u \cdot dY.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left(dY.v \cdot dY.v\right) \cdot \left\lfloorh\right\rfloor\right)\right)\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left\lfloorw\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dY.v \cdot dX.u - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dX.u \cdot dX.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dX.v \cdot dX.v\right)\right)\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left(dY.u \cdot dY.u\right) \cdot \left\lfloorw\right\rfloor, \left\lfloorh\right\rfloor \cdot \left(\left(dY.v \cdot dY.v\right) \cdot \left\lfloorh\right\rfloor\right)\right)\right)}}\\ \end{array}} \]
  3. Add Preprocessing
  4. Applied egg-rr72.8%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dX.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dX.v\right)}^{2}\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dY.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dY.v\right)}^{2}\right)\right)}{\left|\left(\left\lfloorw\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dX.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dX.v\right)}^{2}\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dY.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dY.v\right)}^{2}\right)\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left(\left\lfloorw\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right|}{\sqrt{\mathsf{max}\left(\mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dX.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dX.v\right)}^{2}\right), \mathsf{fma}\left(\left\lfloorw\right\rfloor, \left\lfloorw\right\rfloor \cdot {dY.u}^{2}, {\left(\left\lfloorh\right\rfloor \cdot dY.v\right)}^{2}\right)\right)}}\\ \end{array}\right)} - 1} \]
  5. Simplified77.8%

    \[\leadsto \color{blue}{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array}} \]
  6. Taylor expanded in dX.v around 0 70.3%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left(\color{blue}{{dX.u}^{2} \cdot {\left(\left\lfloorw\right\rfloor\right)}^{2}}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
  7. Step-by-step derivation
    1. *-commutative77.2%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left({\left(\left\lfloorw\right\rfloor\right)}^{2} \cdot {dX.u}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    2. unpow277.2%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor} \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left(\left(\left\lfloorw\right\rfloor \cdot \left\lfloorw\right\rfloor\right) \cdot {dX.u}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    3. unpow277.2%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left\lfloorh\right\rfloor \cdot \color{blue}{\left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left(\left(\left\lfloorw\right\rfloor \cdot \left\lfloorw\right\rfloor\right) \cdot \left(dX.u \cdot dX.u\right), {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    4. swap-sqr77.2%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left(\left(\left\lfloorw\right\rfloor \cdot dX.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dX.u\right), {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    5. unpow277.2%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left({\left(\left\lfloorw\right\rfloor \cdot dX.u\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    6. *-commutative77.2%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor} \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(dX.u \cdot \left\lfloorw\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
  8. Simplified70.3%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left(\color{blue}{{\left(dX.u \cdot \left\lfloorw\right\rfloor\right)}^{2}}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
  9. Step-by-step derivation
    1. expm1-log1p-u69.7%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(dX.u \cdot \left\lfloorw\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}\right)\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    2. *-commutative69.7%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(dX.u \cdot \left\lfloorw\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(\color{blue}{\left\lfloorh\right\rfloor \cdot dX.v}, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}\right)\right)}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    3. *-commutative69.7%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(dX.u \cdot \left\lfloorw\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dX.v, \color{blue}{\left\lfloorw\right\rfloor \cdot dX.u}\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}\right)\right)}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
  10. Applied egg-rr69.7%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(dX.u \cdot \left\lfloorw\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dX.v, \left\lfloorw\right\rfloor \cdot dX.u\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}\right)\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
  11. Taylor expanded in dX.v around 0 71.5%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(dX.u \cdot \left\lfloorw\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dX.v, \left\lfloorw\right\rfloor \cdot dX.u\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}\right)\right)}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left({dX.u}^{2} \cdot {\left(\left\lfloorw\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
  12. Step-by-step derivation
    1. *-commutative77.2%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left({\left(\left\lfloorw\right\rfloor\right)}^{2} \cdot {dX.u}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    2. unpow277.2%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor} \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left(\left(\left\lfloorw\right\rfloor \cdot \left\lfloorw\right\rfloor\right) \cdot {dX.u}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    3. unpow277.2%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left\lfloorh\right\rfloor \cdot \color{blue}{\left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left(\left(\left\lfloorw\right\rfloor \cdot \left\lfloorw\right\rfloor\right) \cdot \left(dX.u \cdot dX.u\right), {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    4. swap-sqr77.2%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left(\left(\left\lfloorw\right\rfloor \cdot dX.u\right) \cdot \left(\left\lfloorw\right\rfloor \cdot dX.u\right), {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    5. unpow277.2%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left({\left(\left\lfloorw\right\rfloor \cdot dX.u\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
    6. *-commutative77.2%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor} \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(dX.u \cdot \left\lfloorw\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
  13. Simplified71.5%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(dX.u \cdot \left\lfloorw\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dX.v, \left\lfloorw\right\rfloor \cdot dX.u\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}\right)\right)}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\color{blue}{\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}\right|}{\sqrt{\mathsf{max}\left({\left(dX.u \cdot \left\lfloorw\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
  14. Final simplification71.5%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(dX.u \cdot \left\lfloorw\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.v \cdot \left\lfloorh\right\rfloor, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}\right)\right)}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left\lfloorh\right\rfloor \cdot \left(\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(dX.u \cdot \left\lfloorw\right\rfloor\right)}^{2}, {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dY.v, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
  15. Add Preprocessing

Reproduce

?
herbie shell --seed 2024116 
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
  :name "Anisotropic x16 LOD (LOD)"
  :precision binary32
  :pre (and (and (and (and (and (and (and (<= 1.0 w) (<= w 16384.0)) (and (<= 1.0 h) (<= h 16384.0))) (and (<= 1e-20 (fabs dX.u)) (<= (fabs dX.u) 1e+20))) (and (<= 1e-20 (fabs dX.v)) (<= (fabs dX.v) 1e+20))) (and (<= 1e-20 (fabs dY.u)) (<= (fabs dY.u) 1e+20))) (and (<= 1e-20 (fabs dY.v)) (<= (fabs dY.v) 1e+20))) (== maxAniso 16.0))
  (log2 (if (> (/ (fmax (+ (* (* (floor w) dX.u) (* (floor w) dX.u)) (* (* (floor h) dX.v) (* (floor h) dX.v))) (+ (* (* (floor w) dY.u) (* (floor w) dY.u)) (* (* (floor h) dY.v) (* (floor h) dY.v)))) (fabs (- (* (* (floor w) dX.u) (* (floor h) dY.v)) (* (* (floor h) dX.v) (* (floor w) dY.u))))) (floor maxAniso)) (/ (sqrt (fmax (+ (* (* (floor w) dX.u) (* (floor w) dX.u)) (* (* (floor h) dX.v) (* (floor h) dX.v))) (+ (* (* (floor w) dY.u) (* (floor w) dY.u)) (* (* (floor h) dY.v) (* (floor h) dY.v))))) (floor maxAniso)) (/ (fabs (- (* (* (floor w) dX.u) (* (floor h) dY.v)) (* (* (floor h) dX.v) (* (floor w) dY.u)))) (sqrt (fmax (+ (* (* (floor w) dX.u) (* (floor w) dX.u)) (* (* (floor h) dX.v) (* (floor h) dX.v))) (+ (* (* (floor w) dY.u) (* (floor w) dY.u)) (* (* (floor h) dY.v) (* (floor h) dY.v)))))))))