?

Average Error: 6.2 → 1.3
Time: 20.4s
Precision: binary64
Cost: 14656

?

\[\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} \]
\[\left(\left(\left(x + -0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\frac{z}{x} \cdot \left(z \cdot y\right) + \left(\frac{0.083333333333333}{x} + \frac{\mathsf{fma}\left(0.0007936500793651, z, -0.0027777777777778\right)}{\frac{x}{z}}\right)\right) \]
(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
 (+
  (+ (- (* (+ x -0.5) (log x)) x) 0.91893853320467)
  (+
   (* (/ z x) (* z y))
   (+
    (/ 0.083333333333333 x)
    (/ (fma 0.0007936500793651 z -0.0027777777777778) (/ x z))))))
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) {
	return ((((x + -0.5) * log(x)) - x) + 0.91893853320467) + (((z / x) * (z * y)) + ((0.083333333333333 / x) + (fma(0.0007936500793651, z, -0.0027777777777778) / (x / z))));
}
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)
	return Float64(Float64(Float64(Float64(Float64(x + -0.5) * log(x)) - x) + 0.91893853320467) + Float64(Float64(Float64(z / x) * Float64(z * y)) + Float64(Float64(0.083333333333333 / x) + Float64(fma(0.0007936500793651, z, -0.0027777777777778) / Float64(x / z)))))
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_] := N[(N[(N[(N[(N[(x + -0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] + N[(N[(N[(z / x), $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision] + N[(N[(0.083333333333333 / x), $MachinePrecision] + N[(N[(0.0007936500793651 * z + -0.0027777777777778), $MachinePrecision] / N[(x / z), $MachinePrecision]), $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}
\left(\left(\left(x + -0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\frac{z}{x} \cdot \left(z \cdot y\right) + \left(\frac{0.083333333333333}{x} + \frac{\mathsf{fma}\left(0.0007936500793651, z, -0.0027777777777778\right)}{\frac{x}{z}}\right)\right)

Error?

Target

Original6.2
Target1.3
Herbie1.3
\[\left(\left(\left(x - 0.5\right) \cdot \log x + \left(0.91893853320467 - x\right)\right) + \frac{0.083333333333333}{x}\right) + \frac{z}{x} \cdot \left(z \cdot \left(y + 0.0007936500793651\right) - 0.0027777777777778\right) \]

Derivation?

  1. Initial program 6.2

    \[\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} \]
  2. Taylor expanded in y around 0 6.2

    \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \color{blue}{\left(\frac{y \cdot {z}^{2}}{x} + \left(0.083333333333333 \cdot \frac{1}{x} + \frac{\left(0.0007936500793651 \cdot z - 0.0027777777777778\right) \cdot z}{x}\right)\right)} \]
  3. Simplified4.2

    \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \color{blue}{\left(\frac{y}{\frac{x}{z \cdot z}} + \left(\frac{0.083333333333333}{x} + \frac{\mathsf{fma}\left(0.0007936500793651, z, -0.0027777777777778\right)}{\frac{x}{z}}\right)\right)} \]
    Proof

    [Start]6.2

    \[ \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\frac{y \cdot {z}^{2}}{x} + \left(0.083333333333333 \cdot \frac{1}{x} + \frac{\left(0.0007936500793651 \cdot z - 0.0027777777777778\right) \cdot z}{x}\right)\right) \]

    associate-/l* [=>]4.2

    \[ \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\color{blue}{\frac{y}{\frac{x}{{z}^{2}}}} + \left(0.083333333333333 \cdot \frac{1}{x} + \frac{\left(0.0007936500793651 \cdot z - 0.0027777777777778\right) \cdot z}{x}\right)\right) \]

    unpow2 [=>]4.2

    \[ \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\frac{y}{\frac{x}{\color{blue}{z \cdot z}}} + \left(0.083333333333333 \cdot \frac{1}{x} + \frac{\left(0.0007936500793651 \cdot z - 0.0027777777777778\right) \cdot z}{x}\right)\right) \]

    associate-*r/ [=>]4.2

    \[ \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\frac{y}{\frac{x}{z \cdot z}} + \left(\color{blue}{\frac{0.083333333333333 \cdot 1}{x}} + \frac{\left(0.0007936500793651 \cdot z - 0.0027777777777778\right) \cdot z}{x}\right)\right) \]

    metadata-eval [=>]4.2

    \[ \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\frac{y}{\frac{x}{z \cdot z}} + \left(\frac{\color{blue}{0.083333333333333}}{x} + \frac{\left(0.0007936500793651 \cdot z - 0.0027777777777778\right) \cdot z}{x}\right)\right) \]

    associate-/l* [=>]4.2

    \[ \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\frac{y}{\frac{x}{z \cdot z}} + \left(\frac{0.083333333333333}{x} + \color{blue}{\frac{0.0007936500793651 \cdot z - 0.0027777777777778}{\frac{x}{z}}}\right)\right) \]

    fma-neg [=>]4.2

    \[ \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\frac{y}{\frac{x}{z \cdot z}} + \left(\frac{0.083333333333333}{x} + \frac{\color{blue}{\mathsf{fma}\left(0.0007936500793651, z, -0.0027777777777778\right)}}{\frac{x}{z}}\right)\right) \]

    metadata-eval [=>]4.2

    \[ \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\frac{y}{\frac{x}{z \cdot z}} + \left(\frac{0.083333333333333}{x} + \frac{\mathsf{fma}\left(0.0007936500793651, z, \color{blue}{-0.0027777777777778}\right)}{\frac{x}{z}}\right)\right) \]
  4. Applied egg-rr1.3

    \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\color{blue}{\frac{z}{x} \cdot \left(y \cdot z\right)} + \left(\frac{0.083333333333333}{x} + \frac{\mathsf{fma}\left(0.0007936500793651, z, -0.0027777777777778\right)}{\frac{x}{z}}\right)\right) \]
  5. Final simplification1.3

    \[\leadsto \left(\left(\left(x + -0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\frac{z}{x} \cdot \left(z \cdot y\right) + \left(\frac{0.083333333333333}{x} + \frac{\mathsf{fma}\left(0.0007936500793651, z, -0.0027777777777778\right)}{\frac{x}{z}}\right)\right) \]

Alternatives

Alternative 1
Error3.4
Cost9417
\[\begin{array}{l} t_0 := \left(\left(x + -0.5\right) \cdot \log x - x\right) + 0.91893853320467\\ t_1 := z \cdot \left(-0.0027777777777778 + z \cdot \left(y + 0.0007936500793651\right)\right)\\ \mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 2 \cdot 10^{+253}\right):\\ \;\;\;\;t_0 + \left(\frac{z}{x} \cdot \left(z \cdot y\right) + \left(\frac{0.083333333333333}{x} + \frac{z \cdot -0.0027777777777778}{x}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 + \frac{0.083333333333333 + t_1}{x}\\ \end{array} \]
Alternative 2
Error1.9
Cost8256
\[\left(\left(\left(x + -0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\frac{z}{x} \cdot \left(z \cdot y\right) + \left(\frac{0.083333333333333}{x} + z \cdot \frac{z}{\frac{x}{0.0007936500793651}}\right)\right) \]
Alternative 3
Error2.7
Cost8004
\[\begin{array}{l} t_0 := 0.91893853320467 + x \cdot \left(\log x + -1\right)\\ \mathbf{if}\;x \leq 1150000000000:\\ \;\;\;\;\left(\left(\left(x + -0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{0.083333333333333 + z \cdot \left(-0.0027777777777778 + z \cdot \left(y + 0.0007936500793651\right)\right)}{x}\\ \mathbf{elif}\;x \leq 6 \cdot 10^{+199}:\\ \;\;\;\;t_0 + \frac{z \cdot z}{x} \cdot \left(y + 0.0007936500793651\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.083333333333333}{x} + t_0\\ \end{array} \]
Alternative 4
Error3.1
Cost7880
\[\begin{array}{l} \mathbf{if}\;x \leq 0.000155:\\ \;\;\;\;\frac{0.083333333333333 + z \cdot \left(-0.0027777777777778 + z \cdot \left(y + 0.0007936500793651\right)\right)}{x} + \left(0.91893853320467 + \log x \cdot -0.5\right)\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{+199}:\\ \;\;\;\;\left(\left(\left(x + -0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{z \cdot z}{x} \cdot \left(y + 0.0007936500793651\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.083333333333333}{x} + \left(0.91893853320467 + x \cdot \left(\log x + -1\right)\right)\\ \end{array} \]
Alternative 5
Error3.6
Cost7752
\[\begin{array}{l} t_0 := 0.91893853320467 + x \cdot \left(\log x + -1\right)\\ \mathbf{if}\;x \leq 0.000155:\\ \;\;\;\;\frac{0.083333333333333 + z \cdot \left(-0.0027777777777778 + z \cdot \left(y + 0.0007936500793651\right)\right)}{x} + \left(0.91893853320467 - x\right)\\ \mathbf{elif}\;x \leq 5 \cdot 10^{+199}:\\ \;\;\;\;t_0 + \frac{z \cdot z}{x} \cdot \left(y + 0.0007936500793651\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.083333333333333}{x} + t_0\\ \end{array} \]
Alternative 6
Error3.3
Cost7752
\[\begin{array}{l} t_0 := 0.91893853320467 + x \cdot \left(\log x + -1\right)\\ \mathbf{if}\;x \leq 0.000155:\\ \;\;\;\;\frac{0.083333333333333 + z \cdot \left(-0.0027777777777778 + z \cdot \left(y + 0.0007936500793651\right)\right)}{x} + \left(0.91893853320467 + \log x \cdot -0.5\right)\\ \mathbf{elif}\;x \leq 10^{+200}:\\ \;\;\;\;t_0 + \frac{z \cdot z}{x} \cdot \left(y + 0.0007936500793651\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.083333333333333}{x} + t_0\\ \end{array} \]
Alternative 7
Error4.9
Cost7624
\[\begin{array}{l} t_0 := 0.91893853320467 + x \cdot \left(\log x + -1\right)\\ \mathbf{if}\;x \leq 18:\\ \;\;\;\;\frac{0.083333333333333 + z \cdot \left(-0.0027777777777778 + z \cdot \left(y + 0.0007936500793651\right)\right)}{x} + \left(0.91893853320467 - x\right)\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{+199}:\\ \;\;\;\;t_0 + \frac{y}{\frac{x}{z \cdot z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.083333333333333}{x} + t_0\\ \end{array} \]
Alternative 8
Error6.6
Cost7364
\[\begin{array}{l} \mathbf{if}\;x \leq 3.1 \cdot 10^{-19}:\\ \;\;\;\;\frac{0.083333333333333 + z \cdot \left(-0.0027777777777778 + z \cdot \left(y + 0.0007936500793651\right)\right)}{x} + \left(0.91893853320467 - x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\left(x + -0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{0.083333333333333}{x}\\ \end{array} \]
Alternative 9
Error7.2
Cost7236
\[\begin{array}{l} \mathbf{if}\;x \leq 10^{+20}:\\ \;\;\;\;\frac{0.083333333333333 + z \cdot \left(-0.0027777777777778 + z \cdot \left(y + 0.0007936500793651\right)\right)}{x} + \left(0.91893853320467 - x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.083333333333333}{x} + \left(0.91893853320467 + x \cdot \left(\log x + -1\right)\right)\\ \end{array} \]
Alternative 10
Error32.4
Cost2121
\[\begin{array}{l} t_0 := z \cdot \left(-0.0027777777777778 + z \cdot \left(y + 0.0007936500793651\right)\right)\\ \mathbf{if}\;t_0 \leq -50000000000 \lor \neg \left(t_0 \leq 7.2\right):\\ \;\;\;\;\frac{z \cdot z}{x} \cdot \left(y + 0.0007936500793651\right) + \left(0.91893853320467 - x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.083333333333333}{x} + \left(x + 0.91893853320467\right)\\ \end{array} \]
Alternative 11
Error37.1
Cost1100
\[\begin{array}{l} t_0 := \left(0.91893853320467 - x\right) + 0.0007936500793651 \cdot \frac{z \cdot z}{x}\\ \mathbf{if}\;z \leq -3.75 \cdot 10^{+36}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 22.5:\\ \;\;\;\;\frac{0.083333333333333}{x} + \left(x + 0.91893853320467\right)\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x + \left(0.91893853320467 + \frac{0.083333333333333}{x}\right)\\ \end{array} \]
Alternative 12
Error37.9
Cost968
\[\begin{array}{l} \mathbf{if}\;z \leq -4.2 \cdot 10^{+36}:\\ \;\;\;\;\left(0.91893853320467 - x\right) + 0.0007936500793651 \cdot \frac{z \cdot z}{x}\\ \mathbf{elif}\;z \leq 15.6:\\ \;\;\;\;\frac{0.083333333333333}{x} + \left(x + 0.91893853320467\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.91893853320467 - x\right) + \frac{y}{\frac{x}{z \cdot z}}\\ \end{array} \]
Alternative 13
Error37.2
Cost968
\[\begin{array}{l} \mathbf{if}\;z \leq -3.1 \cdot 10^{+36}:\\ \;\;\;\;\left(0.91893853320467 - x\right) + \frac{z \cdot 0.0007936500793651}{\frac{x}{z}}\\ \mathbf{elif}\;z \leq 14.8:\\ \;\;\;\;\frac{0.083333333333333}{x} + \left(x + 0.91893853320467\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.91893853320467 - x\right) + \frac{y}{\frac{x}{z \cdot z}}\\ \end{array} \]
Alternative 14
Error37.2
Cost968
\[\begin{array}{l} \mathbf{if}\;z \leq -4.2 \cdot 10^{+36}:\\ \;\;\;\;\left(0.91893853320467 - x\right) + \frac{z \cdot 0.0007936500793651}{\frac{x}{z}}\\ \mathbf{elif}\;z \leq 0.75:\\ \;\;\;\;\frac{0.083333333333333}{x} + \left(x + 0.91893853320467\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.91893853320467 - x\right) + \frac{z \cdot z}{\frac{x}{y}}\\ \end{array} \]
Alternative 15
Error42.2
Cost448
\[0.91893853320467 + 0.083333333333333 \cdot \frac{1}{x} \]
Alternative 16
Error39.2
Cost448
\[x + \left(0.91893853320467 + \frac{0.083333333333333}{x}\right) \]
Alternative 17
Error39.2
Cost448
\[\frac{0.083333333333333}{x} + \left(x + 0.91893853320467\right) \]
Alternative 18
Error42.2
Cost320
\[0.91893853320467 + \frac{0.083333333333333}{x} \]
Alternative 19
Error42.7
Cost192
\[\frac{0.083333333333333}{x} \]
Alternative 20
Error63.3
Cost128
\[-x \]

Error

Reproduce?

herbie shell --seed 2023039 
(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)))