
(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_0) (* t_6 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) * 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_0;
} else {
tmp = t_6 * 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(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_0); else tmp = Float32(t_6 * 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(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_0; else tmp = t_6 * t_4; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloor h\right\rfloor \cdot dX.v\\
t_1 := \left\lfloor w\right\rfloor \cdot dY.u\\
t_2 := \left\lfloor w\right\rfloor \cdot dX.u\\
t_3 := t\_2 \cdot t\_2 + t\_0 \cdot t\_0\\
t_4 := \left\lfloor h\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\_0\\
\mathbf{else}:\\
\;\;\;\;t\_6 \cdot t\_4\\
\end{array}
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 10 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_0) (* t_6 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) * 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_0;
} else {
tmp = t_6 * 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(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_0); else tmp = Float32(t_6 * 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(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_0; else tmp = t_6 * t_4; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloor h\right\rfloor \cdot dX.v\\
t_1 := \left\lfloor w\right\rfloor \cdot dY.u\\
t_2 := \left\lfloor w\right\rfloor \cdot dX.u\\
t_3 := t\_2 \cdot t\_2 + t\_0 \cdot t\_0\\
t_4 := \left\lfloor h\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\_0\\
\mathbf{else}:\\
\;\;\;\;t\_6 \cdot t\_4\\
\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 (pow (hypot t_3 t_0) 2.0)))
(if (>= (+ (* t_3 t_3) (* t_0 t_0)) (+ (* t_1 t_1) (* t_2 t_2)))
(/ t_0 (sqrt (fmax t_4 (pow (hypot t_2 t_1) 2.0))))
(/ t_2 (sqrt (fmax t_4 (pow (hypot t_1 t_2) 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(h) * dY_46_v;
float t_3 = floorf(w) * dX_46_u;
float t_4 = powf(hypotf(t_3, t_0), 2.0f);
float tmp;
if (((t_3 * t_3) + (t_0 * t_0)) >= ((t_1 * t_1) + (t_2 * t_2))) {
tmp = t_0 / sqrtf(fmaxf(t_4, powf(hypotf(t_2, t_1), 2.0f)));
} else {
tmp = t_2 / sqrtf(fmaxf(t_4, powf(hypotf(t_1, t_2), 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(h) * dY_46_v) t_3 = Float32(floor(w) * dX_46_u) t_4 = hypot(t_3, t_0) ^ Float32(2.0) tmp = Float32(0.0) if (Float32(Float32(t_3 * t_3) + Float32(t_0 * t_0)) >= Float32(Float32(t_1 * t_1) + Float32(t_2 * t_2))) tmp = Float32(t_0 / sqrt(((t_4 != t_4) ? (hypot(t_2, t_1) ^ Float32(2.0)) : (((hypot(t_2, t_1) ^ Float32(2.0)) != (hypot(t_2, t_1) ^ Float32(2.0))) ? t_4 : max(t_4, (hypot(t_2, t_1) ^ Float32(2.0))))))); else tmp = Float32(t_2 / sqrt(((t_4 != t_4) ? (hypot(t_1, t_2) ^ Float32(2.0)) : (((hypot(t_1, t_2) ^ Float32(2.0)) != (hypot(t_1, t_2) ^ Float32(2.0))) ? t_4 : max(t_4, (hypot(t_1, t_2) ^ 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(h) * dY_46_v; t_3 = floor(w) * dX_46_u; t_4 = hypot(t_3, t_0) ^ single(2.0); tmp = single(0.0); if (((t_3 * t_3) + (t_0 * t_0)) >= ((t_1 * t_1) + (t_2 * t_2))) tmp = t_0 / sqrt(max(t_4, (hypot(t_2, t_1) ^ single(2.0)))); else tmp = t_2 / sqrt(max(t_4, (hypot(t_1, t_2) ^ single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloor h\right\rfloor \cdot dX.v\\
t_1 := \left\lfloor w\right\rfloor \cdot dY.u\\
t_2 := \left\lfloor h\right\rfloor \cdot dY.v\\
t_3 := \left\lfloor w\right\rfloor \cdot dX.u\\
t_4 := {\left(\mathsf{hypot}\left(t\_3, t\_0\right)\right)}^{2}\\
\mathbf{if}\;t\_3 \cdot t\_3 + t\_0 \cdot t\_0 \geq t\_1 \cdot t\_1 + t\_2 \cdot t\_2:\\
\;\;\;\;\frac{t\_0}{\sqrt{\mathsf{max}\left(t\_4, {\left(\mathsf{hypot}\left(t\_2, t\_1\right)\right)}^{2}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_2}{\sqrt{\mathsf{max}\left(t\_4, {\left(\mathsf{hypot}\left(t\_1, t\_2\right)\right)}^{2}\right)}}\\
\end{array}
\end{array}
Initial program 75.8%
Applied egg-rr76.0%
associate-*l/76.2%
*-un-lft-identity76.2%
Applied egg-rr76.2%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* (floor h) dY.v))
(t_1 (* (floor w) dY.u))
(t_2 (pow (hypot t_0 t_1) 2.0))
(t_3 (* (floor h) dX.v))
(t_4 (pow (hypot (* (floor w) dX.u) t_3) 2.0)))
(if (>= t_4 t_2)
(/ t_3 (sqrt (fmax t_4 (pow (hypot t_1 t_0) 2.0))))
(* (floor h) (* dY.v (sqrt (/ 1.0 (fmax t_4 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 = floorf(w) * dY_46_u;
float t_2 = powf(hypotf(t_0, t_1), 2.0f);
float t_3 = floorf(h) * dX_46_v;
float t_4 = powf(hypotf((floorf(w) * dX_46_u), t_3), 2.0f);
float tmp;
if (t_4 >= t_2) {
tmp = t_3 / sqrtf(fmaxf(t_4, powf(hypotf(t_1, t_0), 2.0f)));
} else {
tmp = floorf(h) * (dY_46_v * sqrtf((1.0f / fmaxf(t_4, 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(h) * dY_46_v) t_1 = Float32(floor(w) * dY_46_u) t_2 = hypot(t_0, t_1) ^ Float32(2.0) t_3 = Float32(floor(h) * dX_46_v) t_4 = hypot(Float32(floor(w) * dX_46_u), t_3) ^ Float32(2.0) tmp = Float32(0.0) if (t_4 >= t_2) tmp = Float32(t_3 / sqrt(((t_4 != t_4) ? (hypot(t_1, t_0) ^ Float32(2.0)) : (((hypot(t_1, t_0) ^ Float32(2.0)) != (hypot(t_1, t_0) ^ Float32(2.0))) ? t_4 : max(t_4, (hypot(t_1, t_0) ^ Float32(2.0))))))); else tmp = Float32(floor(h) * Float32(dY_46_v * sqrt(Float32(Float32(1.0) / ((t_4 != t_4) ? t_2 : ((t_2 != t_2) ? t_4 : max(t_4, 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(h) * dY_46_v; t_1 = floor(w) * dY_46_u; t_2 = hypot(t_0, t_1) ^ single(2.0); t_3 = floor(h) * dX_46_v; t_4 = hypot((floor(w) * dX_46_u), t_3) ^ single(2.0); tmp = single(0.0); if (t_4 >= t_2) tmp = t_3 / sqrt(max(t_4, (hypot(t_1, t_0) ^ single(2.0)))); else tmp = floor(h) * (dY_46_v * sqrt((single(1.0) / max(t_4, t_2)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloor h\right\rfloor \cdot dY.v\\
t_1 := \left\lfloor w\right\rfloor \cdot dY.u\\
t_2 := {\left(\mathsf{hypot}\left(t\_0, t\_1\right)\right)}^{2}\\
t_3 := \left\lfloor h\right\rfloor \cdot dX.v\\
t_4 := {\left(\mathsf{hypot}\left(\left\lfloor w\right\rfloor \cdot dX.u, t\_3\right)\right)}^{2}\\
\mathbf{if}\;t\_4 \geq t\_2:\\
\;\;\;\;\frac{t\_3}{\sqrt{\mathsf{max}\left(t\_4, {\left(\mathsf{hypot}\left(t\_1, t\_0\right)\right)}^{2}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\left\lfloor h\right\rfloor \cdot \left(dY.v \cdot \sqrt{\frac{1}{\mathsf{max}\left(t\_4, t\_2\right)}}\right)\\
\end{array}
\end{array}
Initial program 75.8%
Simplified75.9%
Taylor expanded in w around 0 75.6%
Simplified75.6%
associate-*r*75.6%
*-commutative75.6%
sqrt-div75.7%
metadata-eval75.7%
*-commutative75.7%
*-commutative75.7%
pow1/275.7%
exp-to-pow72.5%
Applied egg-rr75.9%
Final simplification75.9%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (pow (hypot (* (floor w) dY.u) (* (floor h) dY.v)) 2.0))
(t_1 (pow (hypot (* (floor w) dX.u) (* (floor h) dX.v)) 2.0))
(t_2 (sqrt (fmax t_1 t_0))))
(if (>= t_1 t_0) (* dX.v (/ (floor h) t_2)) (/ dY.v (/ t_2 (floor h))))))
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(w) * dY_46_u), (floorf(h) * dY_46_v)), 2.0f);
float t_1 = powf(hypotf((floorf(w) * dX_46_u), (floorf(h) * dX_46_v)), 2.0f);
float t_2 = sqrtf(fmaxf(t_1, t_0));
float tmp;
if (t_1 >= t_0) {
tmp = dX_46_v * (floorf(h) / t_2);
} else {
tmp = dY_46_v / (t_2 / floorf(h));
}
return tmp;
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = hypot(Float32(floor(w) * dY_46_u), Float32(floor(h) * dY_46_v)) ^ Float32(2.0) t_1 = hypot(Float32(floor(w) * dX_46_u), Float32(floor(h) * dX_46_v)) ^ Float32(2.0) t_2 = sqrt(((t_1 != t_1) ? t_0 : ((t_0 != t_0) ? t_1 : max(t_1, t_0)))) tmp = Float32(0.0) if (t_1 >= t_0) tmp = Float32(dX_46_v * Float32(floor(h) / t_2)); else tmp = Float32(dY_46_v / Float32(t_2 / floor(h))); 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 = hypot((floor(w) * dY_46_u), (floor(h) * dY_46_v)) ^ single(2.0); t_1 = hypot((floor(w) * dX_46_u), (floor(h) * dX_46_v)) ^ single(2.0); t_2 = sqrt(max(t_1, t_0)); tmp = single(0.0); if (t_1 >= t_0) tmp = dX_46_v * (floor(h) / t_2); else tmp = dY_46_v / (t_2 / floor(h)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{hypot}\left(\left\lfloor w\right\rfloor \cdot dY.u, \left\lfloor h\right\rfloor \cdot dY.v\right)\right)}^{2}\\
t_1 := {\left(\mathsf{hypot}\left(\left\lfloor w\right\rfloor \cdot dX.u, \left\lfloor h\right\rfloor \cdot dX.v\right)\right)}^{2}\\
t_2 := \sqrt{\mathsf{max}\left(t\_1, t\_0\right)}\\
\mathbf{if}\;t\_1 \geq t\_0:\\
\;\;\;\;dX.v \cdot \frac{\left\lfloor h\right\rfloor }{t\_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{dY.v}{\frac{t\_2}{\left\lfloor h\right\rfloor }}\\
\end{array}
\end{array}
Initial program 75.8%
Applied egg-rr76.0%
associate-*l/76.2%
*-un-lft-identity76.2%
Applied egg-rr76.2%
Taylor expanded in w around 0 75.6%
Simplified75.9%
Final simplification75.9%
(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 (pow (hypot (* (floor w) dX.u) (* (floor h) dX.v)) 2.0))
(t_2 (sqrt (fmax t_1 t_0))))
(if (>= t_1 t_0) (* dX.v (/ (floor h) t_2)) (* (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 = powf(hypotf((floorf(h) * dY_46_v), (floorf(w) * dY_46_u)), 2.0f);
float t_1 = powf(hypotf((floorf(w) * dX_46_u), (floorf(h) * dX_46_v)), 2.0f);
float t_2 = sqrtf(fmaxf(t_1, t_0));
float tmp;
if (t_1 >= t_0) {
tmp = dX_46_v * (floorf(h) / t_2);
} else {
tmp = floorf(h) * (dY_46_v / t_2);
}
return 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 = hypot(Float32(floor(w) * dX_46_u), Float32(floor(h) * dX_46_v)) ^ Float32(2.0) t_2 = sqrt(((t_1 != t_1) ? t_0 : ((t_0 != t_0) ? t_1 : max(t_1, t_0)))) tmp = Float32(0.0) if (t_1 >= t_0) tmp = Float32(dX_46_v * Float32(floor(h) / t_2)); else tmp = Float32(floor(h) * Float32(dY_46_v / 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 = hypot((floor(h) * dY_46_v), (floor(w) * dY_46_u)) ^ single(2.0); t_1 = hypot((floor(w) * dX_46_u), (floor(h) * dX_46_v)) ^ single(2.0); t_2 = sqrt(max(t_1, t_0)); tmp = single(0.0); if (t_1 >= t_0) tmp = dX_46_v * (floor(h) / t_2); else tmp = floor(h) * (dY_46_v / t_2); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{hypot}\left(\left\lfloor h\right\rfloor \cdot dY.v, \left\lfloor w\right\rfloor \cdot dY.u\right)\right)}^{2}\\
t_1 := {\left(\mathsf{hypot}\left(\left\lfloor w\right\rfloor \cdot dX.u, \left\lfloor h\right\rfloor \cdot dX.v\right)\right)}^{2}\\
t_2 := \sqrt{\mathsf{max}\left(t\_1, t\_0\right)}\\
\mathbf{if}\;t\_1 \geq t\_0:\\
\;\;\;\;dX.v \cdot \frac{\left\lfloor h\right\rfloor }{t\_2}\\
\mathbf{else}:\\
\;\;\;\;\left\lfloor h\right\rfloor \cdot \frac{dY.v}{t\_2}\\
\end{array}
\end{array}
Initial program 75.8%
Applied egg-rr76.0%
Taylor expanded in w around 0 75.6%
Simplified75.8%
Final simplification75.8%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* (floor w) dY.u))
(t_1 (* (floor h) dX.v))
(t_2 (pow (hypot (* (floor w) dX.u) t_1) 2.0))
(t_3 (* (floor h) dY.v))
(t_4 (pow (hypot t_0 t_3) 2.0))
(t_5 (sqrt (fmax t_2 t_4)))
(t_6 (sqrt (/ 1.0 (fmax t_2 (pow (hypot t_3 t_0) 2.0))))))
(if (<= dX.u 100000.0)
(if (>= (pow t_1 2.0) t_4)
(* dX.v (/ (floor h) t_5))
(/ dY.v (/ t_5 (floor h))))
(if (>= t_2 (pow t_3 2.0))
(* dX.v (* (floor h) t_6))
(* (floor h) (* dY.v 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) * dY_46_u;
float t_1 = floorf(h) * dX_46_v;
float t_2 = powf(hypotf((floorf(w) * dX_46_u), t_1), 2.0f);
float t_3 = floorf(h) * dY_46_v;
float t_4 = powf(hypotf(t_0, t_3), 2.0f);
float t_5 = sqrtf(fmaxf(t_2, t_4));
float t_6 = sqrtf((1.0f / fmaxf(t_2, powf(hypotf(t_3, t_0), 2.0f))));
float tmp_1;
if (dX_46_u <= 100000.0f) {
float tmp_2;
if (powf(t_1, 2.0f) >= t_4) {
tmp_2 = dX_46_v * (floorf(h) / t_5);
} else {
tmp_2 = dY_46_v / (t_5 / floorf(h));
}
tmp_1 = tmp_2;
} else if (t_2 >= powf(t_3, 2.0f)) {
tmp_1 = dX_46_v * (floorf(h) * t_6);
} else {
tmp_1 = floorf(h) * (dY_46_v * 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) * dY_46_u) t_1 = Float32(floor(h) * dX_46_v) t_2 = hypot(Float32(floor(w) * dX_46_u), t_1) ^ Float32(2.0) t_3 = Float32(floor(h) * dY_46_v) t_4 = hypot(t_0, t_3) ^ Float32(2.0) t_5 = sqrt(((t_2 != t_2) ? t_4 : ((t_4 != t_4) ? t_2 : max(t_2, t_4)))) t_6 = sqrt(Float32(Float32(1.0) / ((t_2 != t_2) ? (hypot(t_3, t_0) ^ Float32(2.0)) : (((hypot(t_3, t_0) ^ Float32(2.0)) != (hypot(t_3, t_0) ^ Float32(2.0))) ? t_2 : max(t_2, (hypot(t_3, t_0) ^ Float32(2.0))))))) tmp_1 = Float32(0.0) if (dX_46_u <= Float32(100000.0)) tmp_2 = Float32(0.0) if ((t_1 ^ Float32(2.0)) >= t_4) tmp_2 = Float32(dX_46_v * Float32(floor(h) / t_5)); else tmp_2 = Float32(dY_46_v / Float32(t_5 / floor(h))); end tmp_1 = tmp_2; elseif (t_2 >= (t_3 ^ Float32(2.0))) tmp_1 = Float32(dX_46_v * Float32(floor(h) * t_6)); else tmp_1 = Float32(floor(h) * Float32(dY_46_v * t_6)); 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 = floor(h) * dX_46_v; t_2 = hypot((floor(w) * dX_46_u), t_1) ^ single(2.0); t_3 = floor(h) * dY_46_v; t_4 = hypot(t_0, t_3) ^ single(2.0); t_5 = sqrt(max(t_2, t_4)); t_6 = sqrt((single(1.0) / max(t_2, (hypot(t_3, t_0) ^ single(2.0))))); tmp_2 = single(0.0); if (dX_46_u <= single(100000.0)) tmp_3 = single(0.0); if ((t_1 ^ single(2.0)) >= t_4) tmp_3 = dX_46_v * (floor(h) / t_5); else tmp_3 = dY_46_v / (t_5 / floor(h)); end tmp_2 = tmp_3; elseif (t_2 >= (t_3 ^ single(2.0))) tmp_2 = dX_46_v * (floor(h) * t_6); else tmp_2 = floor(h) * (dY_46_v * t_6); end tmp_4 = tmp_2; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloor w\right\rfloor \cdot dY.u\\
t_1 := \left\lfloor h\right\rfloor \cdot dX.v\\
t_2 := {\left(\mathsf{hypot}\left(\left\lfloor w\right\rfloor \cdot dX.u, t\_1\right)\right)}^{2}\\
t_3 := \left\lfloor h\right\rfloor \cdot dY.v\\
t_4 := {\left(\mathsf{hypot}\left(t\_0, t\_3\right)\right)}^{2}\\
t_5 := \sqrt{\mathsf{max}\left(t\_2, t\_4\right)}\\
t_6 := \sqrt{\frac{1}{\mathsf{max}\left(t\_2, {\left(\mathsf{hypot}\left(t\_3, t\_0\right)\right)}^{2}\right)}}\\
\mathbf{if}\;dX.u \leq 100000:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;{t\_1}^{2} \geq t\_4:\\
\;\;\;\;dX.v \cdot \frac{\left\lfloor h\right\rfloor }{t\_5}\\
\mathbf{else}:\\
\;\;\;\;\frac{dY.v}{\frac{t\_5}{\left\lfloor h\right\rfloor }}\\
\end{array}\\
\mathbf{elif}\;t\_2 \geq {t\_3}^{2}:\\
\;\;\;\;dX.v \cdot \left(\left\lfloor h\right\rfloor \cdot t\_6\right)\\
\mathbf{else}:\\
\;\;\;\;\left\lfloor h\right\rfloor \cdot \left(dY.v \cdot t\_6\right)\\
\end{array}
\end{array}
if dX.u < 1e5Initial program 75.6%
Simplified75.7%
Taylor expanded in w around 0 75.5%
Simplified75.4%
Taylor expanded in dX.u around 0 69.1%
*-commutative69.1%
unpow269.1%
unpow269.1%
swap-sqr69.1%
unpow269.1%
*-commutative69.1%
Simplified69.1%
Taylor expanded in dX.v around 0 69.2%
Simplified69.5%
if 1e5 < dX.u Initial program 76.5%
Simplified76.9%
Taylor expanded in w around 0 76.4%
Simplified76.5%
Taylor expanded in dY.v around inf 74.5%
*-commutative74.5%
unpow274.5%
unpow274.5%
swap-sqr74.5%
unpow274.5%
Simplified74.5%
Final simplification70.4%
(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 h) dX.v))
(t_3 (pow (hypot (* (floor w) dX.u) t_2) 2.0))
(t_4 (sqrt (fmax t_3 t_1)))
(t_5 (/ dY.v (/ t_4 (floor h))))
(t_6 (* dX.v (/ (floor h) t_4))))
(if (<= dX.u 45000.0)
(if (>= (pow t_2 2.0) t_1) t_6 t_5)
(if (>= t_3 (pow t_0 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) * dY_46_u;
float t_1 = powf(hypotf(t_0, (floorf(h) * dY_46_v)), 2.0f);
float t_2 = floorf(h) * dX_46_v;
float t_3 = powf(hypotf((floorf(w) * dX_46_u), t_2), 2.0f);
float t_4 = sqrtf(fmaxf(t_3, t_1));
float t_5 = dY_46_v / (t_4 / floorf(h));
float t_6 = dX_46_v * (floorf(h) / t_4);
float tmp_1;
if (dX_46_u <= 45000.0f) {
float tmp_2;
if (powf(t_2, 2.0f) >= t_1) {
tmp_2 = t_6;
} else {
tmp_2 = t_5;
}
tmp_1 = tmp_2;
} else if (t_3 >= powf(t_0, 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) * dY_46_u) t_1 = hypot(t_0, Float32(floor(h) * dY_46_v)) ^ Float32(2.0) t_2 = Float32(floor(h) * dX_46_v) t_3 = hypot(Float32(floor(w) * dX_46_u), t_2) ^ Float32(2.0) t_4 = sqrt(((t_3 != t_3) ? t_1 : ((t_1 != t_1) ? t_3 : max(t_3, t_1)))) t_5 = Float32(dY_46_v / Float32(t_4 / floor(h))) t_6 = Float32(dX_46_v * Float32(floor(h) / t_4)) tmp_1 = Float32(0.0) if (dX_46_u <= Float32(45000.0)) tmp_2 = Float32(0.0) if ((t_2 ^ Float32(2.0)) >= t_1) tmp_2 = t_6; else tmp_2 = t_5; end tmp_1 = tmp_2; elseif (t_3 >= (t_0 ^ 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) * dY_46_u; t_1 = hypot(t_0, (floor(h) * dY_46_v)) ^ single(2.0); t_2 = floor(h) * dX_46_v; t_3 = hypot((floor(w) * dX_46_u), t_2) ^ single(2.0); t_4 = sqrt(max(t_3, t_1)); t_5 = dY_46_v / (t_4 / floor(h)); t_6 = dX_46_v * (floor(h) / t_4); tmp_2 = single(0.0); if (dX_46_u <= single(45000.0)) tmp_3 = single(0.0); if ((t_2 ^ single(2.0)) >= t_1) tmp_3 = t_6; else tmp_3 = t_5; end tmp_2 = tmp_3; elseif (t_3 >= (t_0 ^ 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\lfloor w\right\rfloor \cdot dY.u\\
t_1 := {\left(\mathsf{hypot}\left(t\_0, \left\lfloor h\right\rfloor \cdot dY.v\right)\right)}^{2}\\
t_2 := \left\lfloor h\right\rfloor \cdot dX.v\\
t_3 := {\left(\mathsf{hypot}\left(\left\lfloor w\right\rfloor \cdot dX.u, t\_2\right)\right)}^{2}\\
t_4 := \sqrt{\mathsf{max}\left(t\_3, t\_1\right)}\\
t_5 := \frac{dY.v}{\frac{t\_4}{\left\lfloor h\right\rfloor }}\\
t_6 := dX.v \cdot \frac{\left\lfloor h\right\rfloor }{t\_4}\\
\mathbf{if}\;dX.u \leq 45000:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;{t\_2}^{2} \geq t\_1:\\
\;\;\;\;t\_6\\
\mathbf{else}:\\
\;\;\;\;t\_5\\
\end{array}\\
\mathbf{elif}\;t\_3 \geq {t\_0}^{2}:\\
\;\;\;\;t\_6\\
\mathbf{else}:\\
\;\;\;\;t\_5\\
\end{array}
\end{array}
if dX.u < 45000Initial program 75.4%
Simplified75.5%
Taylor expanded in w around 0 75.3%
Simplified75.1%
Taylor expanded in dX.u around 0 68.8%
*-commutative68.8%
unpow268.8%
unpow268.8%
swap-sqr68.8%
unpow268.8%
*-commutative68.8%
Simplified68.8%
Taylor expanded in dX.v around 0 68.9%
Simplified69.2%
if 45000 < dX.u Initial program 77.4%
Applied egg-rr78.1%
associate-*l/78.1%
*-un-lft-identity78.1%
Applied egg-rr78.1%
Taylor expanded in w around 0 77.4%
Simplified77.3%
Taylor expanded in dY.u around inf 71.2%
*-commutative71.2%
unpow271.2%
unpow271.2%
swap-sqr71.2%
unpow271.2%
Simplified71.2%
Final simplification69.6%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* (floor w) dX.u))
(t_1 (* (floor w) dY.u))
(t_2 (* (floor h) dY.v))
(t_3 (pow (hypot t_1 t_2) 2.0))
(t_4 (* (floor h) dX.v))
(t_5 (pow (hypot t_0 t_4) 2.0))
(t_6 (sqrt (fmax t_5 t_3))))
(if (<= dX.u 45000.0)
(if (>= (pow t_4 2.0) t_3)
(* dX.v (/ (floor h) t_6))
(/ dY.v (/ t_6 (floor h))))
(if (>= (pow t_0 2.0) (pow t_1 2.0))
(/ t_4 (sqrt (fmax t_5 (pow (hypot t_2 t_1) 2.0))))
(/ t_2 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 = floorf(w) * dY_46_u;
float t_2 = floorf(h) * dY_46_v;
float t_3 = powf(hypotf(t_1, t_2), 2.0f);
float t_4 = floorf(h) * dX_46_v;
float t_5 = powf(hypotf(t_0, t_4), 2.0f);
float t_6 = sqrtf(fmaxf(t_5, t_3));
float tmp_1;
if (dX_46_u <= 45000.0f) {
float tmp_2;
if (powf(t_4, 2.0f) >= t_3) {
tmp_2 = dX_46_v * (floorf(h) / t_6);
} else {
tmp_2 = dY_46_v / (t_6 / floorf(h));
}
tmp_1 = tmp_2;
} else if (powf(t_0, 2.0f) >= powf(t_1, 2.0f)) {
tmp_1 = t_4 / sqrtf(fmaxf(t_5, powf(hypotf(t_2, t_1), 2.0f)));
} else {
tmp_1 = t_2 / 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 = Float32(floor(w) * dY_46_u) t_2 = Float32(floor(h) * dY_46_v) t_3 = hypot(t_1, t_2) ^ Float32(2.0) t_4 = Float32(floor(h) * dX_46_v) t_5 = hypot(t_0, t_4) ^ Float32(2.0) t_6 = sqrt(((t_5 != t_5) ? t_3 : ((t_3 != t_3) ? t_5 : max(t_5, t_3)))) tmp_1 = Float32(0.0) if (dX_46_u <= Float32(45000.0)) tmp_2 = Float32(0.0) if ((t_4 ^ Float32(2.0)) >= t_3) tmp_2 = Float32(dX_46_v * Float32(floor(h) / t_6)); else tmp_2 = Float32(dY_46_v / Float32(t_6 / floor(h))); end tmp_1 = tmp_2; elseif ((t_0 ^ Float32(2.0)) >= (t_1 ^ Float32(2.0))) tmp_1 = Float32(t_4 / sqrt(((t_5 != t_5) ? (hypot(t_2, t_1) ^ Float32(2.0)) : (((hypot(t_2, t_1) ^ Float32(2.0)) != (hypot(t_2, t_1) ^ Float32(2.0))) ? t_5 : max(t_5, (hypot(t_2, t_1) ^ Float32(2.0))))))); else tmp_1 = Float32(t_2 / t_6); 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 = floor(w) * dY_46_u; t_2 = floor(h) * dY_46_v; t_3 = hypot(t_1, t_2) ^ single(2.0); t_4 = floor(h) * dX_46_v; t_5 = hypot(t_0, t_4) ^ single(2.0); t_6 = sqrt(max(t_5, t_3)); tmp_2 = single(0.0); if (dX_46_u <= single(45000.0)) tmp_3 = single(0.0); if ((t_4 ^ single(2.0)) >= t_3) tmp_3 = dX_46_v * (floor(h) / t_6); else tmp_3 = dY_46_v / (t_6 / floor(h)); end tmp_2 = tmp_3; elseif ((t_0 ^ single(2.0)) >= (t_1 ^ single(2.0))) tmp_2 = t_4 / sqrt(max(t_5, (hypot(t_2, t_1) ^ single(2.0)))); else tmp_2 = t_2 / t_6; end tmp_4 = tmp_2; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloor w\right\rfloor \cdot dX.u\\
t_1 := \left\lfloor w\right\rfloor \cdot dY.u\\
t_2 := \left\lfloor h\right\rfloor \cdot dY.v\\
t_3 := {\left(\mathsf{hypot}\left(t\_1, t\_2\right)\right)}^{2}\\
t_4 := \left\lfloor h\right\rfloor \cdot dX.v\\
t_5 := {\left(\mathsf{hypot}\left(t\_0, t\_4\right)\right)}^{2}\\
t_6 := \sqrt{\mathsf{max}\left(t\_5, t\_3\right)}\\
\mathbf{if}\;dX.u \leq 45000:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;{t\_4}^{2} \geq t\_3:\\
\;\;\;\;dX.v \cdot \frac{\left\lfloor h\right\rfloor }{t\_6}\\
\mathbf{else}:\\
\;\;\;\;\frac{dY.v}{\frac{t\_6}{\left\lfloor h\right\rfloor }}\\
\end{array}\\
\mathbf{elif}\;{t\_0}^{2} \geq {t\_1}^{2}:\\
\;\;\;\;\frac{t\_4}{\sqrt{\mathsf{max}\left(t\_5, {\left(\mathsf{hypot}\left(t\_2, t\_1\right)\right)}^{2}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_2}{t\_6}\\
\end{array}
\end{array}
if dX.u < 45000Initial program 75.4%
Simplified75.5%
Taylor expanded in w around 0 75.3%
Simplified75.1%
Taylor expanded in dX.u around 0 68.8%
*-commutative68.8%
unpow268.8%
unpow268.8%
swap-sqr68.8%
unpow268.8%
*-commutative68.8%
Simplified68.8%
Taylor expanded in dX.v around 0 68.9%
Simplified69.2%
if 45000 < dX.u Initial program 77.4%
Applied egg-rr78.1%
associate-*l/78.1%
*-un-lft-identity78.1%
Applied egg-rr78.1%
Taylor expanded in dY.u around inf 72.0%
*-commutative72.0%
unpow272.0%
unpow272.0%
swap-sqr72.0%
unpow272.0%
Simplified72.0%
Taylor expanded in dX.u around inf 65.7%
*-commutative65.7%
unpow265.7%
unpow265.7%
swap-sqr65.7%
unpow265.7%
*-commutative65.7%
Simplified65.7%
Final simplification68.6%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* (floor w) dY.u))
(t_1 (* (floor h) dY.v))
(t_2 (pow (hypot t_0 t_1) 2.0))
(t_3 (* (floor w) dX.u))
(t_4 (* (floor h) dX.v))
(t_5 (/ (floor h) (sqrt (fmax (pow (hypot t_4 t_3) 2.0) t_2))))
(t_6 (pow (hypot t_3 t_4) 2.0))
(t_7 (pow t_4 2.0)))
(if (<= dY.u 2500000.0)
(if (>= t_7 (pow t_1 2.0)) (* dX.v t_5) (* dY.v t_5))
(if (>= t_7 (pow t_0 2.0))
(/ t_4 (sqrt (fmax t_6 (pow (hypot t_1 t_0) 2.0))))
(/ t_1 (sqrt (fmax t_6 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(h) * dY_46_v;
float t_2 = powf(hypotf(t_0, t_1), 2.0f);
float t_3 = floorf(w) * dX_46_u;
float t_4 = floorf(h) * dX_46_v;
float t_5 = floorf(h) / sqrtf(fmaxf(powf(hypotf(t_4, t_3), 2.0f), t_2));
float t_6 = powf(hypotf(t_3, t_4), 2.0f);
float t_7 = powf(t_4, 2.0f);
float tmp_1;
if (dY_46_u <= 2500000.0f) {
float tmp_2;
if (t_7 >= powf(t_1, 2.0f)) {
tmp_2 = dX_46_v * t_5;
} else {
tmp_2 = dY_46_v * t_5;
}
tmp_1 = tmp_2;
} else if (t_7 >= powf(t_0, 2.0f)) {
tmp_1 = t_4 / sqrtf(fmaxf(t_6, powf(hypotf(t_1, t_0), 2.0f)));
} else {
tmp_1 = t_1 / sqrtf(fmaxf(t_6, t_2));
}
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 = Float32(floor(h) * dY_46_v) t_2 = hypot(t_0, t_1) ^ Float32(2.0) t_3 = Float32(floor(w) * dX_46_u) t_4 = Float32(floor(h) * dX_46_v) t_5 = Float32(floor(h) / sqrt((((hypot(t_4, t_3) ^ Float32(2.0)) != (hypot(t_4, t_3) ^ Float32(2.0))) ? t_2 : ((t_2 != t_2) ? (hypot(t_4, t_3) ^ Float32(2.0)) : max((hypot(t_4, t_3) ^ Float32(2.0)), t_2))))) t_6 = hypot(t_3, t_4) ^ Float32(2.0) t_7 = t_4 ^ Float32(2.0) tmp_1 = Float32(0.0) if (dY_46_u <= Float32(2500000.0)) tmp_2 = Float32(0.0) if (t_7 >= (t_1 ^ Float32(2.0))) tmp_2 = Float32(dX_46_v * t_5); else tmp_2 = Float32(dY_46_v * t_5); end tmp_1 = tmp_2; elseif (t_7 >= (t_0 ^ Float32(2.0))) tmp_1 = Float32(t_4 / sqrt(((t_6 != t_6) ? (hypot(t_1, t_0) ^ Float32(2.0)) : (((hypot(t_1, t_0) ^ Float32(2.0)) != (hypot(t_1, t_0) ^ Float32(2.0))) ? t_6 : max(t_6, (hypot(t_1, t_0) ^ Float32(2.0))))))); else tmp_1 = Float32(t_1 / sqrt(((t_6 != t_6) ? t_2 : ((t_2 != t_2) ? t_6 : max(t_6, t_2))))); 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 = floor(h) * dY_46_v; t_2 = hypot(t_0, t_1) ^ single(2.0); t_3 = floor(w) * dX_46_u; t_4 = floor(h) * dX_46_v; t_5 = floor(h) / sqrt(max((hypot(t_4, t_3) ^ single(2.0)), t_2)); t_6 = hypot(t_3, t_4) ^ single(2.0); t_7 = t_4 ^ single(2.0); tmp_2 = single(0.0); if (dY_46_u <= single(2500000.0)) tmp_3 = single(0.0); if (t_7 >= (t_1 ^ single(2.0))) tmp_3 = dX_46_v * t_5; else tmp_3 = dY_46_v * t_5; end tmp_2 = tmp_3; elseif (t_7 >= (t_0 ^ single(2.0))) tmp_2 = t_4 / sqrt(max(t_6, (hypot(t_1, t_0) ^ single(2.0)))); else tmp_2 = t_1 / sqrt(max(t_6, t_2)); end tmp_4 = tmp_2; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloor w\right\rfloor \cdot dY.u\\
t_1 := \left\lfloor h\right\rfloor \cdot dY.v\\
t_2 := {\left(\mathsf{hypot}\left(t\_0, t\_1\right)\right)}^{2}\\
t_3 := \left\lfloor w\right\rfloor \cdot dX.u\\
t_4 := \left\lfloor h\right\rfloor \cdot dX.v\\
t_5 := \frac{\left\lfloor h\right\rfloor }{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(t\_4, t\_3\right)\right)}^{2}, t\_2\right)}}\\
t_6 := {\left(\mathsf{hypot}\left(t\_3, t\_4\right)\right)}^{2}\\
t_7 := {t\_4}^{2}\\
\mathbf{if}\;dY.u \leq 2500000:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;t\_7 \geq {t\_1}^{2}:\\
\;\;\;\;dX.v \cdot t\_5\\
\mathbf{else}:\\
\;\;\;\;dY.v \cdot t\_5\\
\end{array}\\
\mathbf{elif}\;t\_7 \geq {t\_0}^{2}:\\
\;\;\;\;\frac{t\_4}{\sqrt{\mathsf{max}\left(t\_6, {\left(\mathsf{hypot}\left(t\_1, t\_0\right)\right)}^{2}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{\sqrt{\mathsf{max}\left(t\_6, t\_2\right)}}\\
\end{array}
\end{array}
if dY.u < 2.5e6Initial program 78.7%
Simplified78.9%
Taylor expanded in w around 0 78.6%
Simplified78.5%
Taylor expanded in dX.u around 0 70.5%
*-commutative70.5%
unpow270.5%
unpow270.5%
swap-sqr70.5%
unpow270.5%
*-commutative70.5%
Simplified70.5%
Taylor expanded in dY.v around inf 66.6%
*-commutative71.7%
unpow271.7%
unpow271.7%
swap-sqr71.7%
unpow271.7%
Simplified66.6%
Taylor expanded in dX.v around 0 66.7%
Simplified66.7%
if 2.5e6 < dY.u Initial program 59.4%
Applied egg-rr59.5%
associate-*l/59.5%
*-un-lft-identity59.5%
Applied egg-rr59.5%
Taylor expanded in dY.u around inf 57.1%
*-commutative57.1%
unpow257.1%
unpow257.1%
swap-sqr57.1%
unpow257.1%
Simplified57.1%
Taylor expanded in dX.u around 0 54.7%
*-commutative54.7%
unpow254.7%
unpow254.7%
swap-sqr54.7%
unpow254.7%
*-commutative54.7%
Simplified54.7%
Final simplification64.9%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* (floor w) dY.u))
(t_1 (* (floor h) dY.v))
(t_2 (pow (hypot t_0 t_1) 2.0))
(t_3 (* (floor w) dX.u))
(t_4 (* (floor h) dX.v))
(t_5 (/ (floor h) (sqrt (fmax (pow (hypot t_4 t_3) 2.0) t_2))))
(t_6 (pow (hypot t_3 t_4) 2.0)))
(if (<= dY.u 40000000.0)
(if (>= (pow t_4 2.0) (pow t_1 2.0)) (* dX.v t_5) (* dY.v t_5))
(if (>= (pow t_3 2.0) (pow t_0 2.0))
(/ t_4 (sqrt (fmax t_6 (pow (hypot t_1 t_0) 2.0))))
(/ t_1 (sqrt (fmax t_6 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(h) * dY_46_v;
float t_2 = powf(hypotf(t_0, t_1), 2.0f);
float t_3 = floorf(w) * dX_46_u;
float t_4 = floorf(h) * dX_46_v;
float t_5 = floorf(h) / sqrtf(fmaxf(powf(hypotf(t_4, t_3), 2.0f), t_2));
float t_6 = powf(hypotf(t_3, t_4), 2.0f);
float tmp_1;
if (dY_46_u <= 40000000.0f) {
float tmp_2;
if (powf(t_4, 2.0f) >= powf(t_1, 2.0f)) {
tmp_2 = dX_46_v * t_5;
} else {
tmp_2 = dY_46_v * t_5;
}
tmp_1 = tmp_2;
} else if (powf(t_3, 2.0f) >= powf(t_0, 2.0f)) {
tmp_1 = t_4 / sqrtf(fmaxf(t_6, powf(hypotf(t_1, t_0), 2.0f)));
} else {
tmp_1 = t_1 / sqrtf(fmaxf(t_6, t_2));
}
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 = Float32(floor(h) * dY_46_v) t_2 = hypot(t_0, t_1) ^ Float32(2.0) t_3 = Float32(floor(w) * dX_46_u) t_4 = Float32(floor(h) * dX_46_v) t_5 = Float32(floor(h) / sqrt((((hypot(t_4, t_3) ^ Float32(2.0)) != (hypot(t_4, t_3) ^ Float32(2.0))) ? t_2 : ((t_2 != t_2) ? (hypot(t_4, t_3) ^ Float32(2.0)) : max((hypot(t_4, t_3) ^ Float32(2.0)), t_2))))) t_6 = hypot(t_3, t_4) ^ Float32(2.0) tmp_1 = Float32(0.0) if (dY_46_u <= Float32(40000000.0)) tmp_2 = Float32(0.0) if ((t_4 ^ Float32(2.0)) >= (t_1 ^ Float32(2.0))) tmp_2 = Float32(dX_46_v * t_5); else tmp_2 = Float32(dY_46_v * t_5); end tmp_1 = tmp_2; elseif ((t_3 ^ Float32(2.0)) >= (t_0 ^ Float32(2.0))) tmp_1 = Float32(t_4 / sqrt(((t_6 != t_6) ? (hypot(t_1, t_0) ^ Float32(2.0)) : (((hypot(t_1, t_0) ^ Float32(2.0)) != (hypot(t_1, t_0) ^ Float32(2.0))) ? t_6 : max(t_6, (hypot(t_1, t_0) ^ Float32(2.0))))))); else tmp_1 = Float32(t_1 / sqrt(((t_6 != t_6) ? t_2 : ((t_2 != t_2) ? t_6 : max(t_6, t_2))))); 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 = floor(h) * dY_46_v; t_2 = hypot(t_0, t_1) ^ single(2.0); t_3 = floor(w) * dX_46_u; t_4 = floor(h) * dX_46_v; t_5 = floor(h) / sqrt(max((hypot(t_4, t_3) ^ single(2.0)), t_2)); t_6 = hypot(t_3, t_4) ^ single(2.0); tmp_2 = single(0.0); if (dY_46_u <= single(40000000.0)) tmp_3 = single(0.0); if ((t_4 ^ single(2.0)) >= (t_1 ^ single(2.0))) tmp_3 = dX_46_v * t_5; else tmp_3 = dY_46_v * t_5; end tmp_2 = tmp_3; elseif ((t_3 ^ single(2.0)) >= (t_0 ^ single(2.0))) tmp_2 = t_4 / sqrt(max(t_6, (hypot(t_1, t_0) ^ single(2.0)))); else tmp_2 = t_1 / sqrt(max(t_6, t_2)); end tmp_4 = tmp_2; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloor w\right\rfloor \cdot dY.u\\
t_1 := \left\lfloor h\right\rfloor \cdot dY.v\\
t_2 := {\left(\mathsf{hypot}\left(t\_0, t\_1\right)\right)}^{2}\\
t_3 := \left\lfloor w\right\rfloor \cdot dX.u\\
t_4 := \left\lfloor h\right\rfloor \cdot dX.v\\
t_5 := \frac{\left\lfloor h\right\rfloor }{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(t\_4, t\_3\right)\right)}^{2}, t\_2\right)}}\\
t_6 := {\left(\mathsf{hypot}\left(t\_3, t\_4\right)\right)}^{2}\\
\mathbf{if}\;dY.u \leq 40000000:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;{t\_4}^{2} \geq {t\_1}^{2}:\\
\;\;\;\;dX.v \cdot t\_5\\
\mathbf{else}:\\
\;\;\;\;dY.v \cdot t\_5\\
\end{array}\\
\mathbf{elif}\;{t\_3}^{2} \geq {t\_0}^{2}:\\
\;\;\;\;\frac{t\_4}{\sqrt{\mathsf{max}\left(t\_6, {\left(\mathsf{hypot}\left(t\_1, t\_0\right)\right)}^{2}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{\sqrt{\mathsf{max}\left(t\_6, t\_2\right)}}\\
\end{array}
\end{array}
if dY.u < 4e7Initial program 78.3%
Simplified78.4%
Taylor expanded in w around 0 78.1%
Simplified78.0%
Taylor expanded in dX.u around 0 70.2%
*-commutative70.2%
unpow270.2%
unpow270.2%
swap-sqr70.2%
unpow270.2%
*-commutative70.2%
Simplified70.2%
Taylor expanded in dY.v around inf 66.3%
*-commutative71.4%
unpow271.4%
unpow271.4%
swap-sqr71.4%
unpow271.4%
Simplified66.3%
Taylor expanded in dX.v around 0 66.5%
Simplified66.5%
if 4e7 < dY.u Initial program 60.1%
Applied egg-rr60.1%
associate-*l/60.1%
*-un-lft-identity60.1%
Applied egg-rr60.1%
Taylor expanded in dY.u around inf 57.4%
*-commutative57.4%
unpow257.4%
unpow257.4%
swap-sqr57.4%
unpow257.4%
Simplified57.4%
Taylor expanded in dX.u around inf 54.6%
*-commutative54.6%
unpow254.6%
unpow254.6%
swap-sqr54.6%
unpow254.6%
*-commutative54.6%
Simplified54.6%
Final simplification64.9%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* (floor w) dY.u))
(t_1 (* (floor h) dX.v))
(t_2 (* (floor w) dX.u))
(t_3 (pow (hypot t_2 t_1) 2.0))
(t_4 (* (floor h) dY.v)))
(if (>= (pow t_2 2.0) (pow t_0 2.0))
(/ t_1 (sqrt (fmax t_3 (pow (hypot t_4 t_0) 2.0))))
(/ t_4 (sqrt (fmax t_3 (pow (hypot t_0 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(w) * dY_46_u;
float t_1 = floorf(h) * dX_46_v;
float t_2 = floorf(w) * dX_46_u;
float t_3 = powf(hypotf(t_2, t_1), 2.0f);
float t_4 = floorf(h) * dY_46_v;
float tmp;
if (powf(t_2, 2.0f) >= powf(t_0, 2.0f)) {
tmp = t_1 / sqrtf(fmaxf(t_3, powf(hypotf(t_4, t_0), 2.0f)));
} else {
tmp = t_4 / sqrtf(fmaxf(t_3, powf(hypotf(t_0, 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(w) * dY_46_u) t_1 = Float32(floor(h) * dX_46_v) t_2 = Float32(floor(w) * dX_46_u) t_3 = hypot(t_2, t_1) ^ Float32(2.0) t_4 = Float32(floor(h) * dY_46_v) tmp = Float32(0.0) if ((t_2 ^ Float32(2.0)) >= (t_0 ^ Float32(2.0))) tmp = Float32(t_1 / sqrt(((t_3 != t_3) ? (hypot(t_4, t_0) ^ Float32(2.0)) : (((hypot(t_4, t_0) ^ Float32(2.0)) != (hypot(t_4, t_0) ^ Float32(2.0))) ? t_3 : max(t_3, (hypot(t_4, t_0) ^ Float32(2.0))))))); else tmp = Float32(t_4 / sqrt(((t_3 != t_3) ? (hypot(t_0, t_4) ^ Float32(2.0)) : (((hypot(t_0, t_4) ^ Float32(2.0)) != (hypot(t_0, t_4) ^ Float32(2.0))) ? t_3 : max(t_3, (hypot(t_0, 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(w) * dY_46_u; t_1 = floor(h) * dX_46_v; t_2 = floor(w) * dX_46_u; t_3 = hypot(t_2, t_1) ^ single(2.0); t_4 = floor(h) * dY_46_v; tmp = single(0.0); if ((t_2 ^ single(2.0)) >= (t_0 ^ single(2.0))) tmp = t_1 / sqrt(max(t_3, (hypot(t_4, t_0) ^ single(2.0)))); else tmp = t_4 / sqrt(max(t_3, (hypot(t_0, t_4) ^ single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloor w\right\rfloor \cdot dY.u\\
t_1 := \left\lfloor h\right\rfloor \cdot dX.v\\
t_2 := \left\lfloor w\right\rfloor \cdot dX.u\\
t_3 := {\left(\mathsf{hypot}\left(t\_2, t\_1\right)\right)}^{2}\\
t_4 := \left\lfloor h\right\rfloor \cdot dY.v\\
\mathbf{if}\;{t\_2}^{2} \geq {t\_0}^{2}:\\
\;\;\;\;\frac{t\_1}{\sqrt{\mathsf{max}\left(t\_3, {\left(\mathsf{hypot}\left(t\_4, t\_0\right)\right)}^{2}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_4}{\sqrt{\mathsf{max}\left(t\_3, {\left(\mathsf{hypot}\left(t\_0, t\_4\right)\right)}^{2}\right)}}\\
\end{array}
\end{array}
Initial program 75.8%
Applied egg-rr76.0%
associate-*l/76.2%
*-un-lft-identity76.2%
Applied egg-rr76.2%
Taylor expanded in dY.u around inf 64.8%
*-commutative64.8%
unpow264.8%
unpow264.8%
swap-sqr64.8%
unpow264.8%
Simplified64.8%
Taylor expanded in dX.u around inf 55.4%
*-commutative55.4%
unpow255.4%
unpow255.4%
swap-sqr55.4%
unpow255.4%
*-commutative55.4%
Simplified55.4%
Final simplification55.4%
herbie shell --seed 2024163
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:name "Anisotropic x16 LOD (line direction, v)"
: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 h) dX.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 h) dY.v))))