Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2

Percentage Accurate: 99.8% → 99.8%
Time: 7.9s
Alternatives: 10
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 10 alternatives:

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

Initial Program: 99.8% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 1.0× speedup?

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

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

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

Alternative 2: 64.4% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t\_0 \leq 500:\\
\;\;\;\;-0.5 \cdot \log y - z\\

\mathbf{else}:\\
\;\;\;\;\left(\frac{x}{z} - 1\right) \cdot 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) < -4.99999999999999957e28

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

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

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

    if -4.99999999999999957e28 < (-.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 y around 0

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

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

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

        \[\leadsto \color{blue}{\left(x - \frac{1}{2} \cdot \log y\right) - z} \]
      4. fp-cancel-sub-sign-invN/A

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

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

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

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

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

      \[\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 \log y - z \]
    7. Step-by-step derivation
      1. Applied rewrites89.8%

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

      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. Taylor expanded in z around inf

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

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

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

        \[\leadsto \color{blue}{\left(\frac{\mathsf{fma}\left(\left(-y\right) - 0.5, \log y, y + x\right)}{z} - 1\right) \cdot z} \]
      6. Step-by-step derivation
        1. Applied rewrites55.4%

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

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

            \[\leadsto \left(\frac{x}{z} - 1\right) \cdot z \]
        4. Recombined 3 regimes into one program.
        5. Add Preprocessing

        Alternative 3: 89.6% accurate, 0.9× speedup?

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

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

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

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

              \[\leadsto \color{blue}{\left(x - \frac{1}{2} \cdot \log y\right) - z} \]
            4. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

          if 9.2e11 < y < 2.7500000000000002e84

          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 z around inf

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

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

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

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

            \[\leadsto \frac{x}{z} \cdot z \]
          7. Step-by-step derivation
            1. Applied rewrites36.8%

              \[\leadsto \frac{x}{z} \cdot z \]
            2. Taylor expanded in z around 0

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

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

              if 2.7500000000000002e84 < 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 x around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \left(\color{blue}{\mathsf{fma}\left(x \cdot \frac{0.5 + y}{x}, -\log y, x\right)} + y\right) - z \]
              6. Step-by-step derivation
                1. Applied rewrites80.9%

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

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

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

                    \[\leadsto \left(y - \color{blue}{\left(\mathsf{neg}\left(-1\right)\right)} \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right) - z \]
                  3. fp-cancel-sign-sub-invN/A

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

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

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

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

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

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

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

                    \[\leadsto \left(\left(\frac{-1}{2} \cdot \log y + \color{blue}{\left(\mathsf{neg}\left(y\right)\right) \cdot \log y}\right) + y\right) - z \]
                  11. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(\log y, -y, y\right) - z \]
                7. Recombined 3 regimes into one program.
                8. Add Preprocessing

                Alternative 4: 99.3% accurate, 1.0× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 0.28:\\ \;\;\;\;\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 0.28) (- (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 <= 0.28) {
                		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 <= 0.28)
                		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, 0.28], 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 0.28:\\
                \;\;\;\;\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 < 0.28000000000000003

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

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

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

                      \[\leadsto \color{blue}{\left(x - \frac{1}{2} \cdot \log y\right) - z} \]
                    4. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

                  if 0.28000000000000003 < 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.7

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

                    \[\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 5: 89.3% accurate, 1.0× speedup?

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

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

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

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

                      \[\leadsto \color{blue}{\left(x - \frac{1}{2} \cdot \log y\right) - z} \]
                    4. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

                  if 1.39999999999999992e107 < 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 x around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \left(\color{blue}{\mathsf{fma}\left(x \cdot \frac{0.5 + y}{x}, -\log y, x\right)} + y\right) - z \]
                  6. Step-by-step derivation
                    1. Applied rewrites79.1%

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

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

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

                        \[\leadsto \left(y - \color{blue}{\left(\mathsf{neg}\left(-1\right)\right)} \cdot \left(\log y \cdot \left(\frac{1}{2} + y\right)\right)\right) - z \]
                      3. fp-cancel-sign-sub-invN/A

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

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

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

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

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

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

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

                        \[\leadsto \left(\left(\frac{-1}{2} \cdot \log y + \color{blue}{\left(\mathsf{neg}\left(y\right)\right) \cdot \log y}\right) + y\right) - z \]
                      11. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

                      \[\leadsto \mathsf{fma}\left(\log y, -1 \cdot \color{blue}{y}, y\right) - z \]
                    6. Step-by-step derivation
                      1. Applied rewrites92.5%

                        \[\leadsto \mathsf{fma}\left(\log y, -y, y\right) - z \]
                    7. Recombined 2 regimes into one program.
                    8. Add Preprocessing

                    Alternative 6: 84.5% accurate, 1.0× speedup?

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

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

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

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

                          \[\leadsto \color{blue}{\left(x - \frac{1}{2} \cdot \log y\right) - z} \]
                        4. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

                      if 8.1999999999999998e108 < 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.f6473.9

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

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

                    Alternative 7: 64.2% accurate, 1.0× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 7.5 \cdot 10^{+104}:\\ \;\;\;\;\left(\frac{x}{z} - 1\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;\left(1 - \log y\right) \cdot y\\ \end{array} \end{array} \]
                    (FPCore (x y z)
                     :precision binary64
                     (if (<= y 7.5e+104) (* (- (/ x z) 1.0) z) (* (- 1.0 (log y)) y)))
                    double code(double x, double y, double z) {
                    	double tmp;
                    	if (y <= 7.5e+104) {
                    		tmp = ((x / z) - 1.0) * 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 <= 7.5d+104) then
                            tmp = ((x / z) - 1.0d0) * 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 <= 7.5e+104) {
                    		tmp = ((x / z) - 1.0) * z;
                    	} else {
                    		tmp = (1.0 - Math.log(y)) * y;
                    	}
                    	return tmp;
                    }
                    
                    def code(x, y, z):
                    	tmp = 0
                    	if y <= 7.5e+104:
                    		tmp = ((x / z) - 1.0) * z
                    	else:
                    		tmp = (1.0 - math.log(y)) * y
                    	return tmp
                    
                    function code(x, y, z)
                    	tmp = 0.0
                    	if (y <= 7.5e+104)
                    		tmp = Float64(Float64(Float64(x / z) - 1.0) * 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 <= 7.5e+104)
                    		tmp = ((x / z) - 1.0) * z;
                    	else
                    		tmp = (1.0 - log(y)) * y;
                    	end
                    	tmp_2 = tmp;
                    end
                    
                    code[x_, y_, z_] := If[LessEqual[y, 7.5e+104], N[(N[(N[(x / z), $MachinePrecision] - 1.0), $MachinePrecision] * z), $MachinePrecision], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    \mathbf{if}\;y \leq 7.5 \cdot 10^{+104}:\\
                    \;\;\;\;\left(\frac{x}{z} - 1\right) \cdot z\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;\left(1 - \log y\right) \cdot y\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if y < 7.5000000000000002e104

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

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

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

                        \[\leadsto \color{blue}{\left(\frac{\mathsf{fma}\left(\left(-y\right) - 0.5, \log y, y + x\right)}{z} - 1\right) \cdot z} \]
                      6. Step-by-step derivation
                        1. Applied rewrites64.1%

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

                          \[\leadsto \left(\frac{x}{z} - 1\right) \cdot z \]
                        3. Step-by-step derivation
                          1. Applied rewrites61.0%

                            \[\leadsto \left(\frac{x}{z} - 1\right) \cdot z \]

                          if 7.5000000000000002e104 < 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.f6472.8

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

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

                        Alternative 8: 38.9% accurate, 4.1× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.55 \cdot 10^{+157} \lor \neg \left(x \leq 4 \cdot 10^{+36}\right):\\ \;\;\;\;\frac{x}{z} \cdot z\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \end{array} \]
                        (FPCore (x y z)
                         :precision binary64
                         (if (or (<= x -1.55e+157) (not (<= x 4e+36))) (* (/ x z) z) (- z)))
                        double code(double x, double y, double z) {
                        	double tmp;
                        	if ((x <= -1.55e+157) || !(x <= 4e+36)) {
                        		tmp = (x / z) * z;
                        	} 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 ((x <= (-1.55d+157)) .or. (.not. (x <= 4d+36))) then
                                tmp = (x / z) * z
                            else
                                tmp = -z
                            end if
                            code = tmp
                        end function
                        
                        public static double code(double x, double y, double z) {
                        	double tmp;
                        	if ((x <= -1.55e+157) || !(x <= 4e+36)) {
                        		tmp = (x / z) * z;
                        	} else {
                        		tmp = -z;
                        	}
                        	return tmp;
                        }
                        
                        def code(x, y, z):
                        	tmp = 0
                        	if (x <= -1.55e+157) or not (x <= 4e+36):
                        		tmp = (x / z) * z
                        	else:
                        		tmp = -z
                        	return tmp
                        
                        function code(x, y, z)
                        	tmp = 0.0
                        	if ((x <= -1.55e+157) || !(x <= 4e+36))
                        		tmp = Float64(Float64(x / z) * z);
                        	else
                        		tmp = Float64(-z);
                        	end
                        	return tmp
                        end
                        
                        function tmp_2 = code(x, y, z)
                        	tmp = 0.0;
                        	if ((x <= -1.55e+157) || ~((x <= 4e+36)))
                        		tmp = (x / z) * z;
                        	else
                        		tmp = -z;
                        	end
                        	tmp_2 = tmp;
                        end
                        
                        code[x_, y_, z_] := If[Or[LessEqual[x, -1.55e+157], N[Not[LessEqual[x, 4e+36]], $MachinePrecision]], N[(N[(x / z), $MachinePrecision] * z), $MachinePrecision], (-z)]
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;x \leq -1.55 \cdot 10^{+157} \lor \neg \left(x \leq 4 \cdot 10^{+36}\right):\\
                        \;\;\;\;\frac{x}{z} \cdot z\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;-z\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if x < -1.5499999999999999e157 or 4.00000000000000017e36 < x

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

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

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

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

                            \[\leadsto \frac{x}{z} \cdot z \]
                          7. Step-by-step derivation
                            1. Applied rewrites45.7%

                              \[\leadsto \frac{x}{z} \cdot z \]

                            if -1.5499999999999999e157 < x < 4.00000000000000017e36

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

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

                              \[\leadsto \color{blue}{-z} \]
                          8. Recombined 2 regimes into one program.
                          9. Final simplification40.2%

                            \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.55 \cdot 10^{+157} \lor \neg \left(x \leq 4 \cdot 10^{+36}\right):\\ \;\;\;\;\frac{x}{z} \cdot z\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]
                          10. Add Preprocessing

                          Alternative 9: 48.6% accurate, 5.9× speedup?

                          \[\begin{array}{l} \\ \left(\frac{x}{z} - 1\right) \cdot z \end{array} \]
                          (FPCore (x y z) :precision binary64 (* (- (/ x z) 1.0) z))
                          double code(double x, double y, double z) {
                          	return ((x / z) - 1.0) * 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 / z) - 1.0d0) * z
                          end function
                          
                          public static double code(double x, double y, double z) {
                          	return ((x / z) - 1.0) * z;
                          }
                          
                          def code(x, y, z):
                          	return ((x / z) - 1.0) * z
                          
                          function code(x, y, z)
                          	return Float64(Float64(Float64(x / z) - 1.0) * z)
                          end
                          
                          function tmp = code(x, y, z)
                          	tmp = ((x / z) - 1.0) * z;
                          end
                          
                          code[x_, y_, z_] := N[(N[(N[(x / z), $MachinePrecision] - 1.0), $MachinePrecision] * z), $MachinePrecision]
                          
                          \begin{array}{l}
                          
                          \\
                          \left(\frac{x}{z} - 1\right) \cdot 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}{z \cdot \left(\left(\frac{x}{z} + \frac{y}{z}\right) - \left(1 + \frac{\log y \cdot \left(\frac{1}{2} + y\right)}{z}\right)\right)} \]
                          4. Step-by-step derivation
                            1. *-commutativeN/A

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

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

                            \[\leadsto \color{blue}{\left(\frac{\mathsf{fma}\left(\left(-y\right) - 0.5, \log y, y + x\right)}{z} - 1\right) \cdot z} \]
                          6. Step-by-step derivation
                            1. Applied rewrites51.6%

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

                              \[\leadsto \left(\frac{x}{z} - 1\right) \cdot z \]
                            3. Step-by-step derivation
                              1. Applied rewrites46.3%

                                \[\leadsto \left(\frac{x}{z} - 1\right) \cdot z \]
                              2. Add Preprocessing

                              Alternative 10: 30.6% 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 2024337 
                              (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))