| Alternative 1 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 19648 |
\[\mathsf{fma}\left(x, \log y, \log t - \left(y + z\right)\right)
\]

(FPCore (x y z t) :precision binary64 (+ (- (- (* x (log y)) y) z) (log t)))
(FPCore (x y z t) :precision binary64 (fma x (log y) (- (log t) (+ y z))))
double code(double x, double y, double z, double t) {
return (((x * log(y)) - y) - z) + log(t);
}
double code(double x, double y, double z, double t) {
return fma(x, log(y), (log(t) - (y + z)));
}
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x * log(y)) - y) - z) + log(t)) end
function code(x, y, z, t) return fma(x, log(y), Float64(log(t) - Float64(y + z))) end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision] + N[Log[t], $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := N[(x * N[Log[y], $MachinePrecision] + N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\left(x \cdot \log y - y\right) - z\right) + \log t
\mathsf{fma}\left(x, \log y, \log t - \left(y + z\right)\right)
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Initial program 99.9%
Simplified99.9%
[Start]99.9% | \[ \left(\left(x \cdot \log y - y\right) - z\right) + \log t
\] |
|---|---|
+-commutative [=>]99.9% | \[ \color{blue}{\log t + \left(\left(x \cdot \log y - y\right) - z\right)}
\] |
associate--l- [=>]99.9% | \[ \log t + \color{blue}{\left(x \cdot \log y - \left(y + z\right)\right)}
\] |
associate-+r- [=>]99.9% | \[ \color{blue}{\left(\log t + x \cdot \log y\right) - \left(y + z\right)}
\] |
+-commutative [=>]99.9% | \[ \color{blue}{\left(x \cdot \log y + \log t\right)} - \left(y + z\right)
\] |
associate--l+ [=>]99.9% | \[ \color{blue}{x \cdot \log y + \left(\log t - \left(y + z\right)\right)}
\] |
fma-def [=>]99.9% | \[ \color{blue}{\mathsf{fma}\left(x, \log y, \log t - \left(y + z\right)\right)}
\] |
Final simplification99.9%
| Alternative 1 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 19648 |
| Alternative 2 | |
|---|---|
| Accuracy | 89.0% |
| Cost | 13513 |
| Alternative 3 | |
|---|---|
| Accuracy | 88.9% |
| Cost | 13512 |
| Alternative 4 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 13376 |
| Alternative 5 | |
|---|---|
| Accuracy | 60.7% |
| Cost | 7781 |
| Alternative 6 | |
|---|---|
| Accuracy | 46.4% |
| Cost | 7648 |
| Alternative 7 | |
|---|---|
| Accuracy | 60.2% |
| Cost | 7385 |
| Alternative 8 | |
|---|---|
| Accuracy | 45.0% |
| Cost | 7124 |
| Alternative 9 | |
|---|---|
| Accuracy | 83.8% |
| Cost | 6985 |
| Alternative 10 | |
|---|---|
| Accuracy | 47.7% |
| Cost | 392 |
| Alternative 11 | |
|---|---|
| Accuracy | 31.0% |
| Cost | 128 |
herbie shell --seed 2023171
(FPCore (x y z t)
:name "Numeric.SpecFunctions:incompleteGamma from math-functions-0.1.5.2, A"
:precision binary64
(+ (- (- (* x (log y)) y) z) (log t)))