Anisotropic x16 LOD (LOD)

Percentage Accurate: 76.3% → 76.3%
Time: 56.6s
Alternatives: 11
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 11 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: 76.3% 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: 76.3% accurate, 1.1× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{t\_2}{t\_1}\\


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

    \[\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. Simplified75.7%

    \[\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-rr75.7%

    \[\leadsto \color{blue}{\log \left(e^{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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}}\right)} \]
  5. Add Preprocessing

Alternative 2: 76.3% accurate, 1.2× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{t\_2}{t\_1}\\


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

    \[\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. Simplified75.7%

    \[\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-rr75.7%

    \[\leadsto \color{blue}{\log \left(e^{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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}}\right)} \]
  5. Step-by-step derivation
    1. rem-log-exp75.7%

      \[\leadsto \color{blue}{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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. Applied egg-rr75.7%

    \[\leadsto \color{blue}{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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. Add Preprocessing

Alternative 3: 75.8% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left\lfloorh\right\rfloor \cdot dX.v\\ 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(\left\lfloorw\right\rfloor \cdot dX.u, t\_0\right)\right)}^{2}, t\_1\right)\\ t_3 := \left|\left\lfloorw\right\rfloor \cdot \left(\left\lfloorh\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 (* (floor h) dX.v))
        (t_1 (pow (hypot (* (floor h) dY.v) (* (floor w) dY.u)) 2.0))
        (t_2 (fmax (pow (hypot (* (floor w) dX.u) t_0) 2.0) t_1))
        (t_3
         (fabs (* (floor w) (* (floor h) (- (* 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 = floorf(h) * dX_46_v;
	float t_1 = powf(hypotf((floorf(h) * dY_46_v), (floorf(w) * dY_46_u)), 2.0f);
	float t_2 = fmaxf(powf(hypotf((floorf(w) * dX_46_u), t_0), 2.0f), t_1);
	float t_3 = fabsf((floorf(w) * (floorf(h) * ((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(floor(h) * dX_46_v)
	t_1 = hypot(Float32(floor(h) * dY_46_v), Float32(floor(w) * dY_46_u)) ^ Float32(2.0)
	t_2 = ((hypot(Float32(floor(w) * dX_46_u), t_0) ^ Float32(2.0)) != (hypot(Float32(floor(w) * dX_46_u), t_0) ^ Float32(2.0))) ? t_1 : ((t_1 != t_1) ? (hypot(Float32(floor(w) * dX_46_u), t_0) ^ Float32(2.0)) : max((hypot(Float32(floor(w) * dX_46_u), t_0) ^ Float32(2.0)), t_1))
	t_3 = abs(Float32(floor(w) * Float32(floor(h) * 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 = floor(h) * dX_46_v;
	t_1 = hypot((floor(h) * dY_46_v), (floor(w) * dY_46_u)) ^ single(2.0);
	t_2 = max((hypot((floor(w) * dX_46_u), t_0) ^ single(2.0)), t_1);
	t_3 = abs((floor(w) * (floor(h) * ((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 := \left\lfloorh\right\rfloor \cdot dX.v\\
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(\left\lfloorw\right\rfloor \cdot dX.u, t\_0\right)\right)}^{2}, t\_1\right)\\
t_3 := \left|\left\lfloorw\right\rfloor \cdot \left(\left\lfloorh\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 75.7%

    \[\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. Simplified75.7%

    \[\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-rr75.7%

    \[\leadsto \color{blue}{\log \left(e^{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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}}\right)} \]
  5. Step-by-step derivation
    1. rem-log-exp75.7%

      \[\leadsto \color{blue}{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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. Applied egg-rr75.7%

    \[\leadsto \color{blue}{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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. Taylor expanded in dX.u around 0 75.5%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({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} \]
  8. Step-by-step derivation
    1. unpow275.5%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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(\left(dX.v \cdot dX.v\right) \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} \]
    2. unpow275.5%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\left\lfloorw\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot \color{blue}{\left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)}\right|}{\sqrt{\mathsf{max}\left(\left(dX.v \cdot dX.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot \left\lfloorh\right\rfloor\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} \]
    3. swap-sqr75.5%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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(\left(dX.v \cdot \left\lfloorh\right\rfloor\right) \cdot \left(dX.v \cdot \left\lfloorh\right\rfloor\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. unpow275.5%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\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. Simplified75.5%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\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} \]
  10. Step-by-step derivation
    1. add-log-exp75.5%

      \[\leadsto \color{blue}{\log \left(e^{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\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)} \]
  11. Applied egg-rr75.5%

    \[\leadsto \color{blue}{\log \left(e^{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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\lfloorw\right\rfloor \cdot \left(\left\lfloorh\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\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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\lfloorw\right\rfloor \cdot \left(\left\lfloorh\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)} \]
  12. Add Preprocessing

Alternative 4: 75.8% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left\lfloorh\right\rfloor \cdot dX.v\\ 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(\left\lfloorw\right\rfloor \cdot dX.u, t\_0\right)\right)}^{2}, t\_1\right)\\ t_3 := \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|\\ \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 (* (floor h) dX.v))
        (t_1 (pow (hypot (* (floor h) dY.v) (* (floor w) dY.u)) 2.0))
        (t_2 (fmax (pow (hypot (* (floor w) dX.u) t_0) 2.0) t_1))
        (t_3
         (fabs (* (* (floor w) (floor h)) (- (* 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 = floorf(h) * dX_46_v;
	float t_1 = powf(hypotf((floorf(h) * dY_46_v), (floorf(w) * dY_46_u)), 2.0f);
	float t_2 = fmaxf(powf(hypotf((floorf(w) * dX_46_u), t_0), 2.0f), t_1);
	float t_3 = fabsf(((floorf(w) * floorf(h)) * ((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(floor(h) * dX_46_v)
	t_1 = hypot(Float32(floor(h) * dY_46_v), Float32(floor(w) * dY_46_u)) ^ Float32(2.0)
	t_2 = ((hypot(Float32(floor(w) * dX_46_u), t_0) ^ Float32(2.0)) != (hypot(Float32(floor(w) * dX_46_u), t_0) ^ Float32(2.0))) ? t_1 : ((t_1 != t_1) ? (hypot(Float32(floor(w) * dX_46_u), t_0) ^ Float32(2.0)) : max((hypot(Float32(floor(w) * dX_46_u), t_0) ^ Float32(2.0)), t_1))
	t_3 = abs(Float32(Float32(floor(w) * floor(h)) * 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 = floor(h) * dX_46_v;
	t_1 = hypot((floor(h) * dY_46_v), (floor(w) * dY_46_u)) ^ single(2.0);
	t_2 = max((hypot((floor(w) * dX_46_u), t_0) ^ single(2.0)), t_1);
	t_3 = abs(((floor(w) * floor(h)) * ((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 := \left\lfloorh\right\rfloor \cdot dX.v\\
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(\left\lfloorw\right\rfloor \cdot dX.u, t\_0\right)\right)}^{2}, t\_1\right)\\
t_3 := \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|\\
\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 75.7%

    \[\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. Simplified75.7%

    \[\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-rr75.7%

    \[\leadsto \color{blue}{\log \left(e^{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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}}\right)} \]
  5. Step-by-step derivation
    1. rem-log-exp75.7%

      \[\leadsto \color{blue}{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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. Applied egg-rr75.7%

    \[\leadsto \color{blue}{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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. Taylor expanded in dX.u around 0 75.5%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({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} \]
  8. Step-by-step derivation
    1. unpow275.5%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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(\left(dX.v \cdot dX.v\right) \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} \]
    2. unpow275.5%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\left\lfloorw\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot \color{blue}{\left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)}\right|}{\sqrt{\mathsf{max}\left(\left(dX.v \cdot dX.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot \left\lfloorh\right\rfloor\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} \]
    3. swap-sqr75.5%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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(\left(dX.v \cdot \left\lfloorh\right\rfloor\right) \cdot \left(dX.v \cdot \left\lfloorh\right\rfloor\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. unpow275.5%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\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. Simplified75.5%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\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} \]
  10. Final simplification75.5%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\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} \]
  11. Add Preprocessing

Alternative 5: 75.8% 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(\left\lfloorw\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right|\\ t_2 := \left\lfloorw\right\rfloor \cdot dX.u\\ t_3 := \mathsf{max}\left({\left(\mathsf{hypot}\left(t\_2, \left\lfloorh\right\rfloor \cdot dX.v\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 w) (floor h)) (- (* dX.u dY.v) (* dX.v dY.u)))))
        (t_2 (* (floor w) dX.u))
        (t_3 (fmax (pow (hypot t_2 (* (floor h) dX.v)) 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(w) * floorf(h)) * ((dX_46_u * dY_46_v) - (dX_46_v * dY_46_u))));
	float t_2 = floorf(w) * dX_46_u;
	float t_3 = fmaxf(powf(hypotf(t_2, (floorf(h) * dX_46_v)), 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(Float32(floor(w) * floor(h)) * Float32(Float32(dX_46_u * dY_46_v) - Float32(dX_46_v * dY_46_u))))
	t_2 = Float32(floor(w) * dX_46_u)
	t_3 = ((hypot(t_2, Float32(floor(h) * dX_46_v)) ^ Float32(2.0)) != (hypot(t_2, Float32(floor(h) * dX_46_v)) ^ Float32(2.0))) ? t_0 : ((t_0 != t_0) ? (hypot(t_2, Float32(floor(h) * dX_46_v)) ^ Float32(2.0)) : max((hypot(t_2, Float32(floor(h) * dX_46_v)) ^ 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(w) * floor(h)) * ((dX_46_u * dY_46_v) - (dX_46_v * dY_46_u))));
	t_2 = floor(w) * dX_46_u;
	t_3 = max((hypot(t_2, (floor(h) * dX_46_v)) ^ 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(\left\lfloorw\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right|\\
t_2 := \left\lfloorw\right\rfloor \cdot dX.u\\
t_3 := \mathsf{max}\left({\left(\mathsf{hypot}\left(t\_2, \left\lfloorh\right\rfloor \cdot dX.v\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 75.7%

    \[\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. Simplified75.7%

    \[\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-rr75.7%

    \[\leadsto \color{blue}{\log \left(e^{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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}}\right)} \]
  5. Step-by-step derivation
    1. rem-log-exp75.7%

      \[\leadsto \color{blue}{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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. Applied egg-rr75.7%

    \[\leadsto \color{blue}{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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. Taylor expanded in dX.u around inf 74.5%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({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} \]
  8. Step-by-step derivation
    1. *-commutative74.5%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\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. unpow274.5%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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(\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. unpow274.5%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\left\lfloorw\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot \color{blue}{\left(dX.u \cdot dY.v - dX.v \cdot dY.u\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-sqr74.5%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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(\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. unpow274.5%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\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. *-commutative74.5%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\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. Simplified74.5%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\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} \]
  10. Final simplification74.5%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\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} \]
  11. Add Preprocessing

Alternative 6: 67.4% 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(\left\lfloorw\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right|\\ t_2 := \left\lfloorh\right\rfloor \cdot dX.v\\ t_3 := \sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, t\_2\right)\right)}^{2}, t\_0\right)}\\ \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({t\_2}^{2}, t\_0\right)}{t\_1} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{t\_3}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_1}{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 w) (floor h)) (- (* dX.u dY.v) (* dX.v dY.u)))))
        (t_2 (* (floor h) dX.v))
        (t_3 (sqrt (fmax (pow (hypot (* (floor w) dX.u) t_2) 2.0) t_0))))
   (log2
    (if (> (/ (fmax (pow t_2 2.0) t_0) t_1) (floor maxAniso))
      (/ t_3 (floor maxAniso))
      (/ t_1 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(w) * floorf(h)) * ((dX_46_u * dY_46_v) - (dX_46_v * dY_46_u))));
	float t_2 = floorf(h) * dX_46_v;
	float t_3 = sqrtf(fmaxf(powf(hypotf((floorf(w) * dX_46_u), t_2), 2.0f), t_0));
	float tmp;
	if ((fmaxf(powf(t_2, 2.0f), t_0) / t_1) > floorf(maxAniso)) {
		tmp = t_3 / floorf(maxAniso);
	} else {
		tmp = t_1 / 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(Float32(floor(w) * floor(h)) * Float32(Float32(dX_46_u * dY_46_v) - Float32(dX_46_v * dY_46_u))))
	t_2 = Float32(floor(h) * dX_46_v)
	t_3 = sqrt((((hypot(Float32(floor(w) * dX_46_u), t_2) ^ Float32(2.0)) != (hypot(Float32(floor(w) * dX_46_u), t_2) ^ Float32(2.0))) ? t_0 : ((t_0 != t_0) ? (hypot(Float32(floor(w) * dX_46_u), t_2) ^ Float32(2.0)) : max((hypot(Float32(floor(w) * dX_46_u), t_2) ^ Float32(2.0)), t_0))))
	tmp = Float32(0.0)
	if (Float32((((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))) / t_1) > floor(maxAniso))
		tmp = Float32(t_3 / floor(maxAniso));
	else
		tmp = Float32(t_1 / t_3);
	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(w) * floor(h)) * ((dX_46_u * dY_46_v) - (dX_46_v * dY_46_u))));
	t_2 = floor(h) * dX_46_v;
	t_3 = sqrt(max((hypot((floor(w) * dX_46_u), t_2) ^ single(2.0)), t_0));
	tmp = single(0.0);
	if ((max((t_2 ^ single(2.0)), t_0) / t_1) > floor(maxAniso))
		tmp = t_3 / floor(maxAniso);
	else
		tmp = t_1 / t_3;
	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(\left\lfloorw\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right|\\
t_2 := \left\lfloorh\right\rfloor \cdot dX.v\\
t_3 := \sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, t\_2\right)\right)}^{2}, t\_0\right)}\\
\log_{2} \begin{array}{l}
\mathbf{if}\;\frac{\mathsf{max}\left({t\_2}^{2}, t\_0\right)}{t\_1} > \left\lfloormaxAniso\right\rfloor:\\
\;\;\;\;\frac{t\_3}{\left\lfloormaxAniso\right\rfloor}\\

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


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

    \[\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. Simplified75.7%

    \[\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-rr75.7%

    \[\leadsto \color{blue}{\log \left(e^{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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}}\right)} \]
  5. Step-by-step derivation
    1. rem-log-exp75.7%

      \[\leadsto \color{blue}{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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. Applied egg-rr75.7%

    \[\leadsto \color{blue}{\log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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. Taylor expanded in dX.u around 0 67.2%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left(\color{blue}{{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)}{\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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} \]
  8. Step-by-step derivation
    1. unpow275.5%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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(\left(dX.v \cdot dX.v\right) \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} \]
    2. unpow275.5%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\left\lfloorw\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot \color{blue}{\left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)}\right|}{\sqrt{\mathsf{max}\left(\left(dX.v \cdot dX.v\right) \cdot \left(\left\lfloorh\right\rfloor \cdot \left\lfloorh\right\rfloor\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} \]
    3. swap-sqr75.5%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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(\left(dX.v \cdot \left\lfloorh\right\rfloor\right) \cdot \left(dX.v \cdot \left\lfloorh\right\rfloor\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. unpow275.5%

      \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\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. Simplified67.2%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left(\color{blue}{{\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)}{\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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. Final simplification67.2%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\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)}{\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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(\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({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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. Add Preprocessing

Alternative 7: 39.3% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left\lfloorh\right\rfloor \cdot dY.v\\ t_1 := \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(t\_0, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)\\ t_2 := \sqrt{t\_1}\\ \log_{2} \begin{array}{l} \mathbf{if}\;\frac{t\_1}{\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot t\_0\right)} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{t\_2}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\left(\left\lfloorw\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot \frac{dX.u \cdot dY.v - dX.v \cdot dY.u}{t\_2}\\ \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) dY.v))
        (t_1
         (fmax
          (pow (hypot (* (floor h) dX.v) (* (floor w) dX.u)) 2.0)
          (pow (hypot t_0 (* (floor w) dY.u)) 2.0)))
        (t_2 (sqrt t_1)))
   (log2
    (if (> (/ t_1 (* (floor w) (* dX.u t_0))) (floor maxAniso))
      (/ t_2 (floor maxAniso))
      (* (* (floor w) (floor h)) (/ (- (* dX.u dY.v) (* dX.v dY.u)) t_2))))))
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) * dY_46_v;
	float t_1 = fmaxf(powf(hypotf((floorf(h) * dX_46_v), (floorf(w) * dX_46_u)), 2.0f), powf(hypotf(t_0, (floorf(w) * dY_46_u)), 2.0f));
	float t_2 = sqrtf(t_1);
	float tmp;
	if ((t_1 / (floorf(w) * (dX_46_u * t_0))) > floorf(maxAniso)) {
		tmp = t_2 / floorf(maxAniso);
	} else {
		tmp = (floorf(w) * floorf(h)) * (((dX_46_u * dY_46_v) - (dX_46_v * dY_46_u)) / t_2);
	}
	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) * dY_46_v)
	t_1 = ((hypot(Float32(floor(h) * dX_46_v), Float32(floor(w) * dX_46_u)) ^ Float32(2.0)) != (hypot(Float32(floor(h) * dX_46_v), Float32(floor(w) * dX_46_u)) ^ Float32(2.0))) ? (hypot(t_0, Float32(floor(w) * dY_46_u)) ^ Float32(2.0)) : (((hypot(t_0, Float32(floor(w) * dY_46_u)) ^ Float32(2.0)) != (hypot(t_0, Float32(floor(w) * dY_46_u)) ^ Float32(2.0))) ? (hypot(Float32(floor(h) * dX_46_v), Float32(floor(w) * dX_46_u)) ^ Float32(2.0)) : max((hypot(Float32(floor(h) * dX_46_v), Float32(floor(w) * dX_46_u)) ^ Float32(2.0)), (hypot(t_0, Float32(floor(w) * dY_46_u)) ^ Float32(2.0))))
	t_2 = sqrt(t_1)
	tmp = Float32(0.0)
	if (Float32(t_1 / Float32(floor(w) * Float32(dX_46_u * t_0))) > floor(maxAniso))
		tmp = Float32(t_2 / floor(maxAniso));
	else
		tmp = Float32(Float32(floor(w) * floor(h)) * Float32(Float32(Float32(dX_46_u * dY_46_v) - Float32(dX_46_v * dY_46_u)) / t_2));
	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) * dY_46_v;
	t_1 = max((hypot((floor(h) * dX_46_v), (floor(w) * dX_46_u)) ^ single(2.0)), (hypot(t_0, (floor(w) * dY_46_u)) ^ single(2.0)));
	t_2 = sqrt(t_1);
	tmp = single(0.0);
	if ((t_1 / (floor(w) * (dX_46_u * t_0))) > floor(maxAniso))
		tmp = t_2 / floor(maxAniso);
	else
		tmp = (floor(w) * floor(h)) * (((dX_46_u * dY_46_v) - (dX_46_v * dY_46_u)) / t_2);
	end
	tmp_2 = log2(tmp);
end
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\left(\left\lfloorw\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot \frac{dX.u \cdot dY.v - dX.v \cdot dY.u}{t\_2}\\


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

    \[\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. Add Preprocessing
  3. Applied egg-rr75.7%

    \[\leadsto \color{blue}{1 \cdot \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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\lfloorw\right\rfloor \cdot \left(dX.u \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right) - \left\lfloorh\right\rfloor \cdot \left(dX.v \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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\lfloorw\right\rfloor \cdot \left(dX.u \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right) - \left\lfloorh\right\rfloor \cdot \left(dX.v \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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}} \]
  4. Simplified35.8%

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

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

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

    \[\leadsto \color{blue}{1 \cdot \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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\lfloorw\right\rfloor \cdot \left(\left(dX.u \cdot \left\lfloorh\right\rfloor\right) \cdot dY.v\right)} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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}:\\ \;\;\;\;\left\lfloorw\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \frac{dX.u \cdot dY.v - dX.v \cdot dY.u}{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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)\\ \end{array}} \]
  8. Simplified37.0%

    \[\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\lfloorw\right\rfloor \cdot \left(dX.u \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\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}:\\ \;\;\;\;\left(\left\lfloorw\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot \frac{dX.u \cdot dY.v - dX.v \cdot dY.u}{\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. Final simplification37.0%

    \[\leadsto \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\lfloorw\right\rfloor \cdot \left(dX.u \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\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}:\\ \;\;\;\;\left(\left\lfloorw\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot \frac{dX.u \cdot dY.v - dX.v \cdot dY.u}{\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)}}\\ \end{array} \]
  10. Add Preprocessing

Alternative 8: 39.3% accurate, 1.3× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\left\lfloorw\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}{t\_4}\\


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

    \[\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. Add Preprocessing
  3. Applied egg-rr75.7%

    \[\leadsto \color{blue}{1 \cdot \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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\lfloorw\right\rfloor \cdot \left(dX.u \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right) - \left\lfloorh\right\rfloor \cdot \left(dX.v \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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\lfloorw\right\rfloor \cdot \left(dX.u \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right) - \left\lfloorh\right\rfloor \cdot \left(dX.v \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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}} \]
  4. Simplified35.8%

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

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

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

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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\lfloorw\right\rfloor \cdot \left(dX.u \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\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\lfloorw\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}{\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)}}\\ \end{array} \]
  8. Add Preprocessing

Alternative 9: 38.9% accurate, 1.3× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\left\lfloorw\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(t\_0, t\_3\right)\right)}^{2}, t\_2\right)}}\\


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

    \[\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. Add Preprocessing
  3. Applied egg-rr75.7%

    \[\leadsto \color{blue}{1 \cdot \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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\lfloorw\right\rfloor \cdot \left(dX.u \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right) - \left\lfloorh\right\rfloor \cdot \left(dX.v \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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\lfloorw\right\rfloor \cdot \left(dX.u \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right) - \left\lfloorh\right\rfloor \cdot \left(dX.v \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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}} \]
  4. Simplified35.8%

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

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

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

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

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.u \cdot \left\lfloorw\right\rfloor, dX.v \cdot \left\lfloorh\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\lfloorw\right\rfloor \cdot \left(dX.u \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right)} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\color{blue}{e^{\log \left(\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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) \cdot 0.5}}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left\lfloorw\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot \left(dX.u \cdot dY.v - dX.v \cdot dY.u\right)\right)}{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dX.v, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(dY.v \cdot \left\lfloorh\right\rfloor, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}\\ \end{array} \]
  9. Final simplification36.6%

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

Alternative 10: 39.1% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left\lfloorh\right\rfloor \cdot dX.v\\ t_1 := \left\lfloorh\right\rfloor \cdot dY.v\\ t_2 := {\left(\mathsf{hypot}\left(t\_1, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\\ t_3 := \left\lfloorw\right\rfloor \cdot dX.u\\ t_4 := \mathsf{max}\left({\left(\mathsf{hypot}\left(t\_3, t\_0\right)\right)}^{2}, t\_2\right)\\ \log_{2} \begin{array}{l} \mathbf{if}\;\frac{t\_4}{\left\lfloorw\right\rfloor \cdot \left(dX.u \cdot t\_1\right)} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(t\_0, t\_3\right)\right)}^{2}, t\_2\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;dX.v \cdot \left(\sqrt{\frac{1}{t\_4}} \cdot \left(dY.u \cdot \left(\left\lfloorh\right\rfloor \cdot \left(-\left\lfloorw\right\rfloor\right)\right)\right)\right)\\ \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 h) dY.v))
        (t_2 (pow (hypot t_1 (* (floor w) dY.u)) 2.0))
        (t_3 (* (floor w) dX.u))
        (t_4 (fmax (pow (hypot t_3 t_0) 2.0) t_2)))
   (log2
    (if (> (/ t_4 (* (floor w) (* dX.u t_1))) (floor maxAniso))
      (/ (sqrt (fmax (pow (hypot t_0 t_3) 2.0) t_2)) (floor maxAniso))
      (* dX.v (* (sqrt (/ 1.0 t_4)) (* dY.u (* (floor h) (- (floor w))))))))))
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(h) * dY_46_v;
	float t_2 = powf(hypotf(t_1, (floorf(w) * dY_46_u)), 2.0f);
	float t_3 = floorf(w) * dX_46_u;
	float t_4 = fmaxf(powf(hypotf(t_3, t_0), 2.0f), t_2);
	float tmp;
	if ((t_4 / (floorf(w) * (dX_46_u * t_1))) > floorf(maxAniso)) {
		tmp = sqrtf(fmaxf(powf(hypotf(t_0, t_3), 2.0f), t_2)) / floorf(maxAniso);
	} else {
		tmp = dX_46_v * (sqrtf((1.0f / t_4)) * (dY_46_u * (floorf(h) * -floorf(w))));
	}
	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(h) * dY_46_v)
	t_2 = hypot(t_1, Float32(floor(w) * dY_46_u)) ^ Float32(2.0)
	t_3 = Float32(floor(w) * dX_46_u)
	t_4 = ((hypot(t_3, t_0) ^ Float32(2.0)) != (hypot(t_3, t_0) ^ Float32(2.0))) ? t_2 : ((t_2 != t_2) ? (hypot(t_3, t_0) ^ Float32(2.0)) : max((hypot(t_3, t_0) ^ Float32(2.0)), t_2))
	tmp = Float32(0.0)
	if (Float32(t_4 / Float32(floor(w) * Float32(dX_46_u * t_1))) > floor(maxAniso))
		tmp = Float32(sqrt((((hypot(t_0, t_3) ^ Float32(2.0)) != (hypot(t_0, t_3) ^ Float32(2.0))) ? t_2 : ((t_2 != t_2) ? (hypot(t_0, t_3) ^ Float32(2.0)) : max((hypot(t_0, t_3) ^ Float32(2.0)), t_2)))) / floor(maxAniso));
	else
		tmp = Float32(dX_46_v * Float32(sqrt(Float32(Float32(1.0) / t_4)) * Float32(dY_46_u * Float32(floor(h) * Float32(-floor(w))))));
	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(h) * dY_46_v;
	t_2 = hypot(t_1, (floor(w) * dY_46_u)) ^ single(2.0);
	t_3 = floor(w) * dX_46_u;
	t_4 = max((hypot(t_3, t_0) ^ single(2.0)), t_2);
	tmp = single(0.0);
	if ((t_4 / (floor(w) * (dX_46_u * t_1))) > floor(maxAniso))
		tmp = sqrt(max((hypot(t_0, t_3) ^ single(2.0)), t_2)) / floor(maxAniso);
	else
		tmp = dX_46_v * (sqrt((single(1.0) / t_4)) * (dY_46_u * (floor(h) * -floor(w))));
	end
	tmp_2 = log2(tmp);
end
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;dX.v \cdot \left(\sqrt{\frac{1}{t\_4}} \cdot \left(dY.u \cdot \left(\left\lfloorh\right\rfloor \cdot \left(-\left\lfloorw\right\rfloor\right)\right)\right)\right)\\


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

    \[\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. Add Preprocessing
  3. Applied egg-rr75.7%

    \[\leadsto \color{blue}{1 \cdot \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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\lfloorw\right\rfloor \cdot \left(dX.u \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right) - \left\lfloorh\right\rfloor \cdot \left(dX.v \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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\lfloorw\right\rfloor \cdot \left(dX.u \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right) - \left\lfloorh\right\rfloor \cdot \left(dX.v \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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}} \]
  4. Simplified35.8%

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

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

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

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.u \cdot \left\lfloorw\right\rfloor, dX.v \cdot \left\lfloorh\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\lfloorw\right\rfloor \cdot \left(dX.u \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right)} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dX.v, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(dY.v \cdot \left\lfloorh\right\rfloor, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \left(\left(dX.v \cdot \left(dY.u \cdot \left(\left\lfloorh\right\rfloor \cdot \left\lfloorw\right\rfloor\right)\right)\right) \cdot \sqrt{\frac{1}{\mathsf{max}\left({dX.u}^{2} \cdot {\left(\left\lfloorw\right\rfloor\right)}^{2} + {dX.v}^{2} \cdot {\left(\left\lfloorh\right\rfloor\right)}^{2}, {dY.u}^{2} \cdot {\left(\left\lfloorw\right\rfloor\right)}^{2} + {dY.v}^{2} \cdot {\left(\left\lfloorh\right\rfloor\right)}^{2}\right)}}\right)\\ \end{array} \]
  8. Simplified36.0%

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

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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\lfloorw\right\rfloor \cdot \left(dX.u \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\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}:\\ \;\;\;\;dX.v \cdot \left(\sqrt{\frac{1}{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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)}} \cdot \left(dY.u \cdot \left(\left\lfloorh\right\rfloor \cdot \left(-\left\lfloorw\right\rfloor\right)\right)\right)\right)\\ \end{array} \]
  10. Add Preprocessing

Alternative 11: 37.6% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left\lfloorh\right\rfloor \cdot dY.v\\ t_1 := \mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\right)\right)}^{2}, {\left(\mathsf{hypot}\left(t\_0, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)\\ t_2 := \sqrt{t\_1}\\ \log_{2} \begin{array}{l} \mathbf{if}\;\frac{t\_1}{dX.u \cdot \left(\left\lfloorw\right\rfloor \cdot t\_0\right)} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{t\_2}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;dX.u \cdot \left(\left(\left\lfloorw\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot \frac{dY.v}{t\_2}\right)\\ \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) dY.v))
        (t_1
         (fmax
          (pow (hypot (* (floor w) dX.u) (* (floor h) dX.v)) 2.0)
          (pow (hypot t_0 (* (floor w) dY.u)) 2.0)))
        (t_2 (sqrt t_1)))
   (log2
    (if (> (/ t_1 (* dX.u (* (floor w) t_0))) (floor maxAniso))
      (/ t_2 (floor maxAniso))
      (* dX.u (* (* (floor w) (floor h)) (/ dY.v t_2)))))))
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) * dY_46_v;
	float t_1 = fmaxf(powf(hypotf((floorf(w) * dX_46_u), (floorf(h) * dX_46_v)), 2.0f), powf(hypotf(t_0, (floorf(w) * dY_46_u)), 2.0f));
	float t_2 = sqrtf(t_1);
	float tmp;
	if ((t_1 / (dX_46_u * (floorf(w) * t_0))) > floorf(maxAniso)) {
		tmp = t_2 / floorf(maxAniso);
	} else {
		tmp = dX_46_u * ((floorf(w) * floorf(h)) * (dY_46_v / t_2));
	}
	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) * dY_46_v)
	t_1 = ((hypot(Float32(floor(w) * dX_46_u), Float32(floor(h) * dX_46_v)) ^ Float32(2.0)) != (hypot(Float32(floor(w) * dX_46_u), Float32(floor(h) * dX_46_v)) ^ Float32(2.0))) ? (hypot(t_0, Float32(floor(w) * dY_46_u)) ^ Float32(2.0)) : (((hypot(t_0, Float32(floor(w) * dY_46_u)) ^ Float32(2.0)) != (hypot(t_0, Float32(floor(w) * dY_46_u)) ^ Float32(2.0))) ? (hypot(Float32(floor(w) * dX_46_u), Float32(floor(h) * dX_46_v)) ^ Float32(2.0)) : max((hypot(Float32(floor(w) * dX_46_u), Float32(floor(h) * dX_46_v)) ^ Float32(2.0)), (hypot(t_0, Float32(floor(w) * dY_46_u)) ^ Float32(2.0))))
	t_2 = sqrt(t_1)
	tmp = Float32(0.0)
	if (Float32(t_1 / Float32(dX_46_u * Float32(floor(w) * t_0))) > floor(maxAniso))
		tmp = Float32(t_2 / floor(maxAniso));
	else
		tmp = Float32(dX_46_u * Float32(Float32(floor(w) * floor(h)) * Float32(dY_46_v / t_2)));
	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) * dY_46_v;
	t_1 = max((hypot((floor(w) * dX_46_u), (floor(h) * dX_46_v)) ^ single(2.0)), (hypot(t_0, (floor(w) * dY_46_u)) ^ single(2.0)));
	t_2 = sqrt(t_1);
	tmp = single(0.0);
	if ((t_1 / (dX_46_u * (floor(w) * t_0))) > floor(maxAniso))
		tmp = t_2 / floor(maxAniso);
	else
		tmp = dX_46_u * ((floor(w) * floor(h)) * (dY_46_v / t_2));
	end
	tmp_2 = log2(tmp);
end
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;dX.u \cdot \left(\left(\left\lfloorw\right\rfloor \cdot \left\lfloorh\right\rfloor\right) \cdot \frac{dY.v}{t\_2}\right)\\


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

    \[\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. Add Preprocessing
  3. Applied egg-rr75.7%

    \[\leadsto \color{blue}{1 \cdot \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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\lfloorw\right\rfloor \cdot \left(dX.u \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right) - \left\lfloorh\right\rfloor \cdot \left(dX.v \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right)\right)\right|} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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\lfloorw\right\rfloor \cdot \left(dX.u \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right) - \left\lfloorh\right\rfloor \cdot \left(dX.v \cdot \left(\left\lfloorw\right\rfloor \cdot dY.u\right)\right)\right|}{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dX.u, \left\lfloorh\right\rfloor \cdot dX.v\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}} \]
  4. Simplified35.8%

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

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

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

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.u \cdot \left\lfloorw\right\rfloor, dX.v \cdot \left\lfloorh\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\lfloorw\right\rfloor \cdot \left(dX.u \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right)} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dX.v, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(dY.v \cdot \left\lfloorh\right\rfloor, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;\left(dX.u \cdot \left(dY.v \cdot \left(\left\lfloorh\right\rfloor \cdot \left\lfloorw\right\rfloor\right)\right)\right) \cdot \sqrt{\frac{1}{\mathsf{max}\left({dX.u}^{2} \cdot {\left(\left\lfloorw\right\rfloor\right)}^{2} + {dX.v}^{2} \cdot {\left(\left\lfloorh\right\rfloor\right)}^{2}, {dY.u}^{2} \cdot {\left(\left\lfloorw\right\rfloor\right)}^{2} + {dY.v}^{2} \cdot {\left(\left\lfloorh\right\rfloor\right)}^{2}\right)}}\\ \end{array} \]
  8. Simplified34.8%

    \[\leadsto \log_{2} \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.u \cdot \left\lfloorw\right\rfloor, dX.v \cdot \left\lfloorh\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\lfloorw\right\rfloor \cdot \left(dX.u \cdot \left(\left\lfloorh\right\rfloor \cdot dY.v\right)\right)} > \left\lfloormaxAniso\right\rfloor:\\ \;\;\;\;\frac{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dX.v, dX.u \cdot \left\lfloorw\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(dY.v \cdot \left\lfloorh\right\rfloor, \left\lfloorw\right\rfloor \cdot dY.u\right)\right)}^{2}\right)}}{\left\lfloormaxAniso\right\rfloor}\\ \mathbf{else}:\\ \;\;\;\;dY.v \cdot \left(\sqrt{\frac{1}{\mathsf{max}\left({\left(\mathsf{hypot}\left(dX.u \cdot \left\lfloorw\right\rfloor, dX.v \cdot \left\lfloorh\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)}} \cdot \left(\left\lfloorw\right\rfloor \cdot \left(\left\lfloorh\right\rfloor \cdot dX.u\right)\right)\right)\\ \end{array} \]
  9. Taylor expanded in dX.u around 0 34.8%

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

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

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

Reproduce

?
herbie shell --seed 2024137 
(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)))))))))