?

Average Error: 6.2 → 0.5
Time: 1.7min
Precision: binary64
Cost: 8520

?

\[\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 + \left(\left(\frac{y + 0.0007936500793651}{x} \cdot z\right) \cdot z + \left(\frac{0.083333333333333}{x} + -0.0027777777777778 \cdot \frac{z}{x}\right)\right)\\ \mathbf{if}\;z \leq -1 \cdot 10^{+49}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 10^{-16}:\\ \;\;\;\;t_0 + \frac{\left(\left(\left(0.0007936500793651 + y\right) \cdot z\right) \cdot z + -0.0027777777777778 \cdot z\right) + 0.083333333333333}{x}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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 (+ (- (* (- x 0.5) (log x)) x) 0.91893853320467))
        (t_1
         (+
          t_0
          (+
           (* (* (/ (+ y 0.0007936500793651) x) z) z)
           (+ (/ 0.083333333333333 x) (* -0.0027777777777778 (/ z x)))))))
   (if (<= z -1e+49)
     t_1
     (if (<= z 1e-16)
       (+
        t_0
        (/
         (+
          (+ (* (* (+ 0.0007936500793651 y) z) z) (* -0.0027777777777778 z))
          0.083333333333333)
         x))
       t_1))))
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) / x) * z) * z) + ((0.083333333333333 / x) + (-0.0027777777777778 * (z / x))));
	double tmp;
	if (z <= -1e+49) {
		tmp = t_1;
	} else if (z <= 1e-16) {
		tmp = t_0 + ((((((0.0007936500793651 + y) * z) * z) + (-0.0027777777777778 * z)) + 0.083333333333333) / x);
	} else {
		tmp = t_1;
	}
	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) :: tmp
    t_0 = (((x - 0.5d0) * log(x)) - x) + 0.91893853320467d0
    t_1 = t_0 + (((((y + 0.0007936500793651d0) / x) * z) * z) + ((0.083333333333333d0 / x) + ((-0.0027777777777778d0) * (z / x))))
    if (z <= (-1d+49)) then
        tmp = t_1
    else if (z <= 1d-16) then
        tmp = t_0 + ((((((0.0007936500793651d0 + y) * z) * z) + ((-0.0027777777777778d0) * z)) + 0.083333333333333d0) / x)
    else
        tmp = t_1
    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) / x) * z) * z) + ((0.083333333333333 / x) + (-0.0027777777777778 * (z / x))));
	double tmp;
	if (z <= -1e+49) {
		tmp = t_1;
	} else if (z <= 1e-16) {
		tmp = t_0 + ((((((0.0007936500793651 + y) * z) * z) + (-0.0027777777777778 * z)) + 0.083333333333333) / x);
	} else {
		tmp = t_1;
	}
	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) / x) * z) * z) + ((0.083333333333333 / x) + (-0.0027777777777778 * (z / x))))
	tmp = 0
	if z <= -1e+49:
		tmp = t_1
	elif z <= 1e-16:
		tmp = t_0 + ((((((0.0007936500793651 + y) * z) * z) + (-0.0027777777777778 * z)) + 0.083333333333333) / x)
	else:
		tmp = t_1
	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(y + 0.0007936500793651) / x) * z) * z) + Float64(Float64(0.083333333333333 / x) + Float64(-0.0027777777777778 * Float64(z / x)))))
	tmp = 0.0
	if (z <= -1e+49)
		tmp = t_1;
	elseif (z <= 1e-16)
		tmp = Float64(t_0 + Float64(Float64(Float64(Float64(Float64(Float64(0.0007936500793651 + y) * z) * z) + Float64(-0.0027777777777778 * z)) + 0.083333333333333) / x));
	else
		tmp = t_1;
	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) / x) * z) * z) + ((0.083333333333333 / x) + (-0.0027777777777778 * (z / x))));
	tmp = 0.0;
	if (z <= -1e+49)
		tmp = t_1;
	elseif (z <= 1e-16)
		tmp = t_0 + ((((((0.0007936500793651 + y) * z) * z) + (-0.0027777777777778 * z)) + 0.083333333333333) / x);
	else
		tmp = t_1;
	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[(y + 0.0007936500793651), $MachinePrecision] / x), $MachinePrecision] * z), $MachinePrecision] * z), $MachinePrecision] + N[(N[(0.083333333333333 / x), $MachinePrecision] + N[(-0.0027777777777778 * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1e+49], t$95$1, If[LessEqual[z, 1e-16], N[(t$95$0 + N[(N[(N[(N[(N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision] * z), $MachinePrecision] + N[(-0.0027777777777778 * z), $MachinePrecision]), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\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 + \left(\left(\frac{y + 0.0007936500793651}{x} \cdot z\right) \cdot z + \left(\frac{0.083333333333333}{x} + -0.0027777777777778 \cdot \frac{z}{x}\right)\right)\\
\mathbf{if}\;z \leq -1 \cdot 10^{+49}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq 10^{-16}:\\
\;\;\;\;t_0 + \frac{\left(\left(\left(0.0007936500793651 + y\right) \cdot z\right) \cdot z + -0.0027777777777778 \cdot z\right) + 0.083333333333333}{x}\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.2
Target1.3
Herbie0.5
\[\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 z < -9.99999999999999946e48 or 9.9999999999999998e-17 < z

    1. Initial program 22.5

      \[\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 z around 0 15.2

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

      \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\color{blue}{\left(\frac{y + 0.0007936500793651}{x} \cdot z\right) \cdot z} + \left(0.083333333333333 \cdot \frac{1}{x} + -0.0027777777777778 \cdot \frac{z}{x}\right)\right) \]
    4. Taylor expanded in x around 0 0.4

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

    if -9.99999999999999946e48 < z < 9.9999999999999998e-17

    1. Initial program 0.5

      \[\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-rr0.5

      \[\leadsto \left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\color{blue}{\left(\left(\left(0.0007936500793651 + y\right) \cdot z\right) \cdot z + -0.0027777777777778 \cdot z\right)} + 0.083333333333333}{x} \]
  3. Recombined 2 regimes into one program.

Alternatives

Alternative 1
Error2.9
Cost8520
\[\begin{array}{l} t_0 := \left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\\ t_1 := t_0 + \left(\left(0.0007936500793651 \cdot \frac{z}{x}\right) \cdot z + \left(0.083333333333333 \cdot \frac{1}{x} + -0.0027777777777778 \cdot \frac{z}{x}\right)\right)\\ \mathbf{if}\;z \leq -1.35 \cdot 10^{+84}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 9.2 \cdot 10^{+39}:\\ \;\;\;\;t_0 + \frac{\left(\left(\left(0.0007936500793651 + y\right) \cdot z\right) \cdot z + -0.0027777777777778 \cdot z\right) + 0.083333333333333}{x}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error1.4
Cost8516
\[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\begin{array}{l} \mathbf{if}\;z \ne 0:\\ \;\;\;\;\frac{y - -0.0007936500793651}{\frac{x}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y - -0.0007936500793651}{x} \cdot z\\ \end{array} \cdot z + \left(0.083333333333333 \cdot \frac{1}{x} + -0.0027777777777778 \cdot \frac{z}{x}\right)\right) \]
Alternative 3
Error1.4
Cost8384
\[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \left(\left(\frac{z}{x} \cdot \left(0.0007936500793651 + y\right)\right) \cdot z + \left(0.083333333333333 \cdot \frac{1}{x} + -0.0027777777777778 \cdot \frac{z}{x}\right)\right) \]
Alternative 4
Error3.6
Cost8132
\[\begin{array}{l} \mathbf{if}\;x \leq 2.15 \cdot 10^{+120}:\\ \;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(\left(0.0007936500793651 + y\right) \cdot z\right) \cdot z + -0.0027777777777778 \cdot z\right) + 0.083333333333333}{x}\\ \mathbf{else}:\\ \;\;\;\;\left(0.91893853320467 + \frac{x - \log x \cdot \left(-0.5 + x\right)}{-0.91893853320467} \cdot 0.91893853320467\right) + \frac{0.083333333333333}{x}\\ \end{array} \]
Alternative 5
Error3.7
Cost8004
\[\begin{array}{l} \mathbf{if}\;x \leq 10^{+119}:\\ \;\;\;\;\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}\\ \mathbf{else}:\\ \;\;\;\;\left(0.91893853320467 + \frac{x - \log x \cdot \left(-0.5 + x\right)}{-0.91893853320467} \cdot 0.91893853320467\right) + \frac{0.083333333333333}{x}\\ \end{array} \]
Alternative 6
Error7.7
Cost7876
\[\begin{array}{l} \mathbf{if}\;x \leq 10^{+119}:\\ \;\;\;\;\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(0.0007936500793651 \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}\\ \mathbf{else}:\\ \;\;\;\;\left(0.91893853320467 + \frac{x - \log x \cdot \left(-0.5 + x\right)}{-0.91893853320467} \cdot 0.91893853320467\right) + \frac{0.083333333333333}{x}\\ \end{array} \]
Alternative 7
Error12.0
Cost7360
\[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{1}{x \cdot 12.000000000000048} \]
Alternative 8
Error12.0
Cost7232
\[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{0.083333333333333}{x} \]
Alternative 9
Error12.0
Cost7232
\[\left(\left(\frac{0.083333333333333}{x} + 0.91893853320467\right) - \left(0.5 - x\right) \cdot \log x\right) - x \]
Alternative 10
Error42.8
Cost320
\[\frac{1}{x \cdot 12.000000000000048} \]
Alternative 11
Error42.8
Cost192
\[\frac{0.083333333333333}{x} \]

Error

Reproduce?

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