Numeric.SpecFunctions:$slogFactorial from math-functions-0.1.5.2, B

Percentage Accurate: 93.9% → 99.0%
Time: 15.8s
Alternatives: 20
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \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} \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)))
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);
}
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
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);
}
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)
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 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
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]
\begin{array}{l}

\\
\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}
\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 20 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: 93.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \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} \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)))
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);
}
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
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);
}
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)
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 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
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]
\begin{array}{l}

\\
\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}
\end{array}

Alternative 1: 99.0% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 3.2 \cdot 10^{-81}:\\ \;\;\;\;\mathsf{fma}\left(x - 0.5, \log x, \frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(z, y + 0.0007936500793651, -0.0027777777777778\right), z, 0.083333333333333\right), 0.91893853320467 + x, \left(0.8444480278083504 - x \cdot x\right) \cdot x\right)}{\left(0.91893853320467 + x\right) \cdot x}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x - 0.5, \log x, \mathsf{fma}\left(\mathsf{fma}\left(\frac{y}{x}, z, \frac{\mathsf{fma}\left(0.0007936500793651, z, -0.0027777777777778\right)}{x}\right), z, \frac{0.083333333333333}{x}\right)\right) - \left(x - 0.91893853320467\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x 3.2e-81)
   (fma
    (- x 0.5)
    (log x)
    (/
     (fma
      (fma
       (fma z (+ y 0.0007936500793651) -0.0027777777777778)
       z
       0.083333333333333)
      (+ 0.91893853320467 x)
      (* (- 0.8444480278083504 (* x x)) x))
     (* (+ 0.91893853320467 x) x)))
   (-
    (fma
     (- x 0.5)
     (log x)
     (fma
      (fma (/ y x) z (/ (fma 0.0007936500793651 z -0.0027777777777778) x))
      z
      (/ 0.083333333333333 x)))
    (- x 0.91893853320467))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= 3.2e-81) {
		tmp = fma((x - 0.5), log(x), (fma(fma(fma(z, (y + 0.0007936500793651), -0.0027777777777778), z, 0.083333333333333), (0.91893853320467 + x), ((0.8444480278083504 - (x * x)) * x)) / ((0.91893853320467 + x) * x)));
	} else {
		tmp = fma((x - 0.5), log(x), fma(fma((y / x), z, (fma(0.0007936500793651, z, -0.0027777777777778) / x)), z, (0.083333333333333 / x))) - (x - 0.91893853320467);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (x <= 3.2e-81)
		tmp = fma(Float64(x - 0.5), log(x), Float64(fma(fma(fma(z, Float64(y + 0.0007936500793651), -0.0027777777777778), z, 0.083333333333333), Float64(0.91893853320467 + x), Float64(Float64(0.8444480278083504 - Float64(x * x)) * x)) / Float64(Float64(0.91893853320467 + x) * x)));
	else
		tmp = Float64(fma(Float64(x - 0.5), log(x), fma(fma(Float64(y / x), z, Float64(fma(0.0007936500793651, z, -0.0027777777777778) / x)), z, Float64(0.083333333333333 / x))) - Float64(x - 0.91893853320467));
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[x, 3.2e-81], N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision] + N[(N[(N[(N[(z * N[(y + 0.0007936500793651), $MachinePrecision] + -0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] * N[(0.91893853320467 + x), $MachinePrecision] + N[(N[(0.8444480278083504 - N[(x * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / N[(N[(0.91893853320467 + x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision] + N[(N[(N[(y / x), $MachinePrecision] * z + N[(N[(0.0007936500793651 * z + -0.0027777777777778), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] * z + N[(0.083333333333333 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x - 0.91893853320467), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.2 \cdot 10^{-81}:\\
\;\;\;\;\mathsf{fma}\left(x - 0.5, \log x, \frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(z, y + 0.0007936500793651, -0.0027777777777778\right), z, 0.083333333333333\right), 0.91893853320467 + x, \left(0.8444480278083504 - x \cdot x\right) \cdot x\right)}{\left(0.91893853320467 + x\right) \cdot x}\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x - 0.5, \log x, \mathsf{fma}\left(\mathsf{fma}\left(\frac{y}{x}, z, \frac{\mathsf{fma}\left(0.0007936500793651, z, -0.0027777777777778\right)}{x}\right), z, \frac{0.083333333333333}{x}\right)\right) - \left(x - 0.91893853320467\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 3.2e-81

    1. Initial program 99.6%

      \[\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. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(\left(\left(x - \frac{1}{2}\right) \cdot \log x - x\right) + \frac{91893853320467}{100000000000000}\right) + \frac{\left(\left(y + \frac{7936500793651}{10000000000000000}\right) \cdot z - \frac{13888888888889}{5000000000000000}\right) \cdot z + \frac{83333333333333}{1000000000000000}}{x}} \]
      2. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(\left(\left(x - \frac{1}{2}\right) \cdot \log x - x\right) + \frac{91893853320467}{100000000000000}\right)} + \frac{\left(\left(y + \frac{7936500793651}{10000000000000000}\right) \cdot z - \frac{13888888888889}{5000000000000000}\right) \cdot z + \frac{83333333333333}{1000000000000000}}{x} \]
      3. associate-+l+N/A

        \[\leadsto \color{blue}{\left(\left(x - \frac{1}{2}\right) \cdot \log x - x\right) + \left(\frac{91893853320467}{100000000000000} + \frac{\left(\left(y + \frac{7936500793651}{10000000000000000}\right) \cdot z - \frac{13888888888889}{5000000000000000}\right) \cdot z + \frac{83333333333333}{1000000000000000}}{x}\right)} \]
      4. lift--.f64N/A

        \[\leadsto \color{blue}{\left(\left(x - \frac{1}{2}\right) \cdot \log x - x\right)} + \left(\frac{91893853320467}{100000000000000} + \frac{\left(\left(y + \frac{7936500793651}{10000000000000000}\right) \cdot z - \frac{13888888888889}{5000000000000000}\right) \cdot z + \frac{83333333333333}{1000000000000000}}{x}\right) \]
      5. sub-negN/A

        \[\leadsto \color{blue}{\left(\left(x - \frac{1}{2}\right) \cdot \log x + \left(\mathsf{neg}\left(x\right)\right)\right)} + \left(\frac{91893853320467}{100000000000000} + \frac{\left(\left(y + \frac{7936500793651}{10000000000000000}\right) \cdot z - \frac{13888888888889}{5000000000000000}\right) \cdot z + \frac{83333333333333}{1000000000000000}}{x}\right) \]
      6. associate-+l+N/A

        \[\leadsto \color{blue}{\left(x - \frac{1}{2}\right) \cdot \log x + \left(\left(\mathsf{neg}\left(x\right)\right) + \left(\frac{91893853320467}{100000000000000} + \frac{\left(\left(y + \frac{7936500793651}{10000000000000000}\right) \cdot z - \frac{13888888888889}{5000000000000000}\right) \cdot z + \frac{83333333333333}{1000000000000000}}{x}\right)\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(x - \frac{1}{2}\right) \cdot \log x} + \left(\left(\mathsf{neg}\left(x\right)\right) + \left(\frac{91893853320467}{100000000000000} + \frac{\left(\left(y + \frac{7936500793651}{10000000000000000}\right) \cdot z - \frac{13888888888889}{5000000000000000}\right) \cdot z + \frac{83333333333333}{1000000000000000}}{x}\right)\right) \]
      8. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(x - \frac{1}{2}, \log x, \left(\mathsf{neg}\left(x\right)\right) + \left(\frac{91893853320467}{100000000000000} + \frac{\left(\left(y + \frac{7936500793651}{10000000000000000}\right) \cdot z - \frac{13888888888889}{5000000000000000}\right) \cdot z + \frac{83333333333333}{1000000000000000}}{x}\right)\right)} \]
      9. lower-+.f64N/A

        \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \color{blue}{\left(\mathsf{neg}\left(x\right)\right) + \left(\frac{91893853320467}{100000000000000} + \frac{\left(\left(y + \frac{7936500793651}{10000000000000000}\right) \cdot z - \frac{13888888888889}{5000000000000000}\right) \cdot z + \frac{83333333333333}{1000000000000000}}{x}\right)}\right) \]
      10. lower-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} + \left(\frac{91893853320467}{100000000000000} + \frac{\left(\left(y + \frac{7936500793651}{10000000000000000}\right) \cdot z - \frac{13888888888889}{5000000000000000}\right) \cdot z + \frac{83333333333333}{1000000000000000}}{x}\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \left(\mathsf{neg}\left(x\right)\right) + \color{blue}{\left(\frac{\left(\left(y + \frac{7936500793651}{10000000000000000}\right) \cdot z - \frac{13888888888889}{5000000000000000}\right) \cdot z + \frac{83333333333333}{1000000000000000}}{x} + \frac{91893853320467}{100000000000000}\right)}\right) \]
      12. lower-+.f6499.6

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x - 0.5, \log x, \left(-x\right) + \left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(z, 0.0007936500793651 + y, -0.0027777777777778\right), z, 0.083333333333333\right)}{x} + 0.91893853320467\right)\right)} \]
    5. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \color{blue}{\left(\mathsf{neg}\left(x\right)\right) + \left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(z, \frac{7936500793651}{10000000000000000} + y, \frac{-13888888888889}{5000000000000000}\right), z, \frac{83333333333333}{1000000000000000}\right)}{x} + \frac{91893853320467}{100000000000000}\right)}\right) \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \color{blue}{\left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(z, \frac{7936500793651}{10000000000000000} + y, \frac{-13888888888889}{5000000000000000}\right), z, \frac{83333333333333}{1000000000000000}\right)}{x} + \frac{91893853320467}{100000000000000}\right) + \left(\mathsf{neg}\left(x\right)\right)}\right) \]
      3. lift-+.f64N/A

        \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \color{blue}{\left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(z, \frac{7936500793651}{10000000000000000} + y, \frac{-13888888888889}{5000000000000000}\right), z, \frac{83333333333333}{1000000000000000}\right)}{x} + \frac{91893853320467}{100000000000000}\right)} + \left(\mathsf{neg}\left(x\right)\right)\right) \]
      4. associate-+l+N/A

        \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \color{blue}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(z, \frac{7936500793651}{10000000000000000} + y, \frac{-13888888888889}{5000000000000000}\right), z, \frac{83333333333333}{1000000000000000}\right)}{x} + \left(\frac{91893853320467}{100000000000000} + \left(\mathsf{neg}\left(x\right)\right)\right)}\right) \]
      5. lift-/.f64N/A

        \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \color{blue}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(z, \frac{7936500793651}{10000000000000000} + y, \frac{-13888888888889}{5000000000000000}\right), z, \frac{83333333333333}{1000000000000000}\right)}{x}} + \left(\frac{91893853320467}{100000000000000} + \left(\mathsf{neg}\left(x\right)\right)\right)\right) \]
      6. div-invN/A

        \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(z, \frac{7936500793651}{10000000000000000} + y, \frac{-13888888888889}{5000000000000000}\right), z, \frac{83333333333333}{1000000000000000}\right) \cdot \frac{1}{x}} + \left(\frac{91893853320467}{100000000000000} + \left(\mathsf{neg}\left(x\right)\right)\right)\right) \]
      7. lift-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \mathsf{fma}\left(\mathsf{fma}\left(z, \frac{7936500793651}{10000000000000000} + y, \frac{-13888888888889}{5000000000000000}\right), z, \frac{83333333333333}{1000000000000000}\right) \cdot \frac{1}{x} + \left(\frac{91893853320467}{100000000000000} + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)\right) \]
      8. sub-negN/A

        \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \mathsf{fma}\left(\mathsf{fma}\left(z, \frac{7936500793651}{10000000000000000} + y, \frac{-13888888888889}{5000000000000000}\right), z, \frac{83333333333333}{1000000000000000}\right) \cdot \frac{1}{x} + \color{blue}{\left(\frac{91893853320467}{100000000000000} - x\right)}\right) \]
      9. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(z, \frac{7936500793651}{10000000000000000} + y, \frac{-13888888888889}{5000000000000000}\right), z, \frac{83333333333333}{1000000000000000}\right), \frac{1}{x}, \frac{91893853320467}{100000000000000} - x\right)}\right) \]
      10. lift-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{z \cdot \left(\frac{7936500793651}{10000000000000000} + y\right) + \frac{-13888888888889}{5000000000000000}}, z, \frac{83333333333333}{1000000000000000}\right), \frac{1}{x}, \frac{91893853320467}{100000000000000} - x\right)\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\left(\frac{7936500793651}{10000000000000000} + y\right) \cdot z} + \frac{-13888888888889}{5000000000000000}, z, \frac{83333333333333}{1000000000000000}\right), \frac{1}{x}, \frac{91893853320467}{100000000000000} - x\right)\right) \]
      12. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{7936500793651}{10000000000000000} + y, z, \frac{-13888888888889}{5000000000000000}\right)}, z, \frac{83333333333333}{1000000000000000}\right), \frac{1}{x}, \frac{91893853320467}{100000000000000} - x\right)\right) \]
      13. lift-+.f64N/A

        \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\frac{7936500793651}{10000000000000000} + y}, z, \frac{-13888888888889}{5000000000000000}\right), z, \frac{83333333333333}{1000000000000000}\right), \frac{1}{x}, \frac{91893853320467}{100000000000000} - x\right)\right) \]
      14. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{y + \frac{7936500793651}{10000000000000000}}, z, \frac{-13888888888889}{5000000000000000}\right), z, \frac{83333333333333}{1000000000000000}\right), \frac{1}{x}, \frac{91893853320467}{100000000000000} - x\right)\right) \]
      15. lower-+.f64N/A

        \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{y + \frac{7936500793651}{10000000000000000}}, z, \frac{-13888888888889}{5000000000000000}\right), z, \frac{83333333333333}{1000000000000000}\right), \frac{1}{x}, \frac{91893853320467}{100000000000000} - x\right)\right) \]
      16. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(y + \frac{7936500793651}{10000000000000000}, z, \frac{-13888888888889}{5000000000000000}\right), z, \frac{83333333333333}{1000000000000000}\right), \color{blue}{\frac{1}{x}}, \frac{91893853320467}{100000000000000} - x\right)\right) \]
      17. lower--.f6499.6

        \[\leadsto \mathsf{fma}\left(x - 0.5, \log x, \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(y + 0.0007936500793651, z, -0.0027777777777778\right), z, 0.083333333333333\right), \frac{1}{x}, \color{blue}{0.91893853320467 - x}\right)\right) \]
    6. Applied rewrites99.6%

      \[\leadsto \mathsf{fma}\left(x - 0.5, \log x, \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(y + 0.0007936500793651, z, -0.0027777777777778\right), z, 0.083333333333333\right), \frac{1}{x}, 0.91893853320467 - x\right)}\right) \]
    7. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(y + \frac{7936500793651}{10000000000000000}, z, \frac{-13888888888889}{5000000000000000}\right), z, \frac{83333333333333}{1000000000000000}\right) \cdot \frac{1}{x} + \left(\frac{91893853320467}{100000000000000} - x\right)}\right) \]
      2. lift-/.f64N/A

        \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \mathsf{fma}\left(\mathsf{fma}\left(y + \frac{7936500793651}{10000000000000000}, z, \frac{-13888888888889}{5000000000000000}\right), z, \frac{83333333333333}{1000000000000000}\right) \cdot \color{blue}{\frac{1}{x}} + \left(\frac{91893853320467}{100000000000000} - x\right)\right) \]
      3. un-div-invN/A

        \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \color{blue}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(y + \frac{7936500793651}{10000000000000000}, z, \frac{-13888888888889}{5000000000000000}\right), z, \frac{83333333333333}{1000000000000000}\right)}{x}} + \left(\frac{91893853320467}{100000000000000} - x\right)\right) \]
      4. lift--.f64N/A

        \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \frac{\mathsf{fma}\left(\mathsf{fma}\left(y + \frac{7936500793651}{10000000000000000}, z, \frac{-13888888888889}{5000000000000000}\right), z, \frac{83333333333333}{1000000000000000}\right)}{x} + \color{blue}{\left(\frac{91893853320467}{100000000000000} - x\right)}\right) \]
      5. flip--N/A

        \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \frac{\mathsf{fma}\left(\mathsf{fma}\left(y + \frac{7936500793651}{10000000000000000}, z, \frac{-13888888888889}{5000000000000000}\right), z, \frac{83333333333333}{1000000000000000}\right)}{x} + \color{blue}{\frac{\frac{91893853320467}{100000000000000} \cdot \frac{91893853320467}{100000000000000} - x \cdot x}{\frac{91893853320467}{100000000000000} + x}}\right) \]
      6. frac-addN/A

        \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \color{blue}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(y + \frac{7936500793651}{10000000000000000}, z, \frac{-13888888888889}{5000000000000000}\right), z, \frac{83333333333333}{1000000000000000}\right) \cdot \left(\frac{91893853320467}{100000000000000} + x\right) + x \cdot \left(\frac{91893853320467}{100000000000000} \cdot \frac{91893853320467}{100000000000000} - x \cdot x\right)}{x \cdot \left(\frac{91893853320467}{100000000000000} + x\right)}}\right) \]
      7. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \color{blue}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(y + \frac{7936500793651}{10000000000000000}, z, \frac{-13888888888889}{5000000000000000}\right), z, \frac{83333333333333}{1000000000000000}\right) \cdot \left(\frac{91893853320467}{100000000000000} + x\right) + x \cdot \left(\frac{91893853320467}{100000000000000} \cdot \frac{91893853320467}{100000000000000} - x \cdot x\right)}{x \cdot \left(\frac{91893853320467}{100000000000000} + x\right)}}\right) \]
    8. Applied rewrites99.7%

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

    if 3.2e-81 < x

    1. Initial program 90.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. Add Preprocessing
    3. Taylor expanded in y around 0

      \[\leadsto \color{blue}{\left(\frac{91893853320467}{100000000000000} + \left(\frac{83333333333333}{1000000000000000} \cdot \frac{1}{x} + \left(\log x \cdot \left(x - \frac{1}{2}\right) + \left(\frac{y \cdot {z}^{2}}{x} + \frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x}\right)\right)\right)\right) - x} \]
    4. Applied rewrites99.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x - 0.5, \log x, \mathsf{fma}\left(\mathsf{fma}\left(\frac{y}{x}, z, \frac{\mathsf{fma}\left(0.0007936500793651, z, -0.0027777777777778\right)}{x}\right), z, \frac{0.083333333333333}{x}\right)\right) - \left(x - 0.91893853320467\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 3.2 \cdot 10^{-81}:\\ \;\;\;\;\mathsf{fma}\left(x - 0.5, \log x, \frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(z, y + 0.0007936500793651, -0.0027777777777778\right), z, 0.083333333333333\right), 0.91893853320467 + x, \left(0.8444480278083504 - x \cdot x\right) \cdot x\right)}{\left(0.91893853320467 + x\right) \cdot x}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x - 0.5, \log x, \mathsf{fma}\left(\mathsf{fma}\left(\frac{y}{x}, z, \frac{\mathsf{fma}\left(0.0007936500793651, z, -0.0027777777777778\right)}{x}\right), z, \frac{0.083333333333333}{x}\right)\right) - \left(x - 0.91893853320467\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 59.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x} + \left(\left(\log x \cdot \left(x - 0.5\right) - x\right) + 0.91893853320467\right)\\ t_1 := \frac{z}{x} \cdot z\\ \mathbf{if}\;t\_0 \leq -2 \cdot 10^{+40}:\\ \;\;\;\;t\_1 \cdot y\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+300}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.0007936500793651, z, -0.0027777777777778\right), z, 0.083333333333333\right)}{x}\\ \mathbf{else}:\\ \;\;\;\;t\_1 \cdot 0.0007936500793651\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0
         (+
          (/
           (+
            (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)
            0.083333333333333)
           x)
          (+ (- (* (log x) (- x 0.5)) x) 0.91893853320467)))
        (t_1 (* (/ z x) z)))
   (if (<= t_0 -2e+40)
     (* t_1 y)
     (if (<= t_0 5e+300)
       (/
        (fma
         (fma 0.0007936500793651 z -0.0027777777777778)
         z
         0.083333333333333)
        x)
       (* t_1 0.0007936500793651)))))
double code(double x, double y, double z) {
	double t_0 = ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x) + (((log(x) * (x - 0.5)) - x) + 0.91893853320467);
	double t_1 = (z / x) * z;
	double tmp;
	if (t_0 <= -2e+40) {
		tmp = t_1 * y;
	} else if (t_0 <= 5e+300) {
		tmp = fma(fma(0.0007936500793651, z, -0.0027777777777778), z, 0.083333333333333) / x;
	} else {
		tmp = t_1 * 0.0007936500793651;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(Float64(Float64(Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x) + Float64(Float64(Float64(log(x) * Float64(x - 0.5)) - x) + 0.91893853320467))
	t_1 = Float64(Float64(z / x) * z)
	tmp = 0.0
	if (t_0 <= -2e+40)
		tmp = Float64(t_1 * y);
	elseif (t_0 <= 5e+300)
		tmp = Float64(fma(fma(0.0007936500793651, z, -0.0027777777777778), z, 0.083333333333333) / x);
	else
		tmp = Float64(t_1 * 0.0007936500793651);
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision] + N[(N[(N[(N[Log[x], $MachinePrecision] * N[(x - 0.5), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(z / x), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+40], N[(t$95$1 * y), $MachinePrecision], If[LessEqual[t$95$0, 5e+300], N[(N[(N[(0.0007936500793651 * z + -0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision], N[(t$95$1 * 0.0007936500793651), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x} + \left(\left(\log x \cdot \left(x - 0.5\right) - x\right) + 0.91893853320467\right)\\
t_1 := \frac{z}{x} \cdot z\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+40}:\\
\;\;\;\;t\_1 \cdot y\\

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+300}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.0007936500793651, z, -0.0027777777777778\right), z, 0.083333333333333\right)}{x}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (+.f64 (+.f64 (-.f64 (*.f64 (-.f64 x #s(literal 1/2 binary64)) (log.f64 x)) x) #s(literal 91893853320467/100000000000000 binary64)) (/.f64 (+.f64 (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) #s(literal 83333333333333/1000000000000000 binary64)) x)) < -2.00000000000000006e40

    1. Initial program 90.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. Add Preprocessing
    3. Taylor expanded in y around inf

      \[\leadsto \color{blue}{\frac{y \cdot {z}^{2}}{x}} \]
    4. Step-by-step derivation
      1. associate-/l*N/A

        \[\leadsto \color{blue}{y \cdot \frac{{z}^{2}}{x}} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{\frac{{z}^{2}}{x} \cdot y} \]
      3. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{{z}^{2}}{x} \cdot y} \]
      4. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{{z}^{2}}{x}} \cdot y \]
      5. unpow2N/A

        \[\leadsto \frac{\color{blue}{z \cdot z}}{x} \cdot y \]
      6. lower-*.f6492.7

        \[\leadsto \frac{\color{blue}{z \cdot z}}{x} \cdot y \]
    5. Applied rewrites92.7%

      \[\leadsto \color{blue}{\frac{z \cdot z}{x} \cdot y} \]
    6. Step-by-step derivation
      1. Applied rewrites94.0%

        \[\leadsto \color{blue}{\left(\frac{z}{x} \cdot z\right) \cdot y} \]

      if -2.00000000000000006e40 < (+.f64 (+.f64 (-.f64 (*.f64 (-.f64 x #s(literal 1/2 binary64)) (log.f64 x)) x) #s(literal 91893853320467/100000000000000 binary64)) (/.f64 (+.f64 (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) #s(literal 83333333333333/1000000000000000 binary64)) x)) < 5.00000000000000026e300

      1. Initial program 99.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} \]
      2. Add Preprocessing
      3. Taylor expanded in y around 0

        \[\leadsto \color{blue}{\left(\frac{91893853320467}{100000000000000} + \left(\frac{83333333333333}{1000000000000000} \cdot \frac{1}{x} + \left(\log x \cdot \left(x - \frac{1}{2}\right) + \frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x}\right)\right)\right) - x} \]
      4. Step-by-step derivation
        1. +-commutativeN/A

          \[\leadsto \color{blue}{\left(\left(\frac{83333333333333}{1000000000000000} \cdot \frac{1}{x} + \left(\log x \cdot \left(x - \frac{1}{2}\right) + \frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x}\right)\right) + \frac{91893853320467}{100000000000000}\right)} - x \]
        2. associate-+r+N/A

          \[\leadsto \left(\color{blue}{\left(\left(\frac{83333333333333}{1000000000000000} \cdot \frac{1}{x} + \log x \cdot \left(x - \frac{1}{2}\right)\right) + \frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x}\right)} + \frac{91893853320467}{100000000000000}\right) - x \]
        3. associate-+l+N/A

          \[\leadsto \color{blue}{\left(\left(\frac{83333333333333}{1000000000000000} \cdot \frac{1}{x} + \log x \cdot \left(x - \frac{1}{2}\right)\right) + \left(\frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x} + \frac{91893853320467}{100000000000000}\right)\right)} - x \]
        4. associate--l+N/A

          \[\leadsto \color{blue}{\left(\frac{83333333333333}{1000000000000000} \cdot \frac{1}{x} + \log x \cdot \left(x - \frac{1}{2}\right)\right) + \left(\left(\frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x} + \frac{91893853320467}{100000000000000}\right) - x\right)} \]
        5. lower-+.f64N/A

          \[\leadsto \color{blue}{\left(\frac{83333333333333}{1000000000000000} \cdot \frac{1}{x} + \log x \cdot \left(x - \frac{1}{2}\right)\right) + \left(\left(\frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x} + \frac{91893853320467}{100000000000000}\right) - x\right)} \]
        6. +-commutativeN/A

          \[\leadsto \color{blue}{\left(\log x \cdot \left(x - \frac{1}{2}\right) + \frac{83333333333333}{1000000000000000} \cdot \frac{1}{x}\right)} + \left(\left(\frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x} + \frac{91893853320467}{100000000000000}\right) - x\right) \]
        7. *-commutativeN/A

          \[\leadsto \left(\color{blue}{\left(x - \frac{1}{2}\right) \cdot \log x} + \frac{83333333333333}{1000000000000000} \cdot \frac{1}{x}\right) + \left(\left(\frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x} + \frac{91893853320467}{100000000000000}\right) - x\right) \]
        8. lower-fma.f64N/A

          \[\leadsto \color{blue}{\mathsf{fma}\left(x - \frac{1}{2}, \log x, \frac{83333333333333}{1000000000000000} \cdot \frac{1}{x}\right)} + \left(\left(\frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x} + \frac{91893853320467}{100000000000000}\right) - x\right) \]
        9. lower--.f64N/A

          \[\leadsto \mathsf{fma}\left(\color{blue}{x - \frac{1}{2}}, \log x, \frac{83333333333333}{1000000000000000} \cdot \frac{1}{x}\right) + \left(\left(\frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x} + \frac{91893853320467}{100000000000000}\right) - x\right) \]
        10. lower-log.f64N/A

          \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \color{blue}{\log x}, \frac{83333333333333}{1000000000000000} \cdot \frac{1}{x}\right) + \left(\left(\frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x} + \frac{91893853320467}{100000000000000}\right) - x\right) \]
        11. associate-*r/N/A

          \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \color{blue}{\frac{\frac{83333333333333}{1000000000000000} \cdot 1}{x}}\right) + \left(\left(\frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x} + \frac{91893853320467}{100000000000000}\right) - x\right) \]
        12. metadata-evalN/A

          \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \frac{\color{blue}{\frac{83333333333333}{1000000000000000}}}{x}\right) + \left(\left(\frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x} + \frac{91893853320467}{100000000000000}\right) - x\right) \]
        13. lower-/.f64N/A

          \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \color{blue}{\frac{\frac{83333333333333}{1000000000000000}}{x}}\right) + \left(\left(\frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x} + \frac{91893853320467}{100000000000000}\right) - x\right) \]
        14. lower--.f64N/A

          \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \frac{\frac{83333333333333}{1000000000000000}}{x}\right) + \color{blue}{\left(\left(\frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x} + \frac{91893853320467}{100000000000000}\right) - x\right)} \]
      5. Applied rewrites95.6%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x - 0.5, \log x, \frac{0.083333333333333}{x}\right) + \left(\mathsf{fma}\left(\frac{\mathsf{fma}\left(0.0007936500793651, z, -0.0027777777777778\right)}{x}, z, 0.91893853320467\right) - x\right)} \]
      6. Taylor expanded in x around 0

        \[\leadsto \frac{\frac{83333333333333}{1000000000000000} + z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{\color{blue}{x}} \]
      7. Step-by-step derivation
        1. Applied rewrites44.8%

          \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(0.0007936500793651, z, -0.0027777777777778\right), z, 0.083333333333333\right)}{\color{blue}{x}} \]

        if 5.00000000000000026e300 < (+.f64 (+.f64 (-.f64 (*.f64 (-.f64 x #s(literal 1/2 binary64)) (log.f64 x)) x) #s(literal 91893853320467/100000000000000 binary64)) (/.f64 (+.f64 (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) #s(literal 83333333333333/1000000000000000 binary64)) x))

        1. Initial program 84.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} \]
        2. Add Preprocessing
        3. Taylor expanded in y around 0

          \[\leadsto \color{blue}{\left(\frac{91893853320467}{100000000000000} + \left(\frac{83333333333333}{1000000000000000} \cdot \frac{1}{x} + \left(\log x \cdot \left(x - \frac{1}{2}\right) + \frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x}\right)\right)\right) - x} \]
        4. Step-by-step derivation
          1. +-commutativeN/A

            \[\leadsto \color{blue}{\left(\left(\frac{83333333333333}{1000000000000000} \cdot \frac{1}{x} + \left(\log x \cdot \left(x - \frac{1}{2}\right) + \frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x}\right)\right) + \frac{91893853320467}{100000000000000}\right)} - x \]
          2. associate-+r+N/A

            \[\leadsto \left(\color{blue}{\left(\left(\frac{83333333333333}{1000000000000000} \cdot \frac{1}{x} + \log x \cdot \left(x - \frac{1}{2}\right)\right) + \frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x}\right)} + \frac{91893853320467}{100000000000000}\right) - x \]
          3. associate-+l+N/A

            \[\leadsto \color{blue}{\left(\left(\frac{83333333333333}{1000000000000000} \cdot \frac{1}{x} + \log x \cdot \left(x - \frac{1}{2}\right)\right) + \left(\frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x} + \frac{91893853320467}{100000000000000}\right)\right)} - x \]
          4. associate--l+N/A

            \[\leadsto \color{blue}{\left(\frac{83333333333333}{1000000000000000} \cdot \frac{1}{x} + \log x \cdot \left(x - \frac{1}{2}\right)\right) + \left(\left(\frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x} + \frac{91893853320467}{100000000000000}\right) - x\right)} \]
          5. lower-+.f64N/A

            \[\leadsto \color{blue}{\left(\frac{83333333333333}{1000000000000000} \cdot \frac{1}{x} + \log x \cdot \left(x - \frac{1}{2}\right)\right) + \left(\left(\frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x} + \frac{91893853320467}{100000000000000}\right) - x\right)} \]
          6. +-commutativeN/A

            \[\leadsto \color{blue}{\left(\log x \cdot \left(x - \frac{1}{2}\right) + \frac{83333333333333}{1000000000000000} \cdot \frac{1}{x}\right)} + \left(\left(\frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x} + \frac{91893853320467}{100000000000000}\right) - x\right) \]
          7. *-commutativeN/A

            \[\leadsto \left(\color{blue}{\left(x - \frac{1}{2}\right) \cdot \log x} + \frac{83333333333333}{1000000000000000} \cdot \frac{1}{x}\right) + \left(\left(\frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x} + \frac{91893853320467}{100000000000000}\right) - x\right) \]
          8. lower-fma.f64N/A

            \[\leadsto \color{blue}{\mathsf{fma}\left(x - \frac{1}{2}, \log x, \frac{83333333333333}{1000000000000000} \cdot \frac{1}{x}\right)} + \left(\left(\frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x} + \frac{91893853320467}{100000000000000}\right) - x\right) \]
          9. lower--.f64N/A

            \[\leadsto \mathsf{fma}\left(\color{blue}{x - \frac{1}{2}}, \log x, \frac{83333333333333}{1000000000000000} \cdot \frac{1}{x}\right) + \left(\left(\frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x} + \frac{91893853320467}{100000000000000}\right) - x\right) \]
          10. lower-log.f64N/A

            \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \color{blue}{\log x}, \frac{83333333333333}{1000000000000000} \cdot \frac{1}{x}\right) + \left(\left(\frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x} + \frac{91893853320467}{100000000000000}\right) - x\right) \]
          11. associate-*r/N/A

            \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \color{blue}{\frac{\frac{83333333333333}{1000000000000000} \cdot 1}{x}}\right) + \left(\left(\frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x} + \frac{91893853320467}{100000000000000}\right) - x\right) \]
          12. metadata-evalN/A

            \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \frac{\color{blue}{\frac{83333333333333}{1000000000000000}}}{x}\right) + \left(\left(\frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x} + \frac{91893853320467}{100000000000000}\right) - x\right) \]
          13. lower-/.f64N/A

            \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \color{blue}{\frac{\frac{83333333333333}{1000000000000000}}{x}}\right) + \left(\left(\frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x} + \frac{91893853320467}{100000000000000}\right) - x\right) \]
          14. lower--.f64N/A

            \[\leadsto \mathsf{fma}\left(x - \frac{1}{2}, \log x, \frac{\frac{83333333333333}{1000000000000000}}{x}\right) + \color{blue}{\left(\left(\frac{z \cdot \left(\frac{7936500793651}{10000000000000000} \cdot z - \frac{13888888888889}{5000000000000000}\right)}{x} + \frac{91893853320467}{100000000000000}\right) - x\right)} \]
        5. Applied rewrites87.3%

          \[\leadsto \color{blue}{\mathsf{fma}\left(x - 0.5, \log x, \frac{0.083333333333333}{x}\right) + \left(\mathsf{fma}\left(\frac{\mathsf{fma}\left(0.0007936500793651, z, -0.0027777777777778\right)}{x}, z, 0.91893853320467\right) - x\right)} \]
        6. Taylor expanded in z around inf

          \[\leadsto \frac{7936500793651}{10000000000000000} \cdot \color{blue}{\frac{{z}^{2}}{x}} \]
        7. Step-by-step derivation
          1. Applied rewrites73.2%

            \[\leadsto \left(z \cdot \frac{z}{x}\right) \cdot \color{blue}{0.0007936500793651} \]
        8. Recombined 3 regimes into one program.
        9. Final simplification59.7%

          \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x} + \left(\left(\log x \cdot \left(x - 0.5\right) - x\right) + 0.91893853320467\right) \leq -2 \cdot 10^{+40}:\\ \;\;\;\;\left(\frac{z}{x} \cdot z\right) \cdot y\\ \mathbf{elif}\;\frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x} + \left(\left(\log x \cdot \left(x - 0.5\right) - x\right) + 0.91893853320467\right) \leq 5 \cdot 10^{+300}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.0007936500793651, z, -0.0027777777777778\right), z, 0.083333333333333\right)}{x}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{z}{x} \cdot z\right) \cdot 0.0007936500793651\\ \end{array} \]
        10. Add Preprocessing

        Developer Target 1: 98.7% accurate, 0.9× speedup?

        \[\begin{array}{l} \\ \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) \end{array} \]
        (FPCore (x y z)
         :precision binary64
         (+
          (+ (+ (* (- x 0.5) (log x)) (- 0.91893853320467 x)) (/ 0.083333333333333 x))
          (* (/ z x) (- (* z (+ y 0.0007936500793651)) 0.0027777777777778))))
        double code(double x, double y, double z) {
        	return ((((x - 0.5) * log(x)) + (0.91893853320467 - x)) + (0.083333333333333 / x)) + ((z / x) * ((z * (y + 0.0007936500793651)) - 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)) + (0.91893853320467d0 - x)) + (0.083333333333333d0 / x)) + ((z / x) * ((z * (y + 0.0007936500793651d0)) - 0.0027777777777778d0))
        end function
        
        public static double code(double x, double y, double z) {
        	return ((((x - 0.5) * Math.log(x)) + (0.91893853320467 - x)) + (0.083333333333333 / x)) + ((z / x) * ((z * (y + 0.0007936500793651)) - 0.0027777777777778));
        }
        
        def code(x, y, z):
        	return ((((x - 0.5) * math.log(x)) + (0.91893853320467 - x)) + (0.083333333333333 / x)) + ((z / x) * ((z * (y + 0.0007936500793651)) - 0.0027777777777778))
        
        function code(x, y, z)
        	return Float64(Float64(Float64(Float64(Float64(x - 0.5) * log(x)) + Float64(0.91893853320467 - x)) + Float64(0.083333333333333 / x)) + Float64(Float64(z / x) * Float64(Float64(z * Float64(y + 0.0007936500793651)) - 0.0027777777777778)))
        end
        
        function tmp = code(x, y, z)
        	tmp = ((((x - 0.5) * log(x)) + (0.91893853320467 - x)) + (0.083333333333333 / x)) + ((z / x) * ((z * (y + 0.0007936500793651)) - 0.0027777777777778));
        end
        
        code[x_, y_, z_] := N[(N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] + N[(0.91893853320467 - x), $MachinePrecision]), $MachinePrecision] + N[(0.083333333333333 / x), $MachinePrecision]), $MachinePrecision] + N[(N[(z / x), $MachinePrecision] * N[(N[(z * N[(y + 0.0007936500793651), $MachinePrecision]), $MachinePrecision] - 0.0027777777777778), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
        
        \begin{array}{l}
        
        \\
        \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)
        \end{array}
        

        Reproduce

        ?
        herbie shell --seed 2024230 
        (FPCore (x y z)
          :name "Numeric.SpecFunctions:$slogFactorial from math-functions-0.1.5.2, B"
          :precision binary64
        
          :alt
          (! :herbie-platform default (+ (+ (+ (* (- x 1/2) (log x)) (- 91893853320467/100000000000000 x)) (/ 83333333333333/1000000000000000 x)) (* (/ z x) (- (* z (+ y 7936500793651/10000000000000000)) 13888888888889/5000000000000000))))
        
          (+ (+ (- (* (- x 0.5) (log x)) x) 0.91893853320467) (/ (+ (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z) 0.083333333333333) x)))