
(FPCore (cosTheta c)
:precision binary32
(/
1.0
(+
(+ 1.0 c)
(*
(* (/ 1.0 (sqrt PI)) (/ (sqrt (- (- 1.0 cosTheta) cosTheta)) cosTheta))
(exp (* (- cosTheta) cosTheta))))))
float code(float cosTheta, float c) {
return 1.0f / ((1.0f + c) + (((1.0f / sqrtf(((float) M_PI))) * (sqrtf(((1.0f - cosTheta) - cosTheta)) / cosTheta)) * expf((-cosTheta * cosTheta))));
}
function code(cosTheta, c) return Float32(Float32(1.0) / Float32(Float32(Float32(1.0) + c) + Float32(Float32(Float32(Float32(1.0) / sqrt(Float32(pi))) * Float32(sqrt(Float32(Float32(Float32(1.0) - cosTheta) - cosTheta)) / cosTheta)) * exp(Float32(Float32(-cosTheta) * cosTheta))))) end
function tmp = code(cosTheta, c) tmp = single(1.0) / ((single(1.0) + c) + (((single(1.0) / sqrt(single(pi))) * (sqrt(((single(1.0) - cosTheta) - cosTheta)) / cosTheta)) * exp((-cosTheta * cosTheta)))); end
\begin{array}{l}
\\
\frac{1}{\left(1 + c\right) + \left(\frac{1}{\sqrt{\pi}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(-cosTheta\right) \cdot cosTheta}}
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (cosTheta c)
:precision binary32
(/
1.0
(+
(+ 1.0 c)
(*
(* (/ 1.0 (sqrt PI)) (/ (sqrt (- (- 1.0 cosTheta) cosTheta)) cosTheta))
(exp (* (- cosTheta) cosTheta))))))
float code(float cosTheta, float c) {
return 1.0f / ((1.0f + c) + (((1.0f / sqrtf(((float) M_PI))) * (sqrtf(((1.0f - cosTheta) - cosTheta)) / cosTheta)) * expf((-cosTheta * cosTheta))));
}
function code(cosTheta, c) return Float32(Float32(1.0) / Float32(Float32(Float32(1.0) + c) + Float32(Float32(Float32(Float32(1.0) / sqrt(Float32(pi))) * Float32(sqrt(Float32(Float32(Float32(1.0) - cosTheta) - cosTheta)) / cosTheta)) * exp(Float32(Float32(-cosTheta) * cosTheta))))) end
function tmp = code(cosTheta, c) tmp = single(1.0) / ((single(1.0) + c) + (((single(1.0) / sqrt(single(pi))) * (sqrt(((single(1.0) - cosTheta) - cosTheta)) / cosTheta)) * exp((-cosTheta * cosTheta)))); end
\begin{array}{l}
\\
\frac{1}{\left(1 + c\right) + \left(\frac{1}{\sqrt{\pi}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(-cosTheta\right) \cdot cosTheta}}
\end{array}
(FPCore (cosTheta c)
:precision binary32
(let* ((t_0
(fma
cosTheta
(+
(fma (fma cosTheta 0.5 -1.5) (/ cosTheta (sqrt PI)) c)
(/ -1.0 (sqrt PI)))
(/ 1.0 (sqrt PI)))))
(*
(/ cosTheta (fma cosTheta (* cosTheta cosTheta) (pow t_0 3.0)))
(fma cosTheta cosTheta (* t_0 (- t_0 cosTheta))))))
float code(float cosTheta, float c) {
float t_0 = fmaf(cosTheta, (fmaf(fmaf(cosTheta, 0.5f, -1.5f), (cosTheta / sqrtf(((float) M_PI))), c) + (-1.0f / sqrtf(((float) M_PI)))), (1.0f / sqrtf(((float) M_PI))));
return (cosTheta / fmaf(cosTheta, (cosTheta * cosTheta), powf(t_0, 3.0f))) * fmaf(cosTheta, cosTheta, (t_0 * (t_0 - cosTheta)));
}
function code(cosTheta, c) t_0 = fma(cosTheta, Float32(fma(fma(cosTheta, Float32(0.5), Float32(-1.5)), Float32(cosTheta / sqrt(Float32(pi))), c) + Float32(Float32(-1.0) / sqrt(Float32(pi)))), Float32(Float32(1.0) / sqrt(Float32(pi)))) return Float32(Float32(cosTheta / fma(cosTheta, Float32(cosTheta * cosTheta), (t_0 ^ Float32(3.0)))) * fma(cosTheta, cosTheta, Float32(t_0 * Float32(t_0 - cosTheta)))) end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(cosTheta, \mathsf{fma}\left(\mathsf{fma}\left(cosTheta, 0.5, -1.5\right), \frac{cosTheta}{\sqrt{\pi}}, c\right) + \frac{-1}{\sqrt{\pi}}, \frac{1}{\sqrt{\pi}}\right)\\
\frac{cosTheta}{\mathsf{fma}\left(cosTheta, cosTheta \cdot cosTheta, {t\_0}^{3}\right)} \cdot \mathsf{fma}\left(cosTheta, cosTheta, t\_0 \cdot \left(t\_0 - cosTheta\right)\right)
\end{array}
\end{array}
Initial program 97.5%
Taylor expanded in cosTheta around 0
lower-/.f32N/A
Applied rewrites97.2%
Applied rewrites98.4%
(FPCore (cosTheta c)
:precision binary32
(/
1.0
(+
(+ c 1.0)
(*
(*
(pow (cbrt PI) -1.5)
(/ (sqrt (* cosTheta (+ (/ 1.0 cosTheta) -2.0))) cosTheta))
(exp (* cosTheta (- cosTheta)))))))
float code(float cosTheta, float c) {
return 1.0f / ((c + 1.0f) + ((powf(cbrtf(((float) M_PI)), -1.5f) * (sqrtf((cosTheta * ((1.0f / cosTheta) + -2.0f))) / cosTheta)) * expf((cosTheta * -cosTheta))));
}
function code(cosTheta, c) return Float32(Float32(1.0) / Float32(Float32(c + Float32(1.0)) + Float32(Float32((cbrt(Float32(pi)) ^ Float32(-1.5)) * Float32(sqrt(Float32(cosTheta * Float32(Float32(Float32(1.0) / cosTheta) + Float32(-2.0)))) / cosTheta)) * exp(Float32(cosTheta * Float32(-cosTheta)))))) end
\begin{array}{l}
\\
\frac{1}{\left(c + 1\right) + \left({\left(\sqrt[3]{\pi}\right)}^{-1.5} \cdot \frac{\sqrt{cosTheta \cdot \left(\frac{1}{cosTheta} + -2\right)}}{cosTheta}\right) \cdot e^{cosTheta \cdot \left(-cosTheta\right)}}
\end{array}
Initial program 97.5%
lift-PI.f32N/A
pow1/2N/A
pow-flipN/A
metadata-evalN/A
metadata-evalN/A
lift-PI.f32N/A
add-cube-cbrtN/A
pow3N/A
pow-powN/A
lower-pow.f32N/A
lift-PI.f32N/A
lower-cbrt.f32N/A
metadata-evalN/A
metadata-eval97.9
Applied rewrites97.9%
Taylor expanded in cosTheta around inf
lower-*.f32N/A
sub-negN/A
metadata-evalN/A
rem-square-sqrtN/A
unpow2N/A
lower-+.f32N/A
lower-/.f32N/A
unpow2N/A
rem-square-sqrt97.9
Applied rewrites97.9%
Final simplification97.9%
(FPCore (cosTheta c)
:precision binary32
(/
1.0
(+
(+ c 1.0)
(*
(exp (* cosTheta (- cosTheta)))
(*
(pow (cbrt PI) -1.5)
(/ (sqrt (- (- 1.0 cosTheta) cosTheta)) cosTheta))))))
float code(float cosTheta, float c) {
return 1.0f / ((c + 1.0f) + (expf((cosTheta * -cosTheta)) * (powf(cbrtf(((float) M_PI)), -1.5f) * (sqrtf(((1.0f - cosTheta) - cosTheta)) / cosTheta))));
}
function code(cosTheta, c) return Float32(Float32(1.0) / Float32(Float32(c + Float32(1.0)) + Float32(exp(Float32(cosTheta * Float32(-cosTheta))) * Float32((cbrt(Float32(pi)) ^ Float32(-1.5)) * Float32(sqrt(Float32(Float32(Float32(1.0) - cosTheta) - cosTheta)) / cosTheta))))) end
\begin{array}{l}
\\
\frac{1}{\left(c + 1\right) + e^{cosTheta \cdot \left(-cosTheta\right)} \cdot \left({\left(\sqrt[3]{\pi}\right)}^{-1.5} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right)}
\end{array}
Initial program 97.5%
lift-PI.f32N/A
pow1/2N/A
pow-flipN/A
metadata-evalN/A
metadata-evalN/A
lift-PI.f32N/A
add-cube-cbrtN/A
pow3N/A
pow-powN/A
lower-pow.f32N/A
lift-PI.f32N/A
lower-cbrt.f32N/A
metadata-evalN/A
metadata-eval97.9
Applied rewrites97.9%
Final simplification97.9%
(FPCore (cosTheta c)
:precision binary32
(/
1.0
(fma
(fma
(* cosTheta cosTheta)
(fma
cosTheta
(* cosTheta (fma (* cosTheta cosTheta) -0.16666666666666666 0.5))
-1.0)
1.0)
(/ (sqrt (/ (fma cosTheta -2.0 1.0) PI)) cosTheta)
1.0)))
float code(float cosTheta, float c) {
return 1.0f / fmaf(fmaf((cosTheta * cosTheta), fmaf(cosTheta, (cosTheta * fmaf((cosTheta * cosTheta), -0.16666666666666666f, 0.5f)), -1.0f), 1.0f), (sqrtf((fmaf(cosTheta, -2.0f, 1.0f) / ((float) M_PI))) / cosTheta), 1.0f);
}
function code(cosTheta, c) return Float32(Float32(1.0) / fma(fma(Float32(cosTheta * cosTheta), fma(cosTheta, Float32(cosTheta * fma(Float32(cosTheta * cosTheta), Float32(-0.16666666666666666), Float32(0.5))), Float32(-1.0)), Float32(1.0)), Float32(sqrt(Float32(fma(cosTheta, Float32(-2.0), Float32(1.0)) / Float32(pi))) / cosTheta), Float32(1.0))) end
\begin{array}{l}
\\
\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(cosTheta, cosTheta \cdot \mathsf{fma}\left(cosTheta \cdot cosTheta, -0.16666666666666666, 0.5\right), -1\right), 1\right), \frac{\sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}}{cosTheta}, 1\right)}
\end{array}
Initial program 97.5%
Taylor expanded in c around 0
Applied rewrites97.8%
Taylor expanded in cosTheta around 0
+-commutativeN/A
lower-fma.f32N/A
unpow2N/A
lower-*.f32N/A
sub-negN/A
unpow2N/A
associate-*l*N/A
metadata-evalN/A
lower-fma.f32N/A
lower-*.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
unpow2N/A
lower-*.f3297.8
Applied rewrites97.8%
(FPCore (cosTheta c) :precision binary32 (/ 1.0 (fma (fma (* cosTheta cosTheta) (fma cosTheta (* cosTheta 0.5) -1.0) 1.0) (/ (sqrt (/ (fma cosTheta -2.0 1.0) PI)) cosTheta) 1.0)))
float code(float cosTheta, float c) {
return 1.0f / fmaf(fmaf((cosTheta * cosTheta), fmaf(cosTheta, (cosTheta * 0.5f), -1.0f), 1.0f), (sqrtf((fmaf(cosTheta, -2.0f, 1.0f) / ((float) M_PI))) / cosTheta), 1.0f);
}
function code(cosTheta, c) return Float32(Float32(1.0) / fma(fma(Float32(cosTheta * cosTheta), fma(cosTheta, Float32(cosTheta * Float32(0.5)), Float32(-1.0)), Float32(1.0)), Float32(sqrt(Float32(fma(cosTheta, Float32(-2.0), Float32(1.0)) / Float32(pi))) / cosTheta), Float32(1.0))) end
\begin{array}{l}
\\
\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(cosTheta, cosTheta \cdot 0.5, -1\right), 1\right), \frac{\sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}}{cosTheta}, 1\right)}
\end{array}
Initial program 97.5%
Taylor expanded in c around 0
Applied rewrites97.8%
Taylor expanded in cosTheta around 0
+-commutativeN/A
lower-fma.f32N/A
unpow2N/A
lower-*.f32N/A
sub-negN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f3297.7
Applied rewrites97.7%
(FPCore (cosTheta c)
:precision binary32
(/
1.0
(+
(+ c 1.0)
(/
(+ -1.0 (fma cosTheta (fma cosTheta 0.5 -1.5) (/ 1.0 cosTheta)))
(sqrt PI)))))
float code(float cosTheta, float c) {
return 1.0f / ((c + 1.0f) + ((-1.0f + fmaf(cosTheta, fmaf(cosTheta, 0.5f, -1.5f), (1.0f / cosTheta))) / sqrtf(((float) M_PI))));
}
function code(cosTheta, c) return Float32(Float32(1.0) / Float32(Float32(c + Float32(1.0)) + Float32(Float32(Float32(-1.0) + fma(cosTheta, fma(cosTheta, Float32(0.5), Float32(-1.5)), Float32(Float32(1.0) / cosTheta))) / sqrt(Float32(pi))))) end
\begin{array}{l}
\\
\frac{1}{\left(c + 1\right) + \frac{-1 + \mathsf{fma}\left(cosTheta, \mathsf{fma}\left(cosTheta, 0.5, -1.5\right), \frac{1}{cosTheta}\right)}{\sqrt{\pi}}}
\end{array}
Initial program 97.5%
Taylor expanded in cosTheta around 0
lower-/.f32N/A
Applied rewrites97.2%
Taylor expanded in c around 0
associate-+r+N/A
lower-+.f32N/A
lower-+.f32N/A
associate-+r-N/A
+-commutativeN/A
sub-negN/A
distribute-rgt-outN/A
mul-1-negN/A
lower-fma.f32N/A
Applied rewrites97.0%
Applied rewrites97.7%
Final simplification97.7%
(FPCore (cosTheta c) :precision binary32 (/ 1.0 (fma (fma cosTheta (- cosTheta) 1.0) (/ (sqrt (/ (fma cosTheta -2.0 1.0) PI)) cosTheta) 1.0)))
float code(float cosTheta, float c) {
return 1.0f / fmaf(fmaf(cosTheta, -cosTheta, 1.0f), (sqrtf((fmaf(cosTheta, -2.0f, 1.0f) / ((float) M_PI))) / cosTheta), 1.0f);
}
function code(cosTheta, c) return Float32(Float32(1.0) / fma(fma(cosTheta, Float32(-cosTheta), Float32(1.0)), Float32(sqrt(Float32(fma(cosTheta, Float32(-2.0), Float32(1.0)) / Float32(pi))) / cosTheta), Float32(1.0))) end
\begin{array}{l}
\\
\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(cosTheta, -cosTheta, 1\right), \frac{\sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}}{cosTheta}, 1\right)}
\end{array}
Initial program 97.5%
Taylor expanded in c around 0
Applied rewrites97.8%
Taylor expanded in cosTheta around 0
+-commutativeN/A
mul-1-negN/A
unpow2N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-fma.f32N/A
mul-1-negN/A
lower-neg.f3297.2
Applied rewrites97.2%
(FPCore (cosTheta c) :precision binary32 (* cosTheta (fma (fma PI (- c (sqrt (/ 1.0 PI))) PI) (- cosTheta) (sqrt PI))))
float code(float cosTheta, float c) {
return cosTheta * fmaf(fmaf(((float) M_PI), (c - sqrtf((1.0f / ((float) M_PI)))), ((float) M_PI)), -cosTheta, sqrtf(((float) M_PI)));
}
function code(cosTheta, c) return Float32(cosTheta * fma(fma(Float32(pi), Float32(c - sqrt(Float32(Float32(1.0) / Float32(pi)))), Float32(pi)), Float32(-cosTheta), sqrt(Float32(pi)))) end
\begin{array}{l}
\\
cosTheta \cdot \mathsf{fma}\left(\mathsf{fma}\left(\pi, c - \sqrt{\frac{1}{\pi}}, \pi\right), -cosTheta, \sqrt{\pi}\right)
\end{array}
Initial program 97.5%
Taylor expanded in cosTheta around 0
lower-*.f32N/A
+-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites96.4%
(FPCore (cosTheta c) :precision binary32 (/ 1.0 (fma (/ 1.0 (* cosTheta (sqrt PI))) (- 1.0 cosTheta) (+ c 1.0))))
float code(float cosTheta, float c) {
return 1.0f / fmaf((1.0f / (cosTheta * sqrtf(((float) M_PI)))), (1.0f - cosTheta), (c + 1.0f));
}
function code(cosTheta, c) return Float32(Float32(1.0) / fma(Float32(Float32(1.0) / Float32(cosTheta * sqrt(Float32(pi)))), Float32(Float32(1.0) - cosTheta), Float32(c + Float32(1.0)))) end
\begin{array}{l}
\\
\frac{1}{\mathsf{fma}\left(\frac{1}{cosTheta \cdot \sqrt{\pi}}, 1 - cosTheta, c + 1\right)}
\end{array}
Initial program 97.5%
Taylor expanded in cosTheta around 0
associate-*r*N/A
lower-/.f32N/A
mul-1-negN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
distribute-rgt-out--N/A
lower-*.f32N/A
lower-sqrt.f32N/A
lower-/.f32N/A
lower-PI.f32N/A
lower--.f3295.4
Applied rewrites95.4%
lift-+.f32N/A
lift-PI.f32N/A
lift-/.f32N/A
lift-sqrt.f32N/A
lift--.f32N/A
lift-*.f32N/A
lift-/.f32N/A
+-commutativeN/A
lift-/.f32N/A
lift-*.f32N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f32N/A
Applied rewrites95.4%
lift--.f32N/A
lift-PI.f32N/A
lift-sqrt.f32N/A
clear-numN/A
associate-/r/N/A
lift-/.f32N/A
associate-*r/N/A
div-invN/A
lift-/.f32N/A
lift-+.f32N/A
*-commutativeN/A
lower-fma.f3295.4
Applied rewrites96.0%
(FPCore (cosTheta c) :precision binary32 (/ 1.0 (+ (+ c 1.0) (/ (- 1.0 cosTheta) (* cosTheta (sqrt PI))))))
float code(float cosTheta, float c) {
return 1.0f / ((c + 1.0f) + ((1.0f - cosTheta) / (cosTheta * sqrtf(((float) M_PI)))));
}
function code(cosTheta, c) return Float32(Float32(1.0) / Float32(Float32(c + Float32(1.0)) + Float32(Float32(Float32(1.0) - cosTheta) / Float32(cosTheta * sqrt(Float32(pi)))))) end
function tmp = code(cosTheta, c) tmp = single(1.0) / ((c + single(1.0)) + ((single(1.0) - cosTheta) / (cosTheta * sqrt(single(pi))))); end
\begin{array}{l}
\\
\frac{1}{\left(c + 1\right) + \frac{1 - cosTheta}{cosTheta \cdot \sqrt{\pi}}}
\end{array}
Initial program 97.5%
Taylor expanded in cosTheta around 0
associate-*r*N/A
lower-/.f32N/A
mul-1-negN/A
cancel-sign-sub-invN/A
*-lft-identityN/A
distribute-rgt-out--N/A
lower-*.f32N/A
lower-sqrt.f32N/A
lower-/.f32N/A
lower-PI.f32N/A
lower--.f3295.4
Applied rewrites95.4%
lift-+.f32N/A
lift-PI.f32N/A
lift-/.f32N/A
lift-sqrt.f32N/A
lift--.f32N/A
lift-*.f32N/A
lift-/.f32N/A
+-commutativeN/A
lift-/.f32N/A
lift-*.f32N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f32N/A
Applied rewrites95.4%
lift--.f32N/A
lift-PI.f32N/A
lift-sqrt.f32N/A
clear-numN/A
associate-/r/N/A
lift-/.f32N/A
associate-*r/N/A
div-invN/A
lift-/.f32N/A
lift-+.f32N/A
lower-+.f32N/A
Applied rewrites96.0%
Final simplification96.0%
(FPCore (cosTheta c) :precision binary32 (/ cosTheta (fma (- 1.0 cosTheta) (sqrt (/ 1.0 PI)) cosTheta)))
float code(float cosTheta, float c) {
return cosTheta / fmaf((1.0f - cosTheta), sqrtf((1.0f / ((float) M_PI))), cosTheta);
}
function code(cosTheta, c) return Float32(cosTheta / fma(Float32(Float32(1.0) - cosTheta), sqrt(Float32(Float32(1.0) / Float32(pi))), cosTheta)) end
\begin{array}{l}
\\
\frac{cosTheta}{\mathsf{fma}\left(1 - cosTheta, \sqrt{\frac{1}{\pi}}, cosTheta\right)}
\end{array}
Initial program 97.5%
Taylor expanded in cosTheta around 0
lower-/.f32N/A
Applied rewrites97.2%
Applied rewrites97.5%
Taylor expanded in cosTheta around 0
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-sqrt.f32N/A
lower-/.f32N/A
lower-PI.f3295.7
Applied rewrites95.7%
Taylor expanded in c around 0
lower-/.f32N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt1-inN/A
+-commutativeN/A
lower-fma.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-sqrt.f32N/A
lower-/.f32N/A
lower-PI.f3295.7
Applied rewrites95.7%
(FPCore (cosTheta c) :precision binary32 (* cosTheta (sqrt PI)))
float code(float cosTheta, float c) {
return cosTheta * sqrtf(((float) M_PI));
}
function code(cosTheta, c) return Float32(cosTheta * sqrt(Float32(pi))) end
function tmp = code(cosTheta, c) tmp = cosTheta * sqrt(single(pi)); end
\begin{array}{l}
\\
cosTheta \cdot \sqrt{\pi}
\end{array}
Initial program 97.5%
Taylor expanded in cosTheta around 0
lower-*.f32N/A
lower-sqrt.f32N/A
lower-PI.f3294.1
Applied rewrites94.1%
(FPCore (cosTheta c) :precision binary32 (/ 1.0 c))
float code(float cosTheta, float c) {
return 1.0f / c;
}
real(4) function code(costheta, c)
real(4), intent (in) :: costheta
real(4), intent (in) :: c
code = 1.0e0 / c
end function
function code(cosTheta, c) return Float32(Float32(1.0) / c) end
function tmp = code(cosTheta, c) tmp = single(1.0) / c; end
\begin{array}{l}
\\
\frac{1}{c}
\end{array}
Initial program 97.5%
Taylor expanded in c around inf
lower-/.f324.9
Applied rewrites4.9%
herbie shell --seed 2024219
(FPCore (cosTheta c)
:name "Beckmann Sample, normalization factor"
:precision binary32
:pre (and (and (< 0.0 cosTheta) (< cosTheta 0.9999)) (and (< -1.0 c) (< c 1.0)))
(/ 1.0 (+ (+ 1.0 c) (* (* (/ 1.0 (sqrt PI)) (/ (sqrt (- (- 1.0 cosTheta) cosTheta)) cosTheta)) (exp (* (- cosTheta) cosTheta))))))