| Alternative 1 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 13376 |
\[x + \frac{-1}{\mathsf{fma}\left(e^{z}, \frac{-1.1283791670955126}{y}, x\right)}
\]

(FPCore (x y z) :precision binary64 (+ x (/ y (- (* 1.1283791670955126 (exp z)) (* x y)))))
(FPCore (x y z) :precision binary64 (+ x (/ -1.0 (fma (exp z) (/ -1.1283791670955126 y) x))))
double code(double x, double y, double z) {
return x + (y / ((1.1283791670955126 * exp(z)) - (x * y)));
}
double code(double x, double y, double z) {
return x + (-1.0 / fma(exp(z), (-1.1283791670955126 / y), x));
}
function code(x, y, z) return Float64(x + Float64(y / Float64(Float64(1.1283791670955126 * exp(z)) - Float64(x * y)))) end
function code(x, y, z) return Float64(x + Float64(-1.0 / fma(exp(z), Float64(-1.1283791670955126 / y), x))) end
code[x_, y_, z_] := N[(x + N[(y / N[(N[(1.1283791670955126 * N[Exp[z], $MachinePrecision]), $MachinePrecision] - N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(x + N[(-1.0 / N[(N[Exp[z], $MachinePrecision] * N[(-1.1283791670955126 / y), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}
x + \frac{-1}{\mathsf{fma}\left(e^{z}, \frac{-1.1283791670955126}{y}, x\right)}
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
| Original | 96.5% |
|---|---|
| Target | 99.9% |
| Herbie | 99.9% |
Initial program 93.0%
Simplified99.9%
[Start]93.0% | \[ x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}
\] |
|---|---|
*-lft-identity [<=]93.0% | \[ x + \color{blue}{1 \cdot \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}}
\] |
metadata-eval [<=]93.0% | \[ x + \color{blue}{\frac{-1}{-1}} \cdot \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}
\] |
times-frac [<=]93.0% | \[ x + \color{blue}{\frac{-1 \cdot y}{-1 \cdot \left(1.1283791670955126 \cdot e^{z} - x \cdot y\right)}}
\] |
neg-mul-1 [<=]93.0% | \[ x + \frac{-1 \cdot y}{\color{blue}{-\left(1.1283791670955126 \cdot e^{z} - x \cdot y\right)}}
\] |
sub0-neg [<=]93.1% | \[ x + \frac{-1 \cdot y}{\color{blue}{0 - \left(1.1283791670955126 \cdot e^{z} - x \cdot y\right)}}
\] |
associate-+l- [<=]93.1% | \[ x + \frac{-1 \cdot y}{\color{blue}{\left(0 - 1.1283791670955126 \cdot e^{z}\right) + x \cdot y}}
\] |
neg-sub0 [<=]93.3% | \[ x + \frac{-1 \cdot y}{\color{blue}{\left(-1.1283791670955126 \cdot e^{z}\right)} + x \cdot y}
\] |
+-commutative [<=]93.3% | \[ x + \frac{-1 \cdot y}{\color{blue}{x \cdot y + \left(-1.1283791670955126 \cdot e^{z}\right)}}
\] |
sub-neg [<=]93.3% | \[ x + \frac{-1 \cdot y}{\color{blue}{x \cdot y - 1.1283791670955126 \cdot e^{z}}}
\] |
associate-/l* [=>]93.3% | \[ x + \color{blue}{\frac{-1}{\frac{x \cdot y - 1.1283791670955126 \cdot e^{z}}{y}}}
\] |
div-sub [=>]93.3% | \[ x + \frac{-1}{\color{blue}{\frac{x \cdot y}{y} - \frac{1.1283791670955126 \cdot e^{z}}{y}}}
\] |
associate-*r/ [<=]99.9% | \[ x + \frac{-1}{\color{blue}{x \cdot \frac{y}{y}} - \frac{1.1283791670955126 \cdot e^{z}}{y}}
\] |
*-inverses [=>]99.9% | \[ x + \frac{-1}{x \cdot \color{blue}{1} - \frac{1.1283791670955126 \cdot e^{z}}{y}}
\] |
*-rgt-identity [=>]99.9% | \[ x + \frac{-1}{\color{blue}{x} - \frac{1.1283791670955126 \cdot e^{z}}{y}}
\] |
associate-*l/ [<=]99.9% | \[ x + \frac{-1}{x - \color{blue}{\frac{1.1283791670955126}{y} \cdot e^{z}}}
\] |
cancel-sign-sub-inv [=>]99.9% | \[ x + \frac{-1}{\color{blue}{x + \left(-\frac{1.1283791670955126}{y}\right) \cdot e^{z}}}
\] |
distribute-lft-neg-in [<=]99.9% | \[ x + \frac{-1}{x + \color{blue}{\left(-\frac{1.1283791670955126}{y} \cdot e^{z}\right)}}
\] |
distribute-rgt-neg-in [=>]99.9% | \[ x + \frac{-1}{x + \color{blue}{\frac{1.1283791670955126}{y} \cdot \left(-e^{z}\right)}}
\] |
associate-*l/ [=>]99.9% | \[ x + \frac{-1}{x + \color{blue}{\frac{1.1283791670955126 \cdot \left(-e^{z}\right)}{y}}}
\] |
distribute-rgt-neg-in [<=]99.9% | \[ x + \frac{-1}{x + \frac{\color{blue}{-1.1283791670955126 \cdot e^{z}}}{y}}
\] |
Final simplification99.9%
| Alternative 1 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 13376 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.4% |
| Cost | 7108 |
| Alternative 3 | |
|---|---|
| Accuracy | 81.8% |
| Cost | 850 |
| Alternative 4 | |
|---|---|
| Accuracy | 75.7% |
| Cost | 585 |
| Alternative 5 | |
|---|---|
| Accuracy | 58.9% |
| Cost | 64 |
herbie shell --seed 2023272
(FPCore (x y z)
:name "Numeric.SpecFunctions:invErfc from math-functions-0.1.5.2, A"
:precision binary64
:herbie-target
(+ x (/ 1.0 (- (* (/ 1.1283791670955126 y) (exp z)) x)))
(+ x (/ y (- (* 1.1283791670955126 (exp z)) (* x y)))))