
(FPCore (ux uy maxCos) :precision binary32 (let* ((t_0 (+ (- 1.0 ux) (* ux maxCos)))) (* (cos (* (* uy 2.0) (PI))) (sqrt (- 1.0 (* t_0 t_0))))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}
\end{array}
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (ux uy maxCos) :precision binary32 (let* ((t_0 (+ (- 1.0 ux) (* ux maxCos)))) (* (cos (* (* uy 2.0) (PI))) (sqrt (- 1.0 (* t_0 t_0))))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}
\end{array}
\end{array}
(FPCore (ux uy maxCos)
:precision binary32
(*
(cos (* (+ uy uy) (PI)))
(sqrt
(*
(- (- 2.0 (* (* (- maxCos 1.0) (+ -1.0 maxCos)) ux)) (* 2.0 maxCos))
ux))))\begin{array}{l}
\\
\cos \left(\left(uy + uy\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\left(2 - \left(\left(maxCos - 1\right) \cdot \left(-1 + maxCos\right)\right) \cdot ux\right) - 2 \cdot maxCos\right) \cdot ux}
\end{array}
Initial program 58.2%
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
distribute-lft-inN/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f32N/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f3227.4
Applied rewrites27.0%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites98.9%
lift-*.f32N/A
*-commutativeN/A
count-2-revN/A
lower-+.f3298.9
Applied rewrites98.9%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (- 1.0 ux) (* ux maxCos))) (t_1 (* (* uy uy) -2.0)))
(if (<=
(* (cos (* (* uy 2.0) (PI))) (sqrt (- 1.0 (* t_0 t_0))))
0.019500000402331352)
(* (+ 1.0 (* (* t_1 (PI)) (PI))) (sqrt (* (fma -2.0 maxCos 2.0) ux)))
(* (fma t_1 (* (PI) (PI)) 1.0) (sqrt (- 1.0 (* t_0 (- 1.0 ux))))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
t_1 := \left(uy \cdot uy\right) \cdot -2\\
\mathbf{if}\;\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0} \leq 0.019500000402331352:\\
\;\;\;\;\left(1 + \left(t\_1 \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{1 - t\_0 \cdot \left(1 - ux\right)}\\
\end{array}
\end{array}
if (*.f32 (cos.f32 (*.f32 (*.f32 uy #s(literal 2 binary32)) (PI.f32))) (sqrt.f32 (-.f32 #s(literal 1 binary32) (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)))))) < 0.0195000004Initial program 40.6%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3232.6
Applied rewrites32.6%
Applied rewrites35.0%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
lower--.f3235.2
Applied rewrites35.2%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f3274.3
Applied rewrites74.2%
if 0.0195000004 < (*.f32 (cos.f32 (*.f32 (*.f32 uy #s(literal 2 binary32)) (PI.f32))) (sqrt.f32 (-.f32 #s(literal 1 binary32) (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)))))) Initial program 90.2%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3280.5
Applied rewrites79.5%
Taylor expanded in maxCos around 0
lower--.f3278.3
Applied rewrites77.3%
Final simplification75.8%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* uy uy) -2.0)))
(if (<= (cos (* (* uy 2.0) (PI))) 0.9999899864196777)
(* (+ 1.0 (* (* t_0 (PI)) (PI))) (sqrt (* (fma -2.0 maxCos 2.0) ux)))
(*
(fma t_0 (* (PI) (PI)) 1.0)
(sqrt
(*
(- (- 2.0 (* (* (- maxCos 1.0) (+ -1.0 maxCos)) ux)) (* 2.0 maxCos))
ux))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(uy \cdot uy\right) \cdot -2\\
\mathbf{if}\;\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \leq 0.9999899864196777:\\
\;\;\;\;\left(1 + \left(t\_0 \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_0, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\left(\left(2 - \left(\left(maxCos - 1\right) \cdot \left(-1 + maxCos\right)\right) \cdot ux\right) - 2 \cdot maxCos\right) \cdot ux}\\
\end{array}
\end{array}
if (cos.f32 (*.f32 (*.f32 uy #s(literal 2 binary32)) (PI.f32))) < 0.999989986Initial program 58.1%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3229.7
Applied rewrites29.7%
Applied rewrites39.1%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
lower--.f3239.3
Applied rewrites39.3%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f3248.8
Applied rewrites48.6%
if 0.999989986 < (cos.f32 (*.f32 (*.f32 uy #s(literal 2 binary32)) (PI.f32))) Initial program 58.3%
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
distribute-lft-inN/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f32N/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f3233.8
Applied rewrites34.1%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites99.3%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3297.2
Applied rewrites96.6%
Final simplification74.5%
(FPCore (ux uy maxCos)
:precision binary32
(*
(cos (* (+ uy uy) (PI)))
(sqrt
(*
(- (- (- 2.0 (* (* ux (- maxCos 1.0)) (+ -1.0 maxCos))) maxCos) maxCos)
ux))))\begin{array}{l}
\\
\cos \left(\left(uy + uy\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\left(\left(2 - \left(ux \cdot \left(maxCos - 1\right)\right) \cdot \left(-1 + maxCos\right)\right) - maxCos\right) - maxCos\right) \cdot ux}
\end{array}
Initial program 58.2%
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
distribute-lft-inN/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f32N/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f3227.6
Applied rewrites27.1%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites98.9%
lift-*.f32N/A
*-commutativeN/A
count-2-revN/A
lower-+.f3298.9
Applied rewrites98.9%
Applied rewrites98.8%
(FPCore (ux uy maxCos) :precision binary32 (* (cos (* (+ uy uy) (PI))) (sqrt (* (- (- 2.0 (* (fma -2.0 ux 2.0) maxCos)) ux) ux))))
\begin{array}{l}
\\
\cos \left(\left(uy + uy\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\left(2 - \mathsf{fma}\left(-2, ux, 2\right) \cdot maxCos\right) - ux\right) \cdot ux}
\end{array}
Initial program 58.2%
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
distribute-lft-inN/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f32N/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f3227.5
Applied rewrites27.2%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites98.9%
lift-*.f32N/A
*-commutativeN/A
count-2-revN/A
lower-+.f3298.9
Applied rewrites98.9%
Taylor expanded in maxCos around 0
Applied rewrites92.1%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= uy 0.00011999999696854502)
(*
(fma (* (* uy uy) -2.0) (* (PI) (PI)) 1.0)
(sqrt
(*
(- (- 2.0 (* (* (- maxCos 1.0) (+ -1.0 maxCos)) ux)) (* 2.0 maxCos))
ux)))
(* (cos (* (+ uy uy) (PI))) (sqrt (* (- 2.0 ux) ux)))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;uy \leq 0.00011999999696854502:\\
\;\;\;\;\mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\left(\left(2 - \left(\left(maxCos - 1\right) \cdot \left(-1 + maxCos\right)\right) \cdot ux\right) - 2 \cdot maxCos\right) \cdot ux}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(\left(uy + uy\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(2 - ux\right) \cdot ux}\\
\end{array}
\end{array}
if uy < 1.19999997e-4Initial program 58.7%
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
distribute-lft-inN/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f32N/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f3231.8
Applied rewrites33.5%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites99.4%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3299.2
Applied rewrites98.6%
if 1.19999997e-4 < uy Initial program 57.4%
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
distribute-lft-inN/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f32N/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f3221.8
Applied rewrites22.0%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites98.1%
lift-*.f32N/A
*-commutativeN/A
count-2-revN/A
lower-+.f3298.1
Applied rewrites98.1%
Taylor expanded in maxCos around 0
Applied rewrites94.1%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= ux 7.999999797903001e-5)
(*
(+ 1.0 (* (* (* (* uy uy) -2.0) (PI)) (PI)))
(sqrt (* (fma -2.0 maxCos 2.0) ux)))
(*
(- 1.0 (* (* (* (* uy uy) 2.0) (PI)) (PI)))
(sqrt
(- 1.0 (* (- 1.0 (- ux (* ux maxCos))) (+ (- 1.0 ux) (* ux maxCos))))))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 7.999999797903001 \cdot 10^{-5}:\\
\;\;\;\;\left(1 + \left(\left(\left(uy \cdot uy\right) \cdot -2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \left(\left(\left(uy \cdot uy\right) \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(1 - \left(ux - ux \cdot maxCos\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}\\
\end{array}
\end{array}
if ux < 7.9999998e-5Initial program 36.3%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3231.3
Applied rewrites31.3%
Applied rewrites33.1%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
lower--.f3233.2
Applied rewrites33.2%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f3277.2
Applied rewrites77.1%
if 7.9999998e-5 < ux Initial program 88.3%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3274.8
Applied rewrites73.9%
Applied rewrites79.6%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
lower--.f3279.7
Applied rewrites79.7%
Applied rewrites79.7%
Final simplification78.2%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (- 1.0 ux) (* ux maxCos))))
(if (<= ux 7.999999797903001e-5)
(*
(+ 1.0 (* (* (* (* uy uy) -2.0) (PI)) (PI)))
(sqrt (* (fma -2.0 maxCos 2.0) ux)))
(*
(- 1.0 (* (* (* (* uy uy) 2.0) (PI)) (PI)))
(sqrt (- 1.0 (* t_0 t_0)))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\mathbf{if}\;ux \leq 7.999999797903001 \cdot 10^{-5}:\\
\;\;\;\;\left(1 + \left(\left(\left(uy \cdot uy\right) \cdot -2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \left(\left(\left(uy \cdot uy\right) \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}\\
\end{array}
\end{array}
if ux < 7.9999998e-5Initial program 36.3%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3231.3
Applied rewrites31.3%
Applied rewrites33.1%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
lower--.f3233.2
Applied rewrites33.2%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f3277.2
Applied rewrites77.1%
if 7.9999998e-5 < ux Initial program 88.3%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3274.8
Applied rewrites73.9%
Applied rewrites79.6%
Applied rewrites79.6%
Final simplification78.2%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ 1.0 (* (* (* (* uy uy) -2.0) (PI)) (PI)))))
(if (<= ux 7.999999797903001e-5)
(* t_0 (sqrt (* (fma -2.0 maxCos 2.0) ux)))
(* t_0 (sqrt (- 1.0 (* (+ (- 1.0 ux) (* ux maxCos)) (- 1.0 ux))))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \left(\left(\left(uy \cdot uy\right) \cdot -2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{PI}\left(\right)\\
\mathbf{if}\;ux \leq 7.999999797903001 \cdot 10^{-5}:\\
\;\;\;\;t\_0 \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(1 - ux\right)}\\
\end{array}
\end{array}
if ux < 7.9999998e-5Initial program 36.3%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3231.3
Applied rewrites31.3%
Applied rewrites33.1%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
lower--.f3233.2
Applied rewrites33.2%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f3277.2
Applied rewrites77.1%
if 7.9999998e-5 < ux Initial program 88.3%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3274.8
Applied rewrites73.9%
Applied rewrites79.6%
Taylor expanded in maxCos around 0
lower--.f3277.4
Applied rewrites77.4%
Final simplification77.3%
(FPCore (ux uy maxCos) :precision binary32 (* (+ 1.0 (* (* (* (* uy uy) -2.0) (PI)) (PI))) (sqrt (* (fma -2.0 maxCos 2.0) ux))))
\begin{array}{l}
\\
\left(1 + \left(\left(\left(uy \cdot uy\right) \cdot -2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}
\end{array}
Initial program 58.2%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3249.6
Applied rewrites49.6%
Applied rewrites52.7%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
lower--.f3252.8
Applied rewrites52.8%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f3265.6
Applied rewrites65.5%
Final simplification65.6%
(FPCore (ux uy maxCos) :precision binary32 (* (fma (* (* uy uy) -2.0) (* (PI) (PI)) 1.0) (sqrt (* (- 2.0 (* 2.0 maxCos)) ux))))
\begin{array}{l}
\\
\mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\left(2 - 2 \cdot maxCos\right) \cdot ux}
\end{array}
Initial program 58.2%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3249.6
Applied rewrites49.6%
Taylor expanded in ux around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3261.2
Applied rewrites61.2%
Applied rewrites64.2%
Final simplification64.2%
(FPCore (ux uy maxCos) :precision binary32 (* (fma uy (* uy (* (* (PI) (PI)) -2.0)) 1.0) (sqrt (* 2.0 ux))))
\begin{array}{l}
\\
\mathsf{fma}\left(uy, uy \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot -2\right), 1\right) \cdot \sqrt{2 \cdot ux}
\end{array}
Initial program 58.2%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3249.6
Applied rewrites49.6%
Taylor expanded in ux around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3261.2
Applied rewrites61.2%
Taylor expanded in maxCos around 0
Applied rewrites61.2%
Applied rewrites61.2%
Final simplification61.2%
(FPCore (ux uy maxCos) :precision binary32 (* (* (* (* uy uy) -2.0) (* (PI) (PI))) (sqrt (* 2.0 ux))))
\begin{array}{l}
\\
\left(\left(\left(uy \cdot uy\right) \cdot -2\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2 \cdot ux}
\end{array}
Initial program 58.2%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3249.6
Applied rewrites49.6%
Taylor expanded in ux around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3261.2
Applied rewrites61.2%
Taylor expanded in maxCos around 0
Applied rewrites61.2%
Taylor expanded in uy around inf
Applied rewrites5.4%
Final simplification5.4%
herbie shell --seed 2024339
(FPCore (ux uy maxCos)
:name "UniformSampleCone, x"
:precision binary32
:pre (and (and (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) (* ux maxCos)) (+ (- 1.0 ux) (* ux maxCos)))))))