
(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
(*
(sqrt
(-
(* (* ux ux) (/ (+ (* -2.0 maxCos) 2.0) ux))
(* (pow (- maxCos 1.0) 2.0) (* ux ux))))
(cos (* (PI) (* 2.0 uy)))))\begin{array}{l}
\\
\sqrt{\left(ux \cdot ux\right) \cdot \frac{-2 \cdot maxCos + 2}{ux} - {\left(maxCos - 1\right)}^{2} \cdot \left(ux \cdot ux\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
\end{array}
Initial program 56.3%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
associate--r+N/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
div-subN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f32N/A
lower-/.f32N/A
+-commutativeN/A
lower-fma.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f3270.0
Applied rewrites70.1%
Applied rewrites70.2%
Applied rewrites98.8%
Final simplification98.8%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (* maxCos ux) (- 1.0 ux))) (t_1 (cos (* (PI) (* 2.0 uy)))))
(if (<= (* (sqrt (- 1.0 (* t_0 t_0))) t_1) 0.03200000151991844)
(* (sqrt (* 0.5 (* 4.0 ux))) t_1)
(* (sqrt (- 1.0 (* (* (- (+ (/ 1.0 ux) maxCos) 1.0) ux) t_0))) 1.0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := maxCos \cdot ux + \left(1 - ux\right)\\
t_1 := \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
\mathbf{if}\;\sqrt{1 - t\_0 \cdot t\_0} \cdot t\_1 \leq 0.03200000151991844:\\
\;\;\;\;\sqrt{0.5 \cdot \left(4 \cdot ux\right)} \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(\left(\left(\frac{1}{ux} + maxCos\right) - 1\right) \cdot ux\right) \cdot t\_0} \cdot 1\\
\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.0320000015Initial program 39.3%
lift--.f32N/A
flip--N/A
lower-/.f32N/A
Applied rewrites25.4%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-sqrt.f32N/A
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
lower-sqrt.f32N/A
*-commutativeN/A
lower-*.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f3262.3
Applied rewrites62.8%
Taylor expanded in maxCos around 0
Applied rewrites85.7%
Applied rewrites85.9%
if 0.0320000015 < (*.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 92.2%
Taylor expanded in uy around 0
Applied rewrites82.5%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3282.9
Applied rewrites82.9%
Final simplification85.0%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (- (/ (+ (* -2.0 maxCos) 2.0) ux) (pow (- maxCos 1.0) 2.0)) (* ux ux))) (cos (* (PI) (* 2.0 uy)))))
\begin{array}{l}
\\
\sqrt{\left(\frac{-2 \cdot maxCos + 2}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot \left(ux \cdot ux\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
\end{array}
Initial program 56.3%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
associate--r+N/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
div-subN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f32N/A
lower-/.f32N/A
+-commutativeN/A
lower-fma.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f3270.1
Applied rewrites70.1%
Applied rewrites98.8%
Final simplification98.8%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (cos (* (PI) (* 2.0 uy)))))
(if (<= t_0 0.9999849796295166)
(* (sqrt (* 0.5 (* 4.0 ux))) t_0)
(*
(sqrt (* (- (fma -2.0 maxCos 2.0) (* (pow (- maxCos 1.0) 2.0) ux)) ux))
1.0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
\mathbf{if}\;t\_0 \leq 0.9999849796295166:\\
\;\;\;\;\sqrt{0.5 \cdot \left(4 \cdot ux\right)} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\mathsf{fma}\left(-2, maxCos, 2\right) - {\left(maxCos - 1\right)}^{2} \cdot ux\right) \cdot ux} \cdot 1\\
\end{array}
\end{array}
if (cos.f32 (*.f32 (*.f32 uy #s(literal 2 binary32)) (PI.f32))) < 0.99998498Initial program 54.1%
lift--.f32N/A
flip--N/A
lower-/.f32N/A
Applied rewrites9.2%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-sqrt.f32N/A
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
lower-sqrt.f32N/A
*-commutativeN/A
lower-*.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f3220.0
Applied rewrites20.0%
Taylor expanded in maxCos around 0
Applied rewrites74.4%
Applied rewrites74.6%
if 0.99998498 < (cos.f32 (*.f32 (*.f32 uy #s(literal 2 binary32)) (PI.f32))) Initial program 57.3%
Taylor expanded in uy around 0
Applied rewrites56.9%
Taylor expanded in ux around 0
*-commutativeN/A
associate--l+N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-*.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
+-commutativeN/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f3294.0
Applied rewrites94.0%
Final simplification87.7%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (- (* ux 2.0) (* ux ux))) (cos (* (PI) (* 2.0 uy)))))
\begin{array}{l}
\\
\sqrt{ux \cdot 2 - ux \cdot ux} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
\end{array}
Initial program 56.3%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
associate--r+N/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
div-subN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f32N/A
lower-/.f32N/A
+-commutativeN/A
lower-fma.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f3270.1
Applied rewrites70.1%
Applied rewrites70.2%
Taylor expanded in maxCos around 0
Applied rewrites95.1%
Final simplification95.1%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= ux 0.0001500000071246177)
(* (sqrt (* (fma -2.0 maxCos 2.0) ux)) 1.0)
(*
(sqrt
(-
1.0
(* (* (- (+ (/ 1.0 ux) maxCos) 1.0) ux) (+ (* maxCos ux) (- 1.0 ux)))))
1.0)))
float code(float ux, float uy, float maxCos) {
float tmp;
if (ux <= 0.0001500000071246177f) {
tmp = sqrtf((fmaf(-2.0f, maxCos, 2.0f) * ux)) * 1.0f;
} else {
tmp = sqrtf((1.0f - (((((1.0f / ux) + maxCos) - 1.0f) * ux) * ((maxCos * ux) + (1.0f - ux))))) * 1.0f;
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.0001500000071246177)) tmp = Float32(sqrt(Float32(fma(Float32(-2.0), maxCos, Float32(2.0)) * ux)) * Float32(1.0)); else tmp = Float32(sqrt(Float32(Float32(1.0) - Float32(Float32(Float32(Float32(Float32(Float32(1.0) / ux) + maxCos) - Float32(1.0)) * ux) * Float32(Float32(maxCos * ux) + Float32(Float32(1.0) - ux))))) * Float32(1.0)); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.0001500000071246177:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(\left(\left(\frac{1}{ux} + maxCos\right) - 1\right) \cdot ux\right) \cdot \left(maxCos \cdot ux + \left(1 - ux\right)\right)} \cdot 1\\
\end{array}
\end{array}
if ux < 1.50000007e-4Initial program 34.3%
Taylor expanded in uy around 0
Applied rewrites31.9%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3273.6
Applied rewrites73.2%
if 1.50000007e-4 < ux Initial program 89.9%
Taylor expanded in uy around 0
Applied rewrites75.6%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3276.1
Applied rewrites76.1%
Final simplification74.6%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= ux 0.0001500000071246177)
(* (sqrt (* (fma -2.0 maxCos 2.0) ux)) 1.0)
(*
(sqrt
(- 1.0 (* (- 1.0 (- ux (* maxCos ux))) (+ (* maxCos ux) (- 1.0 ux)))))
1.0)))
float code(float ux, float uy, float maxCos) {
float tmp;
if (ux <= 0.0001500000071246177f) {
tmp = sqrtf((fmaf(-2.0f, maxCos, 2.0f) * ux)) * 1.0f;
} else {
tmp = sqrtf((1.0f - ((1.0f - (ux - (maxCos * ux))) * ((maxCos * ux) + (1.0f - ux))))) * 1.0f;
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.0001500000071246177)) tmp = Float32(sqrt(Float32(fma(Float32(-2.0), maxCos, Float32(2.0)) * ux)) * Float32(1.0)); else tmp = Float32(sqrt(Float32(Float32(1.0) - Float32(Float32(Float32(1.0) - Float32(ux - Float32(maxCos * ux))) * Float32(Float32(maxCos * ux) + Float32(Float32(1.0) - ux))))) * Float32(1.0)); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.0001500000071246177:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(1 - \left(ux - maxCos \cdot ux\right)\right) \cdot \left(maxCos \cdot ux + \left(1 - ux\right)\right)} \cdot 1\\
\end{array}
\end{array}
if ux < 1.50000007e-4Initial program 34.3%
Taylor expanded in uy around 0
Applied rewrites31.9%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3273.6
Applied rewrites73.2%
if 1.50000007e-4 < ux Initial program 89.9%
Taylor expanded in uy around 0
Applied rewrites75.6%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
lower--.f3275.8
lift-*.f32N/A
*-commutativeN/A
lower-*.f3275.8
Applied rewrites75.8%
Final simplification74.5%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (* maxCos ux) (- 1.0 ux))))
(if (<= ux 0.0001500000071246177)
(* (sqrt (* (fma -2.0 maxCos 2.0) ux)) 1.0)
(* (sqrt (- 1.0 (* t_0 t_0))) 1.0))))
float code(float ux, float uy, float maxCos) {
float t_0 = (maxCos * ux) + (1.0f - ux);
float tmp;
if (ux <= 0.0001500000071246177f) {
tmp = sqrtf((fmaf(-2.0f, maxCos, 2.0f) * ux)) * 1.0f;
} else {
tmp = sqrtf((1.0f - (t_0 * t_0))) * 1.0f;
}
return tmp;
}
function code(ux, uy, maxCos) t_0 = Float32(Float32(maxCos * ux) + Float32(Float32(1.0) - ux)) tmp = Float32(0.0) if (ux <= Float32(0.0001500000071246177)) tmp = Float32(sqrt(Float32(fma(Float32(-2.0), maxCos, Float32(2.0)) * ux)) * Float32(1.0)); else tmp = Float32(sqrt(Float32(Float32(1.0) - Float32(t_0 * t_0))) * Float32(1.0)); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := maxCos \cdot ux + \left(1 - ux\right)\\
\mathbf{if}\;ux \leq 0.0001500000071246177:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - t\_0 \cdot t\_0} \cdot 1\\
\end{array}
\end{array}
if ux < 1.50000007e-4Initial program 34.3%
Taylor expanded in uy around 0
Applied rewrites31.9%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3268.1
Applied rewrites73.2%
if 1.50000007e-4 < ux Initial program 89.9%
Taylor expanded in uy around 0
Applied rewrites75.6%
Final simplification73.6%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= ux 0.0001500000071246177)
(* (sqrt (* (fma -2.0 maxCos 2.0) ux)) 1.0)
(*
(sqrt (- 1.0 (* (- (fma ux maxCos 1.0) ux) (+ (* (- maxCos 1.0) ux) 1.0))))
1.0)))
float code(float ux, float uy, float maxCos) {
float tmp;
if (ux <= 0.0001500000071246177f) {
tmp = sqrtf((fmaf(-2.0f, maxCos, 2.0f) * ux)) * 1.0f;
} else {
tmp = sqrtf((1.0f - ((fmaf(ux, maxCos, 1.0f) - ux) * (((maxCos - 1.0f) * ux) + 1.0f)))) * 1.0f;
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.0001500000071246177)) tmp = Float32(sqrt(Float32(fma(Float32(-2.0), maxCos, Float32(2.0)) * ux)) * Float32(1.0)); else tmp = Float32(sqrt(Float32(Float32(1.0) - Float32(Float32(fma(ux, maxCos, Float32(1.0)) - ux) * Float32(Float32(Float32(maxCos - Float32(1.0)) * ux) + Float32(1.0))))) * Float32(1.0)); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.0001500000071246177:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(\mathsf{fma}\left(ux, maxCos, 1\right) - ux\right) \cdot \left(\left(maxCos - 1\right) \cdot ux + 1\right)} \cdot 1\\
\end{array}
\end{array}
if ux < 1.50000007e-4Initial program 34.3%
Taylor expanded in uy around 0
Applied rewrites31.9%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3273.6
Applied rewrites73.2%
if 1.50000007e-4 < ux Initial program 89.9%
Taylor expanded in uy around 0
Applied rewrites75.6%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3276.1
Applied rewrites76.1%
lift-*.f32N/A
*-commutativeN/A
lower-*.f3276.1
Applied rewrites73.5%
Final simplification73.9%
(FPCore (ux uy maxCos) :precision binary32 (if (<= ux 0.0001500000071246177) (* (sqrt (* (fma -2.0 maxCos 2.0) ux)) 1.0) (* (sqrt (- 1.0 (* (- 1.0 ux) (+ (* maxCos ux) (- 1.0 ux))))) 1.0)))
float code(float ux, float uy, float maxCos) {
float tmp;
if (ux <= 0.0001500000071246177f) {
tmp = sqrtf((fmaf(-2.0f, maxCos, 2.0f) * ux)) * 1.0f;
} else {
tmp = sqrtf((1.0f - ((1.0f - ux) * ((maxCos * ux) + (1.0f - ux))))) * 1.0f;
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.0001500000071246177)) tmp = Float32(sqrt(Float32(fma(Float32(-2.0), maxCos, Float32(2.0)) * ux)) * Float32(1.0)); else tmp = Float32(sqrt(Float32(Float32(1.0) - Float32(Float32(Float32(1.0) - ux) * Float32(Float32(maxCos * ux) + Float32(Float32(1.0) - ux))))) * Float32(1.0)); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.0001500000071246177:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot ux + \left(1 - ux\right)\right)} \cdot 1\\
\end{array}
\end{array}
if ux < 1.50000007e-4Initial program 34.3%
Taylor expanded in uy around 0
Applied rewrites31.9%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3273.6
Applied rewrites73.2%
if 1.50000007e-4 < ux Initial program 89.9%
Taylor expanded in uy around 0
Applied rewrites75.6%
Taylor expanded in maxCos around 0
lower--.f3274.2
Applied rewrites74.2%
Final simplification73.8%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (fma -2.0 maxCos 2.0) ux)) 1.0))
float code(float ux, float uy, float maxCos) {
return sqrtf((fmaf(-2.0f, maxCos, 2.0f) * ux)) * 1.0f;
}
function code(ux, uy, maxCos) return Float32(sqrt(Float32(fma(Float32(-2.0), maxCos, Float32(2.0)) * ux)) * Float32(1.0)) end
\begin{array}{l}
\\
\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot 1
\end{array}
Initial program 56.3%
Taylor expanded in uy around 0
Applied rewrites49.2%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3261.1
Applied rewrites62.6%
Final simplification59.4%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (fma -1.0 1.0 1.0)) 1.0))
float code(float ux, float uy, float maxCos) {
return sqrtf(fmaf(-1.0f, 1.0f, 1.0f)) * 1.0f;
}
function code(ux, uy, maxCos) return Float32(sqrt(fma(Float32(-1.0), Float32(1.0), Float32(1.0))) * Float32(1.0)) end
\begin{array}{l}
\\
\sqrt{\mathsf{fma}\left(-1, 1, 1\right)} \cdot 1
\end{array}
Initial program 56.3%
Taylor expanded in uy around 0
Applied rewrites49.2%
Taylor expanded in ux around 0
Applied rewrites6.6%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
neg-mul-1N/A
lower-fma.f3219.4
Applied rewrites20.0%
Final simplification19.9%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (- 1.0 1.0)) 1.0))
float code(float ux, float uy, float maxCos) {
return sqrtf((1.0f - 1.0f)) * 1.0f;
}
real(4) function code(ux, uy, maxcos)
real(4), intent (in) :: ux
real(4), intent (in) :: uy
real(4), intent (in) :: maxcos
code = sqrt((1.0e0 - 1.0e0)) * 1.0e0
end function
function code(ux, uy, maxCos) return Float32(sqrt(Float32(Float32(1.0) - Float32(1.0))) * Float32(1.0)) end
function tmp = code(ux, uy, maxCos) tmp = sqrt((single(1.0) - single(1.0))) * single(1.0); end
\begin{array}{l}
\\
\sqrt{1 - 1} \cdot 1
\end{array}
Initial program 56.3%
Taylor expanded in uy around 0
Applied rewrites49.2%
Taylor expanded in ux around 0
Applied rewrites6.6%
Final simplification6.6%
herbie shell --seed 2024276
(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)))))))