
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (sqrt (- (log (- 1.0 u1)))) (cos (* (* 2.0 (PI)) u2))))
\begin{array}{l}
\\
\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (sqrt (- (log (- 1.0 u1)))) (cos (* (* 2.0 (PI)) u2))))
\begin{array}{l}
\\
\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)
\end{array}
(FPCore (cosTheta_i u1 u2)
:precision binary32
(let* ((t_0 (cbrt (PI))))
(*
(sqrt (- (- (log1p (* (- u1) u1)) (log1p u1))))
(cos (fma (pow t_0 2.0) (* t_0 u2) (* u2 (PI)))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{\mathsf{PI}\left(\right)}\\
\sqrt{-\left(\mathsf{log1p}\left(\left(-u1\right) \cdot u1\right) - \mathsf{log1p}\left(u1\right)\right)} \cdot \cos \left(\mathsf{fma}\left({t\_0}^{2}, t\_0 \cdot u2, u2 \cdot \mathsf{PI}\left(\right)\right)\right)
\end{array}
\end{array}
Initial program 56.8%
lift-log.f32N/A
lift--.f32N/A
flip--N/A
log-divN/A
lower--.f32N/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
lower-log1p.f32N/A
lower-*.f32N/A
lower-neg.f32N/A
lower-log1p.f3298.7
Applied rewrites98.7%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
count-2-revN/A
lift-PI.f32N/A
add-cube-cbrtN/A
associate-*l*N/A
lower-fma.f32N/A
pow2N/A
lower-pow.f32N/A
lift-PI.f32N/A
lower-cbrt.f32N/A
lower-*.f32N/A
lift-PI.f32N/A
lower-cbrt.f32N/A
*-commutativeN/A
lower-*.f3298.8
Applied rewrites98.8%
(FPCore (cosTheta_i u1 u2)
:precision binary32
(let* ((t_0 (sqrt (- (log (- 1.0 u1))))) (t_1 (cos (* (* 2.0 (PI)) u2))))
(if (<= (* t_0 t_1) 0.1899999976158142)
(*
(sqrt (* (fma (fma (fma 0.25 u1 0.3333333333333333) u1 0.5) u1 1.0) u1))
t_1)
(* t_0 (fma (* (* u2 u2) -2.0) (* (PI) (PI)) 1.0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{-\log \left(1 - u1\right)}\\
t_1 := \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\\
\mathbf{if}\;t\_0 \cdot t\_1 \leq 0.1899999976158142:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.25, u1, 0.3333333333333333\right), u1, 0.5\right), u1, 1\right) \cdot u1} \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \mathsf{fma}\left(\left(u2 \cdot u2\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right)\\
\end{array}
\end{array}
if (*.f32 (sqrt.f32 (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))) (cos.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2))) < 0.189999998Initial program 49.2%
Taylor expanded in u1 around 0
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
+-commutativeN/A
lower-fma.f3297.8
Applied rewrites97.8%
if 0.189999998 < (*.f32 (sqrt.f32 (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))) (cos.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2))) Initial program 97.7%
Taylor expanded in u2 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.f3292.6
Applied rewrites92.6%
(FPCore (cosTheta_i u1 u2)
:precision binary32
(let* ((t_0 (sqrt (- (log (- 1.0 u1))))) (t_1 (cos (* (* 2.0 (PI)) u2))))
(if (<= (* t_0 t_1) 0.12999999523162842)
(* (sqrt (- (* (- (* (fma -0.3333333333333333 u1 -0.5) u1) 1.0) u1))) t_1)
(* t_0 (fma (* (* u2 u2) -2.0) (* (PI) (PI)) 1.0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{-\log \left(1 - u1\right)}\\
t_1 := \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\\
\mathbf{if}\;t\_0 \cdot t\_1 \leq 0.12999999523162842:\\
\;\;\;\;\sqrt{-\left(\mathsf{fma}\left(-0.3333333333333333, u1, -0.5\right) \cdot u1 - 1\right) \cdot u1} \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \mathsf{fma}\left(\left(u2 \cdot u2\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right)\\
\end{array}
\end{array}
if (*.f32 (sqrt.f32 (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))) (cos.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2))) < 0.129999995Initial program 47.5%
lift-log.f32N/A
lift--.f32N/A
flip--N/A
log-divN/A
lower--.f32N/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
lower-log1p.f32N/A
lower-*.f32N/A
lower-neg.f32N/A
lower-log1p.f3298.7
Applied rewrites98.7%
Taylor expanded in u1 around 0
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f3297.3
Applied rewrites97.3%
if 0.129999995 < (*.f32 (sqrt.f32 (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))) (cos.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2))) Initial program 97.3%
Taylor expanded in u2 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.f3293.0
Applied rewrites93.0%
(FPCore (cosTheta_i u1 u2)
:precision binary32
(let* ((t_0 (sqrt (- (log (- 1.0 u1))))) (t_1 (cos (* (* 2.0 (PI)) u2))))
(if (<= (* t_0 t_1) 0.12999999523162842)
(* (sqrt (* (fma (fma 0.3333333333333333 u1 0.5) u1 1.0) u1)) t_1)
(* t_0 (fma (* (* u2 u2) -2.0) (* (PI) (PI)) 1.0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{-\log \left(1 - u1\right)}\\
t_1 := \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\\
\mathbf{if}\;t\_0 \cdot t\_1 \leq 0.12999999523162842:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, u1, 0.5\right), u1, 1\right) \cdot u1} \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \mathsf{fma}\left(\left(u2 \cdot u2\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right)\\
\end{array}
\end{array}
if (*.f32 (sqrt.f32 (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))) (cos.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2))) < 0.129999995Initial program 47.5%
Taylor expanded in u1 around 0
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
+-commutativeN/A
lower-fma.f3297.3
Applied rewrites97.3%
if 0.129999995 < (*.f32 (sqrt.f32 (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))) (cos.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2))) Initial program 97.3%
Taylor expanded in u2 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.f3293.0
Applied rewrites93.0%
(FPCore (cosTheta_i u1 u2)
:precision binary32
(let* ((t_0 (sqrt (- (log (- 1.0 u1))))) (t_1 (cos (* (* 2.0 (PI)) u2))))
(if (<= (* t_0 t_1) 0.07000000029802322)
(* (sqrt (* (fma 0.5 u1 1.0) u1)) t_1)
(* t_0 (fma (* (* u2 u2) -2.0) (* (PI) (PI)) 1.0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{-\log \left(1 - u1\right)}\\
t_1 := \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\\
\mathbf{if}\;t\_0 \cdot t\_1 \leq 0.07000000029802322:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(0.5, u1, 1\right) \cdot u1} \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \mathsf{fma}\left(\left(u2 \cdot u2\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right)\\
\end{array}
\end{array}
if (*.f32 (sqrt.f32 (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))) (cos.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2))) < 0.0700000003Initial program 45.0%
Taylor expanded in u1 around 0
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3296.0
Applied rewrites96.0%
if 0.0700000003 < (*.f32 (sqrt.f32 (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))) (cos.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2))) Initial program 96.1%
Taylor expanded in u2 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.f3291.7
Applied rewrites91.7%
(FPCore (cosTheta_i u1 u2)
:precision binary32
(let* ((t_0 (sqrt (- (log (- 1.0 u1))))) (t_1 (cos (* (* 2.0 (PI)) u2))))
(if (<= (* t_0 t_1) 0.07000000029802322)
(* (sqrt (* (fma 0.5 u1 1.0) u1)) t_1)
t_0)))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{-\log \left(1 - u1\right)}\\
t_1 := \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\\
\mathbf{if}\;t\_0 \cdot t\_1 \leq 0.07000000029802322:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(0.5, u1, 1\right) \cdot u1} \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (*.f32 (sqrt.f32 (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))) (cos.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2))) < 0.0700000003Initial program 45.0%
Taylor expanded in u1 around 0
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3296.0
Applied rewrites96.0%
if 0.0700000003 < (*.f32 (sqrt.f32 (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))) (cos.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2))) Initial program 96.1%
lift-neg.f32N/A
lift-log.f32N/A
neg-logN/A
lower-log.f32N/A
lower-/.f3295.1
Applied rewrites95.1%
Taylor expanded in u2 around 0
lower-sqrt.f32N/A
log-recN/A
lower-neg.f32N/A
lower-log.f32N/A
lower--.f3285.9
Applied rewrites85.9%
(FPCore (cosTheta_i u1 u2) :precision binary32 (let* ((t_0 (sqrt (- (log (- 1.0 u1))))) (t_1 (cos (* (* 2.0 (PI)) u2)))) (if (<= (* t_0 t_1) 0.02199999988079071) (* (sqrt u1) t_1) t_0)))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{-\log \left(1 - u1\right)}\\
t_1 := \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\\
\mathbf{if}\;t\_0 \cdot t\_1 \leq 0.02199999988079071:\\
\;\;\;\;\sqrt{u1} \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (*.f32 (sqrt.f32 (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))) (cos.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2))) < 0.0219999999Initial program 38.7%
lift-log.f32N/A
lift--.f32N/A
flip--N/A
log-divN/A
lower--.f32N/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
lower-log1p.f32N/A
lower-*.f32N/A
lower-neg.f32N/A
lower-log1p.f3298.6
Applied rewrites98.6%
Taylor expanded in u1 around 0
lower-sqrt.f3290.3
Applied rewrites90.3%
if 0.0219999999 < (*.f32 (sqrt.f32 (neg.f32 (log.f32 (-.f32 #s(literal 1 binary32) u1)))) (cos.f32 (*.f32 (*.f32 #s(literal 2 binary32) (PI.f32)) u2))) Initial program 91.3%
lift-neg.f32N/A
lift-log.f32N/A
neg-logN/A
lower-log.f32N/A
lower-/.f3290.0
Applied rewrites90.0%
Taylor expanded in u2 around 0
lower-sqrt.f32N/A
log-recN/A
lower-neg.f32N/A
lower-log.f32N/A
lower--.f3281.0
Applied rewrites81.0%
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (sqrt (- (log1p u1) (log1p (* (- u1) u1)))) (cos (* -2.0 (* (PI) u2)))))
\begin{array}{l}
\\
\sqrt{\mathsf{log1p}\left(u1\right) - \mathsf{log1p}\left(\left(-u1\right) \cdot u1\right)} \cdot \cos \left(-2 \cdot \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)
\end{array}
Initial program 56.8%
lift-log.f32N/A
lift--.f32N/A
flip--N/A
log-divN/A
lower--.f32N/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
lower-log1p.f32N/A
lower-*.f32N/A
lower-neg.f32N/A
lower-log1p.f3298.7
Applied rewrites98.7%
Taylor expanded in u2 around inf
*-commutativeN/A
lower-*.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
lower-log1p.f32N/A
mul-1-negN/A
lower-log1p.f32N/A
unpow2N/A
distribute-lft-neg-inN/A
lower-*.f32N/A
lower-neg.f32N/A
cos-neg-revN/A
lower-cos.f32N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f32N/A
Applied rewrites98.7%
(FPCore (cosTheta_i u1 u2)
:precision binary32
(let* ((t_0 (cos (* (* 2.0 (PI)) u2))))
(if (<= u1 0.03500000014901161)
(*
(sqrt (* (fma (fma (fma 0.25 u1 0.3333333333333333) u1 0.5) u1 1.0) u1))
t_0)
(* (sqrt (- (log (- 1.0 u1)))) t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\\
\mathbf{if}\;u1 \leq 0.03500000014901161:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.25, u1, 0.3333333333333333\right), u1, 0.5\right), u1, 1\right) \cdot u1} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{-\log \left(1 - u1\right)} \cdot t\_0\\
\end{array}
\end{array}
if u1 < 0.0350000001Initial program 47.7%
Taylor expanded in u1 around 0
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
+-commutativeN/A
lower-fma.f3298.8
Applied rewrites98.8%
if 0.0350000001 < u1 Initial program 97.3%
(FPCore (cosTheta_i u1 u2) :precision binary32 (sqrt (- (log (- 1.0 u1)))))
float code(float cosTheta_i, float u1, float u2) {
return sqrtf(-logf((1.0f - u1)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(costheta_i, u1, u2)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
code = sqrt(-log((1.0e0 - u1)))
end function
function code(cosTheta_i, u1, u2) return sqrt(Float32(-log(Float32(Float32(1.0) - u1)))) end
function tmp = code(cosTheta_i, u1, u2) tmp = sqrt(-log((single(1.0) - u1))); end
\begin{array}{l}
\\
\sqrt{-\log \left(1 - u1\right)}
\end{array}
Initial program 56.8%
lift-neg.f32N/A
lift-log.f32N/A
neg-logN/A
lower-log.f32N/A
lower-/.f3254.6
Applied rewrites54.6%
Taylor expanded in u2 around 0
lower-sqrt.f32N/A
log-recN/A
lower-neg.f32N/A
lower-log.f32N/A
lower--.f3249.5
Applied rewrites49.5%
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (- (sqrt u1)) 1.0))
float code(float cosTheta_i, float u1, float u2) {
return -sqrtf(u1) * 1.0f;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(costheta_i, u1, u2)
use fmin_fmax_functions
real(4), intent (in) :: costheta_i
real(4), intent (in) :: u1
real(4), intent (in) :: u2
code = -sqrt(u1) * 1.0e0
end function
function code(cosTheta_i, u1, u2) return Float32(Float32(-sqrt(u1)) * Float32(1.0)) end
function tmp = code(cosTheta_i, u1, u2) tmp = -sqrt(u1) * single(1.0); end
\begin{array}{l}
\\
\left(-\sqrt{u1}\right) \cdot 1
\end{array}
Initial program 56.8%
Taylor expanded in u2 around 0
Applied rewrites49.5%
Taylor expanded in u1 around 0
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f32N/A
lower-sqrt.f324.6
Applied rewrites4.6%
Taylor expanded in u1 around 0
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
mul-1-negN/A
lower-neg.f32N/A
lower-sqrt.f324.6
Applied rewrites4.6%
herbie shell --seed 2025009
(FPCore (cosTheta_i u1 u2)
:name "Beckmann Sample, near normal, slope_x"
:precision binary32
:pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0)) (and (<= 2.328306437e-10 u1) (<= u1 1.0))) (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
(* (sqrt (- (log (- 1.0 u1)))) (cos (* (* 2.0 (PI)) u2))))