Average Error: 6.3 → 1.3
Time: 16.2s
Precision: binary64
Cost: 8384
\[\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{1}{x \cdot 12.000000000000048} + \left(\frac{z}{x} \cdot \left(z \cdot \left(0.0007936500793651 + y\right)\right) + \frac{z}{x} \cdot -0.0027777777777778\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)
  (+
   (/ 1.0 (* x 12.000000000000048))
   (+
    (* (/ z x) (* z (+ 0.0007936500793651 y)))
    (* (/ z x) -0.0027777777777778)))))
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) + ((1.0 / (x * 12.000000000000048)) + (((z / x) * (z * (0.0007936500793651 + y))) + ((z / x) * -0.0027777777777778)));
}
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
    code = ((((x + (-0.5d0)) * log(x)) - x) + 0.91893853320467d0) + ((1.0d0 / (x * 12.000000000000048d0)) + (((z / x) * (z * (0.0007936500793651d0 + y))) + ((z / x) * (-0.0027777777777778d0))))
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) {
	return ((((x + -0.5) * Math.log(x)) - x) + 0.91893853320467) + ((1.0 / (x * 12.000000000000048)) + (((z / x) * (z * (0.0007936500793651 + y))) + ((z / x) * -0.0027777777777778)));
}
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):
	return ((((x + -0.5) * math.log(x)) - x) + 0.91893853320467) + ((1.0 / (x * 12.000000000000048)) + (((z / x) * (z * (0.0007936500793651 + y))) + ((z / x) * -0.0027777777777778)))
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(1.0 / Float64(x * 12.000000000000048)) + Float64(Float64(Float64(z / x) * Float64(z * Float64(0.0007936500793651 + y))) + Float64(Float64(z / x) * -0.0027777777777778))))
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 = code(x, y, z)
	tmp = ((((x + -0.5) * log(x)) - x) + 0.91893853320467) + ((1.0 / (x * 12.000000000000048)) + (((z / x) * (z * (0.0007936500793651 + y))) + ((z / x) * -0.0027777777777778)));
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[(1.0 / N[(x * 12.000000000000048), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(z / x), $MachinePrecision] * N[(z * N[(0.0007936500793651 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(z / x), $MachinePrecision] * -0.0027777777777778), $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{1}{x \cdot 12.000000000000048} + \left(\frac{z}{x} \cdot \left(z \cdot \left(0.0007936500793651 + y\right)\right) + \frac{z}{x} \cdot -0.0027777777777778\right)\right)

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.3
Target1.4
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.3

    \[\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.4

    \[\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. Simplified1.4

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

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

    \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\color{blue}{{\left(x \cdot 12.000000000000048\right)}^{-1}} + \left(\frac{z}{x} \cdot \left(z \cdot \left(0.0007936500793651 + y\right)\right) + \frac{z}{x} \cdot -0.0027777777777778\right)\right) \]
  6. Applied egg-rr1.3

    \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\color{blue}{\frac{1}{x \cdot 12.000000000000048}} + \left(\frac{z}{x} \cdot \left(z \cdot \left(0.0007936500793651 + y\right)\right) + \frac{z}{x} \cdot -0.0027777777777778\right)\right) \]
  7. Final simplification1.3

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

Alternatives

Alternative 1
Error0.6
Cost8264
\[\begin{array}{l} t_0 := \left(x + -0.5\right) \cdot \log x\\ t_1 := \left(t_0 + \left(0.91893853320467 - x\right)\right) + z \cdot \left(\frac{z}{x} \cdot \left(0.0007936500793651 + y\right)\right)\\ \mathbf{if}\;z \leq -1 \cdot 10^{+66}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 10^{+20}:\\ \;\;\;\;\left(\left(t_0 - x\right) + 0.91893853320467\right) + \frac{0.083333333333333 + \left(z \cdot \left(z \cdot \left(0.0007936500793651 + y\right)\right) + z \cdot -0.0027777777777778\right)}{x}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error1.4
Cost8256
\[\left(\left(\left(x + -0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\left(\frac{z}{x} \cdot \left(z \cdot \left(0.0007936500793651 + y\right)\right) + \frac{z}{x} \cdot -0.0027777777777778\right) + \frac{0.083333333333333}{x}\right) \]
Alternative 3
Error0.6
Cost8136
\[\begin{array}{l} t_0 := \left(x + -0.5\right) \cdot \log x\\ t_1 := \left(t_0 + \left(0.91893853320467 - x\right)\right) + z \cdot \left(\frac{z}{x} \cdot \left(0.0007936500793651 + y\right)\right)\\ \mathbf{if}\;z \leq -1 \cdot 10^{+66}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 10^{+20}:\\ \;\;\;\;\left(\left(t_0 - x\right) + 0.91893853320467\right) + \frac{0.083333333333333 + z \cdot \left(-0.0027777777777778 + z \cdot \left(0.0007936500793651 + y\right)\right)}{x}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error4.1
Cost7880
\[\begin{array}{l} t_0 := \left(x + -0.5\right) \cdot \log x + \left(0.91893853320467 - x\right)\\ t_1 := t_0 + z \cdot \left(\frac{z}{x} \cdot \left(0.0007936500793651 + y\right)\right)\\ \mathbf{if}\;z \leq -5.834454076510694 \cdot 10^{-71}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{-13}:\\ \;\;\;\;\frac{0.083333333333333}{x} + t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error0.9
Cost7876
\[\begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;\frac{0.083333333333333 + \left(z \cdot \left(z \cdot \left(0.0007936500793651 + y\right)\right) + z \cdot -0.0027777777777778\right)}{x} + \left(0.91893853320467 + \log x \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x + -0.5\right) \cdot \log x + \left(0.91893853320467 - x\right)\right) + z \cdot \left(\frac{z}{x} \cdot \left(0.0007936500793651 + y\right)\right)\\ \end{array} \]
Alternative 6
Error7.2
Cost7752
\[\begin{array}{l} t_0 := \left(x + -0.5\right) \cdot \log x\\ t_1 := \left(\left(t_0 - x\right) + 0.91893853320467\right) + z \cdot \left(z \cdot \frac{0.0007936500793651}{x}\right)\\ \mathbf{if}\;z \leq -0.065:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 5 \cdot 10^{-12}:\\ \;\;\;\;\frac{0.083333333333333}{x} + \left(t_0 + \left(0.91893853320467 - x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error7.2
Cost7752
\[\begin{array}{l} t_0 := \left(x + -0.5\right) \cdot \log x\\ t_1 := \left(\left(t_0 - x\right) + 0.91893853320467\right) + z \cdot \left(z \cdot \frac{0.0007936500793651}{x}\right)\\ \mathbf{if}\;z \leq -0.065:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 5 \cdot 10^{-12}:\\ \;\;\;\;\left(t_0 + \left(0.91893853320467 - x\right)\right) + \frac{0.083333333333333 + z \cdot -0.0027777777777778}{x}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error8.3
Cost7752
\[\begin{array}{l} t_0 := \left(\left(x + -0.5\right) \cdot \log x - x\right) + 0.91893853320467\\ \mathbf{if}\;x \leq 3.7 \cdot 10^{-19}:\\ \;\;\;\;\left(0.91893853320467 + \log x \cdot -0.5\right) + \frac{0.083333333333333 + \left(z \cdot -0.0027777777777778 + z \cdot \left(z \cdot 0.0007936500793651\right)\right)}{x}\\ \mathbf{elif}\;x \leq 2.2489889267123014 \cdot 10^{+86}:\\ \;\;\;\;t_0 + z \cdot \frac{z \cdot y}{x}\\ \mathbf{else}:\\ \;\;\;\;t_0 + z \cdot \left(z \cdot \frac{0.0007936500793651}{x}\right)\\ \end{array} \]
Alternative 9
Error0.9
Cost7748
\[\begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;\frac{0.083333333333333 + z \cdot \left(-0.0027777777777778 + z \cdot \left(0.0007936500793651 + y\right)\right)}{x} + \left(0.91893853320467 + \log x \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x + -0.5\right) \cdot \log x + \left(0.91893853320467 - x\right)\right) + z \cdot \left(\frac{z}{x} \cdot \left(0.0007936500793651 + y\right)\right)\\ \end{array} \]
Alternative 10
Error12.5
Cost7624
\[\begin{array}{l} \mathbf{if}\;z \leq -4.2 \cdot 10^{+82}:\\ \;\;\;\;\frac{0.083333333333333}{x} + x \cdot \left(\log x + -1\right)\\ \mathbf{elif}\;z \leq -0.065:\\ \;\;\;\;\left(0.91893853320467 + \log x \cdot -0.5\right) + \left(z \cdot z\right) \cdot \frac{0.0007936500793651 + y}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.083333333333333}{x} + \left(\left(x + -0.5\right) \cdot \log x + \left(0.91893853320467 - x\right)\right)\\ \end{array} \]
Alternative 11
Error10.0
Cost7624
\[\begin{array}{l} t_0 := \left(0.91893853320467 + x \cdot \left(\log x + -1\right)\right) + z \cdot \left(\frac{z}{x} \cdot y\right)\\ \mathbf{if}\;z \leq -5.834454076510694 \cdot 10^{-71}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{-13}:\\ \;\;\;\;\frac{0.083333333333333}{x} + \left(\left(x + -0.5\right) \cdot \log x + \left(0.91893853320467 - x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 12
Error10.4
Cost7624
\[\begin{array}{l} t_0 := \left(x + -0.5\right) \cdot \log x\\ \mathbf{if}\;z \leq -5.834454076510694 \cdot 10^{-71}:\\ \;\;\;\;\left(\left(t_0 - x\right) + 0.91893853320467\right) + z \cdot \frac{z \cdot y}{x}\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{-13}:\\ \;\;\;\;\frac{0.083333333333333}{x} + \left(t_0 + \left(0.91893853320467 - x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.91893853320467 + x \cdot \left(\log x + -1\right)\right) + z \cdot \left(\frac{z}{x} \cdot y\right)\\ \end{array} \]
Alternative 13
Error12.6
Cost7232
\[\frac{0.083333333333333}{x} + \left(\left(x + -0.5\right) \cdot \log x + \left(0.91893853320467 - x\right)\right) \]
Alternative 14
Error13.5
Cost6976
\[\frac{0.083333333333333}{x} + x \cdot \left(\log x + -1\right) \]
Alternative 15
Error43.0
Cost6656
\[{\left(x \cdot 12.000000000000048\right)}^{-1} \]
Alternative 16
Error43.0
Cost192
\[\frac{0.083333333333333}{x} \]

Error

Reproduce

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