Average Error: 6.3 → 0.4
Time: 21.7s
Precision: binary64
Cost: 8004
\[\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 := \log x \cdot \left(x + -0.5\right)\\ \mathbf{if}\;x \leq 10000000000:\\ \;\;\;\;\left(0.91893853320467 + \left(t_0 - x\right)\right) + \frac{0.083333333333333 + z \cdot \left(-0.0027777777777778 + z \cdot \left(y + 0.0007936500793651\right)\right)}{x}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(0.91893853320467 + t_0\right) - x\right) + z \cdot \left(z \cdot \frac{y + 0.0007936500793651}{x}\right)\\ \end{array} \]
(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 (* (log x) (+ x -0.5))))
   (if (<= x 10000000000.0)
     (+
      (+ 0.91893853320467 (- t_0 x))
      (/
       (+
        0.083333333333333
        (* z (+ -0.0027777777777778 (* z (+ y 0.0007936500793651)))))
       x))
     (+
      (- (+ 0.91893853320467 t_0) x)
      (* 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 = log(x) * (x + -0.5);
	double tmp;
	if (x <= 10000000000.0) {
		tmp = (0.91893853320467 + (t_0 - x)) + ((0.083333333333333 + (z * (-0.0027777777777778 + (z * (y + 0.0007936500793651))))) / x);
	} else {
		tmp = ((0.91893853320467 + t_0) - x) + (z * (z * ((y + 0.0007936500793651) / 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) :: t_0
    real(8) :: tmp
    t_0 = log(x) * (x + (-0.5d0))
    if (x <= 10000000000.0d0) then
        tmp = (0.91893853320467d0 + (t_0 - x)) + ((0.083333333333333d0 + (z * ((-0.0027777777777778d0) + (z * (y + 0.0007936500793651d0))))) / x)
    else
        tmp = ((0.91893853320467d0 + t_0) - x) + (z * (z * ((y + 0.0007936500793651d0) / 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 t_0 = Math.log(x) * (x + -0.5);
	double tmp;
	if (x <= 10000000000.0) {
		tmp = (0.91893853320467 + (t_0 - x)) + ((0.083333333333333 + (z * (-0.0027777777777778 + (z * (y + 0.0007936500793651))))) / x);
	} else {
		tmp = ((0.91893853320467 + t_0) - x) + (z * (z * ((y + 0.0007936500793651) / 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):
	t_0 = math.log(x) * (x + -0.5)
	tmp = 0
	if x <= 10000000000.0:
		tmp = (0.91893853320467 + (t_0 - x)) + ((0.083333333333333 + (z * (-0.0027777777777778 + (z * (y + 0.0007936500793651))))) / x)
	else:
		tmp = ((0.91893853320467 + t_0) - x) + (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(log(x) * Float64(x + -0.5))
	tmp = 0.0
	if (x <= 10000000000.0)
		tmp = Float64(Float64(0.91893853320467 + Float64(t_0 - x)) + Float64(Float64(0.083333333333333 + Float64(z * Float64(-0.0027777777777778 + Float64(z * Float64(y + 0.0007936500793651))))) / x));
	else
		tmp = Float64(Float64(Float64(0.91893853320467 + t_0) - x) + Float64(z * Float64(z * Float64(Float64(y + 0.0007936500793651) / 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)
	t_0 = log(x) * (x + -0.5);
	tmp = 0.0;
	if (x <= 10000000000.0)
		tmp = (0.91893853320467 + (t_0 - x)) + ((0.083333333333333 + (z * (-0.0027777777777778 + (z * (y + 0.0007936500793651))))) / x);
	else
		tmp = ((0.91893853320467 + t_0) - x) + (z * (z * ((y + 0.0007936500793651) / 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_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] * N[(x + -0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 10000000000.0], N[(N[(0.91893853320467 + N[(t$95$0 - x), $MachinePrecision]), $MachinePrecision] + N[(N[(0.083333333333333 + N[(z * N[(-0.0027777777777778 + N[(z * N[(y + 0.0007936500793651), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.91893853320467 + t$95$0), $MachinePrecision] - x), $MachinePrecision] + 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 := \log x \cdot \left(x + -0.5\right)\\
\mathbf{if}\;x \leq 10000000000:\\
\;\;\;\;\left(0.91893853320467 + \left(t_0 - x\right)\right) + \frac{0.083333333333333 + z \cdot \left(-0.0027777777777778 + z \cdot \left(y + 0.0007936500793651\right)\right)}{x}\\

\mathbf{else}:\\
\;\;\;\;\left(\left(0.91893853320467 + t_0\right) - x\right) + z \cdot \left(z \cdot \frac{y + 0.0007936500793651}{x}\right)\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.3
Target1.4
Herbie0.4
\[\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. Split input into 2 regimes
  2. if x < 1e10

    1. Initial program 0.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} \]

    if 1e10 < x

    1. Initial program 10.8

      \[\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. Applied egg-rr10.8

      \[\leadsto \color{blue}{\left(\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} \]
    3. Taylor expanded in z around inf 10.9

      \[\leadsto \left(\left(0.91893853320467 + \left(x + -0.5\right) \cdot \log x\right) - x\right) + \color{blue}{\frac{{z}^{2} \cdot \left(0.0007936500793651 + y\right)}{x}} \]
    4. Simplified0.4

      \[\leadsto \left(\left(0.91893853320467 + \left(x + -0.5\right) \cdot \log x\right) - x\right) + \color{blue}{z \cdot \left(z \cdot \frac{0.0007936500793651 + y}{x}\right)} \]
      Proof
      (*.f64 z (*.f64 z (/.f64 (+.f64 7936500793651/10000000000000000 y) x))): 0 points increase in error, 0 points decrease in error
      (*.f64 z (*.f64 (Rewrite<= /-rgt-identity_binary64 (/.f64 z 1)) (/.f64 (+.f64 7936500793651/10000000000000000 y) x))): 0 points increase in error, 0 points decrease in error
      (*.f64 z (Rewrite<= times-frac_binary64 (/.f64 (*.f64 z (+.f64 7936500793651/10000000000000000 y)) (*.f64 1 x)))): 18 points increase in error, 41 points decrease in error
      (*.f64 z (/.f64 (*.f64 z (+.f64 7936500793651/10000000000000000 y)) (Rewrite=> *-lft-identity_binary64 x))): 0 points increase in error, 0 points decrease in error
      (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 z (*.f64 z (+.f64 7936500793651/10000000000000000 y))) x)): 66 points increase in error, 28 points decrease in error
      (/.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 z z) (+.f64 7936500793651/10000000000000000 y))) x): 31 points increase in error, 28 points decrease in error
      (/.f64 (*.f64 (Rewrite<= unpow2_binary64 (pow.f64 z 2)) (+.f64 7936500793651/10000000000000000 y)) x): 0 points increase in error, 0 points decrease in error
  3. Recombined 2 regimes into one program.
  4. Final simplification0.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 10000000000:\\ \;\;\;\;\left(0.91893853320467 + \left(\log x \cdot \left(x + -0.5\right) - x\right)\right) + \frac{0.083333333333333 + z \cdot \left(-0.0027777777777778 + z \cdot \left(y + 0.0007936500793651\right)\right)}{x}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(0.91893853320467 + \log x \cdot \left(x + -0.5\right)\right) - x\right) + z \cdot \left(z \cdot \frac{y + 0.0007936500793651}{x}\right)\\ \end{array} \]

Alternatives

Alternative 1
Error1.3
Cost26816
\[0.91893853320467 + \mathsf{fma}\left(\frac{z}{x}, \mathsf{fma}\left(z, y + 0.0007936500793651, -0.0027777777777778\right), \frac{0.083333333333333}{x} - \mathsf{fma}\left(\log x, 0.5 - x, x\right)\right) \]
Alternative 2
Error1.4
Cost14272
\[\left(0.91893853320467 + \left(\log x \cdot \left(x + -0.5\right) - x\right)\right) + \left(\frac{0.083333333333333}{x} + \frac{z}{x} \cdot \mathsf{fma}\left(z, y + 0.0007936500793651, -0.0027777777777778\right)\right) \]
Alternative 3
Error0.4
Cost8004
\[\begin{array}{l} t_0 := \left(0.91893853320467 + \log x \cdot \left(x + -0.5\right)\right) - x\\ \mathbf{if}\;x \leq 10000000000:\\ \;\;\;\;\frac{0.083333333333333 + z \cdot \left(-0.0027777777777778 + z \cdot \left(y + 0.0007936500793651\right)\right)}{x} + t_0\\ \mathbf{else}:\\ \;\;\;\;t_0 + z \cdot \left(z \cdot \frac{y + 0.0007936500793651}{x}\right)\\ \end{array} \]
Alternative 4
Error1.8
Cost7872
\[\left(0.91893853320467 + \left(\log x \cdot \left(x + -0.5\right) - x\right)\right) + \left(\frac{0.083333333333333}{x} + \frac{z \cdot \left(y + 0.0007936500793651\right)}{\frac{x}{z}}\right) \]
Alternative 5
Error1.1
Cost7748
\[\begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;0.91893853320467 + \frac{0.083333333333333 + z \cdot \left(-0.0027777777777778 + z \cdot \left(y + 0.0007936500793651\right)\right)}{x}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(0.91893853320467 + \log x \cdot \left(x + -0.5\right)\right) - x\right) + z \cdot \left(z \cdot \frac{y + 0.0007936500793651}{x}\right)\\ \end{array} \]
Alternative 6
Error0.8
Cost7748
\[\begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;\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{else}:\\ \;\;\;\;\left(\left(0.91893853320467 + \log x \cdot \left(x + -0.5\right)\right) - x\right) + z \cdot \left(z \cdot \frac{y + 0.0007936500793651}{x}\right)\\ \end{array} \]
Alternative 7
Error4.0
Cost7620
\[\begin{array}{l} \mathbf{if}\;x \leq 680000:\\ \;\;\;\;0.91893853320467 + \frac{0.083333333333333 + z \cdot \left(-0.0027777777777778 + z \cdot \left(y + 0.0007936500793651\right)\right)}{x}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(0.91893853320467 + \log x \cdot \left(x + -0.5\right)\right) - x\right) + z \cdot \left(z \cdot \frac{y}{x}\right)\\ \end{array} \]
Alternative 8
Error6.9
Cost7364
\[\begin{array}{l} \mathbf{if}\;x \leq 680000:\\ \;\;\;\;0.91893853320467 + \frac{0.083333333333333 + z \cdot \left(-0.0027777777777778 + z \cdot \left(y + 0.0007936500793651\right)\right)}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.083333333333333}{x} + \left(\left(0.91893853320467 + \log x \cdot \left(x + -0.5\right)\right) - x\right)\\ \end{array} \]
Alternative 9
Error6.9
Cost7364
\[\begin{array}{l} \mathbf{if}\;x \leq 680000:\\ \;\;\;\;0.91893853320467 + \frac{0.083333333333333 + z \cdot \left(-0.0027777777777778 + z \cdot \left(y + 0.0007936500793651\right)\right)}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.083333333333333}{x} + \left(0.91893853320467 + \left(\log x \cdot \left(x + -0.5\right) - x\right)\right)\\ \end{array} \]
Alternative 10
Error6.9
Cost7108
\[\begin{array}{l} \mathbf{if}\;x \leq 680000:\\ \;\;\;\;0.91893853320467 + \frac{0.083333333333333 + z \cdot \left(-0.0027777777777778 + z \cdot \left(y + 0.0007936500793651\right)\right)}{x}\\ \mathbf{else}:\\ \;\;\;\;0.91893853320467 + \left(\log x \cdot \left(x + -0.5\right) - x\right)\\ \end{array} \]
Alternative 11
Error7.0
Cost6980
\[\begin{array}{l} \mathbf{if}\;x \leq 680000:\\ \;\;\;\;0.91893853320467 + \frac{0.083333333333333 + z \cdot \left(-0.0027777777777778 + z \cdot \left(y + 0.0007936500793651\right)\right)}{x}\\ \mathbf{else}:\\ \;\;\;\;0.91893853320467 + x \cdot \left(\log x + -1\right)\\ \end{array} \]
Alternative 12
Error52.6
Cost964
\[\begin{array}{l} \mathbf{if}\;y \leq 7484849565.213369:\\ \;\;\;\;0.91893853320467 + \left(\frac{y}{x} + \frac{0.0007936500793651}{x}\right) \cdot \left(z \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;0.91893853320467 + y \cdot \left(z \cdot \frac{z}{x}\right)\\ \end{array} \]
Alternative 13
Error34.5
Cost960
\[0.91893853320467 + \frac{0.083333333333333 + z \cdot \left(-0.0027777777777778 + z \cdot \left(y + 0.0007936500793651\right)\right)}{x} \]
Alternative 14
Error57.4
Cost712
\[\begin{array}{l} t_0 := \frac{z}{\frac{x}{z \cdot y}}\\ \mathbf{if}\;y \leq -2.385123776757165 \cdot 10^{+56}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.1003917037179308 \cdot 10^{-11}:\\ \;\;\;\;0.91893853320467\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 15
Error56.1
Cost576
\[0.91893853320467 + z \cdot \left(\frac{z}{x} \cdot y\right) \]
Alternative 16
Error55.7
Cost576
\[0.91893853320467 + y \cdot \left(z \cdot \frac{z}{x}\right) \]
Alternative 17
Error60.9
Cost64
\[0.91893853320467 \]

Error

Reproduce

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