| Alternative 1 | |
|---|---|
| Error | 5.7 |
| Cost | 31436 |
(FPCore (x y z)
:precision binary64
(+
(+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
(/
(+
(* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)
0.083333333333333)
x)))(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (- (* (- x 0.5) (log x)) x) 0.91893853320467))
(t_1 (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)))
(if (<= t_1 (- INFINITY))
(+ t_0 (* y (/ (pow z 2.0) x)))
(if (<= t_1 1e+258)
(+
t_0
(/
1.0
(/
x
(+
(* z (+ (* z (+ y 0.0007936500793651)) -0.0027777777777778))
0.083333333333333))))
(+ (* x (- (log x) 1.0)) (/ 0.083333333333333 x))))))double code(double x, double y, double z) {
return ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
}
double code(double x, double y, double z) {
double t_0 = (((x - 0.5) * log(x)) - x) + 0.91893853320467;
double t_1 = (((y + 0.0007936500793651) * z) - 0.0027777777777778) * z;
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_0 + (y * (pow(z, 2.0) / x));
} else if (t_1 <= 1e+258) {
tmp = t_0 + (1.0 / (x / ((z * ((z * (y + 0.0007936500793651)) + -0.0027777777777778)) + 0.083333333333333)));
} else {
tmp = (x * (log(x) - 1.0)) + (0.083333333333333 / x);
}
return tmp;
}
public static double code(double x, double y, double z) {
return ((((x - 0.5) * Math.log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
}
public static double code(double x, double y, double z) {
double t_0 = (((x - 0.5) * Math.log(x)) - x) + 0.91893853320467;
double t_1 = (((y + 0.0007936500793651) * z) - 0.0027777777777778) * z;
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = t_0 + (y * (Math.pow(z, 2.0) / x));
} else if (t_1 <= 1e+258) {
tmp = t_0 + (1.0 / (x / ((z * ((z * (y + 0.0007936500793651)) + -0.0027777777777778)) + 0.083333333333333)));
} else {
tmp = (x * (Math.log(x) - 1.0)) + (0.083333333333333 / x);
}
return tmp;
}
def code(x, y, z): return ((((x - 0.5) * math.log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)
def code(x, y, z): t_0 = (((x - 0.5) * math.log(x)) - x) + 0.91893853320467 t_1 = (((y + 0.0007936500793651) * z) - 0.0027777777777778) * z tmp = 0 if t_1 <= -math.inf: tmp = t_0 + (y * (math.pow(z, 2.0) / x)) elif t_1 <= 1e+258: tmp = t_0 + (1.0 / (x / ((z * ((z * (y + 0.0007936500793651)) + -0.0027777777777778)) + 0.083333333333333))) else: tmp = (x * (math.log(x) - 1.0)) + (0.083333333333333 / x) return tmp
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x - 0.5) * log(x)) - x) + 0.91893853320467) + Float64(Float64(Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)) end
function code(x, y, z) t_0 = Float64(Float64(Float64(Float64(x - 0.5) * log(x)) - x) + 0.91893853320467) t_1 = Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(t_0 + Float64(y * Float64((z ^ 2.0) / x))); elseif (t_1 <= 1e+258) tmp = Float64(t_0 + Float64(1.0 / Float64(x / Float64(Float64(z * Float64(Float64(z * Float64(y + 0.0007936500793651)) + -0.0027777777777778)) + 0.083333333333333)))); else tmp = Float64(Float64(x * Float64(log(x) - 1.0)) + Float64(0.083333333333333 / x)); end return tmp end
function tmp = code(x, y, z) tmp = ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x); end
function tmp_2 = code(x, y, z) t_0 = (((x - 0.5) * log(x)) - x) + 0.91893853320467; t_1 = (((y + 0.0007936500793651) * z) - 0.0027777777777778) * z; tmp = 0.0; if (t_1 <= -Inf) tmp = t_0 + (y * ((z ^ 2.0) / x)); elseif (t_1 <= 1e+258) tmp = t_0 + (1.0 / (x / ((z * ((z * (y + 0.0007936500793651)) + -0.0027777777777778)) + 0.083333333333333))); else tmp = (x * (log(x) - 1.0)) + (0.083333333333333 / x); end tmp_2 = tmp; end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] + N[(N[(N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(t$95$0 + N[(y * N[(N[Power[z, 2.0], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+258], N[(t$95$0 + N[(1.0 / N[(x / N[(N[(z * N[(N[(z * N[(y + 0.0007936500793651), $MachinePrecision]), $MachinePrecision] + -0.0027777777777778), $MachinePrecision]), $MachinePrecision] + 0.083333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(N[Log[x], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] + N[(0.083333333333333 / x), $MachinePrecision]), $MachinePrecision]]]]]
\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\begin{array}{l}
t_0 := \left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\\
t_1 := \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;t_0 + y \cdot \frac{{z}^{2}}{x}\\
\mathbf{elif}\;t_1 \leq 10^{+258}:\\
\;\;\;\;t_0 + \frac{1}{\frac{x}{z \cdot \left(z \cdot \left(y + 0.0007936500793651\right) + -0.0027777777777778\right) + 0.083333333333333}}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - 1\right) + \frac{0.083333333333333}{x}\\
\end{array}
Results
| Original | 6.1 |
|---|---|
| Target | 1.4 |
| Herbie | 3.7 |
if (*.f64 (-.f64 (*.f64 (+.f64 y 7936500793651/10000000000000000) z) 13888888888889/5000000000000000) z) < -inf.0Initial program 64.0
Taylor expanded in y around inf 64.0
Simplified24.0
[Start]64.0 | \[ \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{y \cdot {z}^{2}}{x}
\] |
|---|---|
rational.json-simplify-2 [=>]64.0 | \[ \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\color{blue}{{z}^{2} \cdot y}}{x}
\] |
rational.json-simplify-49 [=>]24.0 | \[ \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \color{blue}{y \cdot \frac{{z}^{2}}{x}}
\] |
if -inf.0 < (*.f64 (-.f64 (*.f64 (+.f64 y 7936500793651/10000000000000000) z) 13888888888889/5000000000000000) z) < 1.00000000000000006e258Initial program 0.4
Applied egg-rr0.4
Applied egg-rr0.4
if 1.00000000000000006e258 < (*.f64 (-.f64 (*.f64 (+.f64 y 7936500793651/10000000000000000) z) 13888888888889/5000000000000000) z) Initial program 47.0
Taylor expanded in z around 0 30.8
Taylor expanded in x around inf 30.7
Simplified30.7
[Start]30.7 | \[ \left(-1 \cdot \log \left(\frac{1}{x}\right) - 1\right) \cdot x + \frac{0.083333333333333}{x}
\] |
|---|---|
rational.json-simplify-2 [=>]30.7 | \[ \color{blue}{x \cdot \left(-1 \cdot \log \left(\frac{1}{x}\right) - 1\right)} + \frac{0.083333333333333}{x}
\] |
rational.json-simplify-2 [=>]30.7 | \[ x \cdot \left(\color{blue}{\log \left(\frac{1}{x}\right) \cdot -1} - 1\right) + \frac{0.083333333333333}{x}
\] |
rational.json-simplify-9 [=>]30.7 | \[ x \cdot \left(\color{blue}{\left(-\log \left(\frac{1}{x}\right)\right)} - 1\right) + \frac{0.083333333333333}{x}
\] |
rational.json-simplify-12 [=>]30.7 | \[ x \cdot \left(\color{blue}{\left(0 - \log \left(\frac{1}{x}\right)\right)} - 1\right) + \frac{0.083333333333333}{x}
\] |
rational.json-simplify-42 [=>]30.7 | \[ x \cdot \color{blue}{\left(\left(0 - 1\right) - \log \left(\frac{1}{x}\right)\right)} + \frac{0.083333333333333}{x}
\] |
metadata-eval [=>]30.7 | \[ x \cdot \left(\color{blue}{-1} - \log \left(\frac{1}{x}\right)\right) + \frac{0.083333333333333}{x}
\] |
Taylor expanded in x around 0 30.7
Simplified30.7
[Start]30.7 | \[ -1 \cdot \left(\left(1 + -1 \cdot \log x\right) \cdot x\right) + \frac{0.083333333333333}{x}
\] |
|---|---|
rational.json-simplify-2 [=>]30.7 | \[ -1 \cdot \color{blue}{\left(x \cdot \left(1 + -1 \cdot \log x\right)\right)} + \frac{0.083333333333333}{x}
\] |
rational.json-simplify-43 [=>]30.7 | \[ \color{blue}{x \cdot \left(\left(1 + -1 \cdot \log x\right) \cdot -1\right)} + \frac{0.083333333333333}{x}
\] |
rational.json-simplify-9 [=>]30.7 | \[ x \cdot \color{blue}{\left(-\left(1 + -1 \cdot \log x\right)\right)} + \frac{0.083333333333333}{x}
\] |
rational.json-simplify-12 [=>]30.7 | \[ x \cdot \color{blue}{\left(0 - \left(1 + -1 \cdot \log x\right)\right)} + \frac{0.083333333333333}{x}
\] |
rational.json-simplify-17 [=>]30.7 | \[ x \cdot \left(0 - \color{blue}{\left(-1 \cdot \log x - -1\right)}\right) + \frac{0.083333333333333}{x}
\] |
rational.json-simplify-2 [=>]30.7 | \[ x \cdot \left(0 - \left(\color{blue}{\log x \cdot -1} - -1\right)\right) + \frac{0.083333333333333}{x}
\] |
rational.json-simplify-9 [=>]30.7 | \[ x \cdot \left(0 - \left(\color{blue}{\left(-\log x\right)} - -1\right)\right) + \frac{0.083333333333333}{x}
\] |
rational.json-simplify-12 [=>]30.7 | \[ x \cdot \left(0 - \left(\color{blue}{\left(0 - \log x\right)} - -1\right)\right) + \frac{0.083333333333333}{x}
\] |
rational.json-simplify-42 [=>]30.7 | \[ x \cdot \left(0 - \color{blue}{\left(\left(0 - -1\right) - \log x\right)}\right) + \frac{0.083333333333333}{x}
\] |
metadata-eval [=>]30.7 | \[ x \cdot \left(0 - \left(\color{blue}{1} - \log x\right)\right) + \frac{0.083333333333333}{x}
\] |
rational.json-simplify-45 [=>]30.7 | \[ x \cdot \color{blue}{\left(\log x - \left(1 - 0\right)\right)} + \frac{0.083333333333333}{x}
\] |
metadata-eval [=>]30.7 | \[ x \cdot \left(\log x - \color{blue}{1}\right) + \frac{0.083333333333333}{x}
\] |
Final simplification3.7
| Alternative 1 | |
|---|---|
| Error | 5.7 |
| Cost | 31436 |
| Alternative 2 | |
|---|---|
| Error | 5.8 |
| Cost | 23880 |
| Alternative 3 | |
|---|---|
| Error | 5.3 |
| Cost | 23880 |
| Alternative 4 | |
|---|---|
| Error | 3.3 |
| Cost | 8132 |
| Alternative 5 | |
|---|---|
| Error | 3.3 |
| Cost | 8132 |
| Alternative 6 | |
|---|---|
| Error | 3.3 |
| Cost | 8004 |
| Alternative 7 | |
|---|---|
| Error | 9.4 |
| Cost | 7752 |
| Alternative 8 | |
|---|---|
| Error | 4.3 |
| Cost | 7748 |
| Alternative 9 | |
|---|---|
| Error | 9.3 |
| Cost | 7620 |
| Alternative 10 | |
|---|---|
| Error | 12.1 |
| Cost | 7488 |
| Alternative 11 | |
|---|---|
| Error | 12.1 |
| Cost | 7360 |
| Alternative 12 | |
|---|---|
| Error | 12.1 |
| Cost | 7360 |
| Alternative 13 | |
|---|---|
| Error | 12.1 |
| Cost | 7232 |
| Alternative 14 | |
|---|---|
| Error | 12.9 |
| Cost | 7108 |
| Alternative 15 | |
|---|---|
| Error | 12.9 |
| Cost | 6976 |
| Alternative 16 | |
|---|---|
| Error | 42.6 |
| Cost | 448 |
| Alternative 17 | |
|---|---|
| Error | 42.6 |
| Cost | 448 |
| Alternative 18 | |
|---|---|
| Error | 43.1 |
| Cost | 320 |
| Alternative 19 | |
|---|---|
| Error | 42.6 |
| Cost | 320 |
| Alternative 20 | |
|---|---|
| Error | 43.1 |
| Cost | 192 |
| Alternative 21 | |
|---|---|
| Error | 61.0 |
| Cost | 64 |
herbie shell --seed 2023063
(FPCore (x y z)
:name "Numeric.SpecFunctions:$slogFactorial from math-functions-0.1.5.2, B"
:precision binary64
:herbie-target
(+ (+ (+ (* (- x 0.5) (log x)) (- 0.91893853320467 x)) (/ 0.083333333333333 x)) (* (/ z x) (- (* z (+ y 0.0007936500793651)) 0.0027777777777778)))
(+ (+ (- (* (- x 0.5) (log x)) x) 0.91893853320467) (/ (+ (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z) 0.083333333333333) x)))