| Alternative 1 | |
|---|---|
| Error | 98.5% |
| Cost | 22848.00 |
\[\frac{1}{\mathsf{fma}\left(\frac{\sqrt{\mathsf{fma}\left(cosTheta, -2, 1\right)}}{cosTheta \cdot \sqrt{\pi}}, {\left(e^{cosTheta}\right)}^{\left(-cosTheta\right)}, 1 + c\right)}
\]
(FPCore (cosTheta c)
:precision binary32
(/
1.0
(+
(+ 1.0 c)
(*
(* (/ 1.0 (sqrt PI)) (/ (sqrt (- (- 1.0 cosTheta) cosTheta)) cosTheta))
(exp (* (- cosTheta) cosTheta))))))(FPCore (cosTheta c)
:precision binary32
(let* ((t_0 (* cosTheta (pow (exp cosTheta) cosTheta))))
(*
(/
1.0
(+
(* (- 1.0 (* c c)) t_0)
(* (- 1.0 c) (sqrt (/ (fma cosTheta -2.0 1.0) PI)))))
(* t_0 (- 1.0 c)))))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))));
}
float code(float cosTheta, float c) {
float t_0 = cosTheta * powf(expf(cosTheta), cosTheta);
return (1.0f / (((1.0f - (c * c)) * t_0) + ((1.0f - c) * sqrtf((fmaf(cosTheta, -2.0f, 1.0f) / ((float) M_PI)))))) * (t_0 * (1.0f - c));
}
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 code(cosTheta, c) t_0 = Float32(cosTheta * (exp(cosTheta) ^ cosTheta)) return Float32(Float32(Float32(1.0) / Float32(Float32(Float32(Float32(1.0) - Float32(c * c)) * t_0) + Float32(Float32(Float32(1.0) - c) * sqrt(Float32(fma(cosTheta, Float32(-2.0), Float32(1.0)) / Float32(pi)))))) * Float32(t_0 * Float32(Float32(1.0) - c))) end
\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}}
\begin{array}{l}
t_0 := cosTheta \cdot {\left(e^{cosTheta}\right)}^{cosTheta}\\
\frac{1}{\left(1 - c \cdot c\right) \cdot t_0 + \left(1 - c\right) \cdot \sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}} \cdot \left(t_0 \cdot \left(1 - c\right)\right)
\end{array}
Initial program 97.8
Simplified98.5
[Start]97.8 | \[ \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}}
\] |
|---|---|
+-commutative [=>]97.8 | \[ \frac{1}{\color{blue}{\left(c + 1\right)} + \left(\frac{1}{\sqrt{\pi}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(-cosTheta\right) \cdot cosTheta}}
\] |
associate-+l+ [=>]97.8 | \[ \frac{1}{\color{blue}{c + \left(1 + \left(\frac{1}{\sqrt{\pi}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(-cosTheta\right) \cdot cosTheta}\right)}}
\] |
distribute-lft-neg-out [=>]97.8 | \[ \frac{1}{c + \left(1 + \left(\frac{1}{\sqrt{\pi}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\color{blue}{-cosTheta \cdot cosTheta}}\right)}
\] |
exp-neg [=>]97.8 | \[ \frac{1}{c + \left(1 + \left(\frac{1}{\sqrt{\pi}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot \color{blue}{\frac{1}{e^{cosTheta \cdot cosTheta}}}\right)}
\] |
associate-*r/ [=>]97.8 | \[ \frac{1}{c + \left(1 + \color{blue}{\frac{\left(\frac{1}{\sqrt{\pi}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot 1}{e^{cosTheta \cdot cosTheta}}}\right)}
\] |
associate-/l* [=>]97.8 | \[ \frac{1}{c + \left(1 + \color{blue}{\frac{\frac{1}{\sqrt{\pi}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}}{\frac{e^{cosTheta \cdot cosTheta}}{1}}}\right)}
\] |
associate-*l/ [=>]98.4 | \[ \frac{1}{c + \left(1 + \frac{\color{blue}{\frac{1 \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}}{\sqrt{\pi}}}}{\frac{e^{cosTheta \cdot cosTheta}}{1}}\right)}
\] |
*-lft-identity [=>]98.4 | \[ \frac{1}{c + \left(1 + \frac{\frac{\color{blue}{\frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}}}{\sqrt{\pi}}}{\frac{e^{cosTheta \cdot cosTheta}}{1}}\right)}
\] |
Applied egg-rr61.2
Simplified61.2
[Start]61.2 | \[ \sqrt{{\left(c + \left(1 + \frac{\frac{\sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}}{cosTheta}}{{\left(e^{cosTheta}\right)}^{cosTheta}}\right)\right)}^{-2}}
\] |
|---|---|
+-commutative [=>]61.2 | \[ \sqrt{{\color{blue}{\left(\left(1 + \frac{\frac{\sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}}{cosTheta}}{{\left(e^{cosTheta}\right)}^{cosTheta}}\right) + c\right)}}^{-2}}
\] |
+-commutative [=>]61.2 | \[ \sqrt{{\left(\color{blue}{\left(\frac{\frac{\sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}}{cosTheta}}{{\left(e^{cosTheta}\right)}^{cosTheta}} + 1\right)} + c\right)}^{-2}}
\] |
associate-+l+ [=>]61.2 | \[ \sqrt{{\color{blue}{\left(\frac{\frac{\sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}}{cosTheta}}{{\left(e^{cosTheta}\right)}^{cosTheta}} + \left(1 + c\right)\right)}}^{-2}}
\] |
associate-/r* [<=]61.2 | \[ \sqrt{{\left(\color{blue}{\frac{\sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}}{cosTheta \cdot {\left(e^{cosTheta}\right)}^{cosTheta}}} + \left(1 + c\right)\right)}^{-2}}
\] |
Applied egg-rr98.6
Final simplification98.6
| Alternative 1 | |
|---|---|
| Error | 98.5% |
| Cost | 22848.00 |
| Alternative 2 | |
|---|---|
| Error | 98.5% |
| Cost | 13376.00 |
| Alternative 3 | |
|---|---|
| Error | 98.1% |
| Cost | 10272.00 |
| Alternative 4 | |
|---|---|
| Error | 98.1% |
| Cost | 10208.00 |
| Alternative 5 | |
|---|---|
| Error | 96.3% |
| Cost | 6976.00 |
| Alternative 6 | |
|---|---|
| Error | 94.9% |
| Cost | 6784.00 |
| Alternative 7 | |
|---|---|
| Error | 95.5% |
| Cost | 6784.00 |
| Alternative 8 | |
|---|---|
| Error | 93.1% |
| Cost | 6464.00 |
| Alternative 9 | |
|---|---|
| Error | 10.7% |
| Cost | 32.00 |
herbie shell --seed 2023093
(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))))))