| Alternative 1 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 33024 |
\[x + \mathsf{fma}\left(z, \frac{1 - {\log t}^{2}}{1 + \log t}, \mathsf{fma}\left(a + -0.5, b, y\right)\right)
\]

(FPCore (x y z t a b) :precision binary64 (+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b)))
(FPCore (x y z t a b) :precision binary64 (+ x (fma z (/ (- 1.0 (pow (log t) 2.0)) (+ 1.0 (log t))) (fma (+ a -0.5) b y))))
double code(double x, double y, double z, double t, double a, double b) {
return (((x + y) + z) - (z * log(t))) + ((a - 0.5) * b);
}
double code(double x, double y, double z, double t, double a, double b) {
return x + fma(z, ((1.0 - pow(log(t), 2.0)) / (1.0 + log(t))), fma((a + -0.5), b, y));
}
function code(x, y, z, t, a, b) return Float64(Float64(Float64(Float64(x + y) + z) - Float64(z * log(t))) + Float64(Float64(a - 0.5) * b)) end
function code(x, y, z, t, a, b) return Float64(x + fma(z, Float64(Float64(1.0 - (log(t) ^ 2.0)) / Float64(1.0 + log(t))), fma(Float64(a + -0.5), b, y))) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(N[(x + y), $MachinePrecision] + z), $MachinePrecision] - N[(z * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_] := N[(x + N[(z * N[(N[(1.0 - N[Power[N[Log[t], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a + -0.5), $MachinePrecision] * b + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b
x + \mathsf{fma}\left(z, \frac{1 - {\log t}^{2}}{1 + \log t}, \mathsf{fma}\left(a + -0.5, b, y\right)\right)
Herbie found 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
| Original | 99.8% |
|---|---|
| Target | 99.5% |
| Herbie | 99.9% |
Initial program 99.8%
Simplified99.9%
[Start]99.8% | \[ \left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b
\] |
|---|---|
associate--l+ [=>]99.9% | \[ \color{blue}{\left(\left(x + y\right) + \left(z - z \cdot \log t\right)\right)} + \left(a - 0.5\right) \cdot b
\] |
associate-+l+ [=>]99.9% | \[ \color{blue}{\left(x + y\right) + \left(\left(z - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b\right)}
\] |
associate-+l+ [=>]99.9% | \[ \color{blue}{x + \left(y + \left(\left(z - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b\right)\right)}
\] |
+-commutative [=>]99.9% | \[ x + \left(y + \color{blue}{\left(\left(a - 0.5\right) \cdot b + \left(z - z \cdot \log t\right)\right)}\right)
\] |
associate-+r+ [=>]99.9% | \[ x + \color{blue}{\left(\left(y + \left(a - 0.5\right) \cdot b\right) + \left(z - z \cdot \log t\right)\right)}
\] |
+-commutative [<=]99.9% | \[ x + \left(\color{blue}{\left(\left(a - 0.5\right) \cdot b + y\right)} + \left(z - z \cdot \log t\right)\right)
\] |
+-commutative [<=]99.9% | \[ x + \color{blue}{\left(\left(z - z \cdot \log t\right) + \left(\left(a - 0.5\right) \cdot b + y\right)\right)}
\] |
*-commutative [=>]99.9% | \[ x + \left(\left(z - \color{blue}{\log t \cdot z}\right) + \left(\left(a - 0.5\right) \cdot b + y\right)\right)
\] |
cancel-sign-sub-inv [=>]99.9% | \[ x + \left(\color{blue}{\left(z + \left(-\log t\right) \cdot z\right)} + \left(\left(a - 0.5\right) \cdot b + y\right)\right)
\] |
distribute-rgt1-in [=>]99.9% | \[ x + \left(\color{blue}{\left(\left(-\log t\right) + 1\right) \cdot z} + \left(\left(a - 0.5\right) \cdot b + y\right)\right)
\] |
*-commutative [=>]99.9% | \[ x + \left(\color{blue}{z \cdot \left(\left(-\log t\right) + 1\right)} + \left(\left(a - 0.5\right) \cdot b + y\right)\right)
\] |
fma-def [=>]99.9% | \[ x + \color{blue}{\mathsf{fma}\left(z, \left(-\log t\right) + 1, \left(a - 0.5\right) \cdot b + y\right)}
\] |
+-commutative [=>]99.9% | \[ x + \mathsf{fma}\left(z, \color{blue}{1 + \left(-\log t\right)}, \left(a - 0.5\right) \cdot b + y\right)
\] |
unsub-neg [=>]99.9% | \[ x + \mathsf{fma}\left(z, \color{blue}{1 - \log t}, \left(a - 0.5\right) \cdot b + y\right)
\] |
fma-def [=>]99.9% | \[ x + \mathsf{fma}\left(z, 1 - \log t, \color{blue}{\mathsf{fma}\left(a - 0.5, b, y\right)}\right)
\] |
sub-neg [=>]99.9% | \[ x + \mathsf{fma}\left(z, 1 - \log t, \mathsf{fma}\left(\color{blue}{a + \left(-0.5\right)}, b, y\right)\right)
\] |
metadata-eval [=>]99.9% | \[ x + \mathsf{fma}\left(z, 1 - \log t, \mathsf{fma}\left(a + \color{blue}{-0.5}, b, y\right)\right)
\] |
Applied egg-rr99.8%
[Start]99.9% | \[ x + \mathsf{fma}\left(z, 1 - \log t, \mathsf{fma}\left(a + -0.5, b, y\right)\right)
\] |
|---|---|
flip-- [=>]99.9% | \[ x + \mathsf{fma}\left(z, \color{blue}{\frac{1 \cdot 1 - \log t \cdot \log t}{1 + \log t}}, \mathsf{fma}\left(a + -0.5, b, y\right)\right)
\] |
div-inv [=>]99.8% | \[ x + \mathsf{fma}\left(z, \color{blue}{\left(1 \cdot 1 - \log t \cdot \log t\right) \cdot \frac{1}{1 + \log t}}, \mathsf{fma}\left(a + -0.5, b, y\right)\right)
\] |
metadata-eval [=>]99.8% | \[ x + \mathsf{fma}\left(z, \left(\color{blue}{1} - \log t \cdot \log t\right) \cdot \frac{1}{1 + \log t}, \mathsf{fma}\left(a + -0.5, b, y\right)\right)
\] |
pow2 [=>]99.8% | \[ x + \mathsf{fma}\left(z, \left(1 - \color{blue}{{\log t}^{2}}\right) \cdot \frac{1}{1 + \log t}, \mathsf{fma}\left(a + -0.5, b, y\right)\right)
\] |
Simplified99.9%
[Start]99.8% | \[ x + \mathsf{fma}\left(z, \left(1 - {\log t}^{2}\right) \cdot \frac{1}{1 + \log t}, \mathsf{fma}\left(a + -0.5, b, y\right)\right)
\] |
|---|---|
associate-*r/ [=>]99.9% | \[ x + \mathsf{fma}\left(z, \color{blue}{\frac{\left(1 - {\log t}^{2}\right) \cdot 1}{1 + \log t}}, \mathsf{fma}\left(a + -0.5, b, y\right)\right)
\] |
*-rgt-identity [=>]99.9% | \[ x + \mathsf{fma}\left(z, \frac{\color{blue}{1 - {\log t}^{2}}}{1 + \log t}, \mathsf{fma}\left(a + -0.5, b, y\right)\right)
\] |
Final simplification99.9%
| Alternative 1 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 33024 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 19904 |
| Alternative 3 | |
|---|---|
| Accuracy | 89.8% |
| Cost | 8140 |
| Alternative 4 | |
|---|---|
| Accuracy | 89.8% |
| Cost | 7752 |
| Alternative 5 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 7360 |
| Alternative 6 | |
|---|---|
| Accuracy | 82.2% |
| Cost | 7248 |
| Alternative 7 | |
|---|---|
| Accuracy | 82.6% |
| Cost | 6985 |
| Alternative 8 | |
|---|---|
| Accuracy | 82.5% |
| Cost | 6984 |
| Alternative 9 | |
|---|---|
| Accuracy | 71.0% |
| Cost | 1225 |
| Alternative 10 | |
|---|---|
| Accuracy | 65.2% |
| Cost | 1097 |
| Alternative 11 | |
|---|---|
| Accuracy | 58.0% |
| Cost | 836 |
| Alternative 12 | |
|---|---|
| Accuracy | 49.7% |
| Cost | 721 |
| Alternative 13 | |
|---|---|
| Accuracy | 78.6% |
| Cost | 704 |
| Alternative 14 | |
|---|---|
| Accuracy | 61.8% |
| Cost | 580 |
| Alternative 15 | |
|---|---|
| Accuracy | 78.6% |
| Cost | 576 |
| Alternative 16 | |
|---|---|
| Accuracy | 29.3% |
| Cost | 456 |
| Alternative 17 | |
|---|---|
| Accuracy | 28.9% |
| Cost | 196 |
| Alternative 18 | |
|---|---|
| Accuracy | 21.9% |
| Cost | 64 |
herbie shell --seed 2023263
(FPCore (x y z t a b)
:name "Numeric.SpecFunctions:logBeta from math-functions-0.1.5.2, A"
:precision binary64
:herbie-target
(+ (+ (+ x y) (/ (* (- 1.0 (pow (log t) 2.0)) z) (+ 1.0 (log t)))) (* (- a 0.5) b))
(+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b)))