| Alternative 1 | |
|---|---|
| Accuracy | 99.5% |
| Cost | 8004 |
(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 (* z (+ -0.0027777777777778 (* z (+ y 0.0007936500793651)))))
(t_1 (+ (- (* x (log x)) x) 0.91893853320467)))
(if (<= t_0 -2e+47)
(+ t_1 (* y (/ z (/ x z))))
(if (<= t_0 5e+285)
(+
(fma (+ x -0.5) (log x) (- 0.91893853320467 x))
(/
(fma
z
(fma (+ y 0.0007936500793651) z -0.0027777777777778)
0.083333333333333)
x))
(+ t_1 (* z (* z (/ (+ y 0.0007936500793651) 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 = z * (-0.0027777777777778 + (z * (y + 0.0007936500793651)));
double t_1 = ((x * log(x)) - x) + 0.91893853320467;
double tmp;
if (t_0 <= -2e+47) {
tmp = t_1 + (y * (z / (x / z)));
} else if (t_0 <= 5e+285) {
tmp = fma((x + -0.5), log(x), (0.91893853320467 - x)) + (fma(z, fma((y + 0.0007936500793651), z, -0.0027777777777778), 0.083333333333333) / x);
} else {
tmp = t_1 + (z * (z * ((y + 0.0007936500793651) / 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(z * Float64(-0.0027777777777778 + Float64(z * Float64(y + 0.0007936500793651)))) t_1 = Float64(Float64(Float64(x * log(x)) - x) + 0.91893853320467) tmp = 0.0 if (t_0 <= -2e+47) tmp = Float64(t_1 + Float64(y * Float64(z / Float64(x / z)))); elseif (t_0 <= 5e+285) tmp = Float64(fma(Float64(x + -0.5), log(x), Float64(0.91893853320467 - x)) + Float64(fma(z, fma(Float64(y + 0.0007936500793651), z, -0.0027777777777778), 0.083333333333333) / x)); else tmp = Float64(t_1 + Float64(z * Float64(z * Float64(Float64(y + 0.0007936500793651) / x)))); end return 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[(z * N[(-0.0027777777777778 + N[(z * N[(y + 0.0007936500793651), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(x * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+47], N[(t$95$1 + N[(y * N[(z / N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+285], N[(N[(N[(x + -0.5), $MachinePrecision] * N[Log[x], $MachinePrecision] + N[(0.91893853320467 - x), $MachinePrecision]), $MachinePrecision] + N[(N[(z * N[(N[(y + 0.0007936500793651), $MachinePrecision] * z + -0.0027777777777778), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + N[(z * N[(z * N[(N[(y + 0.0007936500793651), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $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 := z \cdot \left(-0.0027777777777778 + z \cdot \left(y + 0.0007936500793651\right)\right)\\
t_1 := \left(x \cdot \log x - x\right) + 0.91893853320467\\
\mathbf{if}\;t_0 \leq -2 \cdot 10^{+47}:\\
\;\;\;\;t_1 + y \cdot \frac{z}{\frac{x}{z}}\\
\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+285}:\\
\;\;\;\;\mathsf{fma}\left(x + -0.5, \log x, 0.91893853320467 - x\right) + \frac{\mathsf{fma}\left(z, \mathsf{fma}\left(y + 0.0007936500793651, z, -0.0027777777777778\right), 0.083333333333333\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;t_1 + z \cdot \left(z \cdot \frac{y + 0.0007936500793651}{x}\right)\\
\end{array}
| Original | 90.3% |
|---|---|
| Target | 97.9% |
| Herbie | 99.4% |
if (*.f64 (-.f64 (*.f64 (+.f64 y 7936500793651/10000000000000000) z) 13888888888889/5000000000000000) z) < -2.0000000000000001e47Initial program 71.1%
Taylor expanded in z around inf 71.1%
Simplified83.4%
[Start]71.1 | \[ \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{{z}^{2} \cdot \left(0.0007936500793651 + y\right)}{x}
\] |
|---|---|
associate-/l* [=>]83.4 | \[ \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \color{blue}{\frac{{z}^{2}}{\frac{x}{0.0007936500793651 + y}}}
\] |
unpow2 [=>]83.4 | \[ \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\color{blue}{z \cdot z}}{\frac{x}{0.0007936500793651 + y}}
\] |
Taylor expanded in x around inf 83.4%
Simplified83.4%
[Start]83.4 | \[ \left(\left(-1 \cdot \left(\log \left(\frac{1}{x}\right) \cdot x\right) - x\right) + 0.91893853320467\right) + \frac{z \cdot z}{\frac{x}{0.0007936500793651 + y}}
\] |
|---|---|
associate-*r* [=>]83.4 | \[ \left(\left(\color{blue}{\left(-1 \cdot \log \left(\frac{1}{x}\right)\right) \cdot x} - x\right) + 0.91893853320467\right) + \frac{z \cdot z}{\frac{x}{0.0007936500793651 + y}}
\] |
*-commutative [=>]83.4 | \[ \left(\left(\color{blue}{x \cdot \left(-1 \cdot \log \left(\frac{1}{x}\right)\right)} - x\right) + 0.91893853320467\right) + \frac{z \cdot z}{\frac{x}{0.0007936500793651 + y}}
\] |
mul-1-neg [=>]83.4 | \[ \left(\left(x \cdot \color{blue}{\left(-\log \left(\frac{1}{x}\right)\right)} - x\right) + 0.91893853320467\right) + \frac{z \cdot z}{\frac{x}{0.0007936500793651 + y}}
\] |
log-rec [=>]83.4 | \[ \left(\left(x \cdot \left(-\color{blue}{\left(-\log x\right)}\right) - x\right) + 0.91893853320467\right) + \frac{z \cdot z}{\frac{x}{0.0007936500793651 + y}}
\] |
remove-double-neg [=>]83.4 | \[ \left(\left(x \cdot \color{blue}{\log x} - x\right) + 0.91893853320467\right) + \frac{z \cdot z}{\frac{x}{0.0007936500793651 + y}}
\] |
Taylor expanded in y around inf 70.2%
Simplified97.9%
[Start]70.2 | \[ \left(\left(x \cdot \log x - x\right) + 0.91893853320467\right) + \frac{y \cdot {z}^{2}}{x}
\] |
|---|---|
unpow2 [=>]70.2 | \[ \left(\left(x \cdot \log x - x\right) + 0.91893853320467\right) + \frac{y \cdot \color{blue}{\left(z \cdot z\right)}}{x}
\] |
associate-*r/ [<=]88.3 | \[ \left(\left(x \cdot \log x - x\right) + 0.91893853320467\right) + \color{blue}{y \cdot \frac{z \cdot z}{x}}
\] |
associate-/l* [=>]97.9 | \[ \left(\left(x \cdot \log x - x\right) + 0.91893853320467\right) + y \cdot \color{blue}{\frac{z}{\frac{x}{z}}}
\] |
if -2.0000000000000001e47 < (*.f64 (-.f64 (*.f64 (+.f64 y 7936500793651/10000000000000000) z) 13888888888889/5000000000000000) z) < 5.00000000000000016e285Initial program 99.4%
Simplified99.5%
[Start]99.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}
\] |
|---|---|
associate-+l- [=>]99.4 | \[ \color{blue}{\left(\left(x - 0.5\right) \cdot \log x - \left(x - 0.91893853320467\right)\right)} + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\] |
sub-neg [=>]99.4 | \[ \left(\left(x - 0.5\right) \cdot \log x - \color{blue}{\left(x + \left(-0.91893853320467\right)\right)}\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\] |
associate--r+ [=>]99.4 | \[ \color{blue}{\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) - \left(-0.91893853320467\right)\right)} + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\] |
associate--r+ [<=]99.4 | \[ \color{blue}{\left(\left(x - 0.5\right) \cdot \log x - \left(x + \left(-0.91893853320467\right)\right)\right)} + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\] |
sub-neg [<=]99.4 | \[ \left(\left(x - 0.5\right) \cdot \log x - \color{blue}{\left(x - 0.91893853320467\right)}\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\] |
fma-neg [=>]99.5 | \[ \color{blue}{\mathsf{fma}\left(x - 0.5, \log x, -\left(x - 0.91893853320467\right)\right)} + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\] |
sub-neg [=>]99.5 | \[ \mathsf{fma}\left(\color{blue}{x + \left(-0.5\right)}, \log x, -\left(x - 0.91893853320467\right)\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\] |
metadata-eval [=>]99.5 | \[ \mathsf{fma}\left(x + \color{blue}{-0.5}, \log x, -\left(x - 0.91893853320467\right)\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\] |
neg-sub0 [=>]99.5 | \[ \mathsf{fma}\left(x + -0.5, \log x, \color{blue}{0 - \left(x - 0.91893853320467\right)}\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\] |
associate-+l- [<=]99.5 | \[ \mathsf{fma}\left(x + -0.5, \log x, \color{blue}{\left(0 - x\right) + 0.91893853320467}\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\] |
neg-sub0 [<=]99.5 | \[ \mathsf{fma}\left(x + -0.5, \log x, \color{blue}{\left(-x\right)} + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\] |
+-commutative [=>]99.5 | \[ \mathsf{fma}\left(x + -0.5, \log x, \color{blue}{0.91893853320467 + \left(-x\right)}\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\] |
unsub-neg [=>]99.5 | \[ \mathsf{fma}\left(x + -0.5, \log x, \color{blue}{0.91893853320467 - x}\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\] |
if 5.00000000000000016e285 < (*.f64 (-.f64 (*.f64 (+.f64 y 7936500793651/10000000000000000) z) 13888888888889/5000000000000000) z) Initial program 11.1%
Taylor expanded in z around inf 9.7%
Simplified29.3%
[Start]9.7 | \[ \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{{z}^{2} \cdot \left(0.0007936500793651 + y\right)}{x}
\] |
|---|---|
associate-/l* [=>]29.3 | \[ \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \color{blue}{\frac{{z}^{2}}{\frac{x}{0.0007936500793651 + y}}}
\] |
unpow2 [=>]29.3 | \[ \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\color{blue}{z \cdot z}}{\frac{x}{0.0007936500793651 + y}}
\] |
Taylor expanded in x around inf 29.3%
Simplified29.3%
[Start]29.3 | \[ \left(\left(-1 \cdot \left(\log \left(\frac{1}{x}\right) \cdot x\right) - x\right) + 0.91893853320467\right) + \frac{z \cdot z}{\frac{x}{0.0007936500793651 + y}}
\] |
|---|---|
associate-*r* [=>]29.3 | \[ \left(\left(\color{blue}{\left(-1 \cdot \log \left(\frac{1}{x}\right)\right) \cdot x} - x\right) + 0.91893853320467\right) + \frac{z \cdot z}{\frac{x}{0.0007936500793651 + y}}
\] |
*-commutative [=>]29.3 | \[ \left(\left(\color{blue}{x \cdot \left(-1 \cdot \log \left(\frac{1}{x}\right)\right)} - x\right) + 0.91893853320467\right) + \frac{z \cdot z}{\frac{x}{0.0007936500793651 + y}}
\] |
mul-1-neg [=>]29.3 | \[ \left(\left(x \cdot \color{blue}{\left(-\log \left(\frac{1}{x}\right)\right)} - x\right) + 0.91893853320467\right) + \frac{z \cdot z}{\frac{x}{0.0007936500793651 + y}}
\] |
log-rec [=>]29.3 | \[ \left(\left(x \cdot \left(-\color{blue}{\left(-\log x\right)}\right) - x\right) + 0.91893853320467\right) + \frac{z \cdot z}{\frac{x}{0.0007936500793651 + y}}
\] |
remove-double-neg [=>]29.3 | \[ \left(\left(x \cdot \color{blue}{\log x} - x\right) + 0.91893853320467\right) + \frac{z \cdot z}{\frac{x}{0.0007936500793651 + y}}
\] |
Applied egg-rr99.4%
Final simplification99.4%
| Alternative 1 | |
|---|---|
| Accuracy | 99.5% |
| Cost | 8004 |
| Alternative 2 | |
|---|---|
| Accuracy | 86.6% |
| Cost | 7756 |
| Alternative 3 | |
|---|---|
| Accuracy | 86.7% |
| Cost | 7756 |
| Alternative 4 | |
|---|---|
| Accuracy | 88.9% |
| Cost | 7756 |
| Alternative 5 | |
|---|---|
| Accuracy | 88.9% |
| Cost | 7756 |
| Alternative 6 | |
|---|---|
| Accuracy | 88.9% |
| Cost | 7756 |
| Alternative 7 | |
|---|---|
| Accuracy | 94.7% |
| Cost | 7753 |
| Alternative 8 | |
|---|---|
| Accuracy | 94.8% |
| Cost | 7753 |
| Alternative 9 | |
|---|---|
| Accuracy | 94.0% |
| Cost | 7752 |
| Alternative 10 | |
|---|---|
| Accuracy | 98.4% |
| Cost | 7748 |
| Alternative 11 | |
|---|---|
| Accuracy | 98.8% |
| Cost | 7748 |
| Alternative 12 | |
|---|---|
| Accuracy | 98.8% |
| Cost | 7748 |
| Alternative 13 | |
|---|---|
| Accuracy | 79.6% |
| Cost | 7492 |
| Alternative 14 | |
|---|---|
| Accuracy | 81.2% |
| Cost | 7232 |
| Alternative 15 | |
|---|---|
| Accuracy | 79.9% |
| Cost | 7104 |
| Alternative 16 | |
|---|---|
| Accuracy | 32.9% |
| Cost | 192 |
herbie shell --seed 2023141
(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)))