| Alternative 1 | |
|---|---|
| Error | 0.6 |
| Cost | 13640 |
(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)}
| Original | 2.8 |
|---|---|
| Target | 0.1 |
| Herbie | 0.1 |
Initial program 2.8
Simplified0.1
[Start]2.8 | \[ x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}
\] |
|---|---|
--rgt-identity [<=]2.8 | \[ \color{blue}{\left(x - 0\right)} + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}
\] |
associate-+l- [=>]2.8 | \[ \color{blue}{x - \left(0 - \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}\right)}
\] |
sub-neg [=>]2.8 | \[ \color{blue}{x + \left(-\left(0 - \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}\right)\right)}
\] |
+-lft-identity [<=]2.8 | \[ x + \left(-\left(0 - \color{blue}{\left(0 + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}\right)}\right)\right)
\] |
sub0-neg [=>]2.8 | \[ x + \left(-\color{blue}{\left(-\left(0 + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}\right)\right)}\right)
\] |
neg-mul-1 [=>]2.8 | \[ x + \left(-\color{blue}{-1 \cdot \left(0 + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}\right)}\right)
\] |
distribute-lft-neg-in [=>]2.8 | \[ x + \color{blue}{\left(--1\right) \cdot \left(0 + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}\right)}
\] |
+-lft-identity [=>]2.8 | \[ x + \left(--1\right) \cdot \color{blue}{\frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}}
\] |
associate-*r/ [=>]2.8 | \[ x + \color{blue}{\frac{\left(--1\right) \cdot y}{1.1283791670955126 \cdot e^{z} - x \cdot y}}
\] |
sub-neg [=>]2.8 | \[ x + \frac{\left(--1\right) \cdot y}{\color{blue}{1.1283791670955126 \cdot e^{z} + \left(-x \cdot y\right)}}
\] |
+-commutative [=>]2.8 | \[ x + \frac{\left(--1\right) \cdot y}{\color{blue}{\left(-x \cdot y\right) + 1.1283791670955126 \cdot e^{z}}}
\] |
neg-sub0 [=>]2.8 | \[ x + \frac{\left(--1\right) \cdot y}{\color{blue}{\left(0 - x \cdot y\right)} + 1.1283791670955126 \cdot e^{z}}
\] |
associate-+l- [=>]2.8 | \[ x + \frac{\left(--1\right) \cdot y}{\color{blue}{0 - \left(x \cdot y - 1.1283791670955126 \cdot e^{z}\right)}}
\] |
sub0-neg [=>]2.8 | \[ x + \frac{\left(--1\right) \cdot y}{\color{blue}{-\left(x \cdot y - 1.1283791670955126 \cdot e^{z}\right)}}
\] |
neg-mul-1 [=>]2.8 | \[ x + \frac{\left(--1\right) \cdot y}{\color{blue}{-1 \cdot \left(x \cdot y - 1.1283791670955126 \cdot e^{z}\right)}}
\] |
times-frac [=>]2.8 | \[ x + \color{blue}{\frac{--1}{-1} \cdot \frac{y}{x \cdot y - 1.1283791670955126 \cdot e^{z}}}
\] |
metadata-eval [=>]2.8 | \[ x + \frac{\color{blue}{1}}{-1} \cdot \frac{y}{x \cdot y - 1.1283791670955126 \cdot e^{z}}
\] |
metadata-eval [=>]2.8 | \[ x + \color{blue}{-1} \cdot \frac{y}{x \cdot y - 1.1283791670955126 \cdot e^{z}}
\] |
associate-*r/ [=>]2.8 | \[ x + \color{blue}{\frac{-1 \cdot y}{x \cdot y - 1.1283791670955126 \cdot e^{z}}}
\] |
associate-/l* [=>]2.8 | \[ x + \color{blue}{\frac{-1}{\frac{x \cdot y - 1.1283791670955126 \cdot e^{z}}{y}}}
\] |
sub-neg [=>]2.8 | \[ x + \frac{-1}{\frac{\color{blue}{x \cdot y + \left(-1.1283791670955126 \cdot e^{z}\right)}}{y}}
\] |
+-commutative [=>]2.8 | \[ x + \frac{-1}{\frac{\color{blue}{\left(-1.1283791670955126 \cdot e^{z}\right) + x \cdot y}}{y}}
\] |
cancel-sign-sub [<=]2.8 | \[ x + \frac{-1}{\frac{\color{blue}{\left(-1.1283791670955126 \cdot e^{z}\right) - \left(-x\right) \cdot y}}{y}}
\] |
distribute-lft-neg-in [<=]2.8 | \[ x + \frac{-1}{\frac{\left(-1.1283791670955126 \cdot e^{z}\right) - \color{blue}{\left(-x \cdot y\right)}}{y}}
\] |
div-sub [=>]2.8 | \[ x + \frac{-1}{\color{blue}{\frac{-1.1283791670955126 \cdot e^{z}}{y} - \frac{-x \cdot y}{y}}}
\] |
*-lft-identity [<=]2.8 | \[ x + \frac{-1}{\frac{-1.1283791670955126 \cdot e^{z}}{y} - \color{blue}{1 \cdot \frac{-x \cdot y}{y}}}
\] |
metadata-eval [<=]2.8 | \[ x + \frac{-1}{\frac{-1.1283791670955126 \cdot e^{z}}{y} - \color{blue}{\frac{-1}{-1}} \cdot \frac{-x \cdot y}{y}}
\] |
times-frac [<=]2.8 | \[ x + \frac{-1}{\frac{-1.1283791670955126 \cdot e^{z}}{y} - \color{blue}{\frac{-1 \cdot \left(-x \cdot y\right)}{-1 \cdot y}}}
\] |
neg-mul-1 [<=]2.8 | \[ x + \frac{-1}{\frac{-1.1283791670955126 \cdot e^{z}}{y} - \frac{-1 \cdot \left(-x \cdot y\right)}{\color{blue}{-y}}}
\] |
associate-*l/ [<=]2.8 | \[ x + \frac{-1}{\frac{-1.1283791670955126 \cdot e^{z}}{y} - \color{blue}{\frac{-1}{-y} \cdot \left(-x \cdot y\right)}}
\] |
*-commutative [<=]2.8 | \[ x + \frac{-1}{\frac{-1.1283791670955126 \cdot e^{z}}{y} - \color{blue}{\left(-x \cdot y\right) \cdot \frac{-1}{-y}}}
\] |
distribute-lft-neg-in [=>]2.8 | \[ x + \frac{-1}{\frac{-1.1283791670955126 \cdot e^{z}}{y} - \color{blue}{\left(\left(-x\right) \cdot y\right)} \cdot \frac{-1}{-y}}
\] |
associate-*l* [=>]0.1 | \[ x + \frac{-1}{\frac{-1.1283791670955126 \cdot e^{z}}{y} - \color{blue}{\left(-x\right) \cdot \left(y \cdot \frac{-1}{-y}\right)}}
\] |
associate-*r/ [=>]0.0 | \[ x + \frac{-1}{\frac{-1.1283791670955126 \cdot e^{z}}{y} - \left(-x\right) \cdot \color{blue}{\frac{y \cdot -1}{-y}}}
\] |
*-commutative [<=]0.0 | \[ x + \frac{-1}{\frac{-1.1283791670955126 \cdot e^{z}}{y} - \left(-x\right) \cdot \frac{\color{blue}{-1 \cdot y}}{-y}}
\] |
neg-mul-1 [<=]0.0 | \[ x + \frac{-1}{\frac{-1.1283791670955126 \cdot e^{z}}{y} - \left(-x\right) \cdot \frac{\color{blue}{-y}}{-y}}
\] |
*-inverses [=>]0.0 | \[ x + \frac{-1}{\frac{-1.1283791670955126 \cdot e^{z}}{y} - \left(-x\right) \cdot \color{blue}{1}}
\] |
*-rgt-identity [=>]0.0 | \[ x + \frac{-1}{\frac{-1.1283791670955126 \cdot e^{z}}{y} - \color{blue}{\left(-x\right)}}
\] |
sub-neg [=>]0.0 | \[ x + \frac{-1}{\color{blue}{\frac{-1.1283791670955126 \cdot e^{z}}{y} + \left(-\left(-x\right)\right)}}
\] |
remove-double-neg [=>]0.0 | \[ x + \frac{-1}{\frac{-1.1283791670955126 \cdot e^{z}}{y} + \color{blue}{x}}
\] |
distribute-lft-neg-in [=>]0.0 | \[ x + \frac{-1}{\frac{\color{blue}{\left(-1.1283791670955126\right) \cdot e^{z}}}{y} + x}
\] |
associate-/l* [=>]0.0 | \[ x + \frac{-1}{\color{blue}{\frac{-1.1283791670955126}{\frac{y}{e^{z}}}} + x}
\] |
associate-/r/ [=>]0.1 | \[ x + \frac{-1}{\color{blue}{\frac{-1.1283791670955126}{y} \cdot e^{z}} + x}
\] |
metadata-eval [=>]0.1 | \[ x + \frac{-1}{\frac{\color{blue}{-1.1283791670955126}}{y} \cdot e^{z} + x}
\] |
metadata-eval [<=]0.1 | \[ x + \frac{-1}{\frac{\color{blue}{\frac{1.1283791670955126}{-1}}}{y} \cdot e^{z} + x}
\] |
associate-/r* [<=]0.1 | \[ x + \frac{-1}{\color{blue}{\frac{1.1283791670955126}{-1 \cdot y}} \cdot e^{z} + x}
\] |
neg-mul-1 [<=]0.1 | \[ x + \frac{-1}{\frac{1.1283791670955126}{\color{blue}{-y}} \cdot e^{z} + x}
\] |
*-commutative [<=]0.1 | \[ x + \frac{-1}{\color{blue}{e^{z} \cdot \frac{1.1283791670955126}{-y}} + x}
\] |
fma-def [=>]0.1 | \[ x + \frac{-1}{\color{blue}{\mathsf{fma}\left(e^{z}, \frac{1.1283791670955126}{-y}, x\right)}}
\] |
neg-mul-1 [=>]0.1 | \[ x + \frac{-1}{\mathsf{fma}\left(e^{z}, \frac{1.1283791670955126}{\color{blue}{-1 \cdot y}}, x\right)}
\] |
associate-/r* [=>]0.1 | \[ x + \frac{-1}{\mathsf{fma}\left(e^{z}, \color{blue}{\frac{\frac{1.1283791670955126}{-1}}{y}}, x\right)}
\] |
metadata-eval [=>]0.1 | \[ x + \frac{-1}{\mathsf{fma}\left(e^{z}, \frac{\color{blue}{-1.1283791670955126}}{y}, x\right)}
\] |
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 0.6 |
| Cost | 13640 |
| Alternative 2 | |
|---|---|
| Error | 10.1 |
| Cost | 1112 |
| Alternative 3 | |
|---|---|
| Error | 10.1 |
| Cost | 1112 |
| Alternative 4 | |
|---|---|
| Error | 16.3 |
| Cost | 848 |
| Alternative 5 | |
|---|---|
| Error | 0.4 |
| Cost | 840 |
| Alternative 6 | |
|---|---|
| Error | 19.3 |
| Cost | 456 |
| Alternative 7 | |
|---|---|
| Error | 20.2 |
| Cost | 456 |
| Alternative 8 | |
|---|---|
| Error | 19.5 |
| Cost | 64 |
herbie shell --seed 2022364
(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)))))