Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2

Percentage Accurate: 99.8% → 99.8%
Time: 1.5s
Alternatives: 6
Speedup: 1.0×

Specification

?
\[\mathsf{TRUE}\left(\right)\]
\[\begin{array}{l} \\ \left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \end{array} \]
(FPCore (x y z) :precision binary64 (- (+ (- x (* (+ y 0.5) (log y))) y) z))
double code(double x, double y, double z) {
	return ((x - ((y + 0.5) * log(y))) + y) - z;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = ((x - ((y + 0.5d0) * log(y))) + y) - z
end function
public static double code(double x, double y, double z) {
	return ((x - ((y + 0.5) * Math.log(y))) + y) - z;
}
def code(x, y, z):
	return ((x - ((y + 0.5) * math.log(y))) + y) - z
function code(x, y, z)
	return Float64(Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) - z)
end
function tmp = code(x, y, z)
	tmp = ((x - ((y + 0.5) * log(y))) + y) - z;
end
code[x_, y_, z_] := N[(N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}

\\
\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 6 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \end{array} \]
(FPCore (x y z) :precision binary64 (- (+ (- x (* (+ y 0.5) (log y))) y) z))
double code(double x, double y, double z) {
	return ((x - ((y + 0.5) * log(y))) + y) - z;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = ((x - ((y + 0.5d0) * log(y))) + y) - z
end function
public static double code(double x, double y, double z) {
	return ((x - ((y + 0.5) * Math.log(y))) + y) - z;
}
def code(x, y, z):
	return ((x - ((y + 0.5) * math.log(y))) + y) - z
function code(x, y, z)
	return Float64(Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) - z)
end
function tmp = code(x, y, z)
	tmp = ((x - ((y + 0.5) * log(y))) + y) - z;
end
code[x_, y_, z_] := N[(N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}

\\
\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
\end{array}

Alternative 1: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \end{array} \]
(FPCore (x y z) :precision binary64 (- (+ (- x (* (+ y 0.5) (log y))) y) z))
double code(double x, double y, double z) {
	return ((x - ((y + 0.5) * log(y))) + y) - z;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = ((x - ((y + 0.5d0) * log(y))) + y) - z
end function
public static double code(double x, double y, double z) {
	return ((x - ((y + 0.5) * Math.log(y))) + y) - z;
}
def code(x, y, z):
	return ((x - ((y + 0.5) * math.log(y))) + y) - z
function code(x, y, z)
	return Float64(Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) - z)
end
function tmp = code(x, y, z)
	tmp = ((x - ((y + 0.5) * log(y))) + y) - z;
end
code[x_, y_, z_] := N[(N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}

\\
\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
\end{array}
Derivation
  1. Initial program 99.9%

    \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 91.2% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x - \left(y + 0.5\right) \cdot \log y\\ t_1 := t\_0 - z\\ \mathbf{if}\;z \leq -9.5 \cdot 10^{+88}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 6 \cdot 10^{+64}:\\ \;\;\;\;t\_0 + y\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- x (* (+ y 0.5) (log y)))) (t_1 (- t_0 z)))
   (if (<= z -9.5e+88) t_1 (if (<= z 6e+64) (+ t_0 y) t_1))))
double code(double x, double y, double z) {
	double t_0 = x - ((y + 0.5) * log(y));
	double t_1 = t_0 - z;
	double tmp;
	if (z <= -9.5e+88) {
		tmp = t_1;
	} else if (z <= 6e+64) {
		tmp = t_0 + y;
	} 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
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = x - ((y + 0.5d0) * log(y))
    t_1 = t_0 - z
    if (z <= (-9.5d+88)) then
        tmp = t_1
    else if (z <= 6d+64) then
        tmp = t_0 + y
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = x - ((y + 0.5) * Math.log(y));
	double t_1 = t_0 - z;
	double tmp;
	if (z <= -9.5e+88) {
		tmp = t_1;
	} else if (z <= 6e+64) {
		tmp = t_0 + y;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x - ((y + 0.5) * math.log(y))
	t_1 = t_0 - z
	tmp = 0
	if z <= -9.5e+88:
		tmp = t_1
	elif z <= 6e+64:
		tmp = t_0 + y
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(x - Float64(Float64(y + 0.5) * log(y)))
	t_1 = Float64(t_0 - z)
	tmp = 0.0
	if (z <= -9.5e+88)
		tmp = t_1;
	elseif (z <= 6e+64)
		tmp = Float64(t_0 + y);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x - ((y + 0.5) * log(y));
	t_1 = t_0 - z;
	tmp = 0.0;
	if (z <= -9.5e+88)
		tmp = t_1;
	elseif (z <= 6e+64)
		tmp = t_0 + y;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - z), $MachinePrecision]}, If[LessEqual[z, -9.5e+88], t$95$1, If[LessEqual[z, 6e+64], N[(t$95$0 + y), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x - \left(y + 0.5\right) \cdot \log y\\
t_1 := t\_0 - z\\
\mathbf{if}\;z \leq -9.5 \cdot 10^{+88}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 6 \cdot 10^{+64}:\\
\;\;\;\;t\_0 + y\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -9.50000000000000059e88 or 6.0000000000000004e64 < z

    1. Initial program 100.0%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(y - \log y \cdot \left(\frac{1}{2} + y\right)\right)} - z \]
    4. Applied rewrites90.4%

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

    if -9.50000000000000059e88 < z < 6.0000000000000004e64

    1. Initial program 99.8%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(x + y\right) - \left(z + \log y \cdot \left(\frac{1}{2} + y\right)\right)} \]
    4. Applied rewrites97.6%

      \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + y} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 84.2% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \log y - z\\ \mathbf{if}\;z \leq -1.22 \cdot 10^{+118}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 1.65 \cdot 10^{+125}:\\ \;\;\;\;\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- (log y) z)))
   (if (<= z -1.22e+118)
     t_0
     (if (<= z 1.65e+125) (+ (- x (* (+ y 0.5) (log y))) y) t_0))))
double code(double x, double y, double z) {
	double t_0 = log(y) - z;
	double tmp;
	if (z <= -1.22e+118) {
		tmp = t_0;
	} else if (z <= 1.65e+125) {
		tmp = (x - ((y + 0.5) * log(y))) + y;
	} else {
		tmp = t_0;
	}
	return tmp;
}
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(y) - z
    if (z <= (-1.22d+118)) then
        tmp = t_0
    else if (z <= 1.65d+125) then
        tmp = (x - ((y + 0.5d0) * log(y))) + y
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = Math.log(y) - z;
	double tmp;
	if (z <= -1.22e+118) {
		tmp = t_0;
	} else if (z <= 1.65e+125) {
		tmp = (x - ((y + 0.5) * Math.log(y))) + y;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = math.log(y) - z
	tmp = 0
	if z <= -1.22e+118:
		tmp = t_0
	elif z <= 1.65e+125:
		tmp = (x - ((y + 0.5) * math.log(y))) + y
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(log(y) - z)
	tmp = 0.0
	if (z <= -1.22e+118)
		tmp = t_0;
	elseif (z <= 1.65e+125)
		tmp = Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = log(y) - z;
	tmp = 0.0;
	if (z <= -1.22e+118)
		tmp = t_0;
	elseif (z <= 1.65e+125)
		tmp = (x - ((y + 0.5) * log(y))) + y;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Log[y], $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[z, -1.22e+118], t$95$0, If[LessEqual[z, 1.65e+125], N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \log y - z\\
\mathbf{if}\;z \leq -1.22 \cdot 10^{+118}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 1.65 \cdot 10^{+125}:\\
\;\;\;\;\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.2200000000000001e118 or 1.65000000000000003e125 < z

    1. Initial program 100.0%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(y - \log y \cdot \left(\frac{1}{2} + y\right)\right)} - z \]
    4. Applied rewrites92.5%

      \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right)} - z \]
    5. Taylor expanded in x around -inf

      \[\leadsto -1 \cdot \color{blue}{\left(x \cdot \left(\frac{\log y \cdot \left(\frac{1}{2} + y\right)}{x} - 1\right)\right)} - z \]
    6. Applied rewrites77.6%

      \[\leadsto \log y - z \]

    if -1.2200000000000001e118 < z < 1.65000000000000003e125

    1. Initial program 99.8%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(x + y\right) - \left(z + \log y \cdot \left(\frac{1}{2} + y\right)\right)} \]
    4. Applied rewrites94.5%

      \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + y} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 66.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \log y - z\\ \mathbf{if}\;z \leq -5.2 \cdot 10^{+109}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{+125}:\\ \;\;\;\;x - \left(y + 0.5\right) \cdot \log y\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- (log y) z)))
   (if (<= z -5.2e+109)
     t_0
     (if (<= z 1.1e+125) (- x (* (+ y 0.5) (log y))) t_0))))
double code(double x, double y, double z) {
	double t_0 = log(y) - z;
	double tmp;
	if (z <= -5.2e+109) {
		tmp = t_0;
	} else if (z <= 1.1e+125) {
		tmp = x - ((y + 0.5) * log(y));
	} else {
		tmp = t_0;
	}
	return tmp;
}
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(y) - z
    if (z <= (-5.2d+109)) then
        tmp = t_0
    else if (z <= 1.1d+125) then
        tmp = x - ((y + 0.5d0) * log(y))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = Math.log(y) - z;
	double tmp;
	if (z <= -5.2e+109) {
		tmp = t_0;
	} else if (z <= 1.1e+125) {
		tmp = x - ((y + 0.5) * Math.log(y));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = math.log(y) - z
	tmp = 0
	if z <= -5.2e+109:
		tmp = t_0
	elif z <= 1.1e+125:
		tmp = x - ((y + 0.5) * math.log(y))
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(log(y) - z)
	tmp = 0.0
	if (z <= -5.2e+109)
		tmp = t_0;
	elseif (z <= 1.1e+125)
		tmp = Float64(x - Float64(Float64(y + 0.5) * log(y)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = log(y) - z;
	tmp = 0.0;
	if (z <= -5.2e+109)
		tmp = t_0;
	elseif (z <= 1.1e+125)
		tmp = x - ((y + 0.5) * log(y));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Log[y], $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[z, -5.2e+109], t$95$0, If[LessEqual[z, 1.1e+125], N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \log y - z\\
\mathbf{if}\;z \leq -5.2 \cdot 10^{+109}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 1.1 \cdot 10^{+125}:\\
\;\;\;\;x - \left(y + 0.5\right) \cdot \log y\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -5.1999999999999997e109 or 1.09999999999999995e125 < z

    1. Initial program 100.0%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(y - \log y \cdot \left(\frac{1}{2} + y\right)\right)} - z \]
    4. Applied rewrites91.9%

      \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right)} - z \]
    5. Taylor expanded in x around -inf

      \[\leadsto -1 \cdot \color{blue}{\left(x \cdot \left(\frac{\log y \cdot \left(\frac{1}{2} + y\right)}{x} - 1\right)\right)} - z \]
    6. Applied rewrites76.9%

      \[\leadsto \log y - z \]

    if -5.1999999999999997e109 < z < 1.09999999999999995e125

    1. Initial program 99.8%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(x + y\right) - \left(z + \log y \cdot \left(\frac{1}{2} + y\right)\right)} \]
    4. Applied rewrites95.0%

      \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + y} \]
    5. Taylor expanded in x around 0

      \[\leadsto y - \color{blue}{\log y \cdot \left(\frac{1}{2} + y\right)} \]
    6. Applied rewrites70.9%

      \[\leadsto x - \color{blue}{\left(y + 0.5\right) \cdot \log y} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 28.9% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \log y - z \end{array} \]
(FPCore (x y z) :precision binary64 (- (log y) z))
double code(double x, double y, double z) {
	return log(y) - z;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = log(y) - z
end function
public static double code(double x, double y, double z) {
	return Math.log(y) - z;
}
def code(x, y, z):
	return math.log(y) - z
function code(x, y, z)
	return Float64(log(y) - z)
end
function tmp = code(x, y, z)
	tmp = log(y) - z;
end
code[x_, y_, z_] := N[(N[Log[y], $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}

\\
\log y - z
\end{array}
Derivation
  1. Initial program 99.9%

    \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0

    \[\leadsto \color{blue}{\left(y - \log y \cdot \left(\frac{1}{2} + y\right)\right)} - z \]
  4. Applied rewrites80.9%

    \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right)} - z \]
  5. Taylor expanded in x around -inf

    \[\leadsto -1 \cdot \color{blue}{\left(x \cdot \left(\frac{\log y \cdot \left(\frac{1}{2} + y\right)}{x} - 1\right)\right)} - z \]
  6. Applied rewrites29.4%

    \[\leadsto \log y - z \]
  7. Add Preprocessing

Alternative 6: 3.8% accurate, 29.5× speedup?

\[\begin{array}{l} \\ y + 0.5 \end{array} \]
(FPCore (x y z) :precision binary64 (+ y 0.5))
double code(double x, double y, double z) {
	return y + 0.5;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = y + 0.5d0
end function
public static double code(double x, double y, double z) {
	return y + 0.5;
}
def code(x, y, z):
	return y + 0.5
function code(x, y, z)
	return Float64(y + 0.5)
end
function tmp = code(x, y, z)
	tmp = y + 0.5;
end
code[x_, y_, z_] := N[(y + 0.5), $MachinePrecision]
\begin{array}{l}

\\
y + 0.5
\end{array}
Derivation
  1. Initial program 99.9%

    \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0

    \[\leadsto \color{blue}{\left(x + y\right) - \left(z + \log y \cdot \left(\frac{1}{2} + y\right)\right)} \]
  4. Applied rewrites71.4%

    \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + y} \]
  5. Taylor expanded in x around inf

    \[\leadsto \color{blue}{x} \]
  6. Applied rewrites3.8%

    \[\leadsto \color{blue}{y + 0.5} \]
  7. Add Preprocessing

Developer Target 1: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(\left(y + x\right) - z\right) - \left(y + 0.5\right) \cdot \log y \end{array} \]
(FPCore (x y z) :precision binary64 (- (- (+ y x) z) (* (+ y 0.5) (log y))))
double code(double x, double y, double z) {
	return ((y + x) - z) - ((y + 0.5) * log(y));
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = ((y + x) - z) - ((y + 0.5d0) * log(y))
end function
public static double code(double x, double y, double z) {
	return ((y + x) - z) - ((y + 0.5) * Math.log(y));
}
def code(x, y, z):
	return ((y + x) - z) - ((y + 0.5) * math.log(y))
function code(x, y, z)
	return Float64(Float64(Float64(y + x) - z) - Float64(Float64(y + 0.5) * log(y)))
end
function tmp = code(x, y, z)
	tmp = ((y + x) - z) - ((y + 0.5) * log(y));
end
code[x_, y_, z_] := N[(N[(N[(y + x), $MachinePrecision] - z), $MachinePrecision] - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(\left(y + x\right) - z\right) - \left(y + 0.5\right) \cdot \log y
\end{array}

Reproduce

?
herbie shell --seed 2024321 
(FPCore (x y z)
  :name "Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2"
  :precision binary64
  :pre (TRUE)

  :alt
  (! :herbie-platform default (- (- (+ y x) z) (* (+ y 1/2) (log y))))

  (- (+ (- x (* (+ y 0.5) (log y))) y) z))