
(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 w) dX.u))
(t_3 (+ (* t_2 t_2) (* t_0 t_0)))
(t_4 (* (floor h) dY.v))
(t_5 (+ (* t_1 t_1) (* t_4 t_4)))
(t_6 (/ 1.0 (sqrt (fmax t_3 t_5)))))
(if (>= t_3 t_5) (* t_6 t_2) (* t_6 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 = floorf(w) * dY_46_u;
float t_2 = floorf(w) * dX_46_u;
float t_3 = (t_2 * t_2) + (t_0 * t_0);
float t_4 = floorf(h) * dY_46_v;
float t_5 = (t_1 * t_1) + (t_4 * t_4);
float t_6 = 1.0f / sqrtf(fmaxf(t_3, t_5));
float tmp;
if (t_3 >= t_5) {
tmp = t_6 * t_2;
} else {
tmp = t_6 * t_1;
}
return 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(w) * dX_46_u) t_3 = Float32(Float32(t_2 * t_2) + Float32(t_0 * t_0)) t_4 = Float32(floor(h) * dY_46_v) t_5 = Float32(Float32(t_1 * t_1) + Float32(t_4 * t_4)) t_6 = Float32(Float32(1.0) / sqrt(((t_3 != t_3) ? t_5 : ((t_5 != t_5) ? t_3 : max(t_3, t_5))))) tmp = Float32(0.0) if (t_3 >= t_5) tmp = Float32(t_6 * t_2); else tmp = Float32(t_6 * t_1); end return 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(w) * dX_46_u; t_3 = (t_2 * t_2) + (t_0 * t_0); t_4 = floor(h) * dY_46_v; t_5 = (t_1 * t_1) + (t_4 * t_4); t_6 = single(1.0) / sqrt(max(t_3, t_5)); tmp = single(0.0); if (t_3 >= t_5) tmp = t_6 * t_2; else tmp = t_6 * t_1; end tmp_2 = 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\lfloorw\right\rfloor \cdot dX.u\\
t_3 := t\_2 \cdot t\_2 + t\_0 \cdot t\_0\\
t_4 := \left\lfloorh\right\rfloor \cdot dY.v\\
t_5 := t\_1 \cdot t\_1 + t\_4 \cdot t\_4\\
t_6 := \frac{1}{\sqrt{\mathsf{max}\left(t\_3, t\_5\right)}}\\
\mathbf{if}\;t\_3 \geq t\_5:\\
\;\;\;\;t\_6 \cdot t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_6 \cdot t\_1\\
\end{array}
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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 w) dX.u))
(t_3 (+ (* t_2 t_2) (* t_0 t_0)))
(t_4 (* (floor h) dY.v))
(t_5 (+ (* t_1 t_1) (* t_4 t_4)))
(t_6 (/ 1.0 (sqrt (fmax t_3 t_5)))))
(if (>= t_3 t_5) (* t_6 t_2) (* t_6 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 = floorf(w) * dY_46_u;
float t_2 = floorf(w) * dX_46_u;
float t_3 = (t_2 * t_2) + (t_0 * t_0);
float t_4 = floorf(h) * dY_46_v;
float t_5 = (t_1 * t_1) + (t_4 * t_4);
float t_6 = 1.0f / sqrtf(fmaxf(t_3, t_5));
float tmp;
if (t_3 >= t_5) {
tmp = t_6 * t_2;
} else {
tmp = t_6 * t_1;
}
return 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(w) * dX_46_u) t_3 = Float32(Float32(t_2 * t_2) + Float32(t_0 * t_0)) t_4 = Float32(floor(h) * dY_46_v) t_5 = Float32(Float32(t_1 * t_1) + Float32(t_4 * t_4)) t_6 = Float32(Float32(1.0) / sqrt(((t_3 != t_3) ? t_5 : ((t_5 != t_5) ? t_3 : max(t_3, t_5))))) tmp = Float32(0.0) if (t_3 >= t_5) tmp = Float32(t_6 * t_2); else tmp = Float32(t_6 * t_1); end return 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(w) * dX_46_u; t_3 = (t_2 * t_2) + (t_0 * t_0); t_4 = floor(h) * dY_46_v; t_5 = (t_1 * t_1) + (t_4 * t_4); t_6 = single(1.0) / sqrt(max(t_3, t_5)); tmp = single(0.0); if (t_3 >= t_5) tmp = t_6 * t_2; else tmp = t_6 * t_1; end tmp_2 = 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\lfloorw\right\rfloor \cdot dX.u\\
t_3 := t\_2 \cdot t\_2 + t\_0 \cdot t\_0\\
t_4 := \left\lfloorh\right\rfloor \cdot dY.v\\
t_5 := t\_1 \cdot t\_1 + t\_4 \cdot t\_4\\
t_6 := \frac{1}{\sqrt{\mathsf{max}\left(t\_3, t\_5\right)}}\\
\mathbf{if}\;t\_3 \geq t\_5:\\
\;\;\;\;t\_6 \cdot t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_6 \cdot t\_1\\
\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 w) dX.u))
(t_3 (+ (* t_2 t_2) (* t_0 t_0)))
(t_4 (* (floor h) dY.v))
(t_5 (+ (* t_1 t_1) (* t_4 t_4))))
(if (>= t_3 t_5)
(* t_2 (/ 1.0 (sqrt (fmax t_3 t_5))))
(/
t_1
(sqrt (fmax (pow (hypot t_2 t_0) 2.0) (pow (hypot t_1 t_4) 2.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 = floorf(h) * dX_46_v;
float t_1 = floorf(w) * dY_46_u;
float t_2 = floorf(w) * dX_46_u;
float t_3 = (t_2 * t_2) + (t_0 * t_0);
float t_4 = floorf(h) * dY_46_v;
float t_5 = (t_1 * t_1) + (t_4 * t_4);
float tmp;
if (t_3 >= t_5) {
tmp = t_2 * (1.0f / sqrtf(fmaxf(t_3, t_5)));
} else {
tmp = t_1 / sqrtf(fmaxf(powf(hypotf(t_2, t_0), 2.0f), powf(hypotf(t_1, t_4), 2.0f)));
}
return 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(w) * dX_46_u) t_3 = Float32(Float32(t_2 * t_2) + Float32(t_0 * t_0)) t_4 = Float32(floor(h) * dY_46_v) t_5 = Float32(Float32(t_1 * t_1) + Float32(t_4 * t_4)) tmp = Float32(0.0) if (t_3 >= t_5) tmp = Float32(t_2 * Float32(Float32(1.0) / sqrt(((t_3 != t_3) ? t_5 : ((t_5 != t_5) ? t_3 : max(t_3, t_5)))))); else tmp = Float32(t_1 / sqrt((((hypot(t_2, t_0) ^ Float32(2.0)) != (hypot(t_2, t_0) ^ Float32(2.0))) ? (hypot(t_1, t_4) ^ Float32(2.0)) : (((hypot(t_1, t_4) ^ Float32(2.0)) != (hypot(t_1, t_4) ^ Float32(2.0))) ? (hypot(t_2, t_0) ^ Float32(2.0)) : max((hypot(t_2, t_0) ^ Float32(2.0)), (hypot(t_1, t_4) ^ Float32(2.0))))))); end return 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(w) * dX_46_u; t_3 = (t_2 * t_2) + (t_0 * t_0); t_4 = floor(h) * dY_46_v; t_5 = (t_1 * t_1) + (t_4 * t_4); tmp = single(0.0); if (t_3 >= t_5) tmp = t_2 * (single(1.0) / sqrt(max(t_3, t_5))); else tmp = t_1 / sqrt(max((hypot(t_2, t_0) ^ single(2.0)), (hypot(t_1, t_4) ^ single(2.0)))); end tmp_2 = 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\lfloorw\right\rfloor \cdot dX.u\\
t_3 := t\_2 \cdot t\_2 + t\_0 \cdot t\_0\\
t_4 := \left\lfloorh\right\rfloor \cdot dY.v\\
t_5 := t\_1 \cdot t\_1 + t\_4 \cdot t\_4\\
\mathbf{if}\;t\_3 \geq t\_5:\\
\;\;\;\;t\_2 \cdot \frac{1}{\sqrt{\mathsf{max}\left(t\_3, t\_5\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(t\_2, t\_0\right)\right)}^{2}, {\left(\mathsf{hypot}\left(t\_1, t\_4\right)\right)}^{2}\right)}}\\
\end{array}
\end{array}
Initial program 80.9%
pow280.9%
pow-to-exp65.1%
Applied egg-rr65.1%
associate-*l/65.1%
*-un-lft-identity65.1%
Applied egg-rr81.1%
Final simplification81.1%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* (floor w) dY.u))
(t_1 (pow (hypot t_0 (* (floor h) dY.v)) 2.0))
(t_2 (* (floor w) dX.u))
(t_3 (* (floor h) dX.v))
(t_4 (sqrt (fmax (pow (hypot t_2 t_3) 2.0) t_1))))
(if (>= (pow (hypot t_3 t_2) 2.0) t_1) (/ t_2 t_4) (/ t_0 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(w) * dY_46_u;
float t_1 = powf(hypotf(t_0, (floorf(h) * dY_46_v)), 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_2, t_3), 2.0f), t_1));
float tmp;
if (powf(hypotf(t_3, t_2), 2.0f) >= t_1) {
tmp = t_2 / t_4;
} else {
tmp = t_0 / t_4;
}
return tmp;
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = Float32(floor(w) * dY_46_u) t_1 = hypot(t_0, Float32(floor(h) * dY_46_v)) ^ Float32(2.0) t_2 = Float32(floor(w) * dX_46_u) t_3 = Float32(floor(h) * dX_46_v) t_4 = sqrt((((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)))) tmp = Float32(0.0) if ((hypot(t_3, t_2) ^ Float32(2.0)) >= t_1) tmp = Float32(t_2 / t_4); else tmp = Float32(t_0 / t_4); end return tmp end
function tmp_2 = code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = floor(w) * dY_46_u; t_1 = hypot(t_0, (floor(h) * dY_46_v)) ^ single(2.0); t_2 = floor(w) * dX_46_u; t_3 = floor(h) * dX_46_v; t_4 = sqrt(max((hypot(t_2, t_3) ^ single(2.0)), t_1)); tmp = single(0.0); if ((hypot(t_3, t_2) ^ single(2.0)) >= t_1) tmp = t_2 / t_4; else tmp = t_0 / t_4; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloorw\right\rfloor \cdot dY.u\\
t_1 := {\left(\mathsf{hypot}\left(t\_0, \left\lfloorh\right\rfloor \cdot dY.v\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\_2, t\_3\right)\right)}^{2}, t\_1\right)}\\
\mathbf{if}\;{\left(\mathsf{hypot}\left(t\_3, t\_2\right)\right)}^{2} \geq t\_1:\\
\;\;\;\;\frac{t\_2}{t\_4}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{t\_4}\\
\end{array}
\end{array}
Initial program 80.9%
pow280.9%
pow-to-exp65.1%
Applied egg-rr65.1%
associate-*l/65.1%
*-un-lft-identity65.1%
Applied egg-rr81.1%
associate-*l/81.0%
*-un-lft-identity81.0%
Applied egg-rr81.1%
Taylor expanded in w around 0 81.1%
Simplified81.1%
Final simplification81.1%
(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 w) dY.u) (* (floor h) dY.v)) 2.0))
(t_2 (* (floor w) dX.u))
(t_3 (sqrt (/ 1.0 (fmax (pow (hypot t_2 t_0) 2.0) t_1))))
(t_4 (pow (fmax (pow (hypot t_0 t_2) 2.0) t_1) 0.5)))
(if (<= dX.v 100000.0)
(if (>= (pow t_2 2.0) t_1)
(* (floor w) (/ dX.u t_4))
(* dY.u (/ (floor w) t_4)))
(if (>= (pow t_0 2.0) t_1)
(* dX.u (* (floor w) t_3))
(* (floor w) (* dY.u 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 = floorf(h) * dX_46_v;
float t_1 = powf(hypotf((floorf(w) * dY_46_u), (floorf(h) * dY_46_v)), 2.0f);
float t_2 = floorf(w) * dX_46_u;
float t_3 = sqrtf((1.0f / fmaxf(powf(hypotf(t_2, t_0), 2.0f), t_1)));
float t_4 = powf(fmaxf(powf(hypotf(t_0, t_2), 2.0f), t_1), 0.5f);
float tmp_1;
if (dX_46_v <= 100000.0f) {
float tmp_2;
if (powf(t_2, 2.0f) >= t_1) {
tmp_2 = floorf(w) * (dX_46_u / t_4);
} else {
tmp_2 = dY_46_u * (floorf(w) / t_4);
}
tmp_1 = tmp_2;
} else if (powf(t_0, 2.0f) >= t_1) {
tmp_1 = dX_46_u * (floorf(w) * t_3);
} else {
tmp_1 = floorf(w) * (dY_46_u * t_3);
}
return tmp_1;
}
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(w) * dY_46_u), Float32(floor(h) * dY_46_v)) ^ Float32(2.0) t_2 = Float32(floor(w) * dX_46_u) t_3 = sqrt(Float32(Float32(1.0) / (((hypot(t_2, t_0) ^ Float32(2.0)) != (hypot(t_2, t_0) ^ Float32(2.0))) ? t_1 : ((t_1 != t_1) ? (hypot(t_2, t_0) ^ Float32(2.0)) : max((hypot(t_2, t_0) ^ Float32(2.0)), t_1))))) t_4 = (((hypot(t_0, t_2) ^ Float32(2.0)) != (hypot(t_0, t_2) ^ Float32(2.0))) ? t_1 : ((t_1 != t_1) ? (hypot(t_0, t_2) ^ Float32(2.0)) : max((hypot(t_0, t_2) ^ Float32(2.0)), t_1))) ^ Float32(0.5) tmp_1 = Float32(0.0) if (dX_46_v <= Float32(100000.0)) tmp_2 = Float32(0.0) if ((t_2 ^ Float32(2.0)) >= t_1) tmp_2 = Float32(floor(w) * Float32(dX_46_u / t_4)); else tmp_2 = Float32(dY_46_u * Float32(floor(w) / t_4)); end tmp_1 = tmp_2; elseif ((t_0 ^ Float32(2.0)) >= t_1) tmp_1 = Float32(dX_46_u * Float32(floor(w) * t_3)); else tmp_1 = Float32(floor(w) * Float32(dY_46_u * t_3)); end return tmp_1 end
function tmp_4 = 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(w) * dY_46_u), (floor(h) * dY_46_v)) ^ single(2.0); t_2 = floor(w) * dX_46_u; t_3 = sqrt((single(1.0) / max((hypot(t_2, t_0) ^ single(2.0)), t_1))); t_4 = max((hypot(t_0, t_2) ^ single(2.0)), t_1) ^ single(0.5); tmp_2 = single(0.0); if (dX_46_v <= single(100000.0)) tmp_3 = single(0.0); if ((t_2 ^ single(2.0)) >= t_1) tmp_3 = floor(w) * (dX_46_u / t_4); else tmp_3 = dY_46_u * (floor(w) / t_4); end tmp_2 = tmp_3; elseif ((t_0 ^ single(2.0)) >= t_1) tmp_2 = dX_46_u * (floor(w) * t_3); else tmp_2 = floor(w) * (dY_46_u * t_3); end tmp_4 = tmp_2; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloorh\right\rfloor \cdot dX.v\\
t_1 := {\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dY.u, \left\lfloorh\right\rfloor \cdot dY.v\right)\right)}^{2}\\
t_2 := \left\lfloorw\right\rfloor \cdot dX.u\\
t_3 := \sqrt{\frac{1}{\mathsf{max}\left({\left(\mathsf{hypot}\left(t\_2, t\_0\right)\right)}^{2}, t\_1\right)}}\\
t_4 := {\left(\mathsf{max}\left({\left(\mathsf{hypot}\left(t\_0, t\_2\right)\right)}^{2}, t\_1\right)\right)}^{0.5}\\
\mathbf{if}\;dX.v \leq 100000:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;{t\_2}^{2} \geq t\_1:\\
\;\;\;\;\left\lfloorw\right\rfloor \cdot \frac{dX.u}{t\_4}\\
\mathbf{else}:\\
\;\;\;\;dY.u \cdot \frac{\left\lfloorw\right\rfloor}{t\_4}\\
\end{array}\\
\mathbf{elif}\;{t\_0}^{2} \geq t\_1:\\
\;\;\;\;dX.u \cdot \left(\left\lfloorw\right\rfloor \cdot t\_3\right)\\
\mathbf{else}:\\
\;\;\;\;\left\lfloorw\right\rfloor \cdot \left(dY.u \cdot t\_3\right)\\
\end{array}
\end{array}
if dX.v < 1e5Initial program 82.1%
Simplified82.0%
Taylor expanded in w around 0 81.9%
Simplified81.9%
Taylor expanded in dX.u around inf 74.1%
*-commutative74.1%
unpow274.1%
unpow274.1%
swap-sqr74.1%
unpow274.1%
*-commutative74.1%
Simplified74.1%
Applied egg-rr73.8%
Taylor expanded in dX.u around 0 74.1%
Simplified74.1%
if 1e5 < dX.v Initial program 74.2%
Simplified74.0%
Taylor expanded in w around 0 73.9%
Simplified73.7%
Taylor expanded in dX.u around 0 71.8%
unpow271.8%
unpow271.8%
swap-sqr71.8%
unpow271.8%
Simplified71.8%
Final simplification73.8%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* (floor w) dY.u))
(t_1 (pow (hypot t_0 (* (floor h) dY.v)) 2.0))
(t_2 (* (floor w) dX.u))
(t_3 (pow (hypot (* (floor h) dX.v) t_2) 2.0))
(t_4 (fmax t_3 t_1))
(t_5 (pow t_4 -0.5))
(t_6 (pow t_4 0.5)))
(if (<= dX.v 40000.0)
(if (>= (pow t_2 2.0) t_1)
(* (floor w) (/ dX.u t_6))
(* dY.u (/ (floor w) t_6)))
(if (>= t_3 (pow t_0 2.0)) (* t_2 t_5) (* (floor w) (* dY.u 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(w) * dY_46_u;
float t_1 = powf(hypotf(t_0, (floorf(h) * dY_46_v)), 2.0f);
float t_2 = floorf(w) * dX_46_u;
float t_3 = powf(hypotf((floorf(h) * dX_46_v), t_2), 2.0f);
float t_4 = fmaxf(t_3, t_1);
float t_5 = powf(t_4, -0.5f);
float t_6 = powf(t_4, 0.5f);
float tmp_1;
if (dX_46_v <= 40000.0f) {
float tmp_2;
if (powf(t_2, 2.0f) >= t_1) {
tmp_2 = floorf(w) * (dX_46_u / t_6);
} else {
tmp_2 = dY_46_u * (floorf(w) / t_6);
}
tmp_1 = tmp_2;
} else if (t_3 >= powf(t_0, 2.0f)) {
tmp_1 = t_2 * t_5;
} else {
tmp_1 = floorf(w) * (dY_46_u * t_5);
}
return tmp_1;
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = Float32(floor(w) * dY_46_u) t_1 = hypot(t_0, Float32(floor(h) * dY_46_v)) ^ Float32(2.0) t_2 = Float32(floor(w) * dX_46_u) t_3 = hypot(Float32(floor(h) * dX_46_v), t_2) ^ Float32(2.0) t_4 = (t_3 != t_3) ? t_1 : ((t_1 != t_1) ? t_3 : max(t_3, t_1)) t_5 = t_4 ^ Float32(-0.5) t_6 = t_4 ^ Float32(0.5) tmp_1 = Float32(0.0) if (dX_46_v <= Float32(40000.0)) tmp_2 = Float32(0.0) if ((t_2 ^ Float32(2.0)) >= t_1) tmp_2 = Float32(floor(w) * Float32(dX_46_u / t_6)); else tmp_2 = Float32(dY_46_u * Float32(floor(w) / t_6)); end tmp_1 = tmp_2; elseif (t_3 >= (t_0 ^ Float32(2.0))) tmp_1 = Float32(t_2 * t_5); else tmp_1 = Float32(floor(w) * Float32(dY_46_u * t_5)); end return tmp_1 end
function tmp_4 = code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = floor(w) * dY_46_u; t_1 = hypot(t_0, (floor(h) * dY_46_v)) ^ single(2.0); t_2 = floor(w) * dX_46_u; t_3 = hypot((floor(h) * dX_46_v), t_2) ^ single(2.0); t_4 = max(t_3, t_1); t_5 = t_4 ^ single(-0.5); t_6 = t_4 ^ single(0.5); tmp_2 = single(0.0); if (dX_46_v <= single(40000.0)) tmp_3 = single(0.0); if ((t_2 ^ single(2.0)) >= t_1) tmp_3 = floor(w) * (dX_46_u / t_6); else tmp_3 = dY_46_u * (floor(w) / t_6); end tmp_2 = tmp_3; elseif (t_3 >= (t_0 ^ single(2.0))) tmp_2 = t_2 * t_5; else tmp_2 = floor(w) * (dY_46_u * t_5); end tmp_4 = tmp_2; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloorw\right\rfloor \cdot dY.u\\
t_1 := {\left(\mathsf{hypot}\left(t\_0, \left\lfloorh\right\rfloor \cdot dY.v\right)\right)}^{2}\\
t_2 := \left\lfloorw\right\rfloor \cdot dX.u\\
t_3 := {\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dX.v, t\_2\right)\right)}^{2}\\
t_4 := \mathsf{max}\left(t\_3, t\_1\right)\\
t_5 := {t\_4}^{-0.5}\\
t_6 := {t\_4}^{0.5}\\
\mathbf{if}\;dX.v \leq 40000:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;{t\_2}^{2} \geq t\_1:\\
\;\;\;\;\left\lfloorw\right\rfloor \cdot \frac{dX.u}{t\_6}\\
\mathbf{else}:\\
\;\;\;\;dY.u \cdot \frac{\left\lfloorw\right\rfloor}{t\_6}\\
\end{array}\\
\mathbf{elif}\;t\_3 \geq {t\_0}^{2}:\\
\;\;\;\;t\_2 \cdot t\_5\\
\mathbf{else}:\\
\;\;\;\;\left\lfloorw\right\rfloor \cdot \left(dY.u \cdot t\_5\right)\\
\end{array}
\end{array}
if dX.v < 4e4Initial program 82.0%
Simplified81.9%
Taylor expanded in w around 0 81.8%
Simplified81.8%
Taylor expanded in dX.u around inf 74.0%
*-commutative74.0%
unpow274.0%
unpow274.0%
swap-sqr74.0%
unpow274.0%
*-commutative74.0%
Simplified74.0%
Applied egg-rr73.7%
Taylor expanded in dX.u around 0 74.0%
Simplified74.0%
if 4e4 < dX.v Initial program 74.9%
pow1/274.9%
Applied egg-rr74.9%
Taylor expanded in w around 0 74.5%
Simplified74.6%
Taylor expanded in dY.u around inf 68.3%
*-commutative68.3%
unpow268.3%
unpow268.3%
swap-sqr68.3%
unpow268.3%
*-commutative68.3%
Simplified68.3%
Final simplification73.1%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* (floor w) dX.u))
(t_1 (pow t_0 2.0))
(t_2 (* (floor w) dY.u))
(t_3 (* (floor h) dY.v))
(t_4
(fmax
(pow (hypot t_0 (* (floor h) dX.v)) 2.0)
(pow (hypot t_2 t_3) 2.0)))
(t_5 (* (floor w) (* dY.u (sqrt (pow (cbrt t_4) -3.0)))))
(t_6 (* dX.u (* (floor w) (sqrt (/ 1.0 t_4))))))
(if (<= dY.v 0.007000000216066837)
(if (>= t_1 (pow t_2 2.0)) t_6 t_5)
(if (>= t_1 (pow t_3 2.0)) 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(w) * dX_46_u;
float t_1 = powf(t_0, 2.0f);
float t_2 = floorf(w) * dY_46_u;
float t_3 = floorf(h) * dY_46_v;
float t_4 = fmaxf(powf(hypotf(t_0, (floorf(h) * dX_46_v)), 2.0f), powf(hypotf(t_2, t_3), 2.0f));
float t_5 = floorf(w) * (dY_46_u * sqrtf(powf(cbrtf(t_4), -3.0f)));
float t_6 = dX_46_u * (floorf(w) * sqrtf((1.0f / t_4)));
float tmp_1;
if (dY_46_v <= 0.007000000216066837f) {
float tmp_2;
if (t_1 >= powf(t_2, 2.0f)) {
tmp_2 = t_6;
} else {
tmp_2 = t_5;
}
tmp_1 = tmp_2;
} else if (t_1 >= powf(t_3, 2.0f)) {
tmp_1 = t_6;
} else {
tmp_1 = t_5;
}
return tmp_1;
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = Float32(floor(w) * dX_46_u) t_1 = t_0 ^ Float32(2.0) t_2 = Float32(floor(w) * dY_46_u) t_3 = Float32(floor(h) * dY_46_v) t_4 = ((hypot(t_0, Float32(floor(h) * dX_46_v)) ^ Float32(2.0)) != (hypot(t_0, Float32(floor(h) * dX_46_v)) ^ Float32(2.0))) ? (hypot(t_2, t_3) ^ Float32(2.0)) : (((hypot(t_2, t_3) ^ Float32(2.0)) != (hypot(t_2, t_3) ^ Float32(2.0))) ? (hypot(t_0, Float32(floor(h) * dX_46_v)) ^ Float32(2.0)) : max((hypot(t_0, Float32(floor(h) * dX_46_v)) ^ Float32(2.0)), (hypot(t_2, t_3) ^ Float32(2.0)))) t_5 = Float32(floor(w) * Float32(dY_46_u * sqrt((cbrt(t_4) ^ Float32(-3.0))))) t_6 = Float32(dX_46_u * Float32(floor(w) * sqrt(Float32(Float32(1.0) / t_4)))) tmp_1 = Float32(0.0) if (dY_46_v <= Float32(0.007000000216066837)) tmp_2 = Float32(0.0) if (t_1 >= (t_2 ^ Float32(2.0))) tmp_2 = t_6; else tmp_2 = t_5; end tmp_1 = tmp_2; elseif (t_1 >= (t_3 ^ Float32(2.0))) tmp_1 = t_6; else tmp_1 = t_5; end return tmp_1 end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloorw\right\rfloor \cdot dX.u\\
t_1 := {t\_0}^{2}\\
t_2 := \left\lfloorw\right\rfloor \cdot dY.u\\
t_3 := \left\lfloorh\right\rfloor \cdot dY.v\\
t_4 := \mathsf{max}\left({\left(\mathsf{hypot}\left(t\_0, \left\lfloorh\right\rfloor \cdot dX.v\right)\right)}^{2}, {\left(\mathsf{hypot}\left(t\_2, t\_3\right)\right)}^{2}\right)\\
t_5 := \left\lfloorw\right\rfloor \cdot \left(dY.u \cdot \sqrt{{\left(\sqrt[3]{t\_4}\right)}^{-3}}\right)\\
t_6 := dX.u \cdot \left(\left\lfloorw\right\rfloor \cdot \sqrt{\frac{1}{t\_4}}\right)\\
\mathbf{if}\;dY.v \leq 0.007000000216066837:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;t\_1 \geq {t\_2}^{2}:\\
\;\;\;\;t\_6\\
\mathbf{else}:\\
\;\;\;\;t\_5\\
\end{array}\\
\mathbf{elif}\;t\_1 \geq {t\_3}^{2}:\\
\;\;\;\;t\_6\\
\mathbf{else}:\\
\;\;\;\;t\_5\\
\end{array}
\end{array}
if dY.v < 0.00700000022Initial program 79.7%
Simplified79.5%
Taylor expanded in w around 0 79.4%
Simplified79.3%
Taylor expanded in dX.u around inf 69.4%
*-commutative69.4%
unpow269.4%
unpow269.4%
swap-sqr69.4%
unpow269.4%
*-commutative69.4%
Simplified69.4%
Applied egg-rr69.1%
Taylor expanded in dY.u around inf 63.3%
*-commutative70.3%
unpow270.3%
unpow270.3%
swap-sqr70.3%
unpow270.3%
*-commutative70.3%
Simplified63.3%
if 0.00700000022 < dY.v Initial program 83.9%
Simplified83.8%
Taylor expanded in w around 0 83.7%
Simplified83.8%
Taylor expanded in dX.u around inf 72.3%
*-commutative72.3%
unpow272.3%
unpow272.3%
swap-sqr72.3%
unpow272.3%
*-commutative72.3%
Simplified72.3%
Applied egg-rr72.0%
Taylor expanded in dY.u around 0 72.0%
*-commutative72.0%
unpow272.0%
unpow272.0%
swap-sqr72.0%
unpow272.0%
Simplified72.0%
Final simplification65.9%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* (floor w) dX.u))
(t_1 (pow t_0 2.0))
(t_2 (* (floor w) dY.u))
(t_3 (* (floor h) dY.v))
(t_4 (pow (hypot t_2 t_3) 2.0))
(t_5 (fmax (pow (hypot t_0 (* (floor h) dX.v)) 2.0) t_4))
(t_6 (sqrt (/ 1.0 t_5))))
(if (<= dY.v 199999995904.0)
(if (>= t_1 (pow t_2 2.0))
(* dX.u (* (floor w) t_6))
(* (floor w) (* dY.u (sqrt (pow (cbrt t_5) -3.0)))))
(if (>= t_1 (pow t_3 2.0))
(*
dX.u
(*
(floor w)
(sqrt (/ 1.0 (fmax (* (pow dX.v 2.0) (pow (floor h) 2.0)) t_4)))))
(* (floor w) (* dY.u t_6))))))
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(w) * dX_46_u;
float t_1 = powf(t_0, 2.0f);
float t_2 = floorf(w) * dY_46_u;
float t_3 = floorf(h) * dY_46_v;
float t_4 = powf(hypotf(t_2, t_3), 2.0f);
float t_5 = fmaxf(powf(hypotf(t_0, (floorf(h) * dX_46_v)), 2.0f), t_4);
float t_6 = sqrtf((1.0f / t_5));
float tmp_1;
if (dY_46_v <= 199999995904.0f) {
float tmp_2;
if (t_1 >= powf(t_2, 2.0f)) {
tmp_2 = dX_46_u * (floorf(w) * t_6);
} else {
tmp_2 = floorf(w) * (dY_46_u * sqrtf(powf(cbrtf(t_5), -3.0f)));
}
tmp_1 = tmp_2;
} else if (t_1 >= powf(t_3, 2.0f)) {
tmp_1 = dX_46_u * (floorf(w) * sqrtf((1.0f / fmaxf((powf(dX_46_v, 2.0f) * powf(floorf(h), 2.0f)), t_4))));
} else {
tmp_1 = floorf(w) * (dY_46_u * t_6);
}
return tmp_1;
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = Float32(floor(w) * dX_46_u) t_1 = t_0 ^ Float32(2.0) t_2 = Float32(floor(w) * dY_46_u) t_3 = Float32(floor(h) * dY_46_v) t_4 = hypot(t_2, t_3) ^ Float32(2.0) t_5 = ((hypot(t_0, Float32(floor(h) * dX_46_v)) ^ Float32(2.0)) != (hypot(t_0, Float32(floor(h) * dX_46_v)) ^ Float32(2.0))) ? t_4 : ((t_4 != t_4) ? (hypot(t_0, Float32(floor(h) * dX_46_v)) ^ Float32(2.0)) : max((hypot(t_0, Float32(floor(h) * dX_46_v)) ^ Float32(2.0)), t_4)) t_6 = sqrt(Float32(Float32(1.0) / t_5)) tmp_1 = Float32(0.0) if (dY_46_v <= Float32(199999995904.0)) tmp_2 = Float32(0.0) if (t_1 >= (t_2 ^ Float32(2.0))) tmp_2 = Float32(dX_46_u * Float32(floor(w) * t_6)); else tmp_2 = Float32(floor(w) * Float32(dY_46_u * sqrt((cbrt(t_5) ^ Float32(-3.0))))); end tmp_1 = tmp_2; elseif (t_1 >= (t_3 ^ Float32(2.0))) tmp_1 = Float32(dX_46_u * Float32(floor(w) * sqrt(Float32(Float32(1.0) / ((Float32((dX_46_v ^ Float32(2.0)) * (floor(h) ^ Float32(2.0))) != Float32((dX_46_v ^ Float32(2.0)) * (floor(h) ^ Float32(2.0)))) ? t_4 : ((t_4 != t_4) ? Float32((dX_46_v ^ Float32(2.0)) * (floor(h) ^ Float32(2.0))) : max(Float32((dX_46_v ^ Float32(2.0)) * (floor(h) ^ Float32(2.0))), t_4))))))); else tmp_1 = Float32(floor(w) * Float32(dY_46_u * t_6)); end return tmp_1 end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloorw\right\rfloor \cdot dX.u\\
t_1 := {t\_0}^{2}\\
t_2 := \left\lfloorw\right\rfloor \cdot dY.u\\
t_3 := \left\lfloorh\right\rfloor \cdot dY.v\\
t_4 := {\left(\mathsf{hypot}\left(t\_2, t\_3\right)\right)}^{2}\\
t_5 := \mathsf{max}\left({\left(\mathsf{hypot}\left(t\_0, \left\lfloorh\right\rfloor \cdot dX.v\right)\right)}^{2}, t\_4\right)\\
t_6 := \sqrt{\frac{1}{t\_5}}\\
\mathbf{if}\;dY.v \leq 199999995904:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;t\_1 \geq {t\_2}^{2}:\\
\;\;\;\;dX.u \cdot \left(\left\lfloorw\right\rfloor \cdot t\_6\right)\\
\mathbf{else}:\\
\;\;\;\;\left\lfloorw\right\rfloor \cdot \left(dY.u \cdot \sqrt{{\left(\sqrt[3]{t\_5}\right)}^{-3}}\right)\\
\end{array}\\
\mathbf{elif}\;t\_1 \geq {t\_3}^{2}:\\
\;\;\;\;dX.u \cdot \left(\left\lfloorw\right\rfloor \cdot \sqrt{\frac{1}{\mathsf{max}\left({dX.v}^{2} \cdot {\left(\left\lfloorh\right\rfloor\right)}^{2}, t\_4\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;\left\lfloorw\right\rfloor \cdot \left(dY.u \cdot t\_6\right)\\
\end{array}
\end{array}
if dY.v < 199999996000Initial program 81.3%
Simplified81.2%
Taylor expanded in w around 0 81.1%
Simplified81.0%
Taylor expanded in dX.u around inf 70.6%
*-commutative70.6%
unpow270.6%
unpow270.6%
swap-sqr70.6%
unpow270.6%
*-commutative70.6%
Simplified70.6%
Applied egg-rr70.4%
Taylor expanded in dY.u around inf 65.1%
*-commutative69.7%
unpow269.7%
unpow269.7%
swap-sqr69.7%
unpow269.7%
*-commutative69.7%
Simplified65.1%
if 199999996000 < dY.v Initial program 77.6%
Simplified77.2%
Taylor expanded in w around 0 77.0%
Simplified77.4%
Taylor expanded in dX.u around inf 66.7%
*-commutative66.7%
unpow266.7%
unpow266.7%
swap-sqr66.7%
unpow266.7%
*-commutative66.7%
Simplified66.7%
Taylor expanded in dX.u around 0 63.6%
Taylor expanded in dY.u around 0 63.6%
*-commutative66.5%
unpow266.5%
unpow266.5%
swap-sqr66.5%
unpow266.5%
Simplified63.6%
Final simplification64.9%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* (floor w) dX.u))
(t_1 (pow (hypot (* (floor w) dY.u) (* (floor h) dY.v)) 2.0))
(t_2 (pow (fmax (pow (hypot (* (floor h) dX.v) t_0) 2.0) t_1) 0.5)))
(if (>= (pow t_0 2.0) t_1)
(* (floor w) (/ dX.u t_2))
(* dY.u (/ (floor w) 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(w) * dX_46_u;
float t_1 = powf(hypotf((floorf(w) * dY_46_u), (floorf(h) * dY_46_v)), 2.0f);
float t_2 = powf(fmaxf(powf(hypotf((floorf(h) * dX_46_v), t_0), 2.0f), t_1), 0.5f);
float tmp;
if (powf(t_0, 2.0f) >= t_1) {
tmp = floorf(w) * (dX_46_u / t_2);
} else {
tmp = dY_46_u * (floorf(w) / t_2);
}
return tmp;
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = Float32(floor(w) * dX_46_u) t_1 = hypot(Float32(floor(w) * dY_46_u), Float32(floor(h) * dY_46_v)) ^ Float32(2.0) t_2 = (((hypot(Float32(floor(h) * dX_46_v), t_0) ^ Float32(2.0)) != (hypot(Float32(floor(h) * dX_46_v), t_0) ^ Float32(2.0))) ? t_1 : ((t_1 != t_1) ? (hypot(Float32(floor(h) * dX_46_v), t_0) ^ Float32(2.0)) : max((hypot(Float32(floor(h) * dX_46_v), t_0) ^ Float32(2.0)), t_1))) ^ Float32(0.5) tmp = Float32(0.0) if ((t_0 ^ Float32(2.0)) >= t_1) tmp = Float32(floor(w) * Float32(dX_46_u / t_2)); else tmp = Float32(dY_46_u * Float32(floor(w) / t_2)); end return tmp end
function tmp_2 = code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = floor(w) * dX_46_u; t_1 = hypot((floor(w) * dY_46_u), (floor(h) * dY_46_v)) ^ single(2.0); t_2 = max((hypot((floor(h) * dX_46_v), t_0) ^ single(2.0)), t_1) ^ single(0.5); tmp = single(0.0); if ((t_0 ^ single(2.0)) >= t_1) tmp = floor(w) * (dX_46_u / t_2); else tmp = dY_46_u * (floor(w) / t_2); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloorw\right\rfloor \cdot dX.u\\
t_1 := {\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dY.u, \left\lfloorh\right\rfloor \cdot dY.v\right)\right)}^{2}\\
t_2 := {\left(\mathsf{max}\left({\left(\mathsf{hypot}\left(\left\lfloorh\right\rfloor \cdot dX.v, t\_0\right)\right)}^{2}, t\_1\right)\right)}^{0.5}\\
\mathbf{if}\;{t\_0}^{2} \geq t\_1:\\
\;\;\;\;\left\lfloorw\right\rfloor \cdot \frac{dX.u}{t\_2}\\
\mathbf{else}:\\
\;\;\;\;dY.u \cdot \frac{\left\lfloorw\right\rfloor}{t\_2}\\
\end{array}
\end{array}
Initial program 80.9%
Simplified80.8%
Taylor expanded in w around 0 80.7%
Simplified80.7%
Taylor expanded in dX.u around inf 70.2%
*-commutative70.2%
unpow270.2%
unpow270.2%
swap-sqr70.2%
unpow270.2%
*-commutative70.2%
Simplified70.2%
Applied egg-rr70.0%
Taylor expanded in dX.u around 0 70.2%
Simplified70.3%
Final simplification70.3%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* (floor w) dX.u))
(t_1 (pow t_0 2.0))
(t_2 (* (floor w) dY.u))
(t_3 (* (floor h) dY.v))
(t_4 (pow (hypot t_2 t_3) 2.0))
(t_5
(*
(floor w)
(*
dY.u
(sqrt
(/ 1.0 (fmax (pow (hypot t_0 (* (floor h) dX.v)) 2.0) t_4))))))
(t_6
(*
dX.u
(*
(floor w)
(sqrt (/ 1.0 (fmax (* (pow dX.v 2.0) (pow (floor h) 2.0)) t_4)))))))
(if (<= dY.v 0.007000000216066837)
(if (>= t_1 (pow t_2 2.0)) t_6 t_5)
(if (>= t_1 (pow t_3 2.0)) 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(w) * dX_46_u;
float t_1 = powf(t_0, 2.0f);
float t_2 = floorf(w) * dY_46_u;
float t_3 = floorf(h) * dY_46_v;
float t_4 = powf(hypotf(t_2, t_3), 2.0f);
float t_5 = floorf(w) * (dY_46_u * sqrtf((1.0f / fmaxf(powf(hypotf(t_0, (floorf(h) * dX_46_v)), 2.0f), t_4))));
float t_6 = dX_46_u * (floorf(w) * sqrtf((1.0f / fmaxf((powf(dX_46_v, 2.0f) * powf(floorf(h), 2.0f)), t_4))));
float tmp_1;
if (dY_46_v <= 0.007000000216066837f) {
float tmp_2;
if (t_1 >= powf(t_2, 2.0f)) {
tmp_2 = t_6;
} else {
tmp_2 = t_5;
}
tmp_1 = tmp_2;
} else if (t_1 >= powf(t_3, 2.0f)) {
tmp_1 = t_6;
} else {
tmp_1 = t_5;
}
return tmp_1;
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = Float32(floor(w) * dX_46_u) t_1 = t_0 ^ Float32(2.0) t_2 = Float32(floor(w) * dY_46_u) t_3 = Float32(floor(h) * dY_46_v) t_4 = hypot(t_2, t_3) ^ Float32(2.0) t_5 = Float32(floor(w) * Float32(dY_46_u * sqrt(Float32(Float32(1.0) / (((hypot(t_0, Float32(floor(h) * dX_46_v)) ^ Float32(2.0)) != (hypot(t_0, Float32(floor(h) * dX_46_v)) ^ Float32(2.0))) ? t_4 : ((t_4 != t_4) ? (hypot(t_0, Float32(floor(h) * dX_46_v)) ^ Float32(2.0)) : max((hypot(t_0, Float32(floor(h) * dX_46_v)) ^ Float32(2.0)), t_4))))))) t_6 = Float32(dX_46_u * Float32(floor(w) * sqrt(Float32(Float32(1.0) / ((Float32((dX_46_v ^ Float32(2.0)) * (floor(h) ^ Float32(2.0))) != Float32((dX_46_v ^ Float32(2.0)) * (floor(h) ^ Float32(2.0)))) ? t_4 : ((t_4 != t_4) ? Float32((dX_46_v ^ Float32(2.0)) * (floor(h) ^ Float32(2.0))) : max(Float32((dX_46_v ^ Float32(2.0)) * (floor(h) ^ Float32(2.0))), t_4))))))) tmp_1 = Float32(0.0) if (dY_46_v <= Float32(0.007000000216066837)) tmp_2 = Float32(0.0) if (t_1 >= (t_2 ^ Float32(2.0))) tmp_2 = t_6; else tmp_2 = t_5; end tmp_1 = tmp_2; elseif (t_1 >= (t_3 ^ Float32(2.0))) tmp_1 = t_6; else tmp_1 = t_5; end return tmp_1 end
function tmp_4 = code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = floor(w) * dX_46_u; t_1 = t_0 ^ single(2.0); t_2 = floor(w) * dY_46_u; t_3 = floor(h) * dY_46_v; t_4 = hypot(t_2, t_3) ^ single(2.0); t_5 = floor(w) * (dY_46_u * sqrt((single(1.0) / max((hypot(t_0, (floor(h) * dX_46_v)) ^ single(2.0)), t_4)))); t_6 = dX_46_u * (floor(w) * sqrt((single(1.0) / max(((dX_46_v ^ single(2.0)) * (floor(h) ^ single(2.0))), t_4)))); tmp_2 = single(0.0); if (dY_46_v <= single(0.007000000216066837)) tmp_3 = single(0.0); if (t_1 >= (t_2 ^ single(2.0))) tmp_3 = t_6; else tmp_3 = t_5; end tmp_2 = tmp_3; elseif (t_1 >= (t_3 ^ single(2.0))) tmp_2 = t_6; else tmp_2 = t_5; end tmp_4 = tmp_2; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloorw\right\rfloor \cdot dX.u\\
t_1 := {t\_0}^{2}\\
t_2 := \left\lfloorw\right\rfloor \cdot dY.u\\
t_3 := \left\lfloorh\right\rfloor \cdot dY.v\\
t_4 := {\left(\mathsf{hypot}\left(t\_2, t\_3\right)\right)}^{2}\\
t_5 := \left\lfloorw\right\rfloor \cdot \left(dY.u \cdot \sqrt{\frac{1}{\mathsf{max}\left({\left(\mathsf{hypot}\left(t\_0, \left\lfloorh\right\rfloor \cdot dX.v\right)\right)}^{2}, t\_4\right)}}\right)\\
t_6 := dX.u \cdot \left(\left\lfloorw\right\rfloor \cdot \sqrt{\frac{1}{\mathsf{max}\left({dX.v}^{2} \cdot {\left(\left\lfloorh\right\rfloor\right)}^{2}, t\_4\right)}}\right)\\
\mathbf{if}\;dY.v \leq 0.007000000216066837:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;t\_1 \geq {t\_2}^{2}:\\
\;\;\;\;t\_6\\
\mathbf{else}:\\
\;\;\;\;t\_5\\
\end{array}\\
\mathbf{elif}\;t\_1 \geq {t\_3}^{2}:\\
\;\;\;\;t\_6\\
\mathbf{else}:\\
\;\;\;\;t\_5\\
\end{array}
\end{array}
if dY.v < 0.00700000022Initial program 79.7%
Simplified79.5%
Taylor expanded in w around 0 79.4%
Simplified79.3%
Taylor expanded in dX.u around inf 69.4%
*-commutative69.4%
unpow269.4%
unpow269.4%
swap-sqr69.4%
unpow269.4%
*-commutative69.4%
Simplified69.4%
Taylor expanded in dX.u around 0 53.7%
Taylor expanded in dY.u around inf 47.8%
*-commutative70.3%
unpow270.3%
unpow270.3%
swap-sqr70.3%
unpow270.3%
*-commutative70.3%
Simplified47.8%
if 0.00700000022 < dY.v Initial program 83.9%
Simplified83.8%
Taylor expanded in w around 0 83.7%
Simplified83.8%
Taylor expanded in dX.u around inf 72.3%
*-commutative72.3%
unpow272.3%
unpow272.3%
swap-sqr72.3%
unpow272.3%
*-commutative72.3%
Simplified72.3%
Taylor expanded in dX.u around 0 62.5%
Taylor expanded in dY.u around 0 62.5%
*-commutative72.0%
unpow272.0%
unpow272.0%
swap-sqr72.0%
unpow272.0%
Simplified62.5%
Final simplification52.2%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* (floor w) dY.u))
(t_1 (* (floor w) dX.u))
(t_2 (pow (hypot t_0 (* (floor h) dY.v)) 2.0)))
(if (>= (pow t_1 2.0) (pow t_0 2.0))
(*
dX.u
(*
(floor w)
(sqrt (/ 1.0 (fmax (* (pow dX.v 2.0) (pow (floor h) 2.0)) t_2)))))
(*
(floor w)
(*
dY.u
(sqrt (/ 1.0 (fmax (pow (hypot t_1 (* (floor h) dX.v)) 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(w) * dY_46_u;
float t_1 = floorf(w) * dX_46_u;
float t_2 = powf(hypotf(t_0, (floorf(h) * dY_46_v)), 2.0f);
float tmp;
if (powf(t_1, 2.0f) >= powf(t_0, 2.0f)) {
tmp = dX_46_u * (floorf(w) * sqrtf((1.0f / fmaxf((powf(dX_46_v, 2.0f) * powf(floorf(h), 2.0f)), t_2))));
} else {
tmp = floorf(w) * (dY_46_u * sqrtf((1.0f / fmaxf(powf(hypotf(t_1, (floorf(h) * dX_46_v)), 2.0f), t_2))));
}
return tmp;
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = Float32(floor(w) * dY_46_u) t_1 = Float32(floor(w) * dX_46_u) t_2 = hypot(t_0, Float32(floor(h) * dY_46_v)) ^ Float32(2.0) tmp = Float32(0.0) if ((t_1 ^ Float32(2.0)) >= (t_0 ^ Float32(2.0))) tmp = Float32(dX_46_u * Float32(floor(w) * sqrt(Float32(Float32(1.0) / ((Float32((dX_46_v ^ Float32(2.0)) * (floor(h) ^ Float32(2.0))) != Float32((dX_46_v ^ Float32(2.0)) * (floor(h) ^ Float32(2.0)))) ? t_2 : ((t_2 != t_2) ? Float32((dX_46_v ^ Float32(2.0)) * (floor(h) ^ Float32(2.0))) : max(Float32((dX_46_v ^ Float32(2.0)) * (floor(h) ^ Float32(2.0))), t_2))))))); else tmp = Float32(floor(w) * Float32(dY_46_u * sqrt(Float32(Float32(1.0) / (((hypot(t_1, Float32(floor(h) * dX_46_v)) ^ Float32(2.0)) != (hypot(t_1, Float32(floor(h) * dX_46_v)) ^ Float32(2.0))) ? t_2 : ((t_2 != t_2) ? (hypot(t_1, Float32(floor(h) * dX_46_v)) ^ Float32(2.0)) : max((hypot(t_1, Float32(floor(h) * dX_46_v)) ^ Float32(2.0)), t_2))))))); end return tmp end
function tmp_2 = code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = floor(w) * dY_46_u; t_1 = floor(w) * dX_46_u; t_2 = hypot(t_0, (floor(h) * dY_46_v)) ^ single(2.0); tmp = single(0.0); if ((t_1 ^ single(2.0)) >= (t_0 ^ single(2.0))) tmp = dX_46_u * (floor(w) * sqrt((single(1.0) / max(((dX_46_v ^ single(2.0)) * (floor(h) ^ single(2.0))), t_2)))); else tmp = floor(w) * (dY_46_u * sqrt((single(1.0) / max((hypot(t_1, (floor(h) * dX_46_v)) ^ single(2.0)), t_2)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloorw\right\rfloor \cdot dY.u\\
t_1 := \left\lfloorw\right\rfloor \cdot dX.u\\
t_2 := {\left(\mathsf{hypot}\left(t\_0, \left\lfloorh\right\rfloor \cdot dY.v\right)\right)}^{2}\\
\mathbf{if}\;{t\_1}^{2} \geq {t\_0}^{2}:\\
\;\;\;\;dX.u \cdot \left(\left\lfloorw\right\rfloor \cdot \sqrt{\frac{1}{\mathsf{max}\left({dX.v}^{2} \cdot {\left(\left\lfloorh\right\rfloor\right)}^{2}, t\_2\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;\left\lfloorw\right\rfloor \cdot \left(dY.u \cdot \sqrt{\frac{1}{\mathsf{max}\left({\left(\mathsf{hypot}\left(t\_1, \left\lfloorh\right\rfloor \cdot dX.v\right)\right)}^{2}, t\_2\right)}}\right)\\
\end{array}
\end{array}
Initial program 80.9%
Simplified80.8%
Taylor expanded in w around 0 80.7%
Simplified80.7%
Taylor expanded in dX.u around inf 70.2%
*-commutative70.2%
unpow270.2%
unpow270.2%
swap-sqr70.2%
unpow270.2%
*-commutative70.2%
Simplified70.2%
Taylor expanded in dX.u around 0 56.3%
Taylor expanded in dY.u around inf 49.3%
*-commutative66.7%
unpow266.7%
unpow266.7%
swap-sqr66.7%
unpow266.7%
*-commutative66.7%
Simplified49.3%
Final simplification49.3%
herbie shell --seed 2024139
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:name "Anisotropic x16 LOD (line direction, u)"
: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))
(if (>= (+ (* (* (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)))) (* (/ 1.0 (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 w) dX.u)) (* (/ 1.0 (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 w) dY.u))))