| Alternative 1 | |
|---|---|
| Error | 1.0 |
| Cost | 23688 |
(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
(+
t_0
(/
(+
(* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)
0.083333333333333)
x)))
(t_2
(+
(/ 0.083333333333333 x)
(* z (* z (/ (+ y 0.0007936500793651) x))))))
(if (<= t_1 50000000000000.0)
(+ t_0 t_2)
(if (<= t_1 1e+308)
(+
(* x (+ -1.0 (- (log (/ 1.0 x)))))
(/
(+
(- (* (+ y 0.0007936500793651) (* z z)) (* z 0.0027777777777778))
0.083333333333333)
x))
(+ (- (* (log x) x) x) t_2)))))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 = t_0 + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
double t_2 = (0.083333333333333 / x) + (z * (z * ((y + 0.0007936500793651) / x)));
double tmp;
if (t_1 <= 50000000000000.0) {
tmp = t_0 + t_2;
} else if (t_1 <= 1e+308) {
tmp = (x * (-1.0 + -log((1.0 / x)))) + (((((y + 0.0007936500793651) * (z * z)) - (z * 0.0027777777777778)) + 0.083333333333333) / x);
} else {
tmp = ((log(x) * x) - x) + t_2;
}
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) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = (((x - 0.5d0) * log(x)) - x) + 0.91893853320467d0
t_1 = t_0 + ((((((y + 0.0007936500793651d0) * z) - 0.0027777777777778d0) * z) + 0.083333333333333d0) / x)
t_2 = (0.083333333333333d0 / x) + (z * (z * ((y + 0.0007936500793651d0) / x)))
if (t_1 <= 50000000000000.0d0) then
tmp = t_0 + t_2
else if (t_1 <= 1d+308) then
tmp = (x * ((-1.0d0) + -log((1.0d0 / x)))) + (((((y + 0.0007936500793651d0) * (z * z)) - (z * 0.0027777777777778d0)) + 0.083333333333333d0) / x)
else
tmp = ((log(x) * x) - x) + t_2
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 t_0 = (((x - 0.5) * Math.log(x)) - x) + 0.91893853320467;
double t_1 = t_0 + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
double t_2 = (0.083333333333333 / x) + (z * (z * ((y + 0.0007936500793651) / x)));
double tmp;
if (t_1 <= 50000000000000.0) {
tmp = t_0 + t_2;
} else if (t_1 <= 1e+308) {
tmp = (x * (-1.0 + -Math.log((1.0 / x)))) + (((((y + 0.0007936500793651) * (z * z)) - (z * 0.0027777777777778)) + 0.083333333333333) / x);
} else {
tmp = ((Math.log(x) * x) - x) + t_2;
}
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 = t_0 + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x) t_2 = (0.083333333333333 / x) + (z * (z * ((y + 0.0007936500793651) / x))) tmp = 0 if t_1 <= 50000000000000.0: tmp = t_0 + t_2 elif t_1 <= 1e+308: tmp = (x * (-1.0 + -math.log((1.0 / x)))) + (((((y + 0.0007936500793651) * (z * z)) - (z * 0.0027777777777778)) + 0.083333333333333) / x) else: tmp = ((math.log(x) * x) - x) + t_2 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(t_0 + Float64(Float64(Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)) t_2 = Float64(Float64(0.083333333333333 / x) + Float64(z * Float64(z * Float64(Float64(y + 0.0007936500793651) / x)))) tmp = 0.0 if (t_1 <= 50000000000000.0) tmp = Float64(t_0 + t_2); elseif (t_1 <= 1e+308) tmp = Float64(Float64(x * Float64(-1.0 + Float64(-log(Float64(1.0 / x))))) + Float64(Float64(Float64(Float64(Float64(y + 0.0007936500793651) * Float64(z * z)) - Float64(z * 0.0027777777777778)) + 0.083333333333333) / x)); else tmp = Float64(Float64(Float64(log(x) * x) - x) + t_2); 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 = t_0 + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x); t_2 = (0.083333333333333 / x) + (z * (z * ((y + 0.0007936500793651) / x))); tmp = 0.0; if (t_1 <= 50000000000000.0) tmp = t_0 + t_2; elseif (t_1 <= 1e+308) tmp = (x * (-1.0 + -log((1.0 / x)))) + (((((y + 0.0007936500793651) * (z * z)) - (z * 0.0027777777777778)) + 0.083333333333333) / x); else tmp = ((log(x) * x) - x) + t_2; 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[(t$95$0 + N[(N[(N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(0.083333333333333 / x), $MachinePrecision] + N[(z * N[(z * N[(N[(y + 0.0007936500793651), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 50000000000000.0], N[(t$95$0 + t$95$2), $MachinePrecision], If[LessEqual[t$95$1, 1e+308], N[(N[(x * N[(-1.0 + (-N[Log[N[(1.0 / x), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * N[(z * z), $MachinePrecision]), $MachinePrecision] - N[(z * 0.0027777777777778), $MachinePrecision]), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Log[x], $MachinePrecision] * x), $MachinePrecision] - x), $MachinePrecision] + t$95$2), $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 := t_0 + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\\
t_2 := \frac{0.083333333333333}{x} + z \cdot \left(z \cdot \frac{y + 0.0007936500793651}{x}\right)\\
\mathbf{if}\;t_1 \leq 50000000000000:\\
\;\;\;\;t_0 + t_2\\
\mathbf{elif}\;t_1 \leq 10^{+308}:\\
\;\;\;\;x \cdot \left(-1 + \left(-\log \left(\frac{1}{x}\right)\right)\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot \left(z \cdot z\right) - z \cdot 0.0027777777777778\right) + 0.083333333333333}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(\log x \cdot x - x\right) + t_2\\
\end{array}
Results
| Original | 6.1 |
|---|---|
| Target | 1.3 |
| Herbie | 1.0 |
if (+.f64 (+.f64 (-.f64 (*.f64 (-.f64 x 1/2) (log.f64 x)) x) 91893853320467/100000000000000) (/.f64 (+.f64 (*.f64 (-.f64 (*.f64 (+.f64 y 7936500793651/10000000000000000) z) 13888888888889/5000000000000000) z) 83333333333333/1000000000000000) x)) < 5e13Initial program 16.3
Applied egg-rr8.6
Taylor expanded in z around inf 8.9
Simplified7.6
[Start]8.9 | \[ \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\frac{0.083333333333333}{x} + z \cdot \frac{z \cdot \left(0.0007936500793651 + y\right)}{x}\right)
\] |
|---|---|
rational_best-simplify-1 [=>]8.9 | \[ \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\frac{0.083333333333333}{x} + z \cdot \frac{\color{blue}{\left(0.0007936500793651 + y\right) \cdot z}}{x}\right)
\] |
rational_best-simplify-3 [<=]8.9 | \[ \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\frac{0.083333333333333}{x} + z \cdot \frac{\color{blue}{\left(y + 0.0007936500793651\right)} \cdot z}{x}\right)
\] |
rational_best-simplify-62 [<=]7.6 | \[ \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\frac{0.083333333333333}{x} + z \cdot \color{blue}{\left(z \cdot \frac{y + 0.0007936500793651}{x}\right)}\right)
\] |
if 5e13 < (+.f64 (+.f64 (-.f64 (*.f64 (-.f64 x 1/2) (log.f64 x)) x) 91893853320467/100000000000000) (/.f64 (+.f64 (*.f64 (-.f64 (*.f64 (+.f64 y 7936500793651/10000000000000000) z) 13888888888889/5000000000000000) z) 83333333333333/1000000000000000) x)) < 1e308Initial program 0.4
Taylor expanded in x around inf 0.4
Simplified0.4
[Start]0.4 | \[ \left(-1 \cdot \log \left(\frac{1}{x}\right) - 1\right) \cdot x + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\] |
|---|---|
rational_best-simplify-1 [=>]0.4 | \[ \color{blue}{x \cdot \left(-1 \cdot \log \left(\frac{1}{x}\right) - 1\right)} + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\] |
rational_best-simplify-18 [=>]0.4 | \[ x \cdot \color{blue}{\left(-1 \cdot \log \left(\frac{1}{x}\right) + -1\right)} + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\] |
rational_best-simplify-3 [=>]0.4 | \[ x \cdot \color{blue}{\left(-1 + -1 \cdot \log \left(\frac{1}{x}\right)\right)} + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\] |
rational_best-simplify-1 [=>]0.4 | \[ x \cdot \left(-1 + \color{blue}{\log \left(\frac{1}{x}\right) \cdot -1}\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\] |
rational_best-simplify-10 [=>]0.4 | \[ x \cdot \left(-1 + \color{blue}{\left(-\log \left(\frac{1}{x}\right)\right)}\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\] |
Applied egg-rr0.4
if 1e308 < (+.f64 (+.f64 (-.f64 (*.f64 (-.f64 x 1/2) (log.f64 x)) x) 91893853320467/100000000000000) (/.f64 (+.f64 (*.f64 (-.f64 (*.f64 (+.f64 y 7936500793651/10000000000000000) z) 13888888888889/5000000000000000) z) 83333333333333/1000000000000000) x)) Initial program 63.3
Applied egg-rr7.6
Taylor expanded in z around inf 7.6
Simplified0.4
[Start]7.6 | \[ \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\frac{0.083333333333333}{x} + z \cdot \frac{z \cdot \left(0.0007936500793651 + y\right)}{x}\right)
\] |
|---|---|
rational_best-simplify-1 [=>]7.6 | \[ \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\frac{0.083333333333333}{x} + z \cdot \frac{\color{blue}{\left(0.0007936500793651 + y\right) \cdot z}}{x}\right)
\] |
rational_best-simplify-3 [<=]7.6 | \[ \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\frac{0.083333333333333}{x} + z \cdot \frac{\color{blue}{\left(y + 0.0007936500793651\right)} \cdot z}{x}\right)
\] |
rational_best-simplify-62 [<=]0.4 | \[ \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\frac{0.083333333333333}{x} + z \cdot \color{blue}{\left(z \cdot \frac{y + 0.0007936500793651}{x}\right)}\right)
\] |
Taylor expanded in x around inf 0.3
Simplified0.4
[Start]0.3 | \[ \left(-1 \cdot \log \left(\frac{1}{x}\right) - 1\right) \cdot x + \left(\frac{0.083333333333333}{x} + z \cdot \left(z \cdot \frac{y + 0.0007936500793651}{x}\right)\right)
\] |
|---|---|
rational_best-simplify-1 [=>]0.3 | \[ \color{blue}{x \cdot \left(-1 \cdot \log \left(\frac{1}{x}\right) - 1\right)} + \left(\frac{0.083333333333333}{x} + z \cdot \left(z \cdot \frac{y + 0.0007936500793651}{x}\right)\right)
\] |
rational_best-simplify-73 [=>]0.4 | \[ \color{blue}{\left(\left(-1 \cdot \log \left(\frac{1}{x}\right)\right) \cdot x - x \cdot 1\right)} + \left(\frac{0.083333333333333}{x} + z \cdot \left(z \cdot \frac{y + 0.0007936500793651}{x}\right)\right)
\] |
rational_best-simplify-1 [<=]0.4 | \[ \left(\color{blue}{x \cdot \left(-1 \cdot \log \left(\frac{1}{x}\right)\right)} - x \cdot 1\right) + \left(\frac{0.083333333333333}{x} + z \cdot \left(z \cdot \frac{y + 0.0007936500793651}{x}\right)\right)
\] |
rational_best-simplify-1 [=>]0.4 | \[ \left(x \cdot \color{blue}{\left(\log \left(\frac{1}{x}\right) \cdot -1\right)} - x \cdot 1\right) + \left(\frac{0.083333333333333}{x} + z \cdot \left(z \cdot \frac{y + 0.0007936500793651}{x}\right)\right)
\] |
rational_best-simplify-10 [=>]0.4 | \[ \left(x \cdot \color{blue}{\left(-\log \left(\frac{1}{x}\right)\right)} - x \cdot 1\right) + \left(\frac{0.083333333333333}{x} + z \cdot \left(z \cdot \frac{y + 0.0007936500793651}{x}\right)\right)
\] |
rational_best-simplify-7 [=>]0.4 | \[ \left(x \cdot \left(-\log \left(\frac{1}{x}\right)\right) - \color{blue}{x}\right) + \left(\frac{0.083333333333333}{x} + z \cdot \left(z \cdot \frac{y + 0.0007936500793651}{x}\right)\right)
\] |
Taylor expanded in x around 0 0.4
Final simplification1.0
| Alternative 1 | |
|---|---|
| Error | 1.0 |
| Cost | 23688 |
| Alternative 2 | |
|---|---|
| Error | 2.6 |
| Cost | 8904 |
| Alternative 3 | |
|---|---|
| Error | 5.0 |
| Cost | 8144 |
| Alternative 4 | |
|---|---|
| Error | 1.0 |
| Cost | 8136 |
| Alternative 5 | |
|---|---|
| Error | 1.9 |
| Cost | 8008 |
| Alternative 6 | |
|---|---|
| Error | 1.3 |
| Cost | 8000 |
| Alternative 7 | |
|---|---|
| Error | 9.3 |
| Cost | 7880 |
| Alternative 8 | |
|---|---|
| Error | 9.1 |
| Cost | 7620 |
| Alternative 9 | |
|---|---|
| Error | 11.7 |
| Cost | 7232 |
| Alternative 10 | |
|---|---|
| Error | 11.7 |
| Cost | 7232 |
| Alternative 11 | |
|---|---|
| Error | 12.6 |
| Cost | 6976 |
| Alternative 12 | |
|---|---|
| Error | 43.2 |
| Cost | 192 |
herbie shell --seed 2023101
(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)))