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

(FPCore (x y z t a b c i) :precision binary64 (+ (+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c))) (* y i)))
(FPCore (x y z t a b c i) :precision binary64 (+ t (fma y i (fma x (log y) (+ a (fma (+ b -0.5) (log c) z))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
}
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return t + fma(y, i, fma(x, log(y), (a + fma((b + -0.5), log(c), z))));
}
function code(x, y, z, t, a, b, c, i) return Float64(Float64(Float64(Float64(Float64(Float64(x * log(y)) + z) + t) + a) + Float64(Float64(b - 0.5) * log(c))) + Float64(y * i)) end
function code(x, y, z, t, a, b, c, i) return Float64(t + fma(y, i, fma(x, log(y), Float64(a + fma(Float64(b + -0.5), log(c), z))))) end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision] + t), $MachinePrecision] + a), $MachinePrecision] + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(t + N[(y * i + N[(x * N[Log[y], $MachinePrecision] + N[(a + N[(N[(b + -0.5), $MachinePrecision] * N[Log[c], $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i
t + \mathsf{fma}\left(y, i, \mathsf{fma}\left(x, \log y, a + \mathsf{fma}\left(b + -0.5, \log c, z\right)\right)\right)
Herbie found 20 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Initial program 99.9%
Simplified99.9%
[Start]99.9% | \[ \left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i
\] |
|---|---|
associate-+l+ [=>]99.9% | \[ \color{blue}{\left(\left(\left(x \cdot \log y + z\right) + t\right) + \left(a + \left(b - 0.5\right) \cdot \log c\right)\right)} + y \cdot i
\] |
+-commutative [=>]99.9% | \[ \left(\color{blue}{\left(t + \left(x \cdot \log y + z\right)\right)} + \left(a + \left(b - 0.5\right) \cdot \log c\right)\right) + y \cdot i
\] |
associate-+l+ [=>]99.9% | \[ \color{blue}{\left(t + \left(\left(x \cdot \log y + z\right) + \left(a + \left(b - 0.5\right) \cdot \log c\right)\right)\right)} + y \cdot i
\] |
associate-+l+ [=>]99.9% | \[ \color{blue}{t + \left(\left(\left(x \cdot \log y + z\right) + \left(a + \left(b - 0.5\right) \cdot \log c\right)\right) + y \cdot i\right)}
\] |
+-commutative [=>]99.9% | \[ t + \color{blue}{\left(y \cdot i + \left(\left(x \cdot \log y + z\right) + \left(a + \left(b - 0.5\right) \cdot \log c\right)\right)\right)}
\] |
fma-def [=>]99.9% | \[ t + \color{blue}{\mathsf{fma}\left(y, i, \left(x \cdot \log y + z\right) + \left(a + \left(b - 0.5\right) \cdot \log c\right)\right)}
\] |
associate-+l+ [=>]99.9% | \[ t + \mathsf{fma}\left(y, i, \color{blue}{x \cdot \log y + \left(z + \left(a + \left(b - 0.5\right) \cdot \log c\right)\right)}\right)
\] |
fma-def [=>]99.9% | \[ t + \mathsf{fma}\left(y, i, \color{blue}{\mathsf{fma}\left(x, \log y, z + \left(a + \left(b - 0.5\right) \cdot \log c\right)\right)}\right)
\] |
+-commutative [=>]99.9% | \[ t + \mathsf{fma}\left(y, i, \mathsf{fma}\left(x, \log y, \color{blue}{\left(a + \left(b - 0.5\right) \cdot \log c\right) + z}\right)\right)
\] |
associate-+l+ [=>]99.9% | \[ t + \mathsf{fma}\left(y, i, \mathsf{fma}\left(x, \log y, \color{blue}{a + \left(\left(b - 0.5\right) \cdot \log c + z\right)}\right)\right)
\] |
fma-def [=>]99.9% | \[ t + \mathsf{fma}\left(y, i, \mathsf{fma}\left(x, \log y, a + \color{blue}{\mathsf{fma}\left(b - 0.5, \log c, z\right)}\right)\right)
\] |
sub-neg [=>]99.9% | \[ t + \mathsf{fma}\left(y, i, \mathsf{fma}\left(x, \log y, a + \mathsf{fma}\left(\color{blue}{b + \left(-0.5\right)}, \log c, z\right)\right)\right)
\] |
metadata-eval [=>]99.9% | \[ t + \mathsf{fma}\left(y, i, \mathsf{fma}\left(x, \log y, a + \mathsf{fma}\left(b + \color{blue}{-0.5}, \log c, z\right)\right)\right)
\] |
Final simplification99.9%
| Alternative 1 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 32832 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 14016 |
| Alternative 3 | |
|---|---|
| Accuracy | 91.9% |
| Cost | 13897 |
| Alternative 4 | |
|---|---|
| Accuracy | 92.0% |
| Cost | 13896 |
| Alternative 5 | |
|---|---|
| Accuracy | 91.9% |
| Cost | 13641 |
| Alternative 6 | |
|---|---|
| Accuracy | 90.4% |
| Cost | 13513 |
| Alternative 7 | |
|---|---|
| Accuracy | 74.8% |
| Cost | 7625 |
| Alternative 8 | |
|---|---|
| Accuracy | 88.5% |
| Cost | 7625 |
| Alternative 9 | |
|---|---|
| Accuracy | 26.4% |
| Cost | 7512 |
| Alternative 10 | |
|---|---|
| Accuracy | 73.2% |
| Cost | 7496 |
| Alternative 11 | |
|---|---|
| Accuracy | 55.9% |
| Cost | 7376 |
| Alternative 12 | |
|---|---|
| Accuracy | 71.8% |
| Cost | 7369 |
| Alternative 13 | |
|---|---|
| Accuracy | 72.8% |
| Cost | 7368 |
| Alternative 14 | |
|---|---|
| Accuracy | 58.0% |
| Cost | 7248 |
| Alternative 15 | |
|---|---|
| Accuracy | 58.2% |
| Cost | 6852 |
| Alternative 16 | |
|---|---|
| Accuracy | 23.1% |
| Cost | 852 |
| Alternative 17 | |
|---|---|
| Accuracy | 26.5% |
| Cost | 852 |
| Alternative 18 | |
|---|---|
| Accuracy | 21.9% |
| Cost | 724 |
| Alternative 19 | |
|---|---|
| Accuracy | 21.1% |
| Cost | 196 |
| Alternative 20 | |
|---|---|
| Accuracy | 15.8% |
| Cost | 64 |
herbie shell --seed 2023165
(FPCore (x y z t a b c i)
:name "Numeric.SpecFunctions:logBeta from math-functions-0.1.5.2, B"
:precision binary64
(+ (+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c))) (* y i)))