Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2

Percentage Accurate: 99.8% → 99.8%
Time: 8.1s
Alternatives: 11
Speedup: 1.0×

Specification

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

\\
\left(\left(x - \log y \cdot \left(0.5 + y\right)\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. Final simplification99.9%

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

Alternative 2: 72.8% accurate, 0.2× speedup?

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

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{x}{z}, z, -z\right)\\
t_1 := \left(x - \log y \cdot \left(0.5 + y\right)\right) + y\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+128}:\\
\;\;\;\;\left(1 - \log y\right) \cdot y\\

\mathbf{elif}\;t\_1 \leq -500:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;t\_1 \leq 351.5:\\
\;\;\;\;y - \mathsf{fma}\left(0.5, \log y, z\right)\\

\mathbf{elif}\;t\_1 \leq 10^{+192}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{x}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -4.0000000000000003e128

    1. Initial program 99.7%

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

      \[\leadsto \color{blue}{y \cdot \left(1 - -1 \cdot \log \left(\frac{1}{y}\right)\right)} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{\left(1 - -1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot y} \]
      2. mul-1-negN/A

        \[\leadsto \left(1 - \color{blue}{\left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right)}\right) \cdot y \]
      3. log-recN/A

        \[\leadsto \left(1 - \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\log y\right)\right)}\right)\right)\right) \cdot y \]
      4. remove-double-negN/A

        \[\leadsto \left(1 - \color{blue}{\log y}\right) \cdot y \]
      5. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(1 - \log y\right) \cdot y} \]
      6. lower--.f64N/A

        \[\leadsto \color{blue}{\left(1 - \log y\right)} \cdot y \]
      7. lower-log.f6466.7

        \[\leadsto \left(1 - \color{blue}{\log y}\right) \cdot y \]
    5. Applied rewrites66.7%

      \[\leadsto \color{blue}{\left(1 - \log y\right) \cdot y} \]

    if -4.0000000000000003e128 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -500 or 351.5 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 1.00000000000000004e192

    1. Initial program 99.9%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z} \]
      2. flip--N/A

        \[\leadsto \color{blue}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}} \]
      3. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}}} \]
      4. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}}} \]
      5. clear-numN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}}}} \]
      6. flip--N/A

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z}}} \]
      7. lift--.f64N/A

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z}}} \]
      8. lower-/.f6499.7

        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z}}} \]
      9. lift--.f64N/A

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z}}} \]
      10. lift-+.f64N/A

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(z \cdot \left(1 + -1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right)\right)} \]
    6. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \color{blue}{\left(-1 \cdot z\right) \cdot \left(1 + -1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right)} \]
      2. mul-1-negN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z\right)\right)} \cdot \left(1 + -1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right) \]
      3. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(z\right)\right) \cdot \color{blue}{\left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z} + 1\right)} \]
      4. distribute-lft-inN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z\right)\right) \cdot \left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right) + \left(\mathsf{neg}\left(z\right)\right) \cdot 1} \]
      5. *-rgt-identityN/A

        \[\leadsto \left(\mathsf{neg}\left(z\right)\right) \cdot \left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right) + \color{blue}{\left(\mathsf{neg}\left(z\right)\right)} \]
      6. distribute-lft-neg-inN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z \cdot \left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right)\right)\right)} + \left(\mathsf{neg}\left(z\right)\right) \]
      7. *-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right) \cdot z}\right)\right) + \left(\mathsf{neg}\left(z\right)\right) \]
      8. associate-*l*N/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{-1 \cdot \left(\frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z} \cdot z\right)}\right)\right) + \left(\mathsf{neg}\left(z\right)\right) \]
      9. neg-mul-1N/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z} \cdot z\right)\right)}\right)\right) + \left(\mathsf{neg}\left(z\right)\right) \]
      10. remove-double-negN/A

        \[\leadsto \color{blue}{\frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z} \cdot z} + \left(\mathsf{neg}\left(z\right)\right) \]
      11. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}, z, \mathsf{neg}\left(z\right)\right)} \]
    7. Applied rewrites91.2%

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

      \[\leadsto \mathsf{fma}\left(\frac{x}{z}, z, -z\right) \]
    9. Step-by-step derivation
      1. Applied rewrites68.9%

        \[\leadsto \mathsf{fma}\left(\frac{x}{z}, z, -z\right) \]

      if -500 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 351.5

      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}{y - \left(z + \log y \cdot \left(\frac{1}{2} + y\right)\right)} \]
      4. Step-by-step derivation
        1. lower--.f64N/A

          \[\leadsto \color{blue}{y - \left(z + \log y \cdot \left(\frac{1}{2} + y\right)\right)} \]
        2. +-commutativeN/A

          \[\leadsto y - \color{blue}{\left(\log y \cdot \left(\frac{1}{2} + y\right) + z\right)} \]
        3. *-commutativeN/A

          \[\leadsto y - \left(\color{blue}{\left(\frac{1}{2} + y\right) \cdot \log y} + z\right) \]
        4. lower-fma.f64N/A

          \[\leadsto y - \color{blue}{\mathsf{fma}\left(\frac{1}{2} + y, \log y, z\right)} \]
        5. lower-+.f64N/A

          \[\leadsto y - \mathsf{fma}\left(\color{blue}{\frac{1}{2} + y}, \log y, z\right) \]
        6. lower-log.f6498.6

          \[\leadsto y - \mathsf{fma}\left(0.5 + y, \color{blue}{\log y}, z\right) \]
      5. Applied rewrites98.6%

        \[\leadsto \color{blue}{y - \mathsf{fma}\left(0.5 + y, \log y, z\right)} \]
      6. Taylor expanded in y around 0

        \[\leadsto y - \mathsf{fma}\left(\frac{1}{2}, \log \color{blue}{y}, z\right) \]
      7. Step-by-step derivation
        1. Applied rewrites98.3%

          \[\leadsto y - \mathsf{fma}\left(0.5, \log \color{blue}{y}, z\right) \]

        if 1.00000000000000004e192 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y)

        1. Initial program 100.0%

          \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. lift--.f64N/A

            \[\leadsto \color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z} \]
          2. flip--N/A

            \[\leadsto \color{blue}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}} \]
          3. clear-numN/A

            \[\leadsto \color{blue}{\frac{1}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}}} \]
          4. lower-/.f64N/A

            \[\leadsto \color{blue}{\frac{1}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}}} \]
          5. clear-numN/A

            \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}}}} \]
          6. flip--N/A

            \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z}}} \]
          7. lift--.f64N/A

            \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z}}} \]
          8. lower-/.f6499.6

            \[\leadsto \frac{1}{\color{blue}{\frac{1}{\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z}}} \]
          9. lift--.f64N/A

            \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z}}} \]
          10. lift-+.f64N/A

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

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

          \[\leadsto \frac{1}{\color{blue}{\frac{1}{x}}} \]
        6. Step-by-step derivation
          1. lower-/.f6493.8

            \[\leadsto \frac{1}{\color{blue}{\frac{1}{x}}} \]
        7. Applied rewrites93.8%

          \[\leadsto \frac{1}{\color{blue}{\frac{1}{x}}} \]
      8. Recombined 4 regimes into one program.
      9. Final simplification78.0%

        \[\leadsto \begin{array}{l} \mathbf{if}\;\left(x - \log y \cdot \left(0.5 + y\right)\right) + y \leq -4 \cdot 10^{+128}:\\ \;\;\;\;\left(1 - \log y\right) \cdot y\\ \mathbf{elif}\;\left(x - \log y \cdot \left(0.5 + y\right)\right) + y \leq -500:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, z, -z\right)\\ \mathbf{elif}\;\left(x - \log y \cdot \left(0.5 + y\right)\right) + y \leq 351.5:\\ \;\;\;\;y - \mathsf{fma}\left(0.5, \log y, z\right)\\ \mathbf{elif}\;\left(x - \log y \cdot \left(0.5 + y\right)\right) + y \leq 10^{+192}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, z, -z\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1}{x}}\\ \end{array} \]
      10. Add Preprocessing

      Alternative 3: 72.8% accurate, 0.2× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(\frac{x}{z}, z, -z\right)\\ t_1 := \left(x - \log y \cdot \left(0.5 + y\right)\right) + y\\ \mathbf{if}\;t\_1 \leq -4 \cdot 10^{+128}:\\ \;\;\;\;\left(1 - \log y\right) \cdot y\\ \mathbf{elif}\;t\_1 \leq -500:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_1 \leq 351.5:\\ \;\;\;\;-0.5 \cdot \log y - z\\ \mathbf{elif}\;t\_1 \leq 10^{+192}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1}{x}}\\ \end{array} \end{array} \]
      (FPCore (x y z)
       :precision binary64
       (let* ((t_0 (fma (/ x z) z (- z))) (t_1 (+ (- x (* (log y) (+ 0.5 y))) y)))
         (if (<= t_1 -4e+128)
           (* (- 1.0 (log y)) y)
           (if (<= t_1 -500.0)
             t_0
             (if (<= t_1 351.5)
               (- (* -0.5 (log y)) z)
               (if (<= t_1 1e+192) t_0 (/ 1.0 (/ 1.0 x))))))))
      double code(double x, double y, double z) {
      	double t_0 = fma((x / z), z, -z);
      	double t_1 = (x - (log(y) * (0.5 + y))) + y;
      	double tmp;
      	if (t_1 <= -4e+128) {
      		tmp = (1.0 - log(y)) * y;
      	} else if (t_1 <= -500.0) {
      		tmp = t_0;
      	} else if (t_1 <= 351.5) {
      		tmp = (-0.5 * log(y)) - z;
      	} else if (t_1 <= 1e+192) {
      		tmp = t_0;
      	} else {
      		tmp = 1.0 / (1.0 / x);
      	}
      	return tmp;
      }
      
      function code(x, y, z)
      	t_0 = fma(Float64(x / z), z, Float64(-z))
      	t_1 = Float64(Float64(x - Float64(log(y) * Float64(0.5 + y))) + y)
      	tmp = 0.0
      	if (t_1 <= -4e+128)
      		tmp = Float64(Float64(1.0 - log(y)) * y);
      	elseif (t_1 <= -500.0)
      		tmp = t_0;
      	elseif (t_1 <= 351.5)
      		tmp = Float64(Float64(-0.5 * log(y)) - z);
      	elseif (t_1 <= 1e+192)
      		tmp = t_0;
      	else
      		tmp = Float64(1.0 / Float64(1.0 / x));
      	end
      	return tmp
      end
      
      code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x / z), $MachinePrecision] * z + (-z)), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x - N[(N[Log[y], $MachinePrecision] * N[(0.5 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+128], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$1, -500.0], t$95$0, If[LessEqual[t$95$1, 351.5], N[(N[(-0.5 * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[t$95$1, 1e+192], t$95$0, N[(1.0 / N[(1.0 / x), $MachinePrecision]), $MachinePrecision]]]]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \mathsf{fma}\left(\frac{x}{z}, z, -z\right)\\
      t_1 := \left(x - \log y \cdot \left(0.5 + y\right)\right) + y\\
      \mathbf{if}\;t\_1 \leq -4 \cdot 10^{+128}:\\
      \;\;\;\;\left(1 - \log y\right) \cdot y\\
      
      \mathbf{elif}\;t\_1 \leq -500:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;t\_1 \leq 351.5:\\
      \;\;\;\;-0.5 \cdot \log y - z\\
      
      \mathbf{elif}\;t\_1 \leq 10^{+192}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{1}{\frac{1}{x}}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 4 regimes
      2. if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -4.0000000000000003e128

        1. Initial program 99.7%

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

          \[\leadsto \color{blue}{y \cdot \left(1 - -1 \cdot \log \left(\frac{1}{y}\right)\right)} \]
        4. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto \color{blue}{\left(1 - -1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot y} \]
          2. mul-1-negN/A

            \[\leadsto \left(1 - \color{blue}{\left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right)}\right) \cdot y \]
          3. log-recN/A

            \[\leadsto \left(1 - \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\log y\right)\right)}\right)\right)\right) \cdot y \]
          4. remove-double-negN/A

            \[\leadsto \left(1 - \color{blue}{\log y}\right) \cdot y \]
          5. lower-*.f64N/A

            \[\leadsto \color{blue}{\left(1 - \log y\right) \cdot y} \]
          6. lower--.f64N/A

            \[\leadsto \color{blue}{\left(1 - \log y\right)} \cdot y \]
          7. lower-log.f6466.7

            \[\leadsto \left(1 - \color{blue}{\log y}\right) \cdot y \]
        5. Applied rewrites66.7%

          \[\leadsto \color{blue}{\left(1 - \log y\right) \cdot y} \]

        if -4.0000000000000003e128 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -500 or 351.5 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 1.00000000000000004e192

        1. Initial program 99.9%

          \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. lift--.f64N/A

            \[\leadsto \color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z} \]
          2. flip--N/A

            \[\leadsto \color{blue}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}} \]
          3. clear-numN/A

            \[\leadsto \color{blue}{\frac{1}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}}} \]
          4. lower-/.f64N/A

            \[\leadsto \color{blue}{\frac{1}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}}} \]
          5. clear-numN/A

            \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}}}} \]
          6. flip--N/A

            \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z}}} \]
          7. lift--.f64N/A

            \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z}}} \]
          8. lower-/.f6499.7

            \[\leadsto \frac{1}{\color{blue}{\frac{1}{\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z}}} \]
          9. lift--.f64N/A

            \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z}}} \]
          10. lift-+.f64N/A

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

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

          \[\leadsto \color{blue}{-1 \cdot \left(z \cdot \left(1 + -1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right)\right)} \]
        6. Step-by-step derivation
          1. associate-*r*N/A

            \[\leadsto \color{blue}{\left(-1 \cdot z\right) \cdot \left(1 + -1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right)} \]
          2. mul-1-negN/A

            \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z\right)\right)} \cdot \left(1 + -1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right) \]
          3. +-commutativeN/A

            \[\leadsto \left(\mathsf{neg}\left(z\right)\right) \cdot \color{blue}{\left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z} + 1\right)} \]
          4. distribute-lft-inN/A

            \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z\right)\right) \cdot \left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right) + \left(\mathsf{neg}\left(z\right)\right) \cdot 1} \]
          5. *-rgt-identityN/A

            \[\leadsto \left(\mathsf{neg}\left(z\right)\right) \cdot \left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right) + \color{blue}{\left(\mathsf{neg}\left(z\right)\right)} \]
          6. distribute-lft-neg-inN/A

            \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z \cdot \left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right)\right)\right)} + \left(\mathsf{neg}\left(z\right)\right) \]
          7. *-commutativeN/A

            \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right) \cdot z}\right)\right) + \left(\mathsf{neg}\left(z\right)\right) \]
          8. associate-*l*N/A

            \[\leadsto \left(\mathsf{neg}\left(\color{blue}{-1 \cdot \left(\frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z} \cdot z\right)}\right)\right) + \left(\mathsf{neg}\left(z\right)\right) \]
          9. neg-mul-1N/A

            \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z} \cdot z\right)\right)}\right)\right) + \left(\mathsf{neg}\left(z\right)\right) \]
          10. remove-double-negN/A

            \[\leadsto \color{blue}{\frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z} \cdot z} + \left(\mathsf{neg}\left(z\right)\right) \]
          11. lower-fma.f64N/A

            \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}, z, \mathsf{neg}\left(z\right)\right)} \]
        7. Applied rewrites91.2%

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

          \[\leadsto \mathsf{fma}\left(\frac{x}{z}, z, -z\right) \]
        9. Step-by-step derivation
          1. Applied rewrites68.9%

            \[\leadsto \mathsf{fma}\left(\frac{x}{z}, z, -z\right) \]

          if -500 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 351.5

          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 y around 0

            \[\leadsto \color{blue}{\left(x - \frac{1}{2} \cdot \log y\right)} - z \]
          4. Step-by-step derivation
            1. sub-negN/A

              \[\leadsto \color{blue}{\left(x + \left(\mathsf{neg}\left(\frac{1}{2} \cdot \log y\right)\right)\right)} - z \]
            2. +-commutativeN/A

              \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2} \cdot \log y\right)\right) + x\right)} - z \]
            3. distribute-lft-neg-inN/A

              \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \log y} + x\right) - z \]
            4. metadata-evalN/A

              \[\leadsto \left(\color{blue}{\frac{-1}{2}} \cdot \log y + x\right) - z \]
            5. lower-fma.f64N/A

              \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \log y, x\right)} - z \]
            6. lower-log.f6499.7

              \[\leadsto \mathsf{fma}\left(-0.5, \color{blue}{\log y}, x\right) - z \]
          5. Applied rewrites99.7%

            \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5, \log y, x\right)} - z \]
          6. Taylor expanded in x around 0

            \[\leadsto \frac{-1}{2} \cdot \color{blue}{\log y} - z \]
          7. Step-by-step derivation
            1. Applied rewrites98.3%

              \[\leadsto -0.5 \cdot \color{blue}{\log y} - z \]

            if 1.00000000000000004e192 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y)

            1. Initial program 100.0%

              \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
            2. Add Preprocessing
            3. Step-by-step derivation
              1. lift--.f64N/A

                \[\leadsto \color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z} \]
              2. flip--N/A

                \[\leadsto \color{blue}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}} \]
              3. clear-numN/A

                \[\leadsto \color{blue}{\frac{1}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}}} \]
              4. lower-/.f64N/A

                \[\leadsto \color{blue}{\frac{1}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}}} \]
              5. clear-numN/A

                \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}}}} \]
              6. flip--N/A

                \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z}}} \]
              7. lift--.f64N/A

                \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z}}} \]
              8. lower-/.f6499.6

                \[\leadsto \frac{1}{\color{blue}{\frac{1}{\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z}}} \]
              9. lift--.f64N/A

                \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z}}} \]
              10. lift-+.f64N/A

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

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

              \[\leadsto \frac{1}{\color{blue}{\frac{1}{x}}} \]
            6. Step-by-step derivation
              1. lower-/.f6493.8

                \[\leadsto \frac{1}{\color{blue}{\frac{1}{x}}} \]
            7. Applied rewrites93.8%

              \[\leadsto \frac{1}{\color{blue}{\frac{1}{x}}} \]
          8. Recombined 4 regimes into one program.
          9. Final simplification78.0%

            \[\leadsto \begin{array}{l} \mathbf{if}\;\left(x - \log y \cdot \left(0.5 + y\right)\right) + y \leq -4 \cdot 10^{+128}:\\ \;\;\;\;\left(1 - \log y\right) \cdot y\\ \mathbf{elif}\;\left(x - \log y \cdot \left(0.5 + y\right)\right) + y \leq -500:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, z, -z\right)\\ \mathbf{elif}\;\left(x - \log y \cdot \left(0.5 + y\right)\right) + y \leq 351.5:\\ \;\;\;\;-0.5 \cdot \log y - z\\ \mathbf{elif}\;\left(x - \log y \cdot \left(0.5 + y\right)\right) + y \leq 10^{+192}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, z, -z\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1}{x}}\\ \end{array} \]
          10. Add Preprocessing

          Alternative 4: 65.0% accurate, 0.3× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(\left(x - \log y \cdot \left(0.5 + y\right)\right) + y\right) - z\\ \mathbf{if}\;t\_0 \leq -500:\\ \;\;\;\;\left(1 - \log y\right) \cdot y\\ \mathbf{elif}\;t\_0 \leq 500:\\ \;\;\;\;y - \log y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, z, -z\right)\\ \end{array} \end{array} \]
          (FPCore (x y z)
           :precision binary64
           (let* ((t_0 (- (+ (- x (* (log y) (+ 0.5 y))) y) z)))
             (if (<= t_0 -500.0)
               (* (- 1.0 (log y)) y)
               (if (<= t_0 500.0) (- y (* (log y) 0.5)) (fma (/ x z) z (- z))))))
          double code(double x, double y, double z) {
          	double t_0 = ((x - (log(y) * (0.5 + y))) + y) - z;
          	double tmp;
          	if (t_0 <= -500.0) {
          		tmp = (1.0 - log(y)) * y;
          	} else if (t_0 <= 500.0) {
          		tmp = y - (log(y) * 0.5);
          	} else {
          		tmp = fma((x / z), z, -z);
          	}
          	return tmp;
          }
          
          function code(x, y, z)
          	t_0 = Float64(Float64(Float64(x - Float64(log(y) * Float64(0.5 + y))) + y) - z)
          	tmp = 0.0
          	if (t_0 <= -500.0)
          		tmp = Float64(Float64(1.0 - log(y)) * y);
          	elseif (t_0 <= 500.0)
          		tmp = Float64(y - Float64(log(y) * 0.5));
          	else
          		tmp = fma(Float64(x / z), z, Float64(-z));
          	end
          	return tmp
          end
          
          code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(x - N[(N[Log[y], $MachinePrecision] * N[(0.5 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[t$95$0, -500.0], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$0, 500.0], N[(y - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * z + (-z)), $MachinePrecision]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \left(\left(x - \log y \cdot \left(0.5 + y\right)\right) + y\right) - z\\
          \mathbf{if}\;t\_0 \leq -500:\\
          \;\;\;\;\left(1 - \log y\right) \cdot y\\
          
          \mathbf{elif}\;t\_0 \leq 500:\\
          \;\;\;\;y - \log y \cdot 0.5\\
          
          \mathbf{else}:\\
          \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, z, -z\right)\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if (-.f64 (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) z) < -500

            1. Initial program 99.7%

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

              \[\leadsto \color{blue}{y \cdot \left(1 - -1 \cdot \log \left(\frac{1}{y}\right)\right)} \]
            4. Step-by-step derivation
              1. *-commutativeN/A

                \[\leadsto \color{blue}{\left(1 - -1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot y} \]
              2. mul-1-negN/A

                \[\leadsto \left(1 - \color{blue}{\left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right)}\right) \cdot y \]
              3. log-recN/A

                \[\leadsto \left(1 - \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\log y\right)\right)}\right)\right)\right) \cdot y \]
              4. remove-double-negN/A

                \[\leadsto \left(1 - \color{blue}{\log y}\right) \cdot y \]
              5. lower-*.f64N/A

                \[\leadsto \color{blue}{\left(1 - \log y\right) \cdot y} \]
              6. lower--.f64N/A

                \[\leadsto \color{blue}{\left(1 - \log y\right)} \cdot y \]
              7. lower-log.f6457.9

                \[\leadsto \left(1 - \color{blue}{\log y}\right) \cdot y \]
            5. Applied rewrites57.9%

              \[\leadsto \color{blue}{\left(1 - \log y\right) \cdot y} \]

            if -500 < (-.f64 (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) z) < 500

            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}{y - \left(z + \log y \cdot \left(\frac{1}{2} + y\right)\right)} \]
            4. Step-by-step derivation
              1. lower--.f64N/A

                \[\leadsto \color{blue}{y - \left(z + \log y \cdot \left(\frac{1}{2} + y\right)\right)} \]
              2. +-commutativeN/A

                \[\leadsto y - \color{blue}{\left(\log y \cdot \left(\frac{1}{2} + y\right) + z\right)} \]
              3. *-commutativeN/A

                \[\leadsto y - \left(\color{blue}{\left(\frac{1}{2} + y\right) \cdot \log y} + z\right) \]
              4. lower-fma.f64N/A

                \[\leadsto y - \color{blue}{\mathsf{fma}\left(\frac{1}{2} + y, \log y, z\right)} \]
              5. lower-+.f64N/A

                \[\leadsto y - \mathsf{fma}\left(\color{blue}{\frac{1}{2} + y}, \log y, z\right) \]
              6. lower-log.f6497.9

                \[\leadsto y - \mathsf{fma}\left(0.5 + y, \color{blue}{\log y}, z\right) \]
            5. Applied rewrites97.9%

              \[\leadsto \color{blue}{y - \mathsf{fma}\left(0.5 + y, \log y, z\right)} \]
            6. Taylor expanded in z around 0

              \[\leadsto y - \log y \cdot \color{blue}{\left(\frac{1}{2} + y\right)} \]
            7. Step-by-step derivation
              1. Applied rewrites96.9%

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

                \[\leadsto y - \frac{1}{2} \cdot \log y \]
              3. Step-by-step derivation
                1. Applied rewrites96.4%

                  \[\leadsto y - 0.5 \cdot \log y \]

                if 500 < (-.f64 (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) 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. Step-by-step derivation
                  1. lift--.f64N/A

                    \[\leadsto \color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z} \]
                  2. flip--N/A

                    \[\leadsto \color{blue}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}} \]
                  3. clear-numN/A

                    \[\leadsto \color{blue}{\frac{1}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}}} \]
                  4. lower-/.f64N/A

                    \[\leadsto \color{blue}{\frac{1}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}}} \]
                  5. clear-numN/A

                    \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}}}} \]
                  6. flip--N/A

                    \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z}}} \]
                  7. lift--.f64N/A

                    \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z}}} \]
                  8. lower-/.f6499.7

                    \[\leadsto \frac{1}{\color{blue}{\frac{1}{\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z}}} \]
                  9. lift--.f64N/A

                    \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z}}} \]
                  10. lift-+.f64N/A

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

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

                  \[\leadsto \color{blue}{-1 \cdot \left(z \cdot \left(1 + -1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right)\right)} \]
                6. Step-by-step derivation
                  1. associate-*r*N/A

                    \[\leadsto \color{blue}{\left(-1 \cdot z\right) \cdot \left(1 + -1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right)} \]
                  2. mul-1-negN/A

                    \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z\right)\right)} \cdot \left(1 + -1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right) \]
                  3. +-commutativeN/A

                    \[\leadsto \left(\mathsf{neg}\left(z\right)\right) \cdot \color{blue}{\left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z} + 1\right)} \]
                  4. distribute-lft-inN/A

                    \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z\right)\right) \cdot \left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right) + \left(\mathsf{neg}\left(z\right)\right) \cdot 1} \]
                  5. *-rgt-identityN/A

                    \[\leadsto \left(\mathsf{neg}\left(z\right)\right) \cdot \left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right) + \color{blue}{\left(\mathsf{neg}\left(z\right)\right)} \]
                  6. distribute-lft-neg-inN/A

                    \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z \cdot \left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right)\right)\right)} + \left(\mathsf{neg}\left(z\right)\right) \]
                  7. *-commutativeN/A

                    \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right) \cdot z}\right)\right) + \left(\mathsf{neg}\left(z\right)\right) \]
                  8. associate-*l*N/A

                    \[\leadsto \left(\mathsf{neg}\left(\color{blue}{-1 \cdot \left(\frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z} \cdot z\right)}\right)\right) + \left(\mathsf{neg}\left(z\right)\right) \]
                  9. neg-mul-1N/A

                    \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z} \cdot z\right)\right)}\right)\right) + \left(\mathsf{neg}\left(z\right)\right) \]
                  10. remove-double-negN/A

                    \[\leadsto \color{blue}{\frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z} \cdot z} + \left(\mathsf{neg}\left(z\right)\right) \]
                  11. lower-fma.f64N/A

                    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}, z, \mathsf{neg}\left(z\right)\right)} \]
                7. Applied rewrites84.5%

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

                  \[\leadsto \mathsf{fma}\left(\frac{x}{z}, z, -z\right) \]
                9. Step-by-step derivation
                  1. Applied rewrites81.3%

                    \[\leadsto \mathsf{fma}\left(\frac{x}{z}, z, -z\right) \]
                10. Recombined 3 regimes into one program.
                11. Final simplification71.6%

                  \[\leadsto \begin{array}{l} \mathbf{if}\;\left(\left(x - \log y \cdot \left(0.5 + y\right)\right) + y\right) - z \leq -500:\\ \;\;\;\;\left(1 - \log y\right) \cdot y\\ \mathbf{elif}\;\left(\left(x - \log y \cdot \left(0.5 + y\right)\right) + y\right) - z \leq 500:\\ \;\;\;\;y - \log y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, z, -z\right)\\ \end{array} \]
                12. Add Preprocessing

                Alternative 5: 99.1% accurate, 1.0× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 6.4 \cdot 10^{-12}:\\ \;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x - \log y \cdot y\right) + y\right) - z\\ \end{array} \end{array} \]
                (FPCore (x y z)
                 :precision binary64
                 (if (<= y 6.4e-12)
                   (- (fma -0.5 (log y) x) z)
                   (- (+ (- x (* (log y) y)) y) z)))
                double code(double x, double y, double z) {
                	double tmp;
                	if (y <= 6.4e-12) {
                		tmp = fma(-0.5, log(y), x) - z;
                	} else {
                		tmp = ((x - (log(y) * y)) + y) - z;
                	}
                	return tmp;
                }
                
                function code(x, y, z)
                	tmp = 0.0
                	if (y <= 6.4e-12)
                		tmp = Float64(fma(-0.5, log(y), x) - z);
                	else
                		tmp = Float64(Float64(Float64(x - Float64(log(y) * y)) + y) - z);
                	end
                	return tmp
                end
                
                code[x_, y_, z_] := If[LessEqual[y, 6.4e-12], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[(x - N[(N[Log[y], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;y \leq 6.4 \cdot 10^{-12}:\\
                \;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
                
                \mathbf{else}:\\
                \;\;\;\;\left(\left(x - \log y \cdot y\right) + y\right) - z\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if y < 6.4000000000000002e-12

                  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 y around 0

                    \[\leadsto \color{blue}{\left(x - \frac{1}{2} \cdot \log y\right)} - z \]
                  4. Step-by-step derivation
                    1. sub-negN/A

                      \[\leadsto \color{blue}{\left(x + \left(\mathsf{neg}\left(\frac{1}{2} \cdot \log y\right)\right)\right)} - z \]
                    2. +-commutativeN/A

                      \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2} \cdot \log y\right)\right) + x\right)} - z \]
                    3. distribute-lft-neg-inN/A

                      \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \log y} + x\right) - z \]
                    4. metadata-evalN/A

                      \[\leadsto \left(\color{blue}{\frac{-1}{2}} \cdot \log y + x\right) - z \]
                    5. lower-fma.f64N/A

                      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \log y, x\right)} - z \]
                    6. lower-log.f6499.8

                      \[\leadsto \mathsf{fma}\left(-0.5, \color{blue}{\log y}, x\right) - z \]
                  5. Applied rewrites99.8%

                    \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5, \log y, x\right)} - z \]

                  if 6.4000000000000002e-12 < y

                  1. Initial program 99.7%

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

                    \[\leadsto \left(\left(x - \color{blue}{-1 \cdot \left(y \cdot \log \left(\frac{1}{y}\right)\right)}\right) + y\right) - z \]
                  4. Step-by-step derivation
                    1. *-commutativeN/A

                      \[\leadsto \left(\left(x - -1 \cdot \color{blue}{\left(\log \left(\frac{1}{y}\right) \cdot y\right)}\right) + y\right) - z \]
                    2. associate-*r*N/A

                      \[\leadsto \left(\left(x - \color{blue}{\left(-1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot y}\right) + y\right) - z \]
                    3. mul-1-negN/A

                      \[\leadsto \left(\left(x - \color{blue}{\left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right)} \cdot y\right) + y\right) - z \]
                    4. log-recN/A

                      \[\leadsto \left(\left(x - \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\log y\right)\right)}\right)\right) \cdot y\right) + y\right) - z \]
                    5. remove-double-negN/A

                      \[\leadsto \left(\left(x - \color{blue}{\log y} \cdot y\right) + y\right) - z \]
                    6. lower-*.f64N/A

                      \[\leadsto \left(\left(x - \color{blue}{\log y \cdot y}\right) + y\right) - z \]
                    7. lower-log.f6499.3

                      \[\leadsto \left(\left(x - \color{blue}{\log y} \cdot y\right) + y\right) - z \]
                  5. Applied rewrites99.3%

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

                Alternative 6: 89.1% accurate, 1.0× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 1.02 \cdot 10^{+29}:\\ \;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\ \mathbf{else}:\\ \;\;\;\;\left(1 - \log y\right) \cdot y - z\\ \end{array} \end{array} \]
                (FPCore (x y z)
                 :precision binary64
                 (if (<= y 1.02e+29) (- (fma -0.5 (log y) x) z) (- (* (- 1.0 (log y)) y) z)))
                double code(double x, double y, double z) {
                	double tmp;
                	if (y <= 1.02e+29) {
                		tmp = fma(-0.5, log(y), x) - z;
                	} else {
                		tmp = ((1.0 - log(y)) * y) - z;
                	}
                	return tmp;
                }
                
                function code(x, y, z)
                	tmp = 0.0
                	if (y <= 1.02e+29)
                		tmp = Float64(fma(-0.5, log(y), x) - z);
                	else
                		tmp = Float64(Float64(Float64(1.0 - log(y)) * y) - z);
                	end
                	return tmp
                end
                
                code[x_, y_, z_] := If[LessEqual[y, 1.02e+29], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] - z), $MachinePrecision]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;y \leq 1.02 \cdot 10^{+29}:\\
                \;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
                
                \mathbf{else}:\\
                \;\;\;\;\left(1 - \log y\right) \cdot y - z\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if y < 1.0200000000000001e29

                  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 y around 0

                    \[\leadsto \color{blue}{\left(x - \frac{1}{2} \cdot \log y\right)} - z \]
                  4. Step-by-step derivation
                    1. sub-negN/A

                      \[\leadsto \color{blue}{\left(x + \left(\mathsf{neg}\left(\frac{1}{2} \cdot \log y\right)\right)\right)} - z \]
                    2. +-commutativeN/A

                      \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2} \cdot \log y\right)\right) + x\right)} - z \]
                    3. distribute-lft-neg-inN/A

                      \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \log y} + x\right) - z \]
                    4. metadata-evalN/A

                      \[\leadsto \left(\color{blue}{\frac{-1}{2}} \cdot \log y + x\right) - z \]
                    5. lower-fma.f64N/A

                      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \log y, x\right)} - z \]
                    6. lower-log.f6498.6

                      \[\leadsto \mathsf{fma}\left(-0.5, \color{blue}{\log y}, x\right) - z \]
                  5. Applied rewrites98.6%

                    \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5, \log y, x\right)} - z \]

                  if 1.0200000000000001e29 < y

                  1. Initial program 99.7%

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

                    \[\leadsto \color{blue}{y \cdot \left(1 - -1 \cdot \log \left(\frac{1}{y}\right)\right)} - z \]
                  4. Step-by-step derivation
                    1. *-commutativeN/A

                      \[\leadsto \color{blue}{\left(1 - -1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot y} - z \]
                    2. mul-1-negN/A

                      \[\leadsto \left(1 - \color{blue}{\left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right)}\right) \cdot y - z \]
                    3. log-recN/A

                      \[\leadsto \left(1 - \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\log y\right)\right)}\right)\right)\right) \cdot y - z \]
                    4. remove-double-negN/A

                      \[\leadsto \left(1 - \color{blue}{\log y}\right) \cdot y - z \]
                    5. lower-*.f64N/A

                      \[\leadsto \color{blue}{\left(1 - \log y\right) \cdot y} - z \]
                    6. lower--.f64N/A

                      \[\leadsto \color{blue}{\left(1 - \log y\right)} \cdot y - z \]
                    7. lower-log.f6486.2

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

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

                Alternative 7: 84.0% accurate, 1.0× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 6.6 \cdot 10^{+144}:\\ \;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\ \mathbf{else}:\\ \;\;\;\;\left(1 - \log y\right) \cdot y\\ \end{array} \end{array} \]
                (FPCore (x y z)
                 :precision binary64
                 (if (<= y 6.6e+144) (- (fma -0.5 (log y) x) z) (* (- 1.0 (log y)) y)))
                double code(double x, double y, double z) {
                	double tmp;
                	if (y <= 6.6e+144) {
                		tmp = fma(-0.5, log(y), x) - z;
                	} else {
                		tmp = (1.0 - log(y)) * y;
                	}
                	return tmp;
                }
                
                function code(x, y, z)
                	tmp = 0.0
                	if (y <= 6.6e+144)
                		tmp = Float64(fma(-0.5, log(y), x) - z);
                	else
                		tmp = Float64(Float64(1.0 - log(y)) * y);
                	end
                	return tmp
                end
                
                code[x_, y_, z_] := If[LessEqual[y, 6.6e+144], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;y \leq 6.6 \cdot 10^{+144}:\\
                \;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
                
                \mathbf{else}:\\
                \;\;\;\;\left(1 - \log y\right) \cdot y\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if y < 6.6e144

                  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 y around 0

                    \[\leadsto \color{blue}{\left(x - \frac{1}{2} \cdot \log y\right)} - z \]
                  4. Step-by-step derivation
                    1. sub-negN/A

                      \[\leadsto \color{blue}{\left(x + \left(\mathsf{neg}\left(\frac{1}{2} \cdot \log y\right)\right)\right)} - z \]
                    2. +-commutativeN/A

                      \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2} \cdot \log y\right)\right) + x\right)} - z \]
                    3. distribute-lft-neg-inN/A

                      \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) \cdot \log y} + x\right) - z \]
                    4. metadata-evalN/A

                      \[\leadsto \left(\color{blue}{\frac{-1}{2}} \cdot \log y + x\right) - z \]
                    5. lower-fma.f64N/A

                      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{2}, \log y, x\right)} - z \]
                    6. lower-log.f6490.6

                      \[\leadsto \mathsf{fma}\left(-0.5, \color{blue}{\log y}, x\right) - z \]
                  5. Applied rewrites90.6%

                    \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5, \log y, x\right)} - z \]

                  if 6.6e144 < y

                  1. Initial program 99.7%

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

                    \[\leadsto \color{blue}{y \cdot \left(1 - -1 \cdot \log \left(\frac{1}{y}\right)\right)} \]
                  4. Step-by-step derivation
                    1. *-commutativeN/A

                      \[\leadsto \color{blue}{\left(1 - -1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot y} \]
                    2. mul-1-negN/A

                      \[\leadsto \left(1 - \color{blue}{\left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right)}\right) \cdot y \]
                    3. log-recN/A

                      \[\leadsto \left(1 - \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\log y\right)\right)}\right)\right)\right) \cdot y \]
                    4. remove-double-negN/A

                      \[\leadsto \left(1 - \color{blue}{\log y}\right) \cdot y \]
                    5. lower-*.f64N/A

                      \[\leadsto \color{blue}{\left(1 - \log y\right) \cdot y} \]
                    6. lower--.f64N/A

                      \[\leadsto \color{blue}{\left(1 - \log y\right)} \cdot y \]
                    7. lower-log.f6484.0

                      \[\leadsto \left(1 - \color{blue}{\log y}\right) \cdot y \]
                  5. Applied rewrites84.0%

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

                Alternative 8: 63.9% accurate, 1.0× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 6.6 \cdot 10^{+144}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, z, -z\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 - \log y\right) \cdot y\\ \end{array} \end{array} \]
                (FPCore (x y z)
                 :precision binary64
                 (if (<= y 6.6e+144) (fma (/ x z) z (- z)) (* (- 1.0 (log y)) y)))
                double code(double x, double y, double z) {
                	double tmp;
                	if (y <= 6.6e+144) {
                		tmp = fma((x / z), z, -z);
                	} else {
                		tmp = (1.0 - log(y)) * y;
                	}
                	return tmp;
                }
                
                function code(x, y, z)
                	tmp = 0.0
                	if (y <= 6.6e+144)
                		tmp = fma(Float64(x / z), z, Float64(-z));
                	else
                		tmp = Float64(Float64(1.0 - log(y)) * y);
                	end
                	return tmp
                end
                
                code[x_, y_, z_] := If[LessEqual[y, 6.6e+144], N[(N[(x / z), $MachinePrecision] * z + (-z)), $MachinePrecision], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;y \leq 6.6 \cdot 10^{+144}:\\
                \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, z, -z\right)\\
                
                \mathbf{else}:\\
                \;\;\;\;\left(1 - \log y\right) \cdot y\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if y < 6.6e144

                  1. Initial program 99.9%

                    \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
                  2. Add Preprocessing
                  3. Step-by-step derivation
                    1. lift--.f64N/A

                      \[\leadsto \color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z} \]
                    2. flip--N/A

                      \[\leadsto \color{blue}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}} \]
                    3. clear-numN/A

                      \[\leadsto \color{blue}{\frac{1}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}}} \]
                    4. lower-/.f64N/A

                      \[\leadsto \color{blue}{\frac{1}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}}} \]
                    5. clear-numN/A

                      \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}}}} \]
                    6. flip--N/A

                      \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z}}} \]
                    7. lift--.f64N/A

                      \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z}}} \]
                    8. lower-/.f6499.7

                      \[\leadsto \frac{1}{\color{blue}{\frac{1}{\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z}}} \]
                    9. lift--.f64N/A

                      \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z}}} \]
                    10. lift-+.f64N/A

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

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

                    \[\leadsto \color{blue}{-1 \cdot \left(z \cdot \left(1 + -1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right)\right)} \]
                  6. Step-by-step derivation
                    1. associate-*r*N/A

                      \[\leadsto \color{blue}{\left(-1 \cdot z\right) \cdot \left(1 + -1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right)} \]
                    2. mul-1-negN/A

                      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z\right)\right)} \cdot \left(1 + -1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right) \]
                    3. +-commutativeN/A

                      \[\leadsto \left(\mathsf{neg}\left(z\right)\right) \cdot \color{blue}{\left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z} + 1\right)} \]
                    4. distribute-lft-inN/A

                      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z\right)\right) \cdot \left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right) + \left(\mathsf{neg}\left(z\right)\right) \cdot 1} \]
                    5. *-rgt-identityN/A

                      \[\leadsto \left(\mathsf{neg}\left(z\right)\right) \cdot \left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right) + \color{blue}{\left(\mathsf{neg}\left(z\right)\right)} \]
                    6. distribute-lft-neg-inN/A

                      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z \cdot \left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right)\right)\right)} + \left(\mathsf{neg}\left(z\right)\right) \]
                    7. *-commutativeN/A

                      \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right) \cdot z}\right)\right) + \left(\mathsf{neg}\left(z\right)\right) \]
                    8. associate-*l*N/A

                      \[\leadsto \left(\mathsf{neg}\left(\color{blue}{-1 \cdot \left(\frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z} \cdot z\right)}\right)\right) + \left(\mathsf{neg}\left(z\right)\right) \]
                    9. neg-mul-1N/A

                      \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z} \cdot z\right)\right)}\right)\right) + \left(\mathsf{neg}\left(z\right)\right) \]
                    10. remove-double-negN/A

                      \[\leadsto \color{blue}{\frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z} \cdot z} + \left(\mathsf{neg}\left(z\right)\right) \]
                    11. lower-fma.f64N/A

                      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}, z, \mathsf{neg}\left(z\right)\right)} \]
                  7. Applied rewrites82.4%

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

                    \[\leadsto \mathsf{fma}\left(\frac{x}{z}, z, -z\right) \]
                  9. Step-by-step derivation
                    1. Applied rewrites49.0%

                      \[\leadsto \mathsf{fma}\left(\frac{x}{z}, z, -z\right) \]

                    if 6.6e144 < y

                    1. Initial program 99.7%

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

                      \[\leadsto \color{blue}{y \cdot \left(1 - -1 \cdot \log \left(\frac{1}{y}\right)\right)} \]
                    4. Step-by-step derivation
                      1. *-commutativeN/A

                        \[\leadsto \color{blue}{\left(1 - -1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot y} \]
                      2. mul-1-negN/A

                        \[\leadsto \left(1 - \color{blue}{\left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right)}\right) \cdot y \]
                      3. log-recN/A

                        \[\leadsto \left(1 - \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\log y\right)\right)}\right)\right)\right) \cdot y \]
                      4. remove-double-negN/A

                        \[\leadsto \left(1 - \color{blue}{\log y}\right) \cdot y \]
                      5. lower-*.f64N/A

                        \[\leadsto \color{blue}{\left(1 - \log y\right) \cdot y} \]
                      6. lower--.f64N/A

                        \[\leadsto \color{blue}{\left(1 - \log y\right)} \cdot y \]
                      7. lower-log.f6484.0

                        \[\leadsto \left(1 - \color{blue}{\log y}\right) \cdot y \]
                    5. Applied rewrites84.0%

                      \[\leadsto \color{blue}{\left(1 - \log y\right) \cdot y} \]
                  10. Recombined 2 regimes into one program.
                  11. Add Preprocessing

                  Alternative 9: 58.0% accurate, 3.4× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(\frac{x}{z}, z, -z\right)\\ \mathbf{if}\;z \leq -2.8 \cdot 10^{-57}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 0.000108:\\ \;\;\;\;\frac{1}{\frac{1}{x}}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                  (FPCore (x y z)
                   :precision binary64
                   (let* ((t_0 (fma (/ x z) z (- z))))
                     (if (<= z -2.8e-57) t_0 (if (<= z 0.000108) (/ 1.0 (/ 1.0 x)) t_0))))
                  double code(double x, double y, double z) {
                  	double t_0 = fma((x / z), z, -z);
                  	double tmp;
                  	if (z <= -2.8e-57) {
                  		tmp = t_0;
                  	} else if (z <= 0.000108) {
                  		tmp = 1.0 / (1.0 / x);
                  	} else {
                  		tmp = t_0;
                  	}
                  	return tmp;
                  }
                  
                  function code(x, y, z)
                  	t_0 = fma(Float64(x / z), z, Float64(-z))
                  	tmp = 0.0
                  	if (z <= -2.8e-57)
                  		tmp = t_0;
                  	elseif (z <= 0.000108)
                  		tmp = Float64(1.0 / Float64(1.0 / x));
                  	else
                  		tmp = t_0;
                  	end
                  	return tmp
                  end
                  
                  code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x / z), $MachinePrecision] * z + (-z)), $MachinePrecision]}, If[LessEqual[z, -2.8e-57], t$95$0, If[LessEqual[z, 0.000108], N[(1.0 / N[(1.0 / x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  t_0 := \mathsf{fma}\left(\frac{x}{z}, z, -z\right)\\
                  \mathbf{if}\;z \leq -2.8 \cdot 10^{-57}:\\
                  \;\;\;\;t\_0\\
                  
                  \mathbf{elif}\;z \leq 0.000108:\\
                  \;\;\;\;\frac{1}{\frac{1}{x}}\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;t\_0\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if z < -2.7999999999999999e-57 or 1.08e-4 < z

                    1. Initial program 99.9%

                      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
                    2. Add Preprocessing
                    3. Step-by-step derivation
                      1. lift--.f64N/A

                        \[\leadsto \color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z} \]
                      2. flip--N/A

                        \[\leadsto \color{blue}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}} \]
                      3. clear-numN/A

                        \[\leadsto \color{blue}{\frac{1}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}}} \]
                      4. lower-/.f64N/A

                        \[\leadsto \color{blue}{\frac{1}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}}} \]
                      5. clear-numN/A

                        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}}}} \]
                      6. flip--N/A

                        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z}}} \]
                      7. lift--.f64N/A

                        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z}}} \]
                      8. lower-/.f6499.7

                        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z}}} \]
                      9. lift--.f64N/A

                        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z}}} \]
                      10. lift-+.f64N/A

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

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

                      \[\leadsto \color{blue}{-1 \cdot \left(z \cdot \left(1 + -1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right)\right)} \]
                    6. Step-by-step derivation
                      1. associate-*r*N/A

                        \[\leadsto \color{blue}{\left(-1 \cdot z\right) \cdot \left(1 + -1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right)} \]
                      2. mul-1-negN/A

                        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z\right)\right)} \cdot \left(1 + -1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right) \]
                      3. +-commutativeN/A

                        \[\leadsto \left(\mathsf{neg}\left(z\right)\right) \cdot \color{blue}{\left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z} + 1\right)} \]
                      4. distribute-lft-inN/A

                        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z\right)\right) \cdot \left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right) + \left(\mathsf{neg}\left(z\right)\right) \cdot 1} \]
                      5. *-rgt-identityN/A

                        \[\leadsto \left(\mathsf{neg}\left(z\right)\right) \cdot \left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right) + \color{blue}{\left(\mathsf{neg}\left(z\right)\right)} \]
                      6. distribute-lft-neg-inN/A

                        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z \cdot \left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right)\right)\right)} + \left(\mathsf{neg}\left(z\right)\right) \]
                      7. *-commutativeN/A

                        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right) \cdot z}\right)\right) + \left(\mathsf{neg}\left(z\right)\right) \]
                      8. associate-*l*N/A

                        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{-1 \cdot \left(\frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z} \cdot z\right)}\right)\right) + \left(\mathsf{neg}\left(z\right)\right) \]
                      9. neg-mul-1N/A

                        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z} \cdot z\right)\right)}\right)\right) + \left(\mathsf{neg}\left(z\right)\right) \]
                      10. remove-double-negN/A

                        \[\leadsto \color{blue}{\frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z} \cdot z} + \left(\mathsf{neg}\left(z\right)\right) \]
                      11. lower-fma.f64N/A

                        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}, z, \mathsf{neg}\left(z\right)\right)} \]
                    7. Applied rewrites99.1%

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

                      \[\leadsto \mathsf{fma}\left(\frac{x}{z}, z, -z\right) \]
                    9. Step-by-step derivation
                      1. Applied rewrites67.7%

                        \[\leadsto \mathsf{fma}\left(\frac{x}{z}, z, -z\right) \]

                      if -2.7999999999999999e-57 < z < 1.08e-4

                      1. Initial program 99.9%

                        \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
                      2. Add Preprocessing
                      3. Step-by-step derivation
                        1. lift--.f64N/A

                          \[\leadsto \color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z} \]
                        2. flip--N/A

                          \[\leadsto \color{blue}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}} \]
                        3. clear-numN/A

                          \[\leadsto \color{blue}{\frac{1}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}}} \]
                        4. lower-/.f64N/A

                          \[\leadsto \color{blue}{\frac{1}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}}} \]
                        5. clear-numN/A

                          \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}}}} \]
                        6. flip--N/A

                          \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z}}} \]
                        7. lift--.f64N/A

                          \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z}}} \]
                        8. lower-/.f6499.6

                          \[\leadsto \frac{1}{\color{blue}{\frac{1}{\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z}}} \]
                        9. lift--.f64N/A

                          \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z}}} \]
                        10. lift-+.f64N/A

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

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

                        \[\leadsto \frac{1}{\color{blue}{\frac{1}{x}}} \]
                      6. Step-by-step derivation
                        1. lower-/.f6434.4

                          \[\leadsto \frac{1}{\color{blue}{\frac{1}{x}}} \]
                      7. Applied rewrites34.4%

                        \[\leadsto \frac{1}{\color{blue}{\frac{1}{x}}} \]
                    10. Recombined 2 regimes into one program.
                    11. Add Preprocessing

                    Alternative 10: 48.8% accurate, 5.9× speedup?

                    \[\begin{array}{l} \\ \mathsf{fma}\left(\frac{x}{z}, z, -z\right) \end{array} \]
                    (FPCore (x y z) :precision binary64 (fma (/ x z) z (- z)))
                    double code(double x, double y, double z) {
                    	return fma((x / z), z, -z);
                    }
                    
                    function code(x, y, z)
                    	return fma(Float64(x / z), z, Float64(-z))
                    end
                    
                    code[x_, y_, z_] := N[(N[(x / z), $MachinePrecision] * z + (-z)), $MachinePrecision]
                    
                    \begin{array}{l}
                    
                    \\
                    \mathsf{fma}\left(\frac{x}{z}, z, -z\right)
                    \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. Step-by-step derivation
                      1. lift--.f64N/A

                        \[\leadsto \color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z} \]
                      2. flip--N/A

                        \[\leadsto \color{blue}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}} \]
                      3. clear-numN/A

                        \[\leadsto \color{blue}{\frac{1}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}}} \]
                      4. lower-/.f64N/A

                        \[\leadsto \color{blue}{\frac{1}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}}} \]
                      5. clear-numN/A

                        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) \cdot \left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z \cdot z}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) + z}}}} \]
                      6. flip--N/A

                        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z}}} \]
                      7. lift--.f64N/A

                        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z}}} \]
                      8. lower-/.f6499.7

                        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z}}} \]
                      9. lift--.f64N/A

                        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(\left(x - \left(y + \frac{1}{2}\right) \cdot \log y\right) + y\right) - z}}} \]
                      10. lift-+.f64N/A

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

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

                      \[\leadsto \color{blue}{-1 \cdot \left(z \cdot \left(1 + -1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right)\right)} \]
                    6. Step-by-step derivation
                      1. associate-*r*N/A

                        \[\leadsto \color{blue}{\left(-1 \cdot z\right) \cdot \left(1 + -1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right)} \]
                      2. mul-1-negN/A

                        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z\right)\right)} \cdot \left(1 + -1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right) \]
                      3. +-commutativeN/A

                        \[\leadsto \left(\mathsf{neg}\left(z\right)\right) \cdot \color{blue}{\left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z} + 1\right)} \]
                      4. distribute-lft-inN/A

                        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z\right)\right) \cdot \left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right) + \left(\mathsf{neg}\left(z\right)\right) \cdot 1} \]
                      5. *-rgt-identityN/A

                        \[\leadsto \left(\mathsf{neg}\left(z\right)\right) \cdot \left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right) + \color{blue}{\left(\mathsf{neg}\left(z\right)\right)} \]
                      6. distribute-lft-neg-inN/A

                        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z \cdot \left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right)\right)\right)} + \left(\mathsf{neg}\left(z\right)\right) \]
                      7. *-commutativeN/A

                        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(-1 \cdot \frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}\right) \cdot z}\right)\right) + \left(\mathsf{neg}\left(z\right)\right) \]
                      8. associate-*l*N/A

                        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{-1 \cdot \left(\frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z} \cdot z\right)}\right)\right) + \left(\mathsf{neg}\left(z\right)\right) \]
                      9. neg-mul-1N/A

                        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z} \cdot z\right)\right)}\right)\right) + \left(\mathsf{neg}\left(z\right)\right) \]
                      10. remove-double-negN/A

                        \[\leadsto \color{blue}{\frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z} \cdot z} + \left(\mathsf{neg}\left(z\right)\right) \]
                      11. lower-fma.f64N/A

                        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x + \left(y + -1 \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right)}{z}, z, \mathsf{neg}\left(z\right)\right)} \]
                    7. Applied rewrites78.8%

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

                      \[\leadsto \mathsf{fma}\left(\frac{x}{z}, z, -z\right) \]
                    9. Step-by-step derivation
                      1. Applied rewrites39.8%

                        \[\leadsto \mathsf{fma}\left(\frac{x}{z}, z, -z\right) \]
                      2. Add Preprocessing

                      Alternative 11: 30.1% accurate, 39.3× speedup?

                      \[\begin{array}{l} \\ -z \end{array} \]
                      (FPCore (x y z) :precision binary64 (- z))
                      double code(double x, double y, double z) {
                      	return -z;
                      }
                      
                      real(8) function code(x, y, z)
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          real(8), intent (in) :: z
                          code = -z
                      end function
                      
                      public static double code(double x, double y, double z) {
                      	return -z;
                      }
                      
                      def code(x, y, z):
                      	return -z
                      
                      function code(x, y, z)
                      	return Float64(-z)
                      end
                      
                      function tmp = code(x, y, z)
                      	tmp = -z;
                      end
                      
                      code[x_, y_, z_] := (-z)
                      
                      \begin{array}{l}
                      
                      \\
                      -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 z around inf

                        \[\leadsto \color{blue}{-1 \cdot z} \]
                      4. Step-by-step derivation
                        1. mul-1-negN/A

                          \[\leadsto \color{blue}{\mathsf{neg}\left(z\right)} \]
                        2. lower-neg.f6426.4

                          \[\leadsto \color{blue}{-z} \]
                      5. Applied rewrites26.4%

                        \[\leadsto \color{blue}{-z} \]
                      6. 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 2024255 
                      (FPCore (x y z)
                        :name "Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2"
                        :precision binary64
                      
                        :alt
                        (! :herbie-platform default (- (- (+ y x) z) (* (+ y 1/2) (log y))))
                      
                        (- (+ (- x (* (+ y 0.5) (log y))) y) z))