
(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
(/
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.1%
Simplified98.7%
Final simplification98.7%
(FPCore (cosTheta c)
:precision binary32
(/
1.0
(+
1.0
(+
c
(/
(*
(exp (- (pow cosTheta 2.0)))
(sqrt (* cosTheta (- (/ (/ 1.0 PI) cosTheta) (/ 2.0 PI)))))
cosTheta)))))
float code(float cosTheta, float c) {
return 1.0f / (1.0f + (c + ((expf(-powf(cosTheta, 2.0f)) * sqrtf((cosTheta * (((1.0f / ((float) M_PI)) / cosTheta) - (2.0f / ((float) M_PI)))))) / cosTheta)));
}
function code(cosTheta, c) return Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(c + Float32(Float32(exp(Float32(-(cosTheta ^ Float32(2.0)))) * sqrt(Float32(cosTheta * Float32(Float32(Float32(Float32(1.0) / Float32(pi)) / cosTheta) - Float32(Float32(2.0) / Float32(pi)))))) / cosTheta)))) end
function tmp = code(cosTheta, c) tmp = single(1.0) / (single(1.0) + (c + ((exp(-(cosTheta ^ single(2.0))) * sqrt((cosTheta * (((single(1.0) / single(pi)) / cosTheta) - (single(2.0) / single(pi)))))) / cosTheta))); end
\begin{array}{l}
\\
\frac{1}{1 + \left(c + \frac{e^{-{cosTheta}^{2}} \cdot \sqrt{cosTheta \cdot \left(\frac{\frac{1}{\pi}}{cosTheta} - \frac{2}{\pi}\right)}}{cosTheta}\right)}
\end{array}
Initial program 98.1%
+-commutative98.1%
fma-define98.1%
associate-*l/98.5%
*-lft-identity98.5%
associate--l-98.4%
sub-neg98.4%
neg-mul-198.4%
distribute-lft-out98.4%
distribute-rgt-out98.4%
metadata-eval98.4%
distribute-lft-neg-out98.4%
distribute-rgt-neg-out98.4%
exp-prod98.4%
Simplified98.4%
Taylor expanded in c around 0 98.2%
associate-*l/98.2%
mul-1-neg98.2%
+-commutative98.2%
fma-define98.2%
Applied egg-rr98.2%
Taylor expanded in cosTheta around inf 98.2%
associate-/l/98.2%
associate-*r/98.2%
metadata-eval98.2%
Simplified98.2%
(FPCore (cosTheta c)
:precision binary32
(/
1.0
(+
1.0
(+
c
(/
(*
(exp (- (pow cosTheta 2.0)))
(sqrt (+ (/ 1.0 PI) (* -2.0 (/ cosTheta PI)))))
cosTheta)))))
float code(float cosTheta, float c) {
return 1.0f / (1.0f + (c + ((expf(-powf(cosTheta, 2.0f)) * sqrtf(((1.0f / ((float) M_PI)) + (-2.0f * (cosTheta / ((float) M_PI)))))) / cosTheta)));
}
function code(cosTheta, c) return Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(c + Float32(Float32(exp(Float32(-(cosTheta ^ Float32(2.0)))) * sqrt(Float32(Float32(Float32(1.0) / Float32(pi)) + Float32(Float32(-2.0) * Float32(cosTheta / Float32(pi)))))) / cosTheta)))) end
function tmp = code(cosTheta, c) tmp = single(1.0) / (single(1.0) + (c + ((exp(-(cosTheta ^ single(2.0))) * sqrt(((single(1.0) / single(pi)) + (single(-2.0) * (cosTheta / single(pi)))))) / cosTheta))); end
\begin{array}{l}
\\
\frac{1}{1 + \left(c + \frac{e^{-{cosTheta}^{2}} \cdot \sqrt{\frac{1}{\pi} + -2 \cdot \frac{cosTheta}{\pi}}}{cosTheta}\right)}
\end{array}
Initial program 98.1%
+-commutative98.1%
fma-define98.1%
associate-*l/98.5%
*-lft-identity98.5%
associate--l-98.4%
sub-neg98.4%
neg-mul-198.4%
distribute-lft-out98.4%
distribute-rgt-out98.4%
metadata-eval98.4%
distribute-lft-neg-out98.4%
distribute-rgt-neg-out98.4%
exp-prod98.4%
Simplified98.4%
Taylor expanded in c around 0 98.2%
associate-*l/98.2%
mul-1-neg98.2%
+-commutative98.2%
fma-define98.2%
Applied egg-rr98.2%
Taylor expanded in cosTheta around 0 98.2%
Final simplification98.2%
(FPCore (cosTheta c)
:precision binary32
(/
1.0
(+
1.0
(+
c
(*
(sqrt (/ (+ 1.0 (* cosTheta -2.0)) PI))
(/ (exp (- (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))) * (expf(-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(exp(Float32(-(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))) * (exp(-(cosTheta ^ single(2.0))) / cosTheta)))); end
\begin{array}{l}
\\
\frac{1}{1 + \left(c + \sqrt{\frac{1 + cosTheta \cdot -2}{\pi}} \cdot \frac{e^{-{cosTheta}^{2}}}{cosTheta}\right)}
\end{array}
Initial program 98.1%
+-commutative98.1%
fma-define98.1%
associate-*l/98.5%
*-lft-identity98.5%
associate--l-98.4%
sub-neg98.4%
neg-mul-198.4%
distribute-lft-out98.4%
distribute-rgt-out98.4%
metadata-eval98.4%
distribute-lft-neg-out98.4%
distribute-rgt-neg-out98.4%
exp-prod98.4%
Simplified98.4%
Taylor expanded in c around 0 98.2%
Final simplification98.2%
(FPCore (cosTheta c)
:precision binary32
(/
1.0
(+
1.0
(*
(sqrt (/ (+ 1.0 (* cosTheta -2.0)) PI))
(/ (exp (- (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))) * (expf(-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(exp(Float32(-(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))) * (exp(-(cosTheta ^ single(2.0))) / cosTheta))); end
\begin{array}{l}
\\
\frac{1}{1 + \sqrt{\frac{1 + cosTheta \cdot -2}{\pi}} \cdot \frac{e^{-{cosTheta}^{2}}}{cosTheta}}
\end{array}
Initial program 98.1%
+-commutative98.1%
fma-define98.1%
associate-*l/98.5%
*-lft-identity98.5%
associate--l-98.4%
sub-neg98.4%
neg-mul-198.4%
distribute-lft-out98.4%
distribute-rgt-out98.4%
metadata-eval98.4%
distribute-lft-neg-out98.4%
distribute-rgt-neg-out98.4%
exp-prod98.4%
Simplified98.4%
Taylor expanded in c around 0 98.2%
associate-*l/98.2%
mul-1-neg98.2%
+-commutative98.2%
fma-define98.2%
Applied egg-rr98.2%
Taylor expanded in c around 0 97.9%
Final simplification97.9%
(FPCore (cosTheta c) :precision binary32 (* cosTheta (+ (sqrt PI) (* (* cosTheta PI) (- (pow PI -0.5) (+ 1.0 c))))))
float code(float cosTheta, float c) {
return cosTheta * (sqrtf(((float) M_PI)) + ((cosTheta * ((float) M_PI)) * (powf(((float) M_PI), -0.5f) - (1.0f + c))));
}
function code(cosTheta, c) return Float32(cosTheta * Float32(sqrt(Float32(pi)) + Float32(Float32(cosTheta * Float32(pi)) * Float32((Float32(pi) ^ Float32(-0.5)) - Float32(Float32(1.0) + c))))) end
function tmp = code(cosTheta, c) tmp = cosTheta * (sqrt(single(pi)) + ((cosTheta * single(pi)) * ((single(pi) ^ single(-0.5)) - (single(1.0) + c)))); end
\begin{array}{l}
\\
cosTheta \cdot \left(\sqrt{\pi} + \left(cosTheta \cdot \pi\right) \cdot \left({\pi}^{-0.5} - \left(1 + c\right)\right)\right)
\end{array}
Initial program 98.1%
+-commutative98.1%
fma-define98.1%
associate-*l/98.5%
*-lft-identity98.5%
associate--l-98.4%
sub-neg98.4%
neg-mul-198.4%
distribute-lft-out98.4%
distribute-rgt-out98.4%
metadata-eval98.4%
distribute-lft-neg-out98.4%
distribute-rgt-neg-out98.4%
exp-prod98.4%
Simplified98.4%
Taylor expanded in c around 0 98.2%
Taylor expanded in cosTheta around 0 96.8%
mul-1-neg96.8%
unsub-neg96.8%
associate-*r*96.8%
*-commutative96.8%
associate-+r+96.8%
mul-1-neg96.8%
unsub-neg96.8%
Simplified96.8%
*-un-lft-identity96.8%
pow1/296.8%
inv-pow96.8%
pow-pow96.8%
metadata-eval96.8%
Applied egg-rr96.8%
*-lft-identity96.8%
Simplified96.8%
Final simplification96.8%
(FPCore (cosTheta c) :precision binary32 (* cosTheta (+ (sqrt PI) (* (* cosTheta PI) (+ -1.0 (pow PI -0.5))))))
float code(float cosTheta, float c) {
return cosTheta * (sqrtf(((float) M_PI)) + ((cosTheta * ((float) M_PI)) * (-1.0f + powf(((float) M_PI), -0.5f))));
}
function code(cosTheta, c) return Float32(cosTheta * Float32(sqrt(Float32(pi)) + Float32(Float32(cosTheta * Float32(pi)) * Float32(Float32(-1.0) + (Float32(pi) ^ Float32(-0.5)))))) end
function tmp = code(cosTheta, c) tmp = cosTheta * (sqrt(single(pi)) + ((cosTheta * single(pi)) * (single(-1.0) + (single(pi) ^ single(-0.5))))); end
\begin{array}{l}
\\
cosTheta \cdot \left(\sqrt{\pi} + \left(cosTheta \cdot \pi\right) \cdot \left(-1 + {\pi}^{-0.5}\right)\right)
\end{array}
Initial program 98.1%
+-commutative98.1%
fma-define98.1%
associate-*l/98.5%
*-lft-identity98.5%
associate--l-98.4%
sub-neg98.4%
neg-mul-198.4%
distribute-lft-out98.4%
distribute-rgt-out98.4%
metadata-eval98.4%
distribute-lft-neg-out98.4%
distribute-rgt-neg-out98.4%
exp-prod98.4%
Simplified98.4%
Taylor expanded in c around 0 98.2%
Taylor expanded in cosTheta around 0 96.8%
mul-1-neg96.8%
unsub-neg96.8%
associate-*r*96.8%
*-commutative96.8%
associate-+r+96.8%
mul-1-neg96.8%
unsub-neg96.8%
Simplified96.8%
Taylor expanded in c around 0 96.7%
*-un-lft-identity96.8%
pow1/296.8%
inv-pow96.8%
pow-pow96.8%
metadata-eval96.8%
Applied egg-rr96.7%
*-lft-identity96.8%
Simplified96.7%
Final simplification96.7%
(FPCore (cosTheta c) :precision binary32 (/ 1.0 (+ 1.0 (+ c (/ (* (- 1.0 cosTheta) (sqrt (/ 1.0 PI))) cosTheta)))))
float code(float cosTheta, float c) {
return 1.0f / (1.0f + (c + (((1.0f - cosTheta) * sqrtf((1.0f / ((float) M_PI)))) / cosTheta)));
}
function code(cosTheta, c) return Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(c + Float32(Float32(Float32(Float32(1.0) - cosTheta) * sqrt(Float32(Float32(1.0) / Float32(pi)))) / cosTheta)))) end
function tmp = code(cosTheta, c) tmp = single(1.0) / (single(1.0) + (c + (((single(1.0) - cosTheta) * sqrt((single(1.0) / single(pi)))) / cosTheta))); end
\begin{array}{l}
\\
\frac{1}{1 + \left(c + \frac{\left(1 - cosTheta\right) \cdot \sqrt{\frac{1}{\pi}}}{cosTheta}\right)}
\end{array}
Initial program 98.1%
+-commutative98.1%
fma-define98.1%
associate-*l/98.5%
*-lft-identity98.5%
associate--l-98.4%
sub-neg98.4%
neg-mul-198.4%
distribute-lft-out98.4%
distribute-rgt-out98.4%
metadata-eval98.4%
distribute-lft-neg-out98.4%
distribute-rgt-neg-out98.4%
exp-prod98.4%
Simplified98.4%
Taylor expanded in c around 0 98.2%
associate-*l/98.2%
mul-1-neg98.2%
+-commutative98.2%
fma-define98.2%
Applied egg-rr98.2%
Taylor expanded in cosTheta around inf 98.2%
associate-/l/98.2%
associate-*r/98.2%
metadata-eval98.2%
Simplified98.2%
Taylor expanded in cosTheta around 0 96.2%
associate-*r*96.2%
distribute-rgt1-in96.2%
neg-mul-196.2%
Simplified96.2%
Final simplification96.2%
(FPCore (cosTheta c) :precision binary32 (/ 1.0 (- 1.0 (* (/ (pow PI -0.5) cosTheta) (+ cosTheta -1.0)))))
float code(float cosTheta, float c) {
return 1.0f / (1.0f - ((powf(((float) M_PI), -0.5f) / cosTheta) * (cosTheta + -1.0f)));
}
function code(cosTheta, c) return Float32(Float32(1.0) / Float32(Float32(1.0) - Float32(Float32((Float32(pi) ^ Float32(-0.5)) / cosTheta) * Float32(cosTheta + Float32(-1.0))))) end
function tmp = code(cosTheta, c) tmp = single(1.0) / (single(1.0) - (((single(pi) ^ single(-0.5)) / cosTheta) * (cosTheta + single(-1.0)))); end
\begin{array}{l}
\\
\frac{1}{1 - \frac{{\pi}^{-0.5}}{cosTheta} \cdot \left(cosTheta + -1\right)}
\end{array}
Initial program 98.1%
+-commutative98.1%
fma-define98.1%
associate-*l/98.5%
*-lft-identity98.5%
associate--l-98.4%
sub-neg98.4%
neg-mul-198.4%
distribute-lft-out98.4%
distribute-rgt-out98.4%
metadata-eval98.4%
distribute-lft-neg-out98.4%
distribute-rgt-neg-out98.4%
exp-prod98.4%
Simplified98.4%
Taylor expanded in c around 0 98.2%
associate-*l/98.2%
mul-1-neg98.2%
+-commutative98.2%
fma-define98.2%
Applied egg-rr98.2%
Taylor expanded in c around 0 97.9%
Taylor expanded in cosTheta around 0 96.1%
associate-*r*96.1%
distribute-rgt1-in96.1%
mul-1-neg96.1%
Simplified96.1%
*-un-lft-identity96.1%
associate-/l*96.1%
neg-mul-196.1%
fma-define96.1%
inv-pow96.1%
sqrt-pow196.1%
metadata-eval96.1%
Applied egg-rr96.1%
*-lft-identity96.1%
fma-undefine96.1%
neg-mul-196.1%
+-commutative96.1%
sub-neg96.1%
Simplified96.1%
Final simplification96.1%
(FPCore (cosTheta c) :precision binary32 (* cosTheta (- (sqrt PI) (* c (* cosTheta PI)))))
float code(float cosTheta, float c) {
return cosTheta * (sqrtf(((float) M_PI)) - (c * (cosTheta * ((float) M_PI))));
}
function code(cosTheta, c) return Float32(cosTheta * Float32(sqrt(Float32(pi)) - Float32(c * Float32(cosTheta * Float32(pi))))) end
function tmp = code(cosTheta, c) tmp = cosTheta * (sqrt(single(pi)) - (c * (cosTheta * single(pi)))); end
\begin{array}{l}
\\
cosTheta \cdot \left(\sqrt{\pi} - c \cdot \left(cosTheta \cdot \pi\right)\right)
\end{array}
Initial program 98.1%
+-commutative98.1%
fma-define98.1%
associate-*l/98.5%
*-lft-identity98.5%
associate--l-98.4%
sub-neg98.4%
neg-mul-198.4%
distribute-lft-out98.4%
distribute-rgt-out98.4%
metadata-eval98.4%
distribute-lft-neg-out98.4%
distribute-rgt-neg-out98.4%
exp-prod98.4%
Simplified98.4%
Taylor expanded in c around 0 98.2%
Taylor expanded in cosTheta around 0 96.8%
mul-1-neg96.8%
unsub-neg96.8%
associate-*r*96.8%
*-commutative96.8%
associate-+r+96.8%
mul-1-neg96.8%
unsub-neg96.8%
Simplified96.8%
*-un-lft-identity96.8%
pow1/296.8%
inv-pow96.8%
pow-pow96.8%
metadata-eval96.8%
Applied egg-rr96.8%
*-lft-identity96.8%
Simplified96.8%
Taylor expanded in c around inf 94.0%
Final simplification94.0%
(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%
+-commutative98.1%
fma-define98.1%
associate-*l/98.5%
*-lft-identity98.5%
associate--l-98.4%
sub-neg98.4%
neg-mul-198.4%
distribute-lft-out98.4%
distribute-rgt-out98.4%
metadata-eval98.4%
distribute-lft-neg-out98.4%
distribute-rgt-neg-out98.4%
exp-prod98.4%
Simplified98.4%
Taylor expanded in c around 0 98.2%
Taylor expanded in cosTheta around 0 94.0%
(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%
+-commutative98.1%
fma-define98.1%
associate-*l/98.5%
*-lft-identity98.5%
associate--l-98.4%
sub-neg98.4%
neg-mul-198.4%
distribute-lft-out98.4%
distribute-rgt-out98.4%
metadata-eval98.4%
distribute-lft-neg-out98.4%
distribute-rgt-neg-out98.4%
exp-prod98.4%
Simplified98.4%
Taylor expanded in c around 0 98.2%
Taylor expanded in cosTheta around 0 93.2%
associate-*l/93.3%
*-lft-identity93.3%
Simplified93.3%
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%
+-commutative98.1%
fma-define98.1%
associate-*l/98.5%
*-lft-identity98.5%
associate--l-98.4%
sub-neg98.4%
neg-mul-198.4%
distribute-lft-out98.4%
distribute-rgt-out98.4%
metadata-eval98.4%
distribute-lft-neg-out98.4%
distribute-rgt-neg-out98.4%
exp-prod98.4%
Simplified98.4%
Taylor expanded in c around 0 98.2%
Taylor expanded in cosTheta around 0 93.2%
associate-*l/93.3%
*-lft-identity93.3%
Simplified93.3%
Taylor expanded in cosTheta around inf 10.6%
Taylor expanded in c around 0 10.6%
herbie shell --seed 2024107
(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))))))