
(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\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\_0\\
\mathbf{else}:\\
\;\;\;\;t\_6 \cdot t\_4\\
\end{array}
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 4 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\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\_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) dY.v))
(t_1 (* (floor w) dY.u))
(t_2 (pow (hypot t_0 t_1) 2.0))
(t_3 (* dX.v (floor h)))
(t_4 (* dX.u (floor w)))
(t_5 (pow (hypot t_4 t_3) 2.0)))
(if (>= (pow (hypot t_3 t_4) 2.0) t_2)
(* (floor h) (/ dX.v (sqrt (fmax t_5 (pow (hypot t_1 t_0) 2.0)))))
(/ t_0 (sqrt (fmax t_5 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 = dX_46_v * floorf(h);
float t_4 = dX_46_u * floorf(w);
float t_5 = powf(hypotf(t_4, t_3), 2.0f);
float tmp;
if (powf(hypotf(t_3, t_4), 2.0f) >= t_2) {
tmp = floorf(h) * (dX_46_v / sqrtf(fmaxf(t_5, powf(hypotf(t_1, t_0), 2.0f))));
} else {
tmp = t_0 / sqrtf(fmaxf(t_5, 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(dX_46_v * floor(h)) t_4 = Float32(dX_46_u * floor(w)) t_5 = hypot(t_4, t_3) ^ Float32(2.0) tmp = Float32(0.0) if ((hypot(t_3, t_4) ^ Float32(2.0)) >= t_2) tmp = Float32(floor(h) * Float32(dX_46_v / sqrt(((t_5 != t_5) ? (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_5 : max(t_5, (hypot(t_1, t_0) ^ Float32(2.0)))))))); else tmp = Float32(t_0 / sqrt(((t_5 != t_5) ? t_2 : ((t_2 != t_2) ? t_5 : max(t_5, 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 = dX_46_v * floor(h); t_4 = dX_46_u * floor(w); t_5 = hypot(t_4, t_3) ^ single(2.0); tmp = single(0.0); if ((hypot(t_3, t_4) ^ single(2.0)) >= t_2) tmp = floor(h) * (dX_46_v / sqrt(max(t_5, (hypot(t_1, t_0) ^ single(2.0))))); else tmp = t_0 / sqrt(max(t_5, t_2)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left\lfloorh\right\rfloor \cdot dY.v\\
t_1 := \left\lfloorw\right\rfloor \cdot dY.u\\
t_2 := {\left(\mathsf{hypot}\left(t\_0, t\_1\right)\right)}^{2}\\
t_3 := dX.v \cdot \left\lfloorh\right\rfloor\\
t_4 := dX.u \cdot \left\lfloorw\right\rfloor\\
t_5 := {\left(\mathsf{hypot}\left(t\_4, t\_3\right)\right)}^{2}\\
\mathbf{if}\;{\left(\mathsf{hypot}\left(t\_3, t\_4\right)\right)}^{2} \geq t\_2:\\
\;\;\;\;\left\lfloorh\right\rfloor \cdot \frac{dX.v}{\sqrt{\mathsf{max}\left(t\_5, {\left(\mathsf{hypot}\left(t\_1, t\_0\right)\right)}^{2}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{\sqrt{\mathsf{max}\left(t\_5, t\_2\right)}}\\
\end{array}
\end{array}
Initial program 79.4%
Simplified79.3%
Applied egg-rr79.5%
Taylor expanded in w around 0 79.5%
Simplified79.5%
Applied egg-rr75.8%
Simplified79.6%
Final simplification79.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 (* t_2 t_2))
(t_4 (* dX.u (floor w)))
(t_5
(/
1.0
(sqrt (fmax (+ (* t_4 t_4) (* t_0 t_0)) (+ t_3 (* t_1 t_1)))))))
(if (>= (+ (pow t_4 2.0) (pow t_0 2.0)) (+ (pow t_1 2.0) t_3))
(* t_0 t_5)
(* t_2 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 = floorf(h) * dY_46_v;
float t_3 = t_2 * t_2;
float t_4 = dX_46_u * floorf(w);
float t_5 = 1.0f / sqrtf(fmaxf(((t_4 * t_4) + (t_0 * t_0)), (t_3 + (t_1 * t_1))));
float tmp;
if ((powf(t_4, 2.0f) + powf(t_0, 2.0f)) >= (powf(t_1, 2.0f) + t_3)) {
tmp = t_0 * t_5;
} else {
tmp = t_2 * t_5;
}
return tmp;
}
function code(w, h, dX_46_u, dX_46_v, dY_46_u, dY_46_v, maxAniso) t_0 = Float32(dX_46_v * floor(h)) t_1 = Float32(floor(w) * dY_46_u) t_2 = Float32(floor(h) * dY_46_v) t_3 = Float32(t_2 * t_2) t_4 = Float32(dX_46_u * floor(w)) t_5 = Float32(Float32(1.0) / sqrt(((Float32(Float32(t_4 * t_4) + Float32(t_0 * t_0)) != Float32(Float32(t_4 * t_4) + Float32(t_0 * t_0))) ? Float32(t_3 + Float32(t_1 * t_1)) : ((Float32(t_3 + Float32(t_1 * t_1)) != Float32(t_3 + Float32(t_1 * t_1))) ? Float32(Float32(t_4 * t_4) + Float32(t_0 * t_0)) : max(Float32(Float32(t_4 * t_4) + Float32(t_0 * t_0)), Float32(t_3 + Float32(t_1 * t_1))))))) tmp = Float32(0.0) if (Float32((t_4 ^ Float32(2.0)) + (t_0 ^ Float32(2.0))) >= Float32((t_1 ^ Float32(2.0)) + t_3)) tmp = Float32(t_0 * t_5); else tmp = Float32(t_2 * t_5); 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_v * floor(h); t_1 = floor(w) * dY_46_u; t_2 = floor(h) * dY_46_v; t_3 = t_2 * t_2; t_4 = dX_46_u * floor(w); t_5 = single(1.0) / sqrt(max(((t_4 * t_4) + (t_0 * t_0)), (t_3 + (t_1 * t_1)))); tmp = single(0.0); if (((t_4 ^ single(2.0)) + (t_0 ^ single(2.0))) >= ((t_1 ^ single(2.0)) + t_3)) tmp = t_0 * t_5; else tmp = t_2 * t_5; end tmp_2 = tmp; 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 := t\_2 \cdot t\_2\\
t_4 := dX.u \cdot \left\lfloorw\right\rfloor\\
t_5 := \frac{1}{\sqrt{\mathsf{max}\left(t\_4 \cdot t\_4 + t\_0 \cdot t\_0, t\_3 + t\_1 \cdot t\_1\right)}}\\
\mathbf{if}\;{t\_4}^{2} + {t\_0}^{2} \geq {t\_1}^{2} + t\_3:\\
\;\;\;\;t\_0 \cdot t\_5\\
\mathbf{else}:\\
\;\;\;\;t\_2 \cdot t\_5\\
\end{array}
\end{array}
Initial program 79.4%
pow279.4%
Applied egg-rr79.4%
pow279.4%
Applied egg-rr79.4%
Taylor expanded in w around 0 79.4%
*-commutative79.4%
unpow279.4%
unpow279.4%
swap-sqr79.4%
unpow279.4%
Simplified79.4%
Final simplification79.4%
(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 (* dX.v (floor h)))
(t_3 (* dX.u (floor w)))
(t_4 (pow (hypot t_2 t_3) 2.0))
(t_5 (pow (hypot t_3 t_2) 2.0))
(t_6
(* (floor h) (/ dX.v (sqrt (fmax t_5 (pow (hypot t_0 t_1) 2.0))))))
(t_7 (/ t_1 (sqrt (fmax t_5 (pow (hypot t_1 t_0) 2.0))))))
(if (<= dY.u 2.0)
(if (>= t_4 (pow t_1 2.0)) t_6 t_7)
(if (>= t_4 (pow t_0 2.0)) t_6 t_7))))
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 = dX_46_v * floorf(h);
float t_3 = dX_46_u * floorf(w);
float t_4 = powf(hypotf(t_2, t_3), 2.0f);
float t_5 = powf(hypotf(t_3, t_2), 2.0f);
float t_6 = floorf(h) * (dX_46_v / sqrtf(fmaxf(t_5, powf(hypotf(t_0, t_1), 2.0f))));
float t_7 = t_1 / sqrtf(fmaxf(t_5, powf(hypotf(t_1, t_0), 2.0f)));
float tmp_1;
if (dY_46_u <= 2.0f) {
float tmp_2;
if (t_4 >= powf(t_1, 2.0f)) {
tmp_2 = t_6;
} else {
tmp_2 = t_7;
}
tmp_1 = tmp_2;
} else if (t_4 >= powf(t_0, 2.0f)) {
tmp_1 = t_6;
} else {
tmp_1 = t_7;
}
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 = Float32(dX_46_v * floor(h)) t_3 = Float32(dX_46_u * floor(w)) t_4 = hypot(t_2, t_3) ^ Float32(2.0) t_5 = hypot(t_3, t_2) ^ Float32(2.0) t_6 = Float32(floor(h) * Float32(dX_46_v / sqrt(((t_5 != t_5) ? (hypot(t_0, t_1) ^ Float32(2.0)) : (((hypot(t_0, t_1) ^ Float32(2.0)) != (hypot(t_0, t_1) ^ Float32(2.0))) ? t_5 : max(t_5, (hypot(t_0, t_1) ^ Float32(2.0)))))))) t_7 = Float32(t_1 / sqrt(((t_5 != t_5) ? (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_5 : max(t_5, (hypot(t_1, t_0) ^ Float32(2.0))))))) tmp_1 = Float32(0.0) if (dY_46_u <= Float32(2.0)) tmp_2 = Float32(0.0) if (t_4 >= (t_1 ^ Float32(2.0))) tmp_2 = t_6; else tmp_2 = t_7; end tmp_1 = tmp_2; elseif (t_4 >= (t_0 ^ Float32(2.0))) tmp_1 = t_6; else tmp_1 = t_7; 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 = dX_46_v * floor(h); t_3 = dX_46_u * floor(w); t_4 = hypot(t_2, t_3) ^ single(2.0); t_5 = hypot(t_3, t_2) ^ single(2.0); t_6 = floor(h) * (dX_46_v / sqrt(max(t_5, (hypot(t_0, t_1) ^ single(2.0))))); t_7 = t_1 / sqrt(max(t_5, (hypot(t_1, t_0) ^ single(2.0)))); tmp_2 = single(0.0); if (dY_46_u <= single(2.0)) tmp_3 = single(0.0); if (t_4 >= (t_1 ^ single(2.0))) tmp_3 = t_6; else tmp_3 = t_7; end tmp_2 = tmp_3; elseif (t_4 >= (t_0 ^ single(2.0))) tmp_2 = t_6; else tmp_2 = t_7; end tmp_4 = tmp_2; 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 := dX.v \cdot \left\lfloorh\right\rfloor\\
t_3 := dX.u \cdot \left\lfloorw\right\rfloor\\
t_4 := {\left(\mathsf{hypot}\left(t\_2, t\_3\right)\right)}^{2}\\
t_5 := {\left(\mathsf{hypot}\left(t\_3, t\_2\right)\right)}^{2}\\
t_6 := \left\lfloorh\right\rfloor \cdot \frac{dX.v}{\sqrt{\mathsf{max}\left(t\_5, {\left(\mathsf{hypot}\left(t\_0, t\_1\right)\right)}^{2}\right)}}\\
t_7 := \frac{t\_1}{\sqrt{\mathsf{max}\left(t\_5, {\left(\mathsf{hypot}\left(t\_1, t\_0\right)\right)}^{2}\right)}}\\
\mathbf{if}\;dY.u \leq 2:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;t\_4 \geq {t\_1}^{2}:\\
\;\;\;\;t\_6\\
\mathbf{else}:\\
\;\;\;\;t\_7\\
\end{array}\\
\mathbf{elif}\;t\_4 \geq {t\_0}^{2}:\\
\;\;\;\;t\_6\\
\mathbf{else}:\\
\;\;\;\;t\_7\\
\end{array}
\end{array}
if dY.u < 2Initial program 80.3%
Simplified80.3%
Applied egg-rr80.5%
Taylor expanded in w around 0 80.5%
Simplified80.5%
Applied egg-rr77.1%
Simplified80.5%
Taylor expanded in dY.v around inf 72.7%
*-commutative72.7%
unpow272.7%
unpow272.7%
swap-sqr72.7%
unpow272.7%
Simplified72.7%
if 2 < dY.u Initial program 75.9%
Simplified75.8%
Applied egg-rr75.8%
Taylor expanded in w around 0 75.8%
Simplified75.8%
Applied egg-rr70.6%
Simplified75.9%
Taylor expanded in dY.v around 0 70.7%
*-commutative70.7%
unpow270.7%
unpow270.7%
swap-sqr70.7%
unpow270.7%
Simplified70.7%
Final simplification72.3%
(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
:precision binary32
(let* ((t_0 (* (floor h) dY.v))
(t_1 (* dX.v (floor h)))
(t_2 (* dX.u (floor w)))
(t_3 (pow (hypot t_2 t_1) 2.0))
(t_4 (* (floor w) dY.u)))
(if (>= (pow (hypot t_1 t_2) 2.0) (pow t_0 2.0))
(* (floor h) (/ dX.v (sqrt (fmax t_3 (pow (hypot t_4 t_0) 2.0)))))
(/ t_0 (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(h) * dY_46_v;
float t_1 = dX_46_v * floorf(h);
float t_2 = dX_46_u * floorf(w);
float t_3 = powf(hypotf(t_2, t_1), 2.0f);
float t_4 = floorf(w) * dY_46_u;
float tmp;
if (powf(hypotf(t_1, t_2), 2.0f) >= powf(t_0, 2.0f)) {
tmp = floorf(h) * (dX_46_v / sqrtf(fmaxf(t_3, powf(hypotf(t_4, t_0), 2.0f))));
} else {
tmp = t_0 / 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(h) * dY_46_v) t_1 = Float32(dX_46_v * floor(h)) t_2 = Float32(dX_46_u * floor(w)) t_3 = hypot(t_2, t_1) ^ Float32(2.0) t_4 = Float32(floor(w) * dY_46_u) tmp = Float32(0.0) if ((hypot(t_1, t_2) ^ Float32(2.0)) >= (t_0 ^ Float32(2.0))) tmp = Float32(floor(h) * Float32(dX_46_v / 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_0 / 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(h) * dY_46_v; t_1 = dX_46_v * floor(h); t_2 = dX_46_u * floor(w); t_3 = hypot(t_2, t_1) ^ single(2.0); t_4 = floor(w) * dY_46_u; tmp = single(0.0); if ((hypot(t_1, t_2) ^ single(2.0)) >= (t_0 ^ single(2.0))) tmp = floor(h) * (dX_46_v / sqrt(max(t_3, (hypot(t_4, t_0) ^ single(2.0))))); else tmp = t_0 / 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\lfloorh\right\rfloor \cdot dY.v\\
t_1 := dX.v \cdot \left\lfloorh\right\rfloor\\
t_2 := dX.u \cdot \left\lfloorw\right\rfloor\\
t_3 := {\left(\mathsf{hypot}\left(t\_2, t\_1\right)\right)}^{2}\\
t_4 := \left\lfloorw\right\rfloor \cdot dY.u\\
\mathbf{if}\;{\left(\mathsf{hypot}\left(t\_1, t\_2\right)\right)}^{2} \geq {t\_0}^{2}:\\
\;\;\;\;\left\lfloorh\right\rfloor \cdot \frac{dX.v}{\sqrt{\mathsf{max}\left(t\_3, {\left(\mathsf{hypot}\left(t\_4, t\_0\right)\right)}^{2}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{\sqrt{\mathsf{max}\left(t\_3, {\left(\mathsf{hypot}\left(t\_0, t\_4\right)\right)}^{2}\right)}}\\
\end{array}
\end{array}
Initial program 79.4%
Simplified79.3%
Applied egg-rr79.5%
Taylor expanded in w around 0 79.5%
Simplified79.5%
Applied egg-rr75.8%
Simplified79.6%
Taylor expanded in dY.v around inf 68.5%
*-commutative68.5%
unpow268.5%
unpow268.5%
swap-sqr68.5%
unpow268.5%
Simplified68.5%
Final simplification68.5%
herbie shell --seed 2024053
(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))))