| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 13632 |
\[\left(y \cdot \left(1 - \log y\right) + \left(x + \log y \cdot -0.5\right)\right) - z
\]
(FPCore (x y z) :precision binary64 (- (+ (- x (* (+ y 0.5) (log y))) y) z))
(FPCore (x y z) :precision binary64 (- (+ x (+ (exp (log1p y)) (+ (* (log y) (- -0.5 y)) -1.0))) z))
double code(double x, double y, double z) {
return ((x - ((y + 0.5) * log(y))) + y) - z;
}
double code(double x, double y, double z) {
return (x + (exp(log1p(y)) + ((log(y) * (-0.5 - y)) + -1.0))) - z;
}
public static double code(double x, double y, double z) {
return ((x - ((y + 0.5) * Math.log(y))) + y) - z;
}
public static double code(double x, double y, double z) {
return (x + (Math.exp(Math.log1p(y)) + ((Math.log(y) * (-0.5 - y)) + -1.0))) - z;
}
def code(x, y, z): return ((x - ((y + 0.5) * math.log(y))) + y) - z
def code(x, y, z): return (x + (math.exp(math.log1p(y)) + ((math.log(y) * (-0.5 - y)) + -1.0))) - z
function code(x, y, z) return Float64(Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) - z) end
function code(x, y, z) return Float64(Float64(x + Float64(exp(log1p(y)) + Float64(Float64(log(y) * Float64(-0.5 - y)) + -1.0))) - z) end
code[x_, y_, z_] := N[(N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
code[x_, y_, z_] := N[(N[(x + N[(N[Exp[N[Log[1 + y], $MachinePrecision]], $MachinePrecision] + N[(N[(N[Log[y], $MachinePrecision] * N[(-0.5 - y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
\left(x + \left(e^{\mathsf{log1p}\left(y\right)} + \left(\log y \cdot \left(-0.5 - y\right) + -1\right)\right)\right) - z
Results
| Original | 0.1 |
|---|---|
| Target | 0.1 |
| Herbie | 0.1 |
Initial program 0.1
Simplified0.1
[Start]0.1 | \[ \left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
\] |
|---|---|
associate-+l- [=>]0.1 | \[ \color{blue}{\left(x - \left(\left(y + 0.5\right) \cdot \log y - y\right)\right)} - z
\] |
Applied egg-rr0.1
Simplified0.1
[Start]0.1 | \[ \left(x - \left(\left(\left(y + 0.5\right) \cdot \log y - e^{\mathsf{log1p}\left(y\right)}\right) + 1\right)\right) - z
\] |
|---|---|
+-commutative [=>]0.1 | \[ \left(x - \color{blue}{\left(1 + \left(\left(y + 0.5\right) \cdot \log y - e^{\mathsf{log1p}\left(y\right)}\right)\right)}\right) - z
\] |
associate-+r- [=>]0.1 | \[ \left(x - \color{blue}{\left(\left(1 + \left(y + 0.5\right) \cdot \log y\right) - e^{\mathsf{log1p}\left(y\right)}\right)}\right) - z
\] |
*-commutative [=>]0.1 | \[ \left(x - \left(\left(1 + \color{blue}{\log y \cdot \left(y + 0.5\right)}\right) - e^{\mathsf{log1p}\left(y\right)}\right)\right) - z
\] |
+-commutative [<=]0.1 | \[ \left(x - \left(\left(1 + \log y \cdot \color{blue}{\left(0.5 + y\right)}\right) - e^{\mathsf{log1p}\left(y\right)}\right)\right) - z
\] |
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 13632 |
| Alternative 2 | |
|---|---|
| Error | 18.5 |
| Cost | 7772 |
| Alternative 3 | |
|---|---|
| Error | 15.9 |
| Cost | 7640 |
| Alternative 4 | |
|---|---|
| Error | 7.4 |
| Cost | 7241 |
| Alternative 5 | |
|---|---|
| Error | 18.6 |
| Cost | 7117 |
| Alternative 6 | |
|---|---|
| Error | 18.6 |
| Cost | 7116 |
| Alternative 7 | |
|---|---|
| Error | 20.8 |
| Cost | 7116 |
| Alternative 8 | |
|---|---|
| Error | 16.6 |
| Cost | 7112 |
| Alternative 9 | |
|---|---|
| Error | 16.7 |
| Cost | 7112 |
| Alternative 10 | |
|---|---|
| Error | 6.6 |
| Cost | 7112 |
| Alternative 11 | |
|---|---|
| Error | 0.1 |
| Cost | 7104 |
| Alternative 12 | |
|---|---|
| Error | 0.1 |
| Cost | 7104 |
| Alternative 13 | |
|---|---|
| Error | 32.9 |
| Cost | 392 |
| Alternative 14 | |
|---|---|
| Error | 26.5 |
| Cost | 192 |
| Alternative 15 | |
|---|---|
| Error | 44.8 |
| Cost | 64 |
herbie shell --seed 2022364
(FPCore (x y z)
:name "Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(- (- (+ y x) z) (* (+ y 0.5) (log y)))
(- (+ (- x (* (+ y 0.5) (log y))) y) z))