| Alternative 1 | |
|---|---|
| Error | 5.9 |
| Cost | 8008 |
(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
(if (<= x 6e+101)
(+
(- (* (- x 0.5) (log x)) x)
(+
0.91893853320467
(+
(/ (* (pow z 2.0) (+ y 0.0007936500793651)) x)
(+ (/ 0.083333333333333 x) (* -0.0027777777777778 (/ z x))))))
(* (- (* -1.0 (log (/ 1.0 x))) 1.0) 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 tmp;
if (x <= 6e+101) {
tmp = (((x - 0.5) * log(x)) - x) + (0.91893853320467 + (((pow(z, 2.0) * (y + 0.0007936500793651)) / x) + ((0.083333333333333 / x) + (-0.0027777777777778 * (z / x)))));
} else {
tmp = ((-1.0 * log((1.0 / x))) - 1.0) * x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((((x - 0.5d0) * log(x)) - x) + 0.91893853320467d0) + ((((((y + 0.0007936500793651d0) * z) - 0.0027777777777778d0) * z) + 0.083333333333333d0) / x)
end function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= 6d+101) then
tmp = (((x - 0.5d0) * log(x)) - x) + (0.91893853320467d0 + ((((z ** 2.0d0) * (y + 0.0007936500793651d0)) / x) + ((0.083333333333333d0 / x) + ((-0.0027777777777778d0) * (z / x)))))
else
tmp = (((-1.0d0) * log((1.0d0 / x))) - 1.0d0) * x
end if
code = tmp
end function
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 tmp;
if (x <= 6e+101) {
tmp = (((x - 0.5) * Math.log(x)) - x) + (0.91893853320467 + (((Math.pow(z, 2.0) * (y + 0.0007936500793651)) / x) + ((0.083333333333333 / x) + (-0.0027777777777778 * (z / x)))));
} else {
tmp = ((-1.0 * Math.log((1.0 / x))) - 1.0) * 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): tmp = 0 if x <= 6e+101: tmp = (((x - 0.5) * math.log(x)) - x) + (0.91893853320467 + (((math.pow(z, 2.0) * (y + 0.0007936500793651)) / x) + ((0.083333333333333 / x) + (-0.0027777777777778 * (z / x))))) else: tmp = ((-1.0 * math.log((1.0 / x))) - 1.0) * 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) tmp = 0.0 if (x <= 6e+101) tmp = Float64(Float64(Float64(Float64(x - 0.5) * log(x)) - x) + Float64(0.91893853320467 + Float64(Float64(Float64((z ^ 2.0) * Float64(y + 0.0007936500793651)) / x) + Float64(Float64(0.083333333333333 / x) + Float64(-0.0027777777777778 * Float64(z / x)))))); else tmp = Float64(Float64(Float64(-1.0 * log(Float64(1.0 / x))) - 1.0) * 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) tmp = 0.0; if (x <= 6e+101) tmp = (((x - 0.5) * log(x)) - x) + (0.91893853320467 + ((((z ^ 2.0) * (y + 0.0007936500793651)) / x) + ((0.083333333333333 / x) + (-0.0027777777777778 * (z / x))))); else tmp = ((-1.0 * log((1.0 / x))) - 1.0) * 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_] := If[LessEqual[x, 6e+101], N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + N[(0.91893853320467 + N[(N[(N[(N[Power[z, 2.0], $MachinePrecision] * N[(y + 0.0007936500793651), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + N[(N[(0.083333333333333 / x), $MachinePrecision] + N[(-0.0027777777777778 * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-1.0 * N[Log[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision] * x), $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}
\mathbf{if}\;x \leq 6 \cdot 10^{+101}:\\
\;\;\;\;\left(\left(x - 0.5\right) \cdot \log x - x\right) + \left(0.91893853320467 + \left(\frac{{z}^{2} \cdot \left(y + 0.0007936500793651\right)}{x} + \left(\frac{0.083333333333333}{x} + -0.0027777777777778 \cdot \frac{z}{x}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-1 \cdot \log \left(\frac{1}{x}\right) - 1\right) \cdot x\\
\end{array}
Results
| Original | 6.4 |
|---|---|
| Target | 1.3 |
| Herbie | 3.7 |
if x < 5.99999999999999986e101Initial program 1.4
Simplified1.4
[Start]1.4 | \[ \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}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-35 [=>]1.4 | \[ \color{blue}{\frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x} + \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-82 [=>]1.4 | \[ \color{blue}{\left(\left(x - 0.5\right) \cdot \log x - x\right) + \left(\frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x} + 0.91893853320467\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-35 [=>]1.4 | \[ \left(\left(x - 0.5\right) \cdot \log x - x\right) + \color{blue}{\left(0.91893853320467 + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]1.4 | \[ \left(\left(x - 0.5\right) \cdot \log x - x\right) + \left(0.91893853320467 + \frac{\color{blue}{z \cdot \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right)} + 0.083333333333333}{x}\right)
\] |
Taylor expanded in z around inf 1.5
Simplified1.5
[Start]1.5 | \[ \left(\left(x - 0.5\right) \cdot \log x - x\right) + \left(0.91893853320467 + \left(0.083333333333333 \cdot \frac{1}{x} + \left(\frac{{z}^{2} \cdot \left(0.0007936500793651 + y\right)}{x} + -0.0027777777777778 \cdot \frac{z}{x}\right)\right)\right)
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-82 [=>]1.5 | \[ \left(\left(x - 0.5\right) \cdot \log x - x\right) + \left(0.91893853320467 + \color{blue}{\left(\frac{{z}^{2} \cdot \left(0.0007936500793651 + y\right)}{x} + \left(0.083333333333333 \cdot \frac{1}{x} + -0.0027777777777778 \cdot \frac{z}{x}\right)\right)}\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-35 [<=]1.5 | \[ \left(\left(x - 0.5\right) \cdot \log x - x\right) + \left(0.91893853320467 + \left(\frac{{z}^{2} \cdot \color{blue}{\left(y + 0.0007936500793651\right)}}{x} + \left(0.083333333333333 \cdot \frac{1}{x} + -0.0027777777777778 \cdot \frac{z}{x}\right)\right)\right)
\] |
Taylor expanded in x around 0 1.5
if 5.99999999999999986e101 < x Initial program 13.4
Simplified13.4
[Start]13.4 | \[ \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}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-35 [=>]13.4 | \[ \color{blue}{\left(0.91893853320467 + \left(\left(x - 0.5\right) \cdot \log x - x\right)\right)} + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\] |
rational_best_oopsla_all_46_json_45_simplify-108 [=>]13.4 | \[ \color{blue}{\left(\left(\left(x - 0.5\right) \cdot \log x + 0.91893853320467\right) - x\right)} + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\] |
rational_best_oopsla_all_46_json_45_simplify-35 [=>]13.4 | \[ \left(\color{blue}{\left(0.91893853320467 + \left(x - 0.5\right) \cdot \log x\right)} - x\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\] |
rational_best_oopsla_all_46_json_45_simplify-107 [=>]13.4 | \[ \color{blue}{\left(\left(x - 0.5\right) \cdot \log x + \left(0.91893853320467 - x\right)\right)} + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]13.4 | \[ \left(\left(x - 0.5\right) \cdot \log x + \left(0.91893853320467 - x\right)\right) + \frac{\color{blue}{z \cdot \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right)} + 0.083333333333333}{x}
\] |
Taylor expanded in z around 0 6.9
Taylor expanded in x around inf 6.8
Final simplification3.7
| Alternative 1 | |
|---|---|
| Error | 5.9 |
| Cost | 8008 |
| Alternative 2 | |
|---|---|
| Error | 3.7 |
| Cost | 8004 |
| Alternative 3 | |
|---|---|
| Error | 4.6 |
| Cost | 7940 |
| Alternative 4 | |
|---|---|
| Error | 6.4 |
| Cost | 7748 |
| Alternative 5 | |
|---|---|
| Error | 9.4 |
| Cost | 7620 |
| Alternative 6 | |
|---|---|
| Error | 12.0 |
| Cost | 7232 |
| Alternative 7 | |
|---|---|
| Error | 12.9 |
| Cost | 7168 |
| Alternative 8 | |
|---|---|
| Error | 12.9 |
| Cost | 7108 |
| Alternative 9 | |
|---|---|
| Error | 12.6 |
| Cost | 7108 |
| Alternative 10 | |
|---|---|
| Error | 12.9 |
| Cost | 7044 |
| Alternative 11 | |
|---|---|
| Error | 43.1 |
| Cost | 192 |
herbie shell --seed 2023090
(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)))