Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2

Percentage Accurate: 99.8% → 99.8%
Time: 8.7s
Alternatives: 9
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 9 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, 0.5× speedup?

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

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

    \[\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\left(\left(\left(y + x\right) - \log y \cdot y\right) - \log y \cdot 0.5\right)} - z \]
  5. Final simplification99.9%

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

Alternative 2: 54.4% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_0 := \left(\left(x - \left(0.5 + y\right) \cdot \log y\right) + y\right) - z\\
\mathbf{if}\;t\_0 \leq -5:\\
\;\;\;\;\left(1 - \log y\right) \cdot y\\

\mathbf{elif}\;t\_0 \leq 10^{+50}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, y\right)\\

\mathbf{else}:\\
\;\;\;\;-z\\


\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) < -5

    1. Initial program 99.8%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Add Preprocessing
    3. Taylor expanded in 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.f6450.4

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

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

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

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{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.f6488.0

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

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

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

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

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

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

        if 1.0000000000000001e50 < (-.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. 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.f6448.8

            \[\leadsto \color{blue}{-z} \]
        5. Applied rewrites48.8%

          \[\leadsto \color{blue}{-z} \]
      4. Recombined 3 regimes into one program.
      5. Final simplification55.6%

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

      Alternative 3: 90.0% accurate, 0.9× speedup?

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

        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 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.f6489.8

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

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

        if -6.5000000000000005e49 < z < 7.6e21

        1. Initial program 99.8%

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{2}} + \left(\mathsf{neg}\left(y\right)\right), \log y, x + y\right) \]
          8. unsub-negN/A

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

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

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

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

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

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

        if 7.6e21 < z < 2.9e109

        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.f6485.8

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

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

        if 2.9e109 < z

        1. Initial program 100.0%

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

          \[\leadsto \color{blue}{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.f6489.2

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

          \[\leadsto \color{blue}{y - \mathsf{fma}\left(0.5 + y, \log y, z\right)} \]
      3. Recombined 4 regimes into one program.
      4. Final simplification94.9%

        \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -6.5 \cdot 10^{+49}:\\ \;\;\;\;\left(1 - \log y\right) \cdot y - z\\ \mathbf{elif}\;z \leq 7.6 \cdot 10^{+21}:\\ \;\;\;\;\mathsf{fma}\left(-0.5 - y, \log y, x + y\right)\\ \mathbf{elif}\;z \leq 2.9 \cdot 10^{+109}:\\ \;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\ \mathbf{else}:\\ \;\;\;\;y - \mathsf{fma}\left(0.5 + y, \log y, z\right)\\ \end{array} \]
      5. Add Preprocessing

      Alternative 4: 41.2% accurate, 1.0× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -3.2 \cdot 10^{+45}:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \leq 3400000000000:\\ \;\;\;\;-0.5 \cdot \log y\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \end{array} \]
      (FPCore (x y z)
       :precision binary64
       (if (<= z -3.2e+45) (- z) (if (<= z 3400000000000.0) (* -0.5 (log y)) (- z))))
      double code(double x, double y, double z) {
      	double tmp;
      	if (z <= -3.2e+45) {
      		tmp = -z;
      	} else if (z <= 3400000000000.0) {
      		tmp = -0.5 * log(y);
      	} else {
      		tmp = -z;
      	}
      	return tmp;
      }
      
      real(8) function code(x, y, z)
          real(8), intent (in) :: x
          real(8), intent (in) :: y
          real(8), intent (in) :: z
          real(8) :: tmp
          if (z <= (-3.2d+45)) then
              tmp = -z
          else if (z <= 3400000000000.0d0) then
              tmp = (-0.5d0) * log(y)
          else
              tmp = -z
          end if
          code = tmp
      end function
      
      public static double code(double x, double y, double z) {
      	double tmp;
      	if (z <= -3.2e+45) {
      		tmp = -z;
      	} else if (z <= 3400000000000.0) {
      		tmp = -0.5 * Math.log(y);
      	} else {
      		tmp = -z;
      	}
      	return tmp;
      }
      
      def code(x, y, z):
      	tmp = 0
      	if z <= -3.2e+45:
      		tmp = -z
      	elif z <= 3400000000000.0:
      		tmp = -0.5 * math.log(y)
      	else:
      		tmp = -z
      	return tmp
      
      function code(x, y, z)
      	tmp = 0.0
      	if (z <= -3.2e+45)
      		tmp = Float64(-z);
      	elseif (z <= 3400000000000.0)
      		tmp = Float64(-0.5 * log(y));
      	else
      		tmp = Float64(-z);
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y, z)
      	tmp = 0.0;
      	if (z <= -3.2e+45)
      		tmp = -z;
      	elseif (z <= 3400000000000.0)
      		tmp = -0.5 * log(y);
      	else
      		tmp = -z;
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_, z_] := If[LessEqual[z, -3.2e+45], (-z), If[LessEqual[z, 3400000000000.0], N[(-0.5 * N[Log[y], $MachinePrecision]), $MachinePrecision], (-z)]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;z \leq -3.2 \cdot 10^{+45}:\\
      \;\;\;\;-z\\
      
      \mathbf{elif}\;z \leq 3400000000000:\\
      \;\;\;\;-0.5 \cdot \log y\\
      
      \mathbf{else}:\\
      \;\;\;\;-z\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if z < -3.2000000000000003e45 or 3.4e12 < 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. 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.f6463.3

            \[\leadsto \color{blue}{-z} \]
        5. Applied rewrites63.3%

          \[\leadsto \color{blue}{-z} \]

        if -3.2000000000000003e45 < z < 3.4e12

        1. Initial program 99.8%

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

          \[\leadsto \color{blue}{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.f6458.9

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

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

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

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

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

              \[\leadsto -0.5 \cdot \log y \]
          4. Recombined 2 regimes into one program.
          5. Add Preprocessing

          Alternative 5: 89.3% accurate, 1.0× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 8.2 \cdot 10^{+55}:\\ \;\;\;\;\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 8.2e+55) (- (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 <= 8.2e+55) {
          		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 <= 8.2e+55)
          		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, 8.2e+55], 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 8.2 \cdot 10^{+55}:\\
          \;\;\;\;\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 < 8.19999999999999962e55

            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.f6495.6

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

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

            if 8.19999999999999962e55 < 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.f6483.3

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

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

          Alternative 6: 99.8% accurate, 1.0× speedup?

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

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

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

          Alternative 7: 83.4% accurate, 1.0× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 2.02 \cdot 10^{+93}:\\ \;\;\;\;\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 2.02e+93) (- (fma -0.5 (log y) x) z) (* (- 1.0 (log y)) y)))
          double code(double x, double y, double z) {
          	double tmp;
          	if (y <= 2.02e+93) {
          		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 <= 2.02e+93)
          		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, 2.02e+93], 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 2.02 \cdot 10^{+93}:\\
          \;\;\;\;\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 < 2.01999999999999998e93

            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.f6491.6

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

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

            if 2.01999999999999998e93 < 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.f6469.4

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

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

          Alternative 8: 59.7% accurate, 1.0× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 2.6 \cdot 10^{+20}:\\ \;\;\;\;-0.5 \cdot \log y - z\\ \mathbf{else}:\\ \;\;\;\;\left(1 - \log y\right) \cdot y\\ \end{array} \end{array} \]
          (FPCore (x y z)
           :precision binary64
           (if (<= y 2.6e+20) (- (* -0.5 (log y)) z) (* (- 1.0 (log y)) y)))
          double code(double x, double y, double z) {
          	double tmp;
          	if (y <= 2.6e+20) {
          		tmp = (-0.5 * log(y)) - z;
          	} else {
          		tmp = (1.0 - log(y)) * y;
          	}
          	return tmp;
          }
          
          real(8) function code(x, y, z)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              real(8), intent (in) :: z
              real(8) :: tmp
              if (y <= 2.6d+20) then
                  tmp = ((-0.5d0) * log(y)) - z
              else
                  tmp = (1.0d0 - log(y)) * y
              end if
              code = tmp
          end function
          
          public static double code(double x, double y, double z) {
          	double tmp;
          	if (y <= 2.6e+20) {
          		tmp = (-0.5 * Math.log(y)) - z;
          	} else {
          		tmp = (1.0 - Math.log(y)) * y;
          	}
          	return tmp;
          }
          
          def code(x, y, z):
          	tmp = 0
          	if y <= 2.6e+20:
          		tmp = (-0.5 * math.log(y)) - z
          	else:
          		tmp = (1.0 - math.log(y)) * y
          	return tmp
          
          function code(x, y, z)
          	tmp = 0.0
          	if (y <= 2.6e+20)
          		tmp = Float64(Float64(-0.5 * log(y)) - z);
          	else
          		tmp = Float64(Float64(1.0 - log(y)) * y);
          	end
          	return tmp
          end
          
          function tmp_2 = code(x, y, z)
          	tmp = 0.0;
          	if (y <= 2.6e+20)
          		tmp = (-0.5 * log(y)) - z;
          	else
          		tmp = (1.0 - log(y)) * y;
          	end
          	tmp_2 = tmp;
          end
          
          code[x_, y_, z_] := If[LessEqual[y, 2.6e+20], N[(N[(-0.5 * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;y \leq 2.6 \cdot 10^{+20}:\\
          \;\;\;\;-0.5 \cdot \log y - z\\
          
          \mathbf{else}:\\
          \;\;\;\;\left(1 - \log y\right) \cdot y\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if y < 2.6e20

            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.5

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

              \[\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 rewrites59.6%

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

              if 2.6e20 < 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.f6461.9

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

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

            Alternative 9: 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.8%

              \[\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.f6429.0

                \[\leadsto \color{blue}{-z} \]
            5. Applied rewrites29.0%

              \[\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 2024240 
            (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))