| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 13760 |
\[\mathsf{fma}\left(a + -0.5, b, \left(x + y\right) + \left(z - \frac{\log t}{\frac{1}{z}}\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 (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 - 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(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[(1.0 - N[Log[t], $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, 1 - \log t, \mathsf{fma}\left(a + -0.5, b, y\right)\right)
| Original | 0.1 |
|---|---|
| Target | 0.4 |
| Herbie | 0.1 |
Initial program 0.1
Simplified0.1
[Start]0.1 | \[ \left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b
\] |
|---|---|
sub-neg [=>]0.1 | \[ \color{blue}{\left(\left(\left(x + y\right) + z\right) + \left(-z \cdot \log t\right)\right)} + \left(a - 0.5\right) \cdot b
\] |
associate-+l+ [=>]0.1 | \[ \left(\color{blue}{\left(x + \left(y + z\right)\right)} + \left(-z \cdot \log t\right)\right) + \left(a - 0.5\right) \cdot b
\] |
associate-+l+ [=>]0.1 | \[ \color{blue}{\left(x + \left(\left(y + z\right) + \left(-z \cdot \log t\right)\right)\right)} + \left(a - 0.5\right) \cdot b
\] |
associate-+l+ [=>]0.1 | \[ \color{blue}{x + \left(\left(\left(y + z\right) + \left(-z \cdot \log t\right)\right) + \left(a - 0.5\right) \cdot b\right)}
\] |
sub-neg [<=]0.1 | \[ x + \left(\color{blue}{\left(\left(y + z\right) - z \cdot \log t\right)} + \left(a - 0.5\right) \cdot b\right)
\] |
associate-+r- [<=]0.1 | \[ x + \left(\color{blue}{\left(y + \left(z - z \cdot \log t\right)\right)} + \left(a - 0.5\right) \cdot b\right)
\] |
+-commutative [=>]0.1 | \[ x + \left(\color{blue}{\left(\left(z - z \cdot \log t\right) + y\right)} + \left(a - 0.5\right) \cdot b\right)
\] |
associate-+l+ [=>]0.1 | \[ x + \color{blue}{\left(\left(z - z \cdot \log t\right) + \left(y + \left(a - 0.5\right) \cdot b\right)\right)}
\] |
+-commutative [<=]0.1 | \[ x + \left(\left(z - z \cdot \log t\right) + \color{blue}{\left(\left(a - 0.5\right) \cdot b + y\right)}\right)
\] |
sub-neg [=>]0.1 | \[ x + \left(\color{blue}{\left(z + \left(-z \cdot \log t\right)\right)} + \left(\left(a - 0.5\right) \cdot b + y\right)\right)
\] |
+-commutative [=>]0.1 | \[ x + \left(\color{blue}{\left(\left(-z \cdot \log t\right) + z\right)} + \left(\left(a - 0.5\right) \cdot b + y\right)\right)
\] |
neg-sub0 [=>]0.1 | \[ x + \left(\left(\color{blue}{\left(0 - z \cdot \log t\right)} + z\right) + \left(\left(a - 0.5\right) \cdot b + y\right)\right)
\] |
associate-+l- [=>]0.1 | \[ x + \left(\color{blue}{\left(0 - \left(z \cdot \log t - z\right)\right)} + \left(\left(a - 0.5\right) \cdot b + y\right)\right)
\] |
associate-+l- [=>]0.1 | \[ x + \color{blue}{\left(0 - \left(\left(z \cdot \log t - z\right) - \left(\left(a - 0.5\right) \cdot b + y\right)\right)\right)}
\] |
sub0-neg [=>]0.1 | \[ x + \color{blue}{\left(-\left(\left(z \cdot \log t - z\right) - \left(\left(a - 0.5\right) \cdot b + y\right)\right)\right)}
\] |
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 13760 |
| Alternative 2 | |
|---|---|
| Error | 7.0 |
| Cost | 7753 |
| Alternative 3 | |
|---|---|
| Error | 0.1 |
| Cost | 7360 |
| Alternative 4 | |
|---|---|
| Error | 8.3 |
| Cost | 7113 |
| Alternative 5 | |
|---|---|
| Error | 8.5 |
| Cost | 7112 |
| Alternative 6 | |
|---|---|
| Error | 12.3 |
| Cost | 6852 |
| Alternative 7 | |
|---|---|
| Error | 25.6 |
| Cost | 1097 |
| Alternative 8 | |
|---|---|
| Error | 24.8 |
| Cost | 840 |
| Alternative 9 | |
|---|---|
| Error | 24.6 |
| Cost | 840 |
| Alternative 10 | |
|---|---|
| Error | 23.0 |
| Cost | 840 |
| Alternative 11 | |
|---|---|
| Error | 19.7 |
| Cost | 708 |
| Alternative 12 | |
|---|---|
| Error | 14.7 |
| Cost | 704 |
| Alternative 13 | |
|---|---|
| Error | 30.2 |
| Cost | 456 |
| Alternative 14 | |
|---|---|
| Error | 37.1 |
| Cost | 196 |
| Alternative 15 | |
|---|---|
| Error | 48.1 |
| Cost | 64 |
herbie shell --seed 2023016
(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)))