
(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 16 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 (/ 1.0 (fma (/ (/ (sqrt (+ 1.0 (* cosTheta -2.0))) cosTheta) (sqrt PI)) (pow (exp cosTheta) (- cosTheta)) (+ 1.0 c))))
float code(float cosTheta, float c) {
return 1.0f / fmaf(((sqrtf((1.0f + (cosTheta * -2.0f))) / cosTheta) / sqrtf(((float) M_PI))), powf(expf(cosTheta), -cosTheta), (1.0f + c));
}
function code(cosTheta, c) return Float32(Float32(1.0) / fma(Float32(Float32(sqrt(Float32(Float32(1.0) + Float32(cosTheta * Float32(-2.0)))) / cosTheta) / sqrt(Float32(pi))), (exp(cosTheta) ^ Float32(-cosTheta)), Float32(Float32(1.0) + c))) end
\begin{array}{l}
\\
\frac{1}{\mathsf{fma}\left(\frac{\frac{\sqrt{1 + cosTheta \cdot -2}}{cosTheta}}{\sqrt{\pi}}, {\left(e^{cosTheta}\right)}^{\left(-cosTheta\right)}, 1 + c\right)}
\end{array}
Initial program 98.1%
+-commutative98.1%
fma-define98.1%
associate-*l/98.7%
*-lft-identity98.7%
associate--l-98.7%
sub-neg98.7%
neg-mul-198.7%
distribute-lft-out98.7%
distribute-rgt-out98.7%
metadata-eval98.7%
distribute-lft-neg-out98.7%
distribute-rgt-neg-out98.7%
exp-prod98.7%
Simplified98.7%
(FPCore (cosTheta c)
:precision binary32
(/
1.0
(+
1.0
(fma
(/ (sqrt (+ 1.0 (* cosTheta -2.0))) (* cosTheta (sqrt PI)))
(pow (exp (- cosTheta)) cosTheta)
c))))
float code(float cosTheta, float c) {
return 1.0f / (1.0f + fmaf((sqrtf((1.0f + (cosTheta * -2.0f))) / (cosTheta * sqrtf(((float) M_PI)))), powf(expf(-cosTheta), cosTheta), c));
}
function code(cosTheta, c) return Float32(Float32(1.0) / Float32(Float32(1.0) + fma(Float32(sqrt(Float32(Float32(1.0) + Float32(cosTheta * Float32(-2.0)))) / Float32(cosTheta * sqrt(Float32(pi)))), (exp(Float32(-cosTheta)) ^ cosTheta), c))) end
\begin{array}{l}
\\
\frac{1}{1 + \mathsf{fma}\left(\frac{\sqrt{1 + cosTheta \cdot -2}}{cosTheta \cdot \sqrt{\pi}}, {\left(e^{-cosTheta}\right)}^{cosTheta}, c\right)}
\end{array}
Initial program 98.1%
associate-+l+98.1%
+-commutative98.1%
fma-define98.2%
times-frac98.7%
*-lft-identity98.7%
associate--l-98.6%
sub-neg98.6%
neg-mul-198.6%
distribute-lft-out98.6%
distribute-rgt-out98.6%
metadata-eval98.6%
exp-prod98.6%
Simplified98.6%
Final simplification98.6%
(FPCore (cosTheta c)
:precision binary32
(/
1.0
(+
1.0
(-
c
(*
(sqrt (/ (+ 1.0 (* cosTheta -2.0)) PI))
(/ (/ -1.0 (exp (* cosTheta cosTheta))) cosTheta))))))
float code(float cosTheta, float c) {
return 1.0f / (1.0f + (c - (sqrtf(((1.0f + (cosTheta * -2.0f)) / ((float) M_PI))) * ((-1.0f / expf((cosTheta * cosTheta))) / cosTheta))));
}
function code(cosTheta, c) return Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(c - Float32(sqrt(Float32(Float32(Float32(1.0) + Float32(cosTheta * Float32(-2.0))) / Float32(pi))) * Float32(Float32(Float32(-1.0) / exp(Float32(cosTheta * cosTheta))) / cosTheta))))) end
function tmp = code(cosTheta, c) tmp = single(1.0) / (single(1.0) + (c - (sqrt(((single(1.0) + (cosTheta * single(-2.0))) / single(pi))) * ((single(-1.0) / exp((cosTheta * cosTheta))) / cosTheta)))); end
\begin{array}{l}
\\
\frac{1}{1 + \left(c - \sqrt{\frac{1 + cosTheta \cdot -2}{\pi}} \cdot \frac{\frac{-1}{e^{cosTheta \cdot cosTheta}}}{cosTheta}\right)}
\end{array}
Initial program 98.1%
associate-+l+98.1%
+-commutative98.1%
fma-define98.2%
times-frac98.7%
*-lft-identity98.7%
associate--l-98.6%
sub-neg98.6%
neg-mul-198.6%
distribute-lft-out98.6%
distribute-rgt-out98.6%
metadata-eval98.6%
exp-prod98.6%
Simplified98.6%
associate-/l/98.7%
clear-num98.6%
inv-pow98.6%
+-commutative98.6%
fma-define98.6%
Applied egg-rr98.6%
unpow-198.6%
Simplified98.6%
Taylor expanded in c around 0 98.2%
mul-1-neg98.2%
exp-neg98.3%
Applied egg-rr98.3%
unpow298.3%
Applied egg-rr98.3%
Final simplification98.3%
(FPCore (cosTheta c)
:precision binary32
(/
1.0
(+
1.0
(+
c
(*
(sqrt (/ (+ 1.0 (* cosTheta -2.0)) PI))
(/ (exp (* cosTheta (- cosTheta))) cosTheta))))))
float code(float cosTheta, float c) {
return 1.0f / (1.0f + (c + (sqrtf(((1.0f + (cosTheta * -2.0f)) / ((float) M_PI))) * (expf((cosTheta * -cosTheta)) / cosTheta))));
}
function code(cosTheta, c) return Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(c + Float32(sqrt(Float32(Float32(Float32(1.0) + Float32(cosTheta * Float32(-2.0))) / Float32(pi))) * Float32(exp(Float32(cosTheta * Float32(-cosTheta))) / cosTheta))))) end
function tmp = code(cosTheta, c) tmp = single(1.0) / (single(1.0) + (c + (sqrt(((single(1.0) + (cosTheta * single(-2.0))) / single(pi))) * (exp((cosTheta * -cosTheta)) / cosTheta)))); end
\begin{array}{l}
\\
\frac{1}{1 + \left(c + \sqrt{\frac{1 + cosTheta \cdot -2}{\pi}} \cdot \frac{e^{cosTheta \cdot \left(-cosTheta\right)}}{cosTheta}\right)}
\end{array}
Initial program 98.1%
associate-+l+98.1%
+-commutative98.1%
fma-define98.2%
times-frac98.7%
*-lft-identity98.7%
associate--l-98.6%
sub-neg98.6%
neg-mul-198.6%
distribute-lft-out98.6%
distribute-rgt-out98.6%
metadata-eval98.6%
exp-prod98.6%
Simplified98.6%
associate-/l/98.7%
clear-num98.6%
inv-pow98.6%
+-commutative98.6%
fma-define98.6%
Applied egg-rr98.6%
unpow-198.6%
Simplified98.6%
Taylor expanded in c around 0 98.2%
unpow298.3%
Applied egg-rr98.2%
Final simplification98.2%
(FPCore (cosTheta c)
:precision binary32
(/
1.0
(+
1.0
(+
c
(*
(sqrt (/ (+ 1.0 (* cosTheta -2.0)) PI))
(/ (- 1.0 (pow cosTheta 2.0)) cosTheta))))))
float code(float cosTheta, float c) {
return 1.0f / (1.0f + (c + (sqrtf(((1.0f + (cosTheta * -2.0f)) / ((float) M_PI))) * ((1.0f - powf(cosTheta, 2.0f)) / cosTheta))));
}
function code(cosTheta, c) return Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(c + Float32(sqrt(Float32(Float32(Float32(1.0) + Float32(cosTheta * Float32(-2.0))) / Float32(pi))) * Float32(Float32(Float32(1.0) - (cosTheta ^ Float32(2.0))) / cosTheta))))) end
function tmp = code(cosTheta, c) tmp = single(1.0) / (single(1.0) + (c + (sqrt(((single(1.0) + (cosTheta * single(-2.0))) / single(pi))) * ((single(1.0) - (cosTheta ^ single(2.0))) / cosTheta)))); end
\begin{array}{l}
\\
\frac{1}{1 + \left(c + \sqrt{\frac{1 + cosTheta \cdot -2}{\pi}} \cdot \frac{1 - {cosTheta}^{2}}{cosTheta}\right)}
\end{array}
Initial program 98.1%
+-commutative98.1%
fma-define98.1%
associate-*l/98.7%
*-lft-identity98.7%
associate--l-98.7%
sub-neg98.7%
neg-mul-198.7%
distribute-lft-out98.7%
distribute-rgt-out98.7%
metadata-eval98.7%
distribute-lft-neg-out98.7%
distribute-rgt-neg-out98.7%
exp-prod98.7%
Simplified98.7%
Taylor expanded in cosTheta around 0 97.7%
mul-1-neg97.7%
unsub-neg97.7%
Simplified97.7%
Taylor expanded in c around 0 97.3%
Final simplification97.3%
(FPCore (cosTheta c)
:precision binary32
(/
1.0
(+
1.0
(*
(sqrt (/ (+ 1.0 (* cosTheta -2.0)) PI))
(/ (- 1.0 (pow cosTheta 2.0)) cosTheta)))))
float code(float cosTheta, float c) {
return 1.0f / (1.0f + (sqrtf(((1.0f + (cosTheta * -2.0f)) / ((float) M_PI))) * ((1.0f - powf(cosTheta, 2.0f)) / cosTheta)));
}
function code(cosTheta, c) return Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(sqrt(Float32(Float32(Float32(1.0) + Float32(cosTheta * Float32(-2.0))) / Float32(pi))) * Float32(Float32(Float32(1.0) - (cosTheta ^ Float32(2.0))) / cosTheta)))) end
function tmp = code(cosTheta, c) tmp = single(1.0) / (single(1.0) + (sqrt(((single(1.0) + (cosTheta * single(-2.0))) / single(pi))) * ((single(1.0) - (cosTheta ^ single(2.0))) / cosTheta))); end
\begin{array}{l}
\\
\frac{1}{1 + \sqrt{\frac{1 + cosTheta \cdot -2}{\pi}} \cdot \frac{1 - {cosTheta}^{2}}{cosTheta}}
\end{array}
Initial program 98.1%
+-commutative98.1%
fma-define98.1%
associate-*l/98.7%
*-lft-identity98.7%
associate--l-98.7%
sub-neg98.7%
neg-mul-198.7%
distribute-lft-out98.7%
distribute-rgt-out98.7%
metadata-eval98.7%
distribute-lft-neg-out98.7%
distribute-rgt-neg-out98.7%
exp-prod98.7%
Simplified98.7%
Taylor expanded in cosTheta around 0 97.7%
mul-1-neg97.7%
unsub-neg97.7%
Simplified97.7%
Taylor expanded in c around 0 97.1%
Final simplification97.1%
(FPCore (cosTheta c) :precision binary32 (* cosTheta (+ (sqrt PI) (* (* cosTheta PI) (+ (sqrt (/ 1.0 PI)) (- -1.0 c))))))
float code(float cosTheta, float c) {
return cosTheta * (sqrtf(((float) M_PI)) + ((cosTheta * ((float) M_PI)) * (sqrtf((1.0f / ((float) M_PI))) + (-1.0f - c))));
}
function code(cosTheta, c) return Float32(cosTheta * Float32(sqrt(Float32(pi)) + Float32(Float32(cosTheta * Float32(pi)) * Float32(sqrt(Float32(Float32(1.0) / Float32(pi))) + Float32(Float32(-1.0) - c))))) end
function tmp = code(cosTheta, c) tmp = cosTheta * (sqrt(single(pi)) + ((cosTheta * single(pi)) * (sqrt((single(1.0) / single(pi))) + (single(-1.0) - c)))); end
\begin{array}{l}
\\
cosTheta \cdot \left(\sqrt{\pi} + \left(cosTheta \cdot \pi\right) \cdot \left(\sqrt{\frac{1}{\pi}} + \left(-1 - c\right)\right)\right)
\end{array}
Initial program 98.1%
associate-+l+98.1%
+-commutative98.1%
fma-define98.2%
times-frac98.7%
*-lft-identity98.7%
associate--l-98.6%
sub-neg98.6%
neg-mul-198.6%
distribute-lft-out98.6%
distribute-rgt-out98.6%
metadata-eval98.6%
exp-prod98.6%
Simplified98.6%
associate-/l/98.7%
clear-num98.6%
inv-pow98.6%
+-commutative98.6%
fma-define98.6%
Applied egg-rr98.6%
unpow-198.6%
Simplified98.6%
Taylor expanded in cosTheta around 0 96.1%
mul-1-neg96.1%
unsub-neg96.1%
associate-*r*96.1%
associate-+r+96.1%
mul-1-neg96.1%
unsub-neg96.1%
Simplified96.1%
Final simplification96.1%
(FPCore (cosTheta c) :precision binary32 (* cosTheta (+ (sqrt PI) (* (* cosTheta PI) (+ -1.0 (- (sqrt (/ 1.0 PI)) c))))))
float code(float cosTheta, float c) {
return cosTheta * (sqrtf(((float) M_PI)) + ((cosTheta * ((float) M_PI)) * (-1.0f + (sqrtf((1.0f / ((float) M_PI))) - c))));
}
function code(cosTheta, c) return Float32(cosTheta * Float32(sqrt(Float32(pi)) + Float32(Float32(cosTheta * Float32(pi)) * Float32(Float32(-1.0) + Float32(sqrt(Float32(Float32(1.0) / Float32(pi))) - c))))) end
function tmp = code(cosTheta, c) tmp = cosTheta * (sqrt(single(pi)) + ((cosTheta * single(pi)) * (single(-1.0) + (sqrt((single(1.0) / single(pi))) - c)))); end
\begin{array}{l}
\\
cosTheta \cdot \left(\sqrt{\pi} + \left(cosTheta \cdot \pi\right) \cdot \left(-1 + \left(\sqrt{\frac{1}{\pi}} - c\right)\right)\right)
\end{array}
Initial program 98.1%
associate-+l+98.1%
+-commutative98.1%
fma-define98.2%
times-frac98.7%
*-lft-identity98.7%
associate--l-98.6%
sub-neg98.6%
neg-mul-198.6%
distribute-lft-out98.6%
distribute-rgt-out98.6%
metadata-eval98.6%
exp-prod98.6%
Simplified98.6%
Taylor expanded in cosTheta around 0 96.1%
mul-1-neg96.1%
unsub-neg96.1%
associate-*r*96.1%
mul-1-neg96.1%
unsub-neg96.1%
Simplified96.1%
Final simplification96.1%
(FPCore (cosTheta c) :precision binary32 (* cosTheta (+ (sqrt PI) (* (* cosTheta PI) (+ -1.0 (sqrt (/ 1.0 PI)))))))
float code(float cosTheta, float c) {
return cosTheta * (sqrtf(((float) M_PI)) + ((cosTheta * ((float) M_PI)) * (-1.0f + sqrtf((1.0f / ((float) M_PI))))));
}
function code(cosTheta, c) return Float32(cosTheta * Float32(sqrt(Float32(pi)) + Float32(Float32(cosTheta * Float32(pi)) * Float32(Float32(-1.0) + sqrt(Float32(Float32(1.0) / Float32(pi))))))) end
function tmp = code(cosTheta, c) tmp = cosTheta * (sqrt(single(pi)) + ((cosTheta * single(pi)) * (single(-1.0) + sqrt((single(1.0) / single(pi)))))); end
\begin{array}{l}
\\
cosTheta \cdot \left(\sqrt{\pi} + \left(cosTheta \cdot \pi\right) \cdot \left(-1 + \sqrt{\frac{1}{\pi}}\right)\right)
\end{array}
Initial program 98.1%
associate-+l+98.1%
+-commutative98.1%
fma-define98.2%
times-frac98.7%
*-lft-identity98.7%
associate--l-98.6%
sub-neg98.6%
neg-mul-198.6%
distribute-lft-out98.6%
distribute-rgt-out98.6%
metadata-eval98.6%
exp-prod98.6%
Simplified98.6%
associate-/l/98.7%
clear-num98.6%
inv-pow98.6%
+-commutative98.6%
fma-define98.6%
Applied egg-rr98.6%
unpow-198.6%
Simplified98.6%
Taylor expanded in cosTheta around 0 96.1%
mul-1-neg96.1%
unsub-neg96.1%
associate-*r*96.1%
associate-+r+96.1%
mul-1-neg96.1%
unsub-neg96.1%
Simplified96.1%
Taylor expanded in c around 0 96.1%
Final simplification96.1%
(FPCore (cosTheta c) :precision binary32 (/ 1.0 (- 1.0 (- (* (sqrt (/ (+ 1.0 (* cosTheta -2.0)) PI)) (/ -1.0 cosTheta)) c))))
float code(float cosTheta, float c) {
return 1.0f / (1.0f - ((sqrtf(((1.0f + (cosTheta * -2.0f)) / ((float) M_PI))) * (-1.0f / cosTheta)) - c));
}
function code(cosTheta, c) return Float32(Float32(1.0) / Float32(Float32(1.0) - Float32(Float32(sqrt(Float32(Float32(Float32(1.0) + Float32(cosTheta * Float32(-2.0))) / Float32(pi))) * Float32(Float32(-1.0) / cosTheta)) - c))) end
function tmp = code(cosTheta, c) tmp = single(1.0) / (single(1.0) - ((sqrt(((single(1.0) + (cosTheta * single(-2.0))) / single(pi))) * (single(-1.0) / cosTheta)) - c)); end
\begin{array}{l}
\\
\frac{1}{1 - \left(\sqrt{\frac{1 + cosTheta \cdot -2}{\pi}} \cdot \frac{-1}{cosTheta} - c\right)}
\end{array}
Initial program 98.1%
associate-+l+98.1%
+-commutative98.1%
fma-define98.2%
times-frac98.7%
*-lft-identity98.7%
associate--l-98.6%
sub-neg98.6%
neg-mul-198.6%
distribute-lft-out98.6%
distribute-rgt-out98.6%
metadata-eval98.6%
exp-prod98.6%
Simplified98.6%
associate-/l/98.7%
clear-num98.6%
inv-pow98.6%
+-commutative98.6%
fma-define98.6%
Applied egg-rr98.6%
unpow-198.6%
Simplified98.6%
Taylor expanded in c around 0 98.2%
Taylor expanded in cosTheta around 0 95.7%
Final simplification95.7%
(FPCore (cosTheta c) :precision binary32 (/ 1.0 (- 1.0 (- (* (sqrt (/ 1.0 PI)) (- (/ -1.0 cosTheta) -1.0)) c))))
float code(float cosTheta, float c) {
return 1.0f / (1.0f - ((sqrtf((1.0f / ((float) M_PI))) * ((-1.0f / cosTheta) - -1.0f)) - c));
}
function code(cosTheta, c) return Float32(Float32(1.0) / Float32(Float32(1.0) - Float32(Float32(sqrt(Float32(Float32(1.0) / Float32(pi))) * Float32(Float32(Float32(-1.0) / cosTheta) - Float32(-1.0))) - c))) end
function tmp = code(cosTheta, c) tmp = single(1.0) / (single(1.0) - ((sqrt((single(1.0) / single(pi))) * ((single(-1.0) / cosTheta) - single(-1.0))) - c)); end
\begin{array}{l}
\\
\frac{1}{1 - \left(\sqrt{\frac{1}{\pi}} \cdot \left(\frac{-1}{cosTheta} - -1\right) - c\right)}
\end{array}
Initial program 98.1%
associate-+l+98.1%
+-commutative98.1%
fma-define98.2%
times-frac98.7%
*-lft-identity98.7%
associate--l-98.6%
sub-neg98.6%
neg-mul-198.6%
distribute-lft-out98.6%
distribute-rgt-out98.6%
metadata-eval98.6%
exp-prod98.6%
Simplified98.6%
associate-/l/98.7%
clear-num98.6%
inv-pow98.6%
+-commutative98.6%
fma-define98.6%
Applied egg-rr98.6%
unpow-198.6%
Simplified98.6%
Taylor expanded in cosTheta around 0 95.5%
mul-1-neg95.5%
unsub-neg95.5%
Simplified95.5%
Taylor expanded in cosTheta around inf 95.5%
associate--l+95.5%
sub-neg95.5%
mul-1-neg95.5%
+-commutative95.5%
distribute-rgt-out95.4%
Simplified95.4%
Final simplification95.4%
(FPCore (cosTheta c) :precision binary32 (/ 1.0 (+ 1.0 (* (sqrt (/ 1.0 PI)) (+ -1.0 (/ 1.0 cosTheta))))))
float code(float cosTheta, float c) {
return 1.0f / (1.0f + (sqrtf((1.0f / ((float) M_PI))) * (-1.0f + (1.0f / cosTheta))));
}
function code(cosTheta, c) return Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(sqrt(Float32(Float32(1.0) / Float32(pi))) * Float32(Float32(-1.0) + Float32(Float32(1.0) / cosTheta))))) end
function tmp = code(cosTheta, c) tmp = single(1.0) / (single(1.0) + (sqrt((single(1.0) / single(pi))) * (single(-1.0) + (single(1.0) / cosTheta)))); end
\begin{array}{l}
\\
\frac{1}{1 + \sqrt{\frac{1}{\pi}} \cdot \left(-1 + \frac{1}{cosTheta}\right)}
\end{array}
Initial program 98.1%
associate-+l+98.1%
+-commutative98.1%
fma-define98.2%
times-frac98.7%
*-lft-identity98.7%
associate--l-98.6%
sub-neg98.6%
neg-mul-198.6%
distribute-lft-out98.6%
distribute-rgt-out98.6%
metadata-eval98.6%
exp-prod98.6%
Simplified98.6%
associate-/l/98.7%
clear-num98.6%
inv-pow98.6%
+-commutative98.6%
fma-define98.6%
Applied egg-rr98.6%
unpow-198.6%
Simplified98.6%
Taylor expanded in cosTheta around 0 95.5%
mul-1-neg95.5%
unsub-neg95.5%
Simplified95.5%
Taylor expanded in c around 0 95.4%
associate--l+95.4%
sub-neg95.4%
mul-1-neg95.4%
+-commutative95.4%
distribute-rgt-out95.4%
Simplified95.4%
(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 98.1%
associate-+l+98.1%
+-commutative98.1%
fma-define98.2%
times-frac98.7%
*-lft-identity98.7%
associate--l-98.6%
sub-neg98.6%
neg-mul-198.6%
distribute-lft-out98.6%
distribute-rgt-out98.6%
metadata-eval98.6%
exp-prod98.6%
Simplified98.6%
associate-/l/98.7%
clear-num98.6%
inv-pow98.6%
+-commutative98.6%
fma-define98.6%
Applied egg-rr98.6%
unpow-198.6%
Simplified98.6%
Taylor expanded in c around 0 98.2%
Taylor expanded in cosTheta around 0 93.8%
(FPCore (cosTheta c) :precision binary32 (/ 1.0 (* c (- 1.0 (/ -1.0 c)))))
float code(float cosTheta, float c) {
return 1.0f / (c * (1.0f - (-1.0f / c)));
}
real(4) function code(costheta, c)
real(4), intent (in) :: costheta
real(4), intent (in) :: c
code = 1.0e0 / (c * (1.0e0 - ((-1.0e0) / c)))
end function
function code(cosTheta, c) return Float32(Float32(1.0) / Float32(c * Float32(Float32(1.0) - Float32(Float32(-1.0) / c)))) end
function tmp = code(cosTheta, c) tmp = single(1.0) / (c * (single(1.0) - (single(-1.0) / c))); end
\begin{array}{l}
\\
\frac{1}{c \cdot \left(1 - \frac{-1}{c}\right)}
\end{array}
Initial program 98.1%
associate-+l+98.1%
+-commutative98.1%
fma-define98.2%
times-frac98.7%
*-lft-identity98.7%
associate--l-98.6%
sub-neg98.6%
neg-mul-198.6%
distribute-lft-out98.6%
distribute-rgt-out98.6%
metadata-eval98.6%
exp-prod98.6%
Simplified98.6%
associate-/l/98.7%
clear-num98.6%
inv-pow98.6%
+-commutative98.6%
fma-define98.6%
Applied egg-rr98.6%
unpow-198.6%
Simplified98.6%
Taylor expanded in cosTheta around 0 93.2%
Taylor expanded in cosTheta around inf 10.6%
Taylor expanded in c around inf 10.6%
Final simplification10.6%
(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}
\\
1 - c
\end{array}
Initial program 98.1%
associate-+l+98.1%
+-commutative98.1%
fma-define98.2%
times-frac98.7%
*-lft-identity98.7%
associate--l-98.6%
sub-neg98.6%
neg-mul-198.6%
distribute-lft-out98.6%
distribute-rgt-out98.6%
metadata-eval98.6%
exp-prod98.6%
Simplified98.6%
associate-/l/98.7%
clear-num98.6%
inv-pow98.6%
+-commutative98.6%
fma-define98.6%
Applied egg-rr98.6%
unpow-198.6%
Simplified98.6%
Taylor expanded in cosTheta around 0 93.2%
Taylor expanded in cosTheta around inf 10.6%
Taylor expanded in c around 0 10.6%
mul-1-neg10.6%
unsub-neg10.6%
Simplified10.6%
(FPCore (cosTheta c) :precision binary32 1.0)
float code(float cosTheta, float c) {
return 1.0f;
}
real(4) function code(costheta, c)
real(4), intent (in) :: costheta
real(4), intent (in) :: c
code = 1.0e0
end function
function code(cosTheta, c) return Float32(1.0) end
function tmp = code(cosTheta, c) tmp = single(1.0); end
\begin{array}{l}
\\
1
\end{array}
Initial program 98.1%
associate-+l+98.1%
+-commutative98.1%
fma-define98.2%
times-frac98.7%
*-lft-identity98.7%
associate--l-98.6%
sub-neg98.6%
neg-mul-198.6%
distribute-lft-out98.6%
distribute-rgt-out98.6%
metadata-eval98.6%
exp-prod98.6%
Simplified98.6%
associate-/l/98.7%
clear-num98.6%
inv-pow98.6%
+-commutative98.6%
fma-define98.6%
Applied egg-rr98.6%
unpow-198.6%
Simplified98.6%
Taylor expanded in cosTheta around 0 93.2%
Taylor expanded in cosTheta around inf 10.6%
Taylor expanded in c around 0 10.6%
herbie shell --seed 2024110
(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))))))