
(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 11 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 w) dY.u))
(t_1 (* (floor h) dY.v))
(t_2 (pow (hypot t_0 t_1) 2.0))
(t_3 (* dX.u (floor w)))
(t_4 (pow (hypot t_3 (* dX.v (floor h))) 2.0)))
(if (>= t_4 t_2)
(/ t_3 (sqrt (fmax t_4 t_2)))
(*
dY.u
(/
(floor w)
(sqrt (fmax t_4 (fma (* (floor w) t_0) dY.u (pow t_1 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) * dY_46_v;
float t_2 = powf(hypotf(t_0, t_1), 2.0f);
float t_3 = dX_46_u * floorf(w);
float t_4 = powf(hypotf(t_3, (dX_46_v * floorf(h))), 2.0f);
float tmp;
if (t_4 >= t_2) {
tmp = t_3 / sqrtf(fmaxf(t_4, t_2));
} else {
tmp = dY_46_u * (floorf(w) / sqrtf(fmaxf(t_4, fmaf((floorf(w) * t_0), dY_46_u, powf(t_1, 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) * dY_46_v) t_2 = hypot(t_0, t_1) ^ Float32(2.0) t_3 = Float32(dX_46_u * floor(w)) t_4 = hypot(t_3, Float32(dX_46_v * floor(h))) ^ Float32(2.0) tmp = Float32(0.0) if (t_4 >= t_2) tmp = Float32(t_3 / sqrt(((t_4 != t_4) ? t_2 : ((t_2 != t_2) ? t_4 : max(t_4, t_2))))); else tmp = Float32(dY_46_u * Float32(floor(w) / sqrt(((t_4 != t_4) ? fma(Float32(floor(w) * t_0), dY_46_u, (t_1 ^ Float32(2.0))) : ((fma(Float32(floor(w) * t_0), dY_46_u, (t_1 ^ Float32(2.0))) != fma(Float32(floor(w) * t_0), dY_46_u, (t_1 ^ Float32(2.0)))) ? t_4 : max(t_4, fma(Float32(floor(w) * t_0), dY_46_u, (t_1 ^ Float32(2.0))))))))); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloorw\right\rfloor \cdot dY.u\\
t_1 := \left\lfloorh\right\rfloor \cdot dY.v\\
t_2 := {\left(\mathsf{hypot}\left(t\_0, t\_1\right)\right)}^{2}\\
t_3 := dX.u \cdot \left\lfloorw\right\rfloor\\
t_4 := {\left(\mathsf{hypot}\left(t\_3, dX.v \cdot \left\lfloorh\right\rfloor\right)\right)}^{2}\\
\mathbf{if}\;t\_4 \geq t\_2:\\
\;\;\;\;\frac{t\_3}{\sqrt{\mathsf{max}\left(t\_4, t\_2\right)}}\\
\mathbf{else}:\\
\;\;\;\;dY.u \cdot \frac{\left\lfloorw\right\rfloor}{\sqrt{\mathsf{max}\left(t\_4, \mathsf{fma}\left(\left\lfloorw\right\rfloor \cdot t\_0, dY.u, {t\_1}^{2}\right)\right)}}\\
\end{array}
\end{array}
Initial program 77.6%
Simplified77.7%
pow277.7%
Applied egg-rr77.7%
Taylor expanded in w around 0 77.5%
Simplified77.7%
unpow277.7%
hypot-undefine77.7%
hypot-undefine77.7%
add-sqr-sqrt77.7%
associate-*r*77.7%
fma-define77.8%
pow277.8%
Applied egg-rr77.8%
Final simplification77.8%
(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 (* dX.u (floor w)))
(t_2 (pow (hypot t_1 (* dX.v (floor h))) 2.0))
(t_3 (sqrt (fmax t_2 t_0))))
(if (>= t_2 t_0) (/ t_1 t_3) (* dY.u (/ (floor w) 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(w) * dY_46_u), (floorf(h) * dY_46_v)), 2.0f);
float t_1 = dX_46_u * floorf(w);
float t_2 = powf(hypotf(t_1, (dX_46_v * floorf(h))), 2.0f);
float t_3 = sqrtf(fmaxf(t_2, t_0));
float tmp;
if (t_2 >= t_0) {
tmp = t_1 / t_3;
} else {
tmp = dY_46_u * (floorf(w) / t_3);
}
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 = Float32(dX_46_u * floor(w)) t_2 = hypot(t_1, Float32(dX_46_v * floor(h))) ^ Float32(2.0) t_3 = sqrt(((t_2 != t_2) ? t_0 : ((t_0 != t_0) ? t_2 : max(t_2, t_0)))) tmp = Float32(0.0) if (t_2 >= t_0) tmp = Float32(t_1 / t_3); else tmp = Float32(dY_46_u * Float32(floor(w) / t_3)); 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 = dX_46_u * floor(w); t_2 = hypot(t_1, (dX_46_v * floor(h))) ^ single(2.0); t_3 = sqrt(max(t_2, t_0)); tmp = single(0.0); if (t_2 >= t_0) tmp = t_1 / t_3; else tmp = dY_46_u * (floor(w) / t_3); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dY.u, \left\lfloorh\right\rfloor \cdot dY.v\right)\right)}^{2}\\
t_1 := dX.u \cdot \left\lfloorw\right\rfloor\\
t_2 := {\left(\mathsf{hypot}\left(t\_1, dX.v \cdot \left\lfloorh\right\rfloor\right)\right)}^{2}\\
t_3 := \sqrt{\mathsf{max}\left(t\_2, t\_0\right)}\\
\mathbf{if}\;t\_2 \geq t\_0:\\
\;\;\;\;\frac{t\_1}{t\_3}\\
\mathbf{else}:\\
\;\;\;\;dY.u \cdot \frac{\left\lfloorw\right\rfloor}{t\_3}\\
\end{array}
\end{array}
Initial program 77.6%
Simplified77.7%
pow277.7%
Applied egg-rr77.7%
Taylor expanded in w around 0 77.5%
Simplified77.7%
(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 (* dX.u (floor w)) (* dX.v (floor h))) 2.0))
(t_2 (/ (floor w) (sqrt (fmax t_1 t_0)))))
(if (>= t_1 t_0) (* dX.u t_2) (* 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 = powf(hypotf((floorf(w) * dY_46_u), (floorf(h) * dY_46_v)), 2.0f);
float t_1 = powf(hypotf((dX_46_u * floorf(w)), (dX_46_v * floorf(h))), 2.0f);
float t_2 = floorf(w) / sqrtf(fmaxf(t_1, t_0));
float tmp;
if (t_1 >= t_0) {
tmp = dX_46_u * t_2;
} else {
tmp = dY_46_u * 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(w) * dY_46_u), Float32(floor(h) * dY_46_v)) ^ Float32(2.0) t_1 = hypot(Float32(dX_46_u * floor(w)), Float32(dX_46_v * floor(h))) ^ Float32(2.0) t_2 = Float32(floor(w) / 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_u * t_2); else tmp = Float32(dY_46_u * 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(w) * dY_46_u), (floor(h) * dY_46_v)) ^ single(2.0); t_1 = hypot((dX_46_u * floor(w)), (dX_46_v * floor(h))) ^ single(2.0); t_2 = floor(w) / sqrt(max(t_1, t_0)); tmp = single(0.0); if (t_1 >= t_0) tmp = dX_46_u * t_2; else tmp = dY_46_u * t_2; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{hypot}\left(\left\lfloorw\right\rfloor \cdot dY.u, \left\lfloorh\right\rfloor \cdot dY.v\right)\right)}^{2}\\
t_1 := {\left(\mathsf{hypot}\left(dX.u \cdot \left\lfloorw\right\rfloor, dX.v \cdot \left\lfloorh\right\rfloor\right)\right)}^{2}\\
t_2 := \frac{\left\lfloorw\right\rfloor}{\sqrt{\mathsf{max}\left(t\_1, t\_0\right)}}\\
\mathbf{if}\;t\_1 \geq t\_0:\\
\;\;\;\;dX.u \cdot t\_2\\
\mathbf{else}:\\
\;\;\;\;dY.u \cdot t\_2\\
\end{array}
\end{array}
Initial program 77.6%
Simplified77.7%
pow277.7%
Applied egg-rr77.7%
Taylor expanded in w around 0 77.5%
Simplified77.7%
Taylor expanded in dX.u around 0 77.5%
Simplified77.6%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* dX.v (floor h)))
(t_1 (* (floor w) dY.u))
(t_2 (* (floor h) dY.v))
(t_3 (pow (hypot t_1 t_2) 2.0))
(t_4 (* dX.u (floor w)))
(t_5 (pow (hypot t_4 t_0) 2.0))
(t_6 (sqrt (fmax t_5 t_3)))
(t_7 (/ t_4 t_6)))
(if (<= dX.v 5000.0)
(if (>= (pow t_4 2.0) t_3) t_7 (/ t_1 t_6))
(if (>= (pow t_0 2.0) t_3)
t_7
(*
dY.u
(/
(floor w)
(sqrt (fmax t_5 (fma (* (floor w) t_1) dY.u (pow 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 = dX_46_v * floorf(h);
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 = dX_46_u * floorf(w);
float t_5 = powf(hypotf(t_4, t_0), 2.0f);
float t_6 = sqrtf(fmaxf(t_5, t_3));
float t_7 = t_4 / t_6;
float tmp_1;
if (dX_46_v <= 5000.0f) {
float tmp_2;
if (powf(t_4, 2.0f) >= t_3) {
tmp_2 = t_7;
} else {
tmp_2 = t_1 / t_6;
}
tmp_1 = tmp_2;
} else if (powf(t_0, 2.0f) >= t_3) {
tmp_1 = t_7;
} else {
tmp_1 = dY_46_u * (floorf(w) / sqrtf(fmaxf(t_5, fmaf((floorf(w) * t_1), dY_46_u, powf(t_2, 2.0f)))));
}
return tmp_1;
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = Float32(dX_46_v * floor(h)) t_1 = 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(dX_46_u * floor(w)) t_5 = hypot(t_4, t_0) ^ Float32(2.0) t_6 = sqrt(((t_5 != t_5) ? t_3 : ((t_3 != t_3) ? t_5 : max(t_5, t_3)))) t_7 = Float32(t_4 / t_6) tmp_1 = Float32(0.0) if (dX_46_v <= Float32(5000.0)) tmp_2 = Float32(0.0) if ((t_4 ^ Float32(2.0)) >= t_3) tmp_2 = t_7; else tmp_2 = Float32(t_1 / t_6); end tmp_1 = tmp_2; elseif ((t_0 ^ Float32(2.0)) >= t_3) tmp_1 = t_7; else tmp_1 = Float32(dY_46_u * Float32(floor(w) / sqrt(((t_5 != t_5) ? fma(Float32(floor(w) * t_1), dY_46_u, (t_2 ^ Float32(2.0))) : ((fma(Float32(floor(w) * t_1), dY_46_u, (t_2 ^ Float32(2.0))) != fma(Float32(floor(w) * t_1), dY_46_u, (t_2 ^ Float32(2.0)))) ? t_5 : max(t_5, fma(Float32(floor(w) * t_1), dY_46_u, (t_2 ^ Float32(2.0))))))))); end return tmp_1 end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := dX.v \cdot \left\lfloorh\right\rfloor\\
t_1 := \left\lfloorw\right\rfloor \cdot dY.u\\
t_2 := \left\lfloorh\right\rfloor \cdot dY.v\\
t_3 := {\left(\mathsf{hypot}\left(t\_1, t\_2\right)\right)}^{2}\\
t_4 := dX.u \cdot \left\lfloorw\right\rfloor\\
t_5 := {\left(\mathsf{hypot}\left(t\_4, t\_0\right)\right)}^{2}\\
t_6 := \sqrt{\mathsf{max}\left(t\_5, t\_3\right)}\\
t_7 := \frac{t\_4}{t\_6}\\
\mathbf{if}\;dX.v \leq 5000:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;{t\_4}^{2} \geq t\_3:\\
\;\;\;\;t\_7\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{t\_6}\\
\end{array}\\
\mathbf{elif}\;{t\_0}^{2} \geq t\_3:\\
\;\;\;\;t\_7\\
\mathbf{else}:\\
\;\;\;\;dY.u \cdot \frac{\left\lfloorw\right\rfloor}{\sqrt{\mathsf{max}\left(t\_5, \mathsf{fma}\left(\left\lfloorw\right\rfloor \cdot t\_1, dY.u, {t\_2}^{2}\right)\right)}}\\
\end{array}
\end{array}
if dX.v < 5e3Initial program 79.9%
Simplified80.0%
Taylor expanded in w around 0 79.9%
Simplified79.7%
Taylor expanded in dX.u around inf 73.8%
unpow273.8%
unpow273.8%
swap-sqr73.8%
unpow273.8%
Simplified73.8%
Taylor expanded in dX.u around 0 74.0%
Simplified74.3%
if 5e3 < dX.v Initial program 67.6%
Simplified67.8%
pow267.8%
Applied egg-rr67.8%
Taylor expanded in w around 0 67.5%
Simplified67.8%
unpow267.8%
hypot-undefine67.8%
hypot-undefine67.8%
add-sqr-sqrt67.8%
associate-*r*67.8%
fma-define67.8%
pow267.8%
Applied egg-rr67.8%
Taylor expanded in dX.u around 0 65.9%
Final simplification72.7%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* (floor h) dY.v))
(t_1 (* dX.u (floor w)))
(t_2 (* (floor w) dY.u))
(t_3 (pow (hypot t_1 (* dX.v (floor h))) 2.0))
(t_4 (fmax t_3 (pow (hypot t_2 t_0) 2.0)))
(t_5 (sqrt t_4))
(t_6 (sqrt (/ 1.0 t_4))))
(if (<= dY.v 0.004999999888241291)
(if (>= t_3 (pow t_2 2.0)) (* dX.u (* (floor w) t_6)) (* t_2 t_6))
(if (>= t_3 (pow t_0 2.0)) (/ t_1 t_5) (* dY.u (/ (floor w) 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) * dY_46_v;
float t_1 = dX_46_u * floorf(w);
float t_2 = floorf(w) * dY_46_u;
float t_3 = powf(hypotf(t_1, (dX_46_v * floorf(h))), 2.0f);
float t_4 = fmaxf(t_3, powf(hypotf(t_2, t_0), 2.0f));
float t_5 = sqrtf(t_4);
float t_6 = sqrtf((1.0f / t_4));
float tmp_1;
if (dY_46_v <= 0.004999999888241291f) {
float tmp_2;
if (t_3 >= powf(t_2, 2.0f)) {
tmp_2 = dX_46_u * (floorf(w) * t_6);
} else {
tmp_2 = t_2 * t_6;
}
tmp_1 = tmp_2;
} else if (t_3 >= powf(t_0, 2.0f)) {
tmp_1 = t_1 / t_5;
} else {
tmp_1 = dY_46_u * (floorf(w) / 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(h) * dY_46_v) t_1 = Float32(dX_46_u * floor(w)) t_2 = Float32(floor(w) * dY_46_u) t_3 = hypot(t_1, Float32(dX_46_v * floor(h))) ^ Float32(2.0) t_4 = (t_3 != t_3) ? (hypot(t_2, t_0) ^ Float32(2.0)) : (((hypot(t_2, t_0) ^ Float32(2.0)) != (hypot(t_2, t_0) ^ Float32(2.0))) ? t_3 : max(t_3, (hypot(t_2, t_0) ^ Float32(2.0)))) t_5 = sqrt(t_4) t_6 = sqrt(Float32(Float32(1.0) / t_4)) tmp_1 = Float32(0.0) if (dY_46_v <= Float32(0.004999999888241291)) tmp_2 = Float32(0.0) if (t_3 >= (t_2 ^ Float32(2.0))) tmp_2 = Float32(dX_46_u * Float32(floor(w) * t_6)); else tmp_2 = Float32(t_2 * t_6); end tmp_1 = tmp_2; elseif (t_3 >= (t_0 ^ Float32(2.0))) tmp_1 = Float32(t_1 / t_5); else tmp_1 = Float32(dY_46_u * Float32(floor(w) / 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(h) * dY_46_v; t_1 = dX_46_u * floor(w); t_2 = floor(w) * dY_46_u; t_3 = hypot(t_1, (dX_46_v * floor(h))) ^ single(2.0); t_4 = max(t_3, (hypot(t_2, t_0) ^ single(2.0))); t_5 = sqrt(t_4); t_6 = sqrt((single(1.0) / t_4)); tmp_2 = single(0.0); if (dY_46_v <= single(0.004999999888241291)) tmp_3 = single(0.0); if (t_3 >= (t_2 ^ single(2.0))) tmp_3 = dX_46_u * (floor(w) * t_6); else tmp_3 = t_2 * t_6; end tmp_2 = tmp_3; elseif (t_3 >= (t_0 ^ single(2.0))) tmp_2 = t_1 / t_5; else tmp_2 = dY_46_u * (floor(w) / t_5); end tmp_4 = tmp_2; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloorh\right\rfloor \cdot dY.v\\
t_1 := dX.u \cdot \left\lfloorw\right\rfloor\\
t_2 := \left\lfloorw\right\rfloor \cdot dY.u\\
t_3 := {\left(\mathsf{hypot}\left(t\_1, dX.v \cdot \left\lfloorh\right\rfloor\right)\right)}^{2}\\
t_4 := \mathsf{max}\left(t\_3, {\left(\mathsf{hypot}\left(t\_2, t\_0\right)\right)}^{2}\right)\\
t_5 := \sqrt{t\_4}\\
t_6 := \sqrt{\frac{1}{t\_4}}\\
\mathbf{if}\;dY.v \leq 0.004999999888241291:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;t\_3 \geq {t\_2}^{2}:\\
\;\;\;\;dX.u \cdot \left(\left\lfloorw\right\rfloor \cdot t\_6\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2 \cdot t\_6\\
\end{array}\\
\mathbf{elif}\;t\_3 \geq {t\_0}^{2}:\\
\;\;\;\;\frac{t\_1}{t\_5}\\
\mathbf{else}:\\
\;\;\;\;dY.u \cdot \frac{\left\lfloorw\right\rfloor}{t\_5}\\
\end{array}
\end{array}
if dY.v < 0.00499999989Initial program 76.0%
Simplified76.1%
Taylor expanded in w around 0 75.8%
Simplified75.8%
Taylor expanded in dY.u around inf 66.2%
*-commutative66.2%
unpow266.2%
unpow266.2%
swap-sqr66.2%
unpow266.2%
Simplified66.2%
if 0.00499999989 < dY.v Initial program 81.7%
Simplified81.6%
pow281.6%
Applied egg-rr81.6%
Taylor expanded in w around 0 81.8%
Simplified81.9%
Taylor expanded in dY.u around 0 78.2%
*-commutative78.2%
unpow278.2%
unpow278.2%
swap-sqr78.2%
unpow278.2%
Simplified78.2%
Final simplification69.6%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* dX.v (floor h)))
(t_1 (* (floor w) dY.u))
(t_2 (pow (hypot t_1 (* (floor h) dY.v)) 2.0))
(t_3 (* dX.u (floor w)))
(t_4 (fmax (pow (hypot t_3 t_0) 2.0) t_2))
(t_5 (sqrt (/ 1.0 t_4)))
(t_6 (sqrt t_4)))
(if (<= dX.v 5000.0)
(if (>= (pow t_3 2.0) t_2) (/ t_3 t_6) (/ t_1 t_6))
(if (>= (pow t_0 2.0) t_2)
(* dX.u (* (floor w) 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 = dX_46_v * floorf(h);
float t_1 = floorf(w) * dY_46_u;
float t_2 = powf(hypotf(t_1, (floorf(h) * dY_46_v)), 2.0f);
float t_3 = dX_46_u * floorf(w);
float t_4 = fmaxf(powf(hypotf(t_3, t_0), 2.0f), t_2);
float t_5 = sqrtf((1.0f / t_4));
float t_6 = sqrtf(t_4);
float tmp_1;
if (dX_46_v <= 5000.0f) {
float tmp_2;
if (powf(t_3, 2.0f) >= t_2) {
tmp_2 = t_3 / t_6;
} else {
tmp_2 = t_1 / t_6;
}
tmp_1 = tmp_2;
} else if (powf(t_0, 2.0f) >= t_2) {
tmp_1 = dX_46_u * (floorf(w) * 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(dX_46_v * floor(h)) t_1 = Float32(floor(w) * dY_46_u) t_2 = hypot(t_1, Float32(floor(h) * dY_46_v)) ^ Float32(2.0) t_3 = Float32(dX_46_u * floor(w)) 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)) t_5 = sqrt(Float32(Float32(1.0) / t_4)) t_6 = sqrt(t_4) tmp_1 = Float32(0.0) if (dX_46_v <= Float32(5000.0)) tmp_2 = Float32(0.0) if ((t_3 ^ Float32(2.0)) >= t_2) tmp_2 = Float32(t_3 / t_6); else tmp_2 = Float32(t_1 / t_6); end tmp_1 = tmp_2; elseif ((t_0 ^ Float32(2.0)) >= t_2) tmp_1 = Float32(dX_46_u * Float32(floor(w) * 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 = dX_46_v * floor(h); t_1 = floor(w) * dY_46_u; t_2 = hypot(t_1, (floor(h) * dY_46_v)) ^ single(2.0); t_3 = dX_46_u * floor(w); t_4 = max((hypot(t_3, t_0) ^ single(2.0)), t_2); t_5 = sqrt((single(1.0) / t_4)); t_6 = sqrt(t_4); tmp_2 = single(0.0); if (dX_46_v <= single(5000.0)) tmp_3 = single(0.0); if ((t_3 ^ single(2.0)) >= t_2) tmp_3 = t_3 / t_6; else tmp_3 = t_1 / t_6; end tmp_2 = tmp_3; elseif ((t_0 ^ single(2.0)) >= t_2) tmp_2 = dX_46_u * (floor(w) * 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 := dX.v \cdot \left\lfloorh\right\rfloor\\
t_1 := \left\lfloorw\right\rfloor \cdot dY.u\\
t_2 := {\left(\mathsf{hypot}\left(t\_1, \left\lfloorh\right\rfloor \cdot dY.v\right)\right)}^{2}\\
t_3 := dX.u \cdot \left\lfloorw\right\rfloor\\
t_4 := \mathsf{max}\left({\left(\mathsf{hypot}\left(t\_3, t\_0\right)\right)}^{2}, t\_2\right)\\
t_5 := \sqrt{\frac{1}{t\_4}}\\
t_6 := \sqrt{t\_4}\\
\mathbf{if}\;dX.v \leq 5000:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;{t\_3}^{2} \geq t\_2:\\
\;\;\;\;\frac{t\_3}{t\_6}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{t\_6}\\
\end{array}\\
\mathbf{elif}\;{t\_0}^{2} \geq t\_2:\\
\;\;\;\;dX.u \cdot \left(\left\lfloorw\right\rfloor \cdot t\_5\right)\\
\mathbf{else}:\\
\;\;\;\;\left\lfloorw\right\rfloor \cdot \left(dY.u \cdot t\_5\right)\\
\end{array}
\end{array}
if dX.v < 5e3Initial program 79.9%
Simplified80.0%
Taylor expanded in w around 0 79.9%
Simplified79.7%
Taylor expanded in dX.u around inf 73.8%
unpow273.8%
unpow273.8%
swap-sqr73.8%
unpow273.8%
Simplified73.8%
Taylor expanded in dX.u around 0 74.0%
Simplified74.3%
if 5e3 < dX.v Initial program 67.6%
Simplified67.8%
Taylor expanded in w around 0 67.5%
Simplified67.3%
Taylor expanded in dX.u around 0 65.4%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* dX.v (floor h)))
(t_1 (* (floor w) dY.u))
(t_2 (pow (hypot t_1 (* (floor h) dY.v)) 2.0))
(t_3 (* dX.u (floor w)))
(t_4 (sqrt (fmax (pow (hypot t_3 t_0) 2.0) t_2))))
(if (<= dX.v 5000.0)
(if (>= (pow t_3 2.0) t_2) (/ t_3 t_4) (/ t_1 t_4))
(if (>= (pow t_0 2.0) t_2)
(/ t_3 (sqrt (fmax (pow (* dX.v (- (floor h))) 2.0) t_2)))
(* dY.u (/ (floor w) 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 = dX_46_v * floorf(h);
float t_1 = floorf(w) * dY_46_u;
float t_2 = powf(hypotf(t_1, (floorf(h) * dY_46_v)), 2.0f);
float t_3 = dX_46_u * floorf(w);
float t_4 = sqrtf(fmaxf(powf(hypotf(t_3, t_0), 2.0f), t_2));
float tmp_1;
if (dX_46_v <= 5000.0f) {
float tmp_2;
if (powf(t_3, 2.0f) >= t_2) {
tmp_2 = t_3 / t_4;
} else {
tmp_2 = t_1 / t_4;
}
tmp_1 = tmp_2;
} else if (powf(t_0, 2.0f) >= t_2) {
tmp_1 = t_3 / sqrtf(fmaxf(powf((dX_46_v * -floorf(h)), 2.0f), t_2));
} else {
tmp_1 = dY_46_u * (floorf(w) / t_4);
}
return tmp_1;
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = Float32(dX_46_v * floor(h)) t_1 = Float32(floor(w) * dY_46_u) t_2 = hypot(t_1, Float32(floor(h) * dY_46_v)) ^ Float32(2.0) t_3 = Float32(dX_46_u * floor(w)) t_4 = sqrt((((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_1 = Float32(0.0) if (dX_46_v <= Float32(5000.0)) tmp_2 = Float32(0.0) if ((t_3 ^ Float32(2.0)) >= t_2) tmp_2 = Float32(t_3 / t_4); else tmp_2 = Float32(t_1 / t_4); end tmp_1 = tmp_2; elseif ((t_0 ^ Float32(2.0)) >= t_2) tmp_1 = Float32(t_3 / sqrt((((Float32(dX_46_v * Float32(-floor(h))) ^ Float32(2.0)) != (Float32(dX_46_v * Float32(-floor(h))) ^ Float32(2.0))) ? t_2 : ((t_2 != t_2) ? (Float32(dX_46_v * Float32(-floor(h))) ^ Float32(2.0)) : max((Float32(dX_46_v * Float32(-floor(h))) ^ Float32(2.0)), t_2))))); else tmp_1 = Float32(dY_46_u * Float32(floor(w) / t_4)); 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 = dX_46_v * floor(h); t_1 = floor(w) * dY_46_u; t_2 = hypot(t_1, (floor(h) * dY_46_v)) ^ single(2.0); t_3 = dX_46_u * floor(w); t_4 = sqrt(max((hypot(t_3, t_0) ^ single(2.0)), t_2)); tmp_2 = single(0.0); if (dX_46_v <= single(5000.0)) tmp_3 = single(0.0); if ((t_3 ^ single(2.0)) >= t_2) tmp_3 = t_3 / t_4; else tmp_3 = t_1 / t_4; end tmp_2 = tmp_3; elseif ((t_0 ^ single(2.0)) >= t_2) tmp_2 = t_3 / sqrt(max(((dX_46_v * -floor(h)) ^ single(2.0)), t_2)); else tmp_2 = dY_46_u * (floor(w) / t_4); end tmp_4 = tmp_2; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := dX.v \cdot \left\lfloorh\right\rfloor\\
t_1 := \left\lfloorw\right\rfloor \cdot dY.u\\
t_2 := {\left(\mathsf{hypot}\left(t\_1, \left\lfloorh\right\rfloor \cdot dY.v\right)\right)}^{2}\\
t_3 := dX.u \cdot \left\lfloorw\right\rfloor\\
t_4 := \sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(t\_3, t\_0\right)\right)}^{2}, t\_2\right)}\\
\mathbf{if}\;dX.v \leq 5000:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;{t\_3}^{2} \geq t\_2:\\
\;\;\;\;\frac{t\_3}{t\_4}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{t\_4}\\
\end{array}\\
\mathbf{elif}\;{t\_0}^{2} \geq t\_2:\\
\;\;\;\;\frac{t\_3}{\sqrt{\mathsf{max}\left({\left(dX.v \cdot \left(-\left\lfloorh\right\rfloor\right)\right)}^{2}, t\_2\right)}}\\
\mathbf{else}:\\
\;\;\;\;dY.u \cdot \frac{\left\lfloorw\right\rfloor}{t\_4}\\
\end{array}
\end{array}
if dX.v < 5e3Initial program 79.9%
Simplified80.0%
Taylor expanded in w around 0 79.9%
Simplified79.7%
Taylor expanded in dX.u around inf 73.8%
unpow273.8%
unpow273.8%
swap-sqr73.8%
unpow273.8%
Simplified73.8%
Taylor expanded in dX.u around 0 74.0%
Simplified74.3%
if 5e3 < dX.v Initial program 67.6%
Simplified67.8%
pow267.8%
Applied egg-rr67.8%
Taylor expanded in w around 0 67.5%
Simplified67.8%
Taylor expanded in dX.v around -inf 62.2%
mul-1-neg62.2%
*-commutative62.2%
distribute-rgt-neg-in62.2%
Simplified62.2%
Taylor expanded in dX.u around 0 61.8%
Final simplification71.9%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* (floor w) dY.u))
(t_1 (* dX.u (floor w)))
(t_2 (pow (hypot t_0 (* (floor h) dY.v)) 2.0))
(t_3 (sqrt (fmax (pow (hypot t_1 (* dX.v (floor h))) 2.0) t_2))))
(if (>= (pow t_1 2.0) t_2) (/ t_1 t_3) (/ t_0 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(w) * dY_46_u;
float t_1 = dX_46_u * floorf(w);
float t_2 = powf(hypotf(t_0, (floorf(h) * dY_46_v)), 2.0f);
float t_3 = sqrtf(fmaxf(powf(hypotf(t_1, (dX_46_v * floorf(h))), 2.0f), t_2));
float tmp;
if (powf(t_1, 2.0f) >= t_2) {
tmp = t_1 / t_3;
} else {
tmp = t_0 / t_3;
}
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(dX_46_u * floor(w)) t_2 = hypot(t_0, Float32(floor(h) * dY_46_v)) ^ Float32(2.0) t_3 = sqrt((((hypot(t_1, Float32(dX_46_v * floor(h))) ^ Float32(2.0)) != (hypot(t_1, Float32(dX_46_v * floor(h))) ^ Float32(2.0))) ? t_2 : ((t_2 != t_2) ? (hypot(t_1, Float32(dX_46_v * floor(h))) ^ Float32(2.0)) : max((hypot(t_1, Float32(dX_46_v * floor(h))) ^ Float32(2.0)), t_2)))) tmp = Float32(0.0) if ((t_1 ^ Float32(2.0)) >= t_2) tmp = Float32(t_1 / t_3); else tmp = Float32(t_0 / t_3); 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 = dX_46_u * floor(w); t_2 = hypot(t_0, (floor(h) * dY_46_v)) ^ single(2.0); t_3 = sqrt(max((hypot(t_1, (dX_46_v * floor(h))) ^ single(2.0)), t_2)); tmp = single(0.0); if ((t_1 ^ single(2.0)) >= t_2) tmp = t_1 / t_3; else tmp = t_0 / t_3; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloorw\right\rfloor \cdot dY.u\\
t_1 := dX.u \cdot \left\lfloorw\right\rfloor\\
t_2 := {\left(\mathsf{hypot}\left(t\_0, \left\lfloorh\right\rfloor \cdot dY.v\right)\right)}^{2}\\
t_3 := \sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(t\_1, dX.v \cdot \left\lfloorh\right\rfloor\right)\right)}^{2}, t\_2\right)}\\
\mathbf{if}\;{t\_1}^{2} \geq t\_2:\\
\;\;\;\;\frac{t\_1}{t\_3}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{t\_3}\\
\end{array}
\end{array}
Initial program 77.6%
Simplified77.7%
Taylor expanded in w around 0 77.5%
Simplified77.4%
Taylor expanded in dX.u around inf 67.7%
unpow267.7%
unpow267.7%
swap-sqr67.7%
unpow267.7%
Simplified67.7%
Taylor expanded in dX.u around 0 67.8%
Simplified68.1%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* dX.u (floor w)))
(t_1 (pow (hypot (* (floor w) dY.u) (* (floor h) dY.v)) 2.0))
(t_2
(/
(floor w)
(sqrt (fmax (pow (hypot t_0 (* dX.v (floor h))) 2.0) t_1)))))
(if (>= (pow t_0 2.0) t_1) (* dX.u t_2) (* 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 = dX_46_u * floorf(w);
float t_1 = powf(hypotf((floorf(w) * dY_46_u), (floorf(h) * dY_46_v)), 2.0f);
float t_2 = floorf(w) / sqrtf(fmaxf(powf(hypotf(t_0, (dX_46_v * floorf(h))), 2.0f), t_1));
float tmp;
if (powf(t_0, 2.0f) >= t_1) {
tmp = dX_46_u * t_2;
} else {
tmp = dY_46_u * t_2;
}
return tmp;
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = Float32(dX_46_u * floor(w)) t_1 = hypot(Float32(floor(w) * dY_46_u), Float32(floor(h) * dY_46_v)) ^ Float32(2.0) t_2 = Float32(floor(w) / sqrt((((hypot(t_0, Float32(dX_46_v * floor(h))) ^ Float32(2.0)) != (hypot(t_0, Float32(dX_46_v * floor(h))) ^ Float32(2.0))) ? t_1 : ((t_1 != t_1) ? (hypot(t_0, Float32(dX_46_v * floor(h))) ^ Float32(2.0)) : max((hypot(t_0, Float32(dX_46_v * floor(h))) ^ Float32(2.0)), t_1))))) tmp = Float32(0.0) if ((t_0 ^ Float32(2.0)) >= t_1) tmp = Float32(dX_46_u * t_2); else tmp = Float32(dY_46_u * 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 = dX_46_u * floor(w); t_1 = hypot((floor(w) * dY_46_u), (floor(h) * dY_46_v)) ^ single(2.0); t_2 = floor(w) / sqrt(max((hypot(t_0, (dX_46_v * floor(h))) ^ single(2.0)), t_1)); tmp = single(0.0); if ((t_0 ^ single(2.0)) >= t_1) tmp = dX_46_u * t_2; else tmp = dY_46_u * t_2; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := dX.u \cdot \left\lfloorw\right\rfloor\\
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 := \frac{\left\lfloorw\right\rfloor}{\sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(t\_0, dX.v \cdot \left\lfloorh\right\rfloor\right)\right)}^{2}, t\_1\right)}}\\
\mathbf{if}\;{t\_0}^{2} \geq t\_1:\\
\;\;\;\;dX.u \cdot t\_2\\
\mathbf{else}:\\
\;\;\;\;dY.u \cdot t\_2\\
\end{array}
\end{array}
Initial program 77.6%
Simplified77.7%
Taylor expanded in w around 0 77.5%
Simplified77.4%
Taylor expanded in dX.u around inf 67.7%
unpow267.7%
unpow267.7%
swap-sqr67.7%
unpow267.7%
Simplified67.7%
Taylor expanded in dX.u around 0 67.8%
Simplified67.9%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* dX.u (floor w)))
(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 (* dX.v (floor h))) 2.0)
(pow (hypot t_2 t_3) 2.0)))
(t_5 (sqrt (/ 1.0 t_4)))
(t_6 (sqrt t_4)))
(if (<= dY.v 0.11500000208616257)
(if (>= t_1 (pow t_2 2.0))
(* dX.u (* (floor w) t_5))
(* (floor w) (* dY.u t_5)))
(if (>= t_1 (pow t_3 2.0)) (/ t_0 t_6) (/ 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 = dX_46_u * floorf(w);
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, (dX_46_v * floorf(h))), 2.0f), powf(hypotf(t_2, t_3), 2.0f));
float t_5 = sqrtf((1.0f / t_4));
float t_6 = sqrtf(t_4);
float tmp_1;
if (dY_46_v <= 0.11500000208616257f) {
float tmp_2;
if (t_1 >= powf(t_2, 2.0f)) {
tmp_2 = dX_46_u * (floorf(w) * t_5);
} else {
tmp_2 = floorf(w) * (dY_46_u * t_5);
}
tmp_1 = tmp_2;
} else if (t_1 >= powf(t_3, 2.0f)) {
tmp_1 = t_0 / t_6;
} 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(dX_46_u * floor(w)) 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(dX_46_v * floor(h))) ^ Float32(2.0)) != (hypot(t_0, Float32(dX_46_v * floor(h))) ^ 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(dX_46_v * floor(h))) ^ Float32(2.0)) : max((hypot(t_0, Float32(dX_46_v * floor(h))) ^ Float32(2.0)), (hypot(t_2, t_3) ^ Float32(2.0)))) t_5 = sqrt(Float32(Float32(1.0) / t_4)) t_6 = sqrt(t_4) tmp_1 = Float32(0.0) if (dY_46_v <= Float32(0.11500000208616257)) tmp_2 = Float32(0.0) if (t_1 >= (t_2 ^ Float32(2.0))) tmp_2 = Float32(dX_46_u * Float32(floor(w) * t_5)); else tmp_2 = Float32(floor(w) * Float32(dY_46_u * t_5)); end tmp_1 = tmp_2; elseif (t_1 >= (t_3 ^ Float32(2.0))) tmp_1 = Float32(t_0 / t_6); 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 = dX_46_u * floor(w); t_1 = t_0 ^ single(2.0); t_2 = floor(w) * dY_46_u; t_3 = floor(h) * dY_46_v; t_4 = max((hypot(t_0, (dX_46_v * floor(h))) ^ single(2.0)), (hypot(t_2, t_3) ^ single(2.0))); t_5 = sqrt((single(1.0) / t_4)); t_6 = sqrt(t_4); tmp_2 = single(0.0); if (dY_46_v <= single(0.11500000208616257)) tmp_3 = single(0.0); if (t_1 >= (t_2 ^ single(2.0))) tmp_3 = dX_46_u * (floor(w) * t_5); else tmp_3 = floor(w) * (dY_46_u * t_5); end tmp_2 = tmp_3; elseif (t_1 >= (t_3 ^ single(2.0))) tmp_2 = t_0 / t_6; else tmp_2 = t_2 / t_6; end tmp_4 = tmp_2; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := dX.u \cdot \left\lfloorw\right\rfloor\\
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, dX.v \cdot \left\lfloorh\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(t\_2, t\_3\right)\right)}^{2}\right)\\
t_5 := \sqrt{\frac{1}{t\_4}}\\
t_6 := \sqrt{t\_4}\\
\mathbf{if}\;dY.v \leq 0.11500000208616257:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;t\_1 \geq {t\_2}^{2}:\\
\;\;\;\;dX.u \cdot \left(\left\lfloorw\right\rfloor \cdot t\_5\right)\\
\mathbf{else}:\\
\;\;\;\;\left\lfloorw\right\rfloor \cdot \left(dY.u \cdot t\_5\right)\\
\end{array}\\
\mathbf{elif}\;t\_1 \geq {t\_3}^{2}:\\
\;\;\;\;\frac{t\_0}{t\_6}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_2}{t\_6}\\
\end{array}
\end{array}
if dY.v < 0.115000002Initial program 76.1%
Simplified76.2%
Taylor expanded in w around 0 76.0%
Simplified75.8%
Taylor expanded in dX.u around inf 64.5%
unpow264.5%
unpow264.5%
swap-sqr64.5%
unpow264.5%
Simplified64.5%
Taylor expanded in dY.u around inf 60.8%
*-commutative66.1%
unpow266.1%
unpow266.1%
swap-sqr66.1%
unpow266.1%
Simplified60.8%
if 0.115000002 < dY.v Initial program 81.7%
Simplified81.7%
Taylor expanded in w around 0 81.9%
Simplified81.6%
Taylor expanded in dX.u around inf 76.6%
unpow276.6%
unpow276.6%
swap-sqr76.6%
unpow276.6%
Simplified76.6%
Taylor expanded in dY.u around 0 75.2%
*-commutative78.0%
unpow278.0%
unpow278.0%
swap-sqr78.0%
unpow278.0%
Simplified75.2%
Taylor expanded in dX.u around 0 75.5%
Simplified75.6%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* (floor h) dY.v))
(t_1 (* dX.u (floor w)))
(t_2 (* (floor w) dY.u))
(t_3
(sqrt
(fmax
(pow (hypot t_1 (* dX.v (floor h))) 2.0)
(pow (hypot t_2 t_0) 2.0)))))
(if (>= (pow t_1 2.0) (pow t_0 2.0)) (/ t_1 t_3) (/ t_2 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) * dY_46_v;
float t_1 = dX_46_u * floorf(w);
float t_2 = floorf(w) * dY_46_u;
float t_3 = sqrtf(fmaxf(powf(hypotf(t_1, (dX_46_v * floorf(h))), 2.0f), powf(hypotf(t_2, t_0), 2.0f)));
float tmp;
if (powf(t_1, 2.0f) >= powf(t_0, 2.0f)) {
tmp = t_1 / t_3;
} else {
tmp = t_2 / t_3;
}
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(dX_46_u * floor(w)) t_2 = Float32(floor(w) * dY_46_u) t_3 = sqrt((((hypot(t_1, Float32(dX_46_v * floor(h))) ^ Float32(2.0)) != (hypot(t_1, Float32(dX_46_v * floor(h))) ^ Float32(2.0))) ? (hypot(t_2, t_0) ^ Float32(2.0)) : (((hypot(t_2, t_0) ^ Float32(2.0)) != (hypot(t_2, t_0) ^ Float32(2.0))) ? (hypot(t_1, Float32(dX_46_v * floor(h))) ^ Float32(2.0)) : max((hypot(t_1, Float32(dX_46_v * floor(h))) ^ Float32(2.0)), (hypot(t_2, t_0) ^ Float32(2.0)))))) tmp = Float32(0.0) if ((t_1 ^ Float32(2.0)) >= (t_0 ^ Float32(2.0))) tmp = Float32(t_1 / t_3); else tmp = Float32(t_2 / t_3); 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 = dX_46_u * floor(w); t_2 = floor(w) * dY_46_u; t_3 = sqrt(max((hypot(t_1, (dX_46_v * floor(h))) ^ single(2.0)), (hypot(t_2, t_0) ^ single(2.0)))); tmp = single(0.0); if ((t_1 ^ single(2.0)) >= (t_0 ^ single(2.0))) tmp = t_1 / t_3; else tmp = t_2 / t_3; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloorh\right\rfloor \cdot dY.v\\
t_1 := dX.u \cdot \left\lfloorw\right\rfloor\\
t_2 := \left\lfloorw\right\rfloor \cdot dY.u\\
t_3 := \sqrt{\mathsf{max}\left({\left(\mathsf{hypot}\left(t\_1, dX.v \cdot \left\lfloorh\right\rfloor\right)\right)}^{2}, {\left(\mathsf{hypot}\left(t\_2, t\_0\right)\right)}^{2}\right)}\\
\mathbf{if}\;{t\_1}^{2} \geq {t\_0}^{2}:\\
\;\;\;\;\frac{t\_1}{t\_3}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_2}{t\_3}\\
\end{array}
\end{array}
Initial program 77.6%
Simplified77.7%
Taylor expanded in w around 0 77.5%
Simplified77.4%
Taylor expanded in dX.u around inf 67.7%
unpow267.7%
unpow267.7%
swap-sqr67.7%
unpow267.7%
Simplified67.7%
Taylor expanded in dY.u around 0 61.6%
*-commutative66.3%
unpow266.3%
unpow266.3%
swap-sqr66.3%
unpow266.3%
Simplified61.6%
Taylor expanded in dX.u around 0 61.7%
Simplified61.9%
herbie shell --seed 2024117
(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))))