| Alternative 1 | |
|---|---|
| Error | 0.5 |
| Cost | 16640 |
\[\frac{1}{c + \left(1 + \frac{\frac{\sqrt{1 + cosTheta \cdot -2}}{\sqrt{cosTheta \cdot \pi} \cdot \sqrt{cosTheta}}}{e^{cosTheta \cdot cosTheta}}\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 0.7
Simplified0.5
[Start]0.7 | \[ \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 [=>]0.7 | \[ \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+ [=>]0.7 | \[ \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 [=>]0.7 | \[ \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 [=>]0.7 | \[ \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/ [=>]0.7 | \[ \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* [=>]0.7 | \[ \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/ [=>]0.5 | \[ \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 [=>]0.5 | \[ \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-rr0.8
Simplified0.7
[Start]0.8 | \[ {\left(\sqrt{c + \left(1 + \frac{\sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}}{e^{cosTheta \cdot cosTheta} \cdot cosTheta}\right)}\right)}^{-1} \cdot {\left(\sqrt{c + \left(1 + \frac{\sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}}{e^{cosTheta \cdot cosTheta} \cdot cosTheta}\right)}\right)}^{-1}
\] |
|---|---|
pow-sqr [=>]0.7 | \[ \color{blue}{{\left(\sqrt{c + \left(1 + \frac{\sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}}{e^{cosTheta \cdot cosTheta} \cdot cosTheta}\right)}\right)}^{\left(2 \cdot -1\right)}}
\] |
associate-+r+ [=>]0.7 | \[ {\left(\sqrt{\color{blue}{\left(c + 1\right) + \frac{\sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}}{e^{cosTheta \cdot cosTheta} \cdot cosTheta}}}\right)}^{\left(2 \cdot -1\right)}
\] |
+-commutative [<=]0.7 | \[ {\left(\sqrt{\color{blue}{\left(1 + c\right)} + \frac{\sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}}{e^{cosTheta \cdot cosTheta} \cdot cosTheta}}\right)}^{\left(2 \cdot -1\right)}
\] |
*-commutative [=>]0.7 | \[ {\left(\sqrt{\left(1 + c\right) + \frac{\sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}}{\color{blue}{cosTheta \cdot e^{cosTheta \cdot cosTheta}}}}\right)}^{\left(2 \cdot -1\right)}
\] |
metadata-eval [=>]0.7 | \[ {\left(\sqrt{\left(1 + c\right) + \frac{\sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{\pi}}}{cosTheta \cdot e^{cosTheta \cdot cosTheta}}}\right)}^{\color{blue}{-2}}
\] |
Applied egg-rr0.4
Final simplification0.4
| Alternative 1 | |
|---|---|
| Error | 0.5 |
| Cost | 16640 |
| Alternative 2 | |
|---|---|
| Error | 0.5 |
| Cost | 13376 |
| Alternative 3 | |
|---|---|
| Error | 0.6 |
| Cost | 13312 |
| Alternative 4 | |
|---|---|
| Error | 0.7 |
| Cost | 13248 |
| Alternative 5 | |
|---|---|
| Error | 1.0 |
| Cost | 10048 |
| Alternative 6 | |
|---|---|
| Error | 1.2 |
| Cost | 6912 |
| Alternative 7 | |
|---|---|
| Error | 1.6 |
| Cost | 6784 |
| Alternative 8 | |
|---|---|
| Error | 1.4 |
| Cost | 6784 |
| Alternative 9 | |
|---|---|
| Error | 2.2 |
| Cost | 6464 |
| Alternative 10 | |
|---|---|
| Error | 28.6 |
| Cost | 96 |
| Alternative 11 | |
|---|---|
| Error | 28.6 |
| Cost | 32 |
herbie shell --seed 2023025
(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))))))