
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
:pre (and (and (and (and (and (and (<= -10000.0 xi) (<= xi 10000.0))
(and (<= -10000.0 yi) (<= yi 10000.0)))
(and (<= -10000.0 zi) (<= zi 10000.0)))
(and (<= 2.328306437e-10 ux) (<= ux 1.0)))
(and (<= 2.328306437e-10 uy) (<= uy 1.0)))
(and (<= 0.0 maxCos) (<= maxCos 1.0)))
(let* ((t_0 (* (* (- 1.0 ux) maxCos) ux))
(t_1 (sqrt (- 1.0 (* t_0 t_0))))
(t_2 (* (* uy 2.0) PI)))
(+
(+ (* (* (cos t_2) t_1) xi) (* (* (sin t_2) t_1) yi))
(* t_0 zi))))float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
float t_0 = ((1.0f - ux) * maxCos) * ux;
float t_1 = sqrtf((1.0f - (t_0 * t_0)));
float t_2 = (uy * 2.0f) * ((float) M_PI);
return (((cosf(t_2) * t_1) * xi) + ((sinf(t_2) * t_1) * yi)) + (t_0 * zi);
}
function code(xi, yi, zi, ux, uy, maxCos) t_0 = Float32(Float32(Float32(Float32(1.0) - ux) * maxCos) * ux) t_1 = sqrt(Float32(Float32(1.0) - Float32(t_0 * t_0))) t_2 = Float32(Float32(uy * Float32(2.0)) * Float32(pi)) return Float32(Float32(Float32(Float32(cos(t_2) * t_1) * xi) + Float32(Float32(sin(t_2) * t_1) * yi)) + Float32(t_0 * zi)) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) t_0 = ((single(1.0) - ux) * maxCos) * ux; t_1 = sqrt((single(1.0) - (t_0 * t_0))); t_2 = (uy * single(2.0)) * single(pi); tmp = (((cos(t_2) * t_1) * xi) + ((sin(t_2) * t_1) * yi)) + (t_0 * zi); end
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
t_1 := \sqrt{1 - t\_0 \cdot t\_0}\\
t_2 := \left(uy \cdot 2\right) \cdot \pi\\
\left(\left(\cos t\_2 \cdot t\_1\right) \cdot xi + \left(\sin t\_2 \cdot t\_1\right) \cdot yi\right) + t\_0 \cdot zi
\end{array}
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
:pre (and (and (and (and (and (and (<= -10000.0 xi) (<= xi 10000.0))
(and (<= -10000.0 yi) (<= yi 10000.0)))
(and (<= -10000.0 zi) (<= zi 10000.0)))
(and (<= 2.328306437e-10 ux) (<= ux 1.0)))
(and (<= 2.328306437e-10 uy) (<= uy 1.0)))
(and (<= 0.0 maxCos) (<= maxCos 1.0)))
(let* ((t_0 (* (* (- 1.0 ux) maxCos) ux))
(t_1 (sqrt (- 1.0 (* t_0 t_0))))
(t_2 (* (* uy 2.0) PI)))
(+
(+ (* (* (cos t_2) t_1) xi) (* (* (sin t_2) t_1) yi))
(* t_0 zi))))float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
float t_0 = ((1.0f - ux) * maxCos) * ux;
float t_1 = sqrtf((1.0f - (t_0 * t_0)));
float t_2 = (uy * 2.0f) * ((float) M_PI);
return (((cosf(t_2) * t_1) * xi) + ((sinf(t_2) * t_1) * yi)) + (t_0 * zi);
}
function code(xi, yi, zi, ux, uy, maxCos) t_0 = Float32(Float32(Float32(Float32(1.0) - ux) * maxCos) * ux) t_1 = sqrt(Float32(Float32(1.0) - Float32(t_0 * t_0))) t_2 = Float32(Float32(uy * Float32(2.0)) * Float32(pi)) return Float32(Float32(Float32(Float32(cos(t_2) * t_1) * xi) + Float32(Float32(sin(t_2) * t_1) * yi)) + Float32(t_0 * zi)) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) t_0 = ((single(1.0) - ux) * maxCos) * ux; t_1 = sqrt((single(1.0) - (t_0 * t_0))); t_2 = (uy * single(2.0)) * single(pi); tmp = (((cos(t_2) * t_1) * xi) + ((sin(t_2) * t_1) * yi)) + (t_0 * zi); end
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
t_1 := \sqrt{1 - t\_0 \cdot t\_0}\\
t_2 := \left(uy \cdot 2\right) \cdot \pi\\
\left(\left(\cos t\_2 \cdot t\_1\right) \cdot xi + \left(\sin t\_2 \cdot t\_1\right) \cdot yi\right) + t\_0 \cdot zi
\end{array}
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
:pre (and (and (and (and (and (and (<= -10000.0 xi) (<= xi 10000.0))
(and (<= -10000.0 yi) (<= yi 10000.0)))
(and (<= -10000.0 zi) (<= zi 10000.0)))
(and (<= 2.328306437e-10 ux) (<= ux 1.0)))
(and (<= 2.328306437e-10 uy) (<= uy 1.0)))
(and (<= 0.0 maxCos) (<= maxCos 1.0)))
(let* ((t_0 (* (* maxCos (- 1.0 ux)) ux))
(t_1 (* PI (+ uy uy)))
(t_2 (sqrt (fma (* (- ux 1.0) maxCos) (* t_0 ux) 1.0))))
(fma (* t_2 (cos t_1)) xi (fma (* yi t_2) (sin t_1) (* zi t_0)))))float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
float t_0 = (maxCos * (1.0f - ux)) * ux;
float t_1 = ((float) M_PI) * (uy + uy);
float t_2 = sqrtf(fmaf(((ux - 1.0f) * maxCos), (t_0 * ux), 1.0f));
return fmaf((t_2 * cosf(t_1)), xi, fmaf((yi * t_2), sinf(t_1), (zi * t_0)));
}
function code(xi, yi, zi, ux, uy, maxCos) t_0 = Float32(Float32(maxCos * Float32(Float32(1.0) - ux)) * ux) t_1 = Float32(Float32(pi) * Float32(uy + uy)) t_2 = sqrt(fma(Float32(Float32(ux - Float32(1.0)) * maxCos), Float32(t_0 * ux), Float32(1.0))) return fma(Float32(t_2 * cos(t_1)), xi, fma(Float32(yi * t_2), sin(t_1), Float32(zi * t_0))) end
\begin{array}{l}
t_0 := \left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\\
t_1 := \pi \cdot \left(uy + uy\right)\\
t_2 := \sqrt{\mathsf{fma}\left(\left(ux - 1\right) \cdot maxCos, t\_0 \cdot ux, 1\right)}\\
\mathsf{fma}\left(t\_2 \cdot \cos t\_1, xi, \mathsf{fma}\left(yi \cdot t\_2, \sin t\_1, zi \cdot t\_0\right)\right)
\end{array}
Initial program 98.9%
Applied rewrites99.0%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
:pre (and (and (and (and (and (and (<= -10000.0 xi) (<= xi 10000.0))
(and (<= -10000.0 yi) (<= yi 10000.0)))
(and (<= -10000.0 zi) (<= zi 10000.0)))
(and (<= 2.328306437e-10 ux) (<= ux 1.0)))
(and (<= 2.328306437e-10 uy) (<= uy 1.0)))
(and (<= 0.0 maxCos) (<= maxCos 1.0)))
(let* ((t_0 (* PI (+ uy uy))))
(fma
(* zi (- 1.0 ux))
(* maxCos ux)
(*
(sqrt
(fma
(* (- ux 1.0) maxCos)
(* (* (* maxCos (- 1.0 ux)) ux) ux)
1.0))
(fma (sin t_0) yi (* (cos t_0) xi))))))float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
float t_0 = ((float) M_PI) * (uy + uy);
return fmaf((zi * (1.0f - ux)), (maxCos * ux), (sqrtf(fmaf(((ux - 1.0f) * maxCos), (((maxCos * (1.0f - ux)) * ux) * ux), 1.0f)) * fmaf(sinf(t_0), yi, (cosf(t_0) * xi))));
}
function code(xi, yi, zi, ux, uy, maxCos) t_0 = Float32(Float32(pi) * Float32(uy + uy)) return fma(Float32(zi * Float32(Float32(1.0) - ux)), Float32(maxCos * ux), Float32(sqrt(fma(Float32(Float32(ux - Float32(1.0)) * maxCos), Float32(Float32(Float32(maxCos * Float32(Float32(1.0) - ux)) * ux) * ux), Float32(1.0))) * fma(sin(t_0), yi, Float32(cos(t_0) * xi)))) end
\begin{array}{l}
t_0 := \pi \cdot \left(uy + uy\right)\\
\mathsf{fma}\left(zi \cdot \left(1 - ux\right), maxCos \cdot ux, \sqrt{\mathsf{fma}\left(\left(ux - 1\right) \cdot maxCos, \left(\left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\right) \cdot ux, 1\right)} \cdot \mathsf{fma}\left(\sin t\_0, yi, \cos t\_0 \cdot xi\right)\right)
\end{array}
Initial program 98.9%
Applied rewrites99.0%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
:pre (and (and (and (and (and (and (<= -10000.0 xi) (<= xi 10000.0))
(and (<= -10000.0 yi) (<= yi 10000.0)))
(and (<= -10000.0 zi) (<= zi 10000.0)))
(and (<= 2.328306437e-10 ux) (<= ux 1.0)))
(and (<= 2.328306437e-10 uy) (<= uy 1.0)))
(and (<= 0.0 maxCos) (<= maxCos 1.0)))
(let* ((t_0 (* PI (+ uy uy))))
(fma
(* zi (- 1.0 ux))
(* maxCos ux)
(*
(sqrt (fma (* (- ux 1.0) maxCos) (* (* maxCos ux) ux) 1.0))
(fma (sin t_0) yi (* (cos t_0) xi))))))float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
float t_0 = ((float) M_PI) * (uy + uy);
return fmaf((zi * (1.0f - ux)), (maxCos * ux), (sqrtf(fmaf(((ux - 1.0f) * maxCos), ((maxCos * ux) * ux), 1.0f)) * fmaf(sinf(t_0), yi, (cosf(t_0) * xi))));
}
function code(xi, yi, zi, ux, uy, maxCos) t_0 = Float32(Float32(pi) * Float32(uy + uy)) return fma(Float32(zi * Float32(Float32(1.0) - ux)), Float32(maxCos * ux), Float32(sqrt(fma(Float32(Float32(ux - Float32(1.0)) * maxCos), Float32(Float32(maxCos * ux) * ux), Float32(1.0))) * fma(sin(t_0), yi, Float32(cos(t_0) * xi)))) end
\begin{array}{l}
t_0 := \pi \cdot \left(uy + uy\right)\\
\mathsf{fma}\left(zi \cdot \left(1 - ux\right), maxCos \cdot ux, \sqrt{\mathsf{fma}\left(\left(ux - 1\right) \cdot maxCos, \left(maxCos \cdot ux\right) \cdot ux, 1\right)} \cdot \mathsf{fma}\left(\sin t\_0, yi, \cos t\_0 \cdot xi\right)\right)
\end{array}
Initial program 98.9%
Applied rewrites99.0%
Taylor expanded in ux around 0
Applied rewrites98.9%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
:pre (and (and (and (and (and (and (<= -10000.0 xi) (<= xi 10000.0))
(and (<= -10000.0 yi) (<= yi 10000.0)))
(and (<= -10000.0 zi) (<= zi 10000.0)))
(and (<= 2.328306437e-10 ux) (<= ux 1.0)))
(and (<= 2.328306437e-10 uy) (<= uy 1.0)))
(and (<= 0.0 maxCos) (<= maxCos 1.0)))
(let* ((t_0 (* (+ PI PI) uy)))
(fma
(* (* maxCos (- 1.0 ux)) ux)
zi
(fma (sin t_0) yi (* (cos t_0) xi)))))float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
float t_0 = (((float) M_PI) + ((float) M_PI)) * uy;
return fmaf(((maxCos * (1.0f - ux)) * ux), zi, fmaf(sinf(t_0), yi, (cosf(t_0) * xi)));
}
function code(xi, yi, zi, ux, uy, maxCos) t_0 = Float32(Float32(Float32(pi) + Float32(pi)) * uy) return fma(Float32(Float32(maxCos * Float32(Float32(1.0) - ux)) * ux), zi, fma(sin(t_0), yi, Float32(cos(t_0) * xi))) end
\begin{array}{l}
t_0 := \left(\pi + \pi\right) \cdot uy\\
\mathsf{fma}\left(\left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux, zi, \mathsf{fma}\left(\sin t\_0, yi, \cos t\_0 \cdot xi\right)\right)
\end{array}
Initial program 98.9%
Taylor expanded in xi around 0
Applied rewrites44.0%
Taylor expanded in maxCos around 0
Applied rewrites98.8%
Applied rewrites98.8%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
:pre (and (and (and (and (and (and (<= -10000.0 xi) (<= xi 10000.0))
(and (<= -10000.0 yi) (<= yi 10000.0)))
(and (<= -10000.0 zi) (<= zi 10000.0)))
(and (<= 2.328306437e-10 ux) (<= ux 1.0)))
(and (<= 2.328306437e-10 uy) (<= uy 1.0)))
(and (<= 0.0 maxCos) (<= maxCos 1.0)))
(let* ((t_0 (* 2.0 (* uy PI))))
(if (<= uy 0.007000000216066837)
(fma
maxCos
(* ux (* zi (- 1.0 ux)))
(+
xi
(*
uy
(fma
2.0
(* yi PI)
(*
uy
(fma
-2.0
(* xi (pow PI 2.0))
(* -1.3333333333333333 (* uy (* yi (pow PI 3.0))))))))))
(fma xi (cos t_0) (* yi (sin t_0))))))float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
float t_0 = 2.0f * (uy * ((float) M_PI));
float tmp;
if (uy <= 0.007000000216066837f) {
tmp = fmaf(maxCos, (ux * (zi * (1.0f - ux))), (xi + (uy * fmaf(2.0f, (yi * ((float) M_PI)), (uy * fmaf(-2.0f, (xi * powf(((float) M_PI), 2.0f)), (-1.3333333333333333f * (uy * (yi * powf(((float) M_PI), 3.0f))))))))));
} else {
tmp = fmaf(xi, cosf(t_0), (yi * sinf(t_0)));
}
return tmp;
}
function code(xi, yi, zi, ux, uy, maxCos) t_0 = Float32(Float32(2.0) * Float32(uy * Float32(pi))) tmp = Float32(0.0) if (uy <= Float32(0.007000000216066837)) tmp = fma(maxCos, Float32(ux * Float32(zi * Float32(Float32(1.0) - ux))), Float32(xi + Float32(uy * fma(Float32(2.0), Float32(yi * Float32(pi)), Float32(uy * fma(Float32(-2.0), Float32(xi * (Float32(pi) ^ Float32(2.0))), Float32(Float32(-1.3333333333333333) * Float32(uy * Float32(yi * (Float32(pi) ^ Float32(3.0))))))))))); else tmp = fma(xi, cos(t_0), Float32(yi * sin(t_0))); end return tmp end
\begin{array}{l}
t_0 := 2 \cdot \left(uy \cdot \pi\right)\\
\mathbf{if}\;uy \leq 0.007000000216066837:\\
\;\;\;\;\mathsf{fma}\left(maxCos, ux \cdot \left(zi \cdot \left(1 - ux\right)\right), xi + uy \cdot \mathsf{fma}\left(2, yi \cdot \pi, uy \cdot \mathsf{fma}\left(-2, xi \cdot {\pi}^{2}, -1.3333333333333333 \cdot \left(uy \cdot \left(yi \cdot {\pi}^{3}\right)\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(xi, \cos t\_0, yi \cdot \sin t\_0\right)\\
\end{array}
if uy < 0.00700000022Initial program 98.9%
Taylor expanded in xi around 0
Applied rewrites44.0%
Taylor expanded in maxCos around 0
Applied rewrites98.8%
Taylor expanded in uy around 0
Applied rewrites89.6%
if 0.00700000022 < uy Initial program 98.9%
Taylor expanded in xi around 0
Applied rewrites44.0%
Taylor expanded in ux around 0
Applied rewrites90.8%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
:pre (and (and (and (and (and (and (<= -10000.0 xi) (<= xi 10000.0))
(and (<= -10000.0 yi) (<= yi 10000.0)))
(and (<= -10000.0 zi) (<= zi 10000.0)))
(and (<= 2.328306437e-10 ux) (<= ux 1.0)))
(and (<= 2.328306437e-10 uy) (<= uy 1.0)))
(and (<= 0.0 maxCos) (<= maxCos 1.0)))
(let* ((t_0 (* 2.0 (* uy PI))))
(fma maxCos (* ux zi) (fma xi (cos t_0) (* yi (sin t_0))))))float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
float t_0 = 2.0f * (uy * ((float) M_PI));
return fmaf(maxCos, (ux * zi), fmaf(xi, cosf(t_0), (yi * sinf(t_0))));
}
function code(xi, yi, zi, ux, uy, maxCos) t_0 = Float32(Float32(2.0) * Float32(uy * Float32(pi))) return fma(maxCos, Float32(ux * zi), fma(xi, cos(t_0), Float32(yi * sin(t_0)))) end
\begin{array}{l}
t_0 := 2 \cdot \left(uy \cdot \pi\right)\\
\mathsf{fma}\left(maxCos, ux \cdot zi, \mathsf{fma}\left(xi, \cos t\_0, yi \cdot \sin t\_0\right)\right)
\end{array}
Initial program 98.9%
Taylor expanded in ux around 0
Applied rewrites95.8%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
:pre (and (and (and (and (and (and (<= -10000.0 xi) (<= xi 10000.0))
(and (<= -10000.0 yi) (<= yi 10000.0)))
(and (<= -10000.0 zi) (<= zi 10000.0)))
(and (<= 2.328306437e-10 ux) (<= ux 1.0)))
(and (<= 2.328306437e-10 uy) (<= uy 1.0)))
(and (<= 0.0 maxCos) (<= maxCos 1.0)))
(fma
maxCos
(* ux (* zi (- 1.0 ux)))
(+
xi
(*
uy
(fma
2.0
(* yi PI)
(*
uy
(fma
-2.0
(* xi (pow PI 2.0))
(* -1.3333333333333333 (* uy (* yi (pow PI 3.0)))))))))))float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return fmaf(maxCos, (ux * (zi * (1.0f - ux))), (xi + (uy * fmaf(2.0f, (yi * ((float) M_PI)), (uy * fmaf(-2.0f, (xi * powf(((float) M_PI), 2.0f)), (-1.3333333333333333f * (uy * (yi * powf(((float) M_PI), 3.0f))))))))));
}
function code(xi, yi, zi, ux, uy, maxCos) return fma(maxCos, Float32(ux * Float32(zi * Float32(Float32(1.0) - ux))), Float32(xi + Float32(uy * fma(Float32(2.0), Float32(yi * Float32(pi)), Float32(uy * fma(Float32(-2.0), Float32(xi * (Float32(pi) ^ Float32(2.0))), Float32(Float32(-1.3333333333333333) * Float32(uy * Float32(yi * (Float32(pi) ^ Float32(3.0))))))))))) end
\mathsf{fma}\left(maxCos, ux \cdot \left(zi \cdot \left(1 - ux\right)\right), xi + uy \cdot \mathsf{fma}\left(2, yi \cdot \pi, uy \cdot \mathsf{fma}\left(-2, xi \cdot {\pi}^{2}, -1.3333333333333333 \cdot \left(uy \cdot \left(yi \cdot {\pi}^{3}\right)\right)\right)\right)\right)
Initial program 98.9%
Taylor expanded in xi around 0
Applied rewrites44.0%
Taylor expanded in maxCos around 0
Applied rewrites98.8%
Taylor expanded in uy around 0
Applied rewrites89.6%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
:pre (and (and (and (and (and (and (<= -10000.0 xi) (<= xi 10000.0))
(and (<= -10000.0 yi) (<= yi 10000.0)))
(and (<= -10000.0 zi) (<= zi 10000.0)))
(and (<= 2.328306437e-10 ux) (<= ux 1.0)))
(and (<= 2.328306437e-10 uy) (<= uy 1.0)))
(and (<= 0.0 maxCos) (<= maxCos 1.0)))
(fma
maxCos
(* ux (* zi (- 1.0 ux)))
(fma xi (cos (* 2.0 (* uy PI))) (* 2.0 (* uy (* yi PI))))))float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return fmaf(maxCos, (ux * (zi * (1.0f - ux))), fmaf(xi, cosf((2.0f * (uy * ((float) M_PI)))), (2.0f * (uy * (yi * ((float) M_PI))))));
}
function code(xi, yi, zi, ux, uy, maxCos) return fma(maxCos, Float32(ux * Float32(zi * Float32(Float32(1.0) - ux))), fma(xi, cos(Float32(Float32(2.0) * Float32(uy * Float32(pi)))), Float32(Float32(2.0) * Float32(uy * Float32(yi * Float32(pi)))))) end
\mathsf{fma}\left(maxCos, ux \cdot \left(zi \cdot \left(1 - ux\right)\right), \mathsf{fma}\left(xi, \cos \left(2 \cdot \left(uy \cdot \pi\right)\right), 2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right)\right)\right)
Initial program 98.9%
Taylor expanded in xi around 0
Applied rewrites44.0%
Taylor expanded in maxCos around 0
Applied rewrites98.8%
Taylor expanded in uy around 0
Applied rewrites90.2%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
:pre (and (and (and (and (and (and (<= -10000.0 xi) (<= xi 10000.0))
(and (<= -10000.0 yi) (<= yi 10000.0)))
(and (<= -10000.0 zi) (<= zi 10000.0)))
(and (<= 2.328306437e-10 ux) (<= ux 1.0)))
(and (<= 2.328306437e-10 uy) (<= uy 1.0)))
(and (<= 0.0 maxCos) (<= maxCos 1.0)))
(+
xi
(fma
maxCos
(* ux (* zi (- 1.0 ux)))
(* uy (fma -2.0 (* uy (* xi (pow PI 2.0))) (* 2.0 (* yi PI)))))))float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return xi + fmaf(maxCos, (ux * (zi * (1.0f - ux))), (uy * fmaf(-2.0f, (uy * (xi * powf(((float) M_PI), 2.0f))), (2.0f * (yi * ((float) M_PI))))));
}
function code(xi, yi, zi, ux, uy, maxCos) return Float32(xi + fma(maxCos, Float32(ux * Float32(zi * Float32(Float32(1.0) - ux))), Float32(uy * fma(Float32(-2.0), Float32(uy * Float32(xi * (Float32(pi) ^ Float32(2.0)))), Float32(Float32(2.0) * Float32(yi * Float32(pi))))))) end
xi + \mathsf{fma}\left(maxCos, ux \cdot \left(zi \cdot \left(1 - ux\right)\right), uy \cdot \mathsf{fma}\left(-2, uy \cdot \left(xi \cdot {\pi}^{2}\right), 2 \cdot \left(yi \cdot \pi\right)\right)\right)
Initial program 98.9%
Taylor expanded in xi around 0
Applied rewrites44.0%
Taylor expanded in maxCos around 0
Applied rewrites98.8%
Taylor expanded in uy around 0
Applied rewrites86.1%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
:pre (and (and (and (and (and (and (<= -10000.0 xi) (<= xi 10000.0))
(and (<= -10000.0 yi) (<= yi 10000.0)))
(and (<= -10000.0 zi) (<= zi 10000.0)))
(and (<= 2.328306437e-10 ux) (<= ux 1.0)))
(and (<= 2.328306437e-10 uy) (<= uy 1.0)))
(and (<= 0.0 maxCos) (<= maxCos 1.0)))
(+ xi (fma 2.0 (* uy (* yi PI)) (* maxCos (* ux (* zi (- 1.0 ux)))))))float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return xi + fmaf(2.0f, (uy * (yi * ((float) M_PI))), (maxCos * (ux * (zi * (1.0f - ux)))));
}
function code(xi, yi, zi, ux, uy, maxCos) return Float32(xi + fma(Float32(2.0), Float32(uy * Float32(yi * Float32(pi))), Float32(maxCos * Float32(ux * Float32(zi * Float32(Float32(1.0) - ux)))))) end
xi + \mathsf{fma}\left(2, uy \cdot \left(yi \cdot \pi\right), maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\right)
Initial program 98.9%
Taylor expanded in xi around 0
Applied rewrites44.0%
Taylor expanded in maxCos around 0
Applied rewrites98.8%
Taylor expanded in uy around 0
Applied rewrites81.8%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
:pre (and (and (and (and (and (and (<= -10000.0 xi) (<= xi 10000.0))
(and (<= -10000.0 yi) (<= yi 10000.0)))
(and (<= -10000.0 zi) (<= zi 10000.0)))
(and (<= 2.328306437e-10 ux) (<= ux 1.0)))
(and (<= 2.328306437e-10 uy) (<= uy 1.0)))
(and (<= 0.0 maxCos) (<= maxCos 1.0)))
(fma maxCos (* ux (* zi (- 1.0 ux))) (+ xi (* 2.0 (* uy (* yi PI))))))float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return fmaf(maxCos, (ux * (zi * (1.0f - ux))), (xi + (2.0f * (uy * (yi * ((float) M_PI))))));
}
function code(xi, yi, zi, ux, uy, maxCos) return fma(maxCos, Float32(ux * Float32(zi * Float32(Float32(1.0) - ux))), Float32(xi + Float32(Float32(2.0) * Float32(uy * Float32(yi * Float32(pi)))))) end
\mathsf{fma}\left(maxCos, ux \cdot \left(zi \cdot \left(1 - ux\right)\right), xi + 2 \cdot \left(uy \cdot \left(yi \cdot \pi\right)\right)\right)
Initial program 98.9%
Taylor expanded in xi around 0
Applied rewrites44.0%
Taylor expanded in maxCos around 0
Applied rewrites98.8%
Taylor expanded in uy around 0
Applied rewrites81.8%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
:pre (and (and (and (and (and (and (<= -10000.0 xi) (<= xi 10000.0))
(and (<= -10000.0 yi) (<= yi 10000.0)))
(and (<= -10000.0 zi) (<= zi 10000.0)))
(and (<= 2.328306437e-10 ux) (<= ux 1.0)))
(and (<= 2.328306437e-10 uy) (<= uy 1.0)))
(and (<= 0.0 maxCos) (<= maxCos 1.0)))
(+ xi (* maxCos (* ux (* zi (- 1.0 ux))))))float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return xi + (maxCos * (ux * (zi * (1.0f - ux))));
}
real(4) function code(xi, yi, zi, ux, uy, maxcos)
use fmin_fmax_functions
real(4), intent (in) :: xi
real(4), intent (in) :: yi
real(4), intent (in) :: zi
real(4), intent (in) :: ux
real(4), intent (in) :: uy
real(4), intent (in) :: maxcos
code = xi + (maxcos * (ux * (zi * (1.0e0 - ux))))
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(xi + Float32(maxCos * Float32(ux * Float32(zi * Float32(Float32(1.0) - ux))))) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = xi + (maxCos * (ux * (zi * (single(1.0) - ux)))); end
xi + maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)
Initial program 98.9%
Taylor expanded in uy around 0
Applied rewrites52.0%
Taylor expanded in maxCos around 0
Applied rewrites51.9%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
:pre (and (and (and (and (and (and (<= -10000.0 xi) (<= xi 10000.0))
(and (<= -10000.0 yi) (<= yi 10000.0)))
(and (<= -10000.0 zi) (<= zi 10000.0)))
(and (<= 2.328306437e-10 ux) (<= ux 1.0)))
(and (<= 2.328306437e-10 uy) (<= uy 1.0)))
(and (<= 0.0 maxCos) (<= maxCos 1.0)))
(fma (* maxCos ux) zi xi))float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return fmaf((maxCos * ux), zi, xi);
}
function code(xi, yi, zi, ux, uy, maxCos) return fma(Float32(maxCos * ux), zi, xi) end
\mathsf{fma}\left(maxCos \cdot ux, zi, xi\right)
Initial program 98.9%
Taylor expanded in uy around 0
Applied rewrites52.0%
Taylor expanded in ux around 0
Applied rewrites49.8%
Applied rewrites49.8%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
:pre (and (and (and (and (and (and (<= -10000.0 xi) (<= xi 10000.0))
(and (<= -10000.0 yi) (<= yi 10000.0)))
(and (<= -10000.0 zi) (<= zi 10000.0)))
(and (<= 2.328306437e-10 ux) (<= ux 1.0)))
(and (<= 2.328306437e-10 uy) (<= uy 1.0)))
(and (<= 0.0 maxCos) (<= maxCos 1.0)))
(* (* maxCos ux) zi))float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return (maxCos * ux) * zi;
}
real(4) function code(xi, yi, zi, ux, uy, maxcos)
use fmin_fmax_functions
real(4), intent (in) :: xi
real(4), intent (in) :: yi
real(4), intent (in) :: zi
real(4), intent (in) :: ux
real(4), intent (in) :: uy
real(4), intent (in) :: maxcos
code = (maxcos * ux) * zi
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(maxCos * ux) * zi) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = (maxCos * ux) * zi; end
\left(maxCos \cdot ux\right) \cdot zi
Initial program 98.9%
Taylor expanded in uy around 0
Applied rewrites52.0%
Taylor expanded in ux around 0
Applied rewrites49.8%
Taylor expanded in xi around 0
Applied rewrites11.8%
Applied rewrites11.8%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
:pre (and (and (and (and (and (and (<= -10000.0 xi) (<= xi 10000.0))
(and (<= -10000.0 yi) (<= yi 10000.0)))
(and (<= -10000.0 zi) (<= zi 10000.0)))
(and (<= 2.328306437e-10 ux) (<= ux 1.0)))
(and (<= 2.328306437e-10 uy) (<= uy 1.0)))
(and (<= 0.0 maxCos) (<= maxCos 1.0)))
(* maxCos (* ux zi)))float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return maxCos * (ux * zi);
}
real(4) function code(xi, yi, zi, ux, uy, maxcos)
use fmin_fmax_functions
real(4), intent (in) :: xi
real(4), intent (in) :: yi
real(4), intent (in) :: zi
real(4), intent (in) :: ux
real(4), intent (in) :: uy
real(4), intent (in) :: maxcos
code = maxcos * (ux * zi)
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(maxCos * Float32(ux * zi)) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = maxCos * (ux * zi); end
maxCos \cdot \left(ux \cdot zi\right)
Initial program 98.9%
Taylor expanded in uy around 0
Applied rewrites52.0%
Taylor expanded in ux around 0
Applied rewrites49.8%
Taylor expanded in xi around 0
Applied rewrites11.8%
herbie shell --seed 2025359
(FPCore (xi yi zi ux uy maxCos)
:name "UniformSampleCone 2"
:precision binary32
:pre (and (and (and (and (and (and (<= -10000.0 xi) (<= xi 10000.0)) (and (<= -10000.0 yi) (<= yi 10000.0))) (and (<= -10000.0 zi) (<= zi 10000.0))) (and (<= 2.328306437e-10 ux) (<= ux 1.0))) (and (<= 2.328306437e-10 uy) (<= uy 1.0))) (and (<= 0.0 maxCos) (<= maxCos 1.0)))
(+ (+ (* (* (cos (* (* uy 2.0) PI)) (sqrt (- 1.0 (* (* (* (- 1.0 ux) maxCos) ux) (* (* (- 1.0 ux) maxCos) ux))))) xi) (* (* (sin (* (* uy 2.0) PI)) (sqrt (- 1.0 (* (* (* (- 1.0 ux) maxCos) ux) (* (* (- 1.0 ux) maxCos) ux))))) yi)) (* (* (* (- 1.0 ux) maxCos) ux) zi)))