| Alternative 1 | |
|---|---|
| Error | 0.5 |
| Cost | 16576 |
\[\frac{1}{c + \left(1 + \frac{\frac{\sqrt{\frac{\mathsf{fma}\left(cosTheta, -2, 1\right)}{cosTheta \cdot \pi}}}{\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 (/ 1.0 (fma (/ (/ (sqrt (- 1.0 (+ cosTheta cosTheta))) cosTheta) (sqrt PI)) (pow (exp cosTheta) (- cosTheta)) (+ 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) {
return 1.0f / fmaf(((sqrtf((1.0f - (cosTheta + cosTheta))) / cosTheta) / sqrtf(((float) M_PI))), powf(expf(cosTheta), -cosTheta), (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) return Float32(Float32(1.0) / fma(Float32(Float32(sqrt(Float32(Float32(1.0) - Float32(cosTheta + cosTheta))) / cosTheta) / sqrt(Float32(pi))), (exp(cosTheta) ^ Float32(-cosTheta)), 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}}
\frac{1}{\mathsf{fma}\left(\frac{\frac{\sqrt{1 - \left(cosTheta + cosTheta\right)}}{cosTheta}}{\sqrt{\pi}}, {\left(e^{cosTheta}\right)}^{\left(-cosTheta\right)}, 1 + c\right)}
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(\frac{1}{\sqrt{\pi}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}\right) \cdot e^{\left(-cosTheta\right) \cdot cosTheta} + \left(1 + c\right)}}
\] |
fma-def [=>]0.7 | \[ \frac{1}{\color{blue}{\mathsf{fma}\left(\frac{1}{\sqrt{\pi}} \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}, e^{\left(-cosTheta\right) \cdot cosTheta}, 1 + c\right)}}
\] |
associate-*l/ [=>]0.5 | \[ \frac{1}{\mathsf{fma}\left(\color{blue}{\frac{1 \cdot \frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}}{\sqrt{\pi}}}, e^{\left(-cosTheta\right) \cdot cosTheta}, 1 + c\right)}
\] |
*-lft-identity [=>]0.5 | \[ \frac{1}{\mathsf{fma}\left(\frac{\color{blue}{\frac{\sqrt{\left(1 - cosTheta\right) - cosTheta}}{cosTheta}}}{\sqrt{\pi}}, e^{\left(-cosTheta\right) \cdot cosTheta}, 1 + c\right)}
\] |
associate--l- [=>]0.5 | \[ \frac{1}{\mathsf{fma}\left(\frac{\frac{\sqrt{\color{blue}{1 - \left(cosTheta + cosTheta\right)}}}{cosTheta}}{\sqrt{\pi}}, e^{\left(-cosTheta\right) \cdot cosTheta}, 1 + c\right)}
\] |
*-commutative [=>]0.5 | \[ \frac{1}{\mathsf{fma}\left(\frac{\frac{\sqrt{1 - \left(cosTheta + cosTheta\right)}}{cosTheta}}{\sqrt{\pi}}, e^{\color{blue}{cosTheta \cdot \left(-cosTheta\right)}}, 1 + c\right)}
\] |
exp-prod [=>]0.5 | \[ \frac{1}{\mathsf{fma}\left(\frac{\frac{\sqrt{1 - \left(cosTheta + cosTheta\right)}}{cosTheta}}{\sqrt{\pi}}, \color{blue}{{\left(e^{cosTheta}\right)}^{\left(-cosTheta\right)}}, 1 + c\right)}
\] |
Final simplification0.5
| Alternative 1 | |
|---|---|
| Error | 0.5 |
| Cost | 16576 |
| Alternative 2 | |
|---|---|
| Error | 0.7 |
| Cost | 13376 |
| Alternative 3 | |
|---|---|
| Error | 0.5 |
| Cost | 13376 |
| Alternative 4 | |
|---|---|
| Error | 0.6 |
| Cost | 13312 |
| Alternative 5 | |
|---|---|
| Error | 0.8 |
| Cost | 13280 |
| Alternative 6 | |
|---|---|
| Error | 0.7 |
| Cost | 10144 |
| Alternative 7 | |
|---|---|
| Error | 1.2 |
| Cost | 10112 |
| Alternative 8 | |
|---|---|
| Error | 1.2 |
| Cost | 6976 |
| Alternative 9 | |
|---|---|
| Error | 1.2 |
| Cost | 6912 |
| Alternative 10 | |
|---|---|
| Error | 1.4 |
| Cost | 6880 |
| Alternative 11 | |
|---|---|
| Error | 1.6 |
| Cost | 6816 |
| Alternative 12 | |
|---|---|
| Error | 1.6 |
| Cost | 6784 |
| Alternative 13 | |
|---|---|
| Error | 2.2 |
| Cost | 6464 |
| Alternative 14 | |
|---|---|
| Error | 28.6 |
| Cost | 96 |
| Alternative 15 | |
|---|---|
| Error | 28.6 |
| Cost | 32 |
herbie shell --seed 2023034
(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))))))