Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2

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

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 99.8% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(x + \mathsf{fma}\left(\log y, -0.5 - y, y\right)\right) - z \end{array} \]
(FPCore (x y z) :precision binary64 (- (+ x (fma (log y) (- -0.5 y) y)) z))
double code(double x, double y, double z) {
	return (x + fma(log(y), (-0.5 - y), y)) - z;
}
function code(x, y, z)
	return Float64(Float64(x + fma(log(y), Float64(-0.5 - y), y)) - z)
end
code[x_, y_, z_] := N[(N[(x + N[(N[Log[y], $MachinePrecision] * N[(-0.5 - y), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}

\\
\left(x + \mathsf{fma}\left(\log y, -0.5 - y, y\right)\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. sub-negN/A

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(x + \mathsf{fma}\left(\log y, \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) - y}, y\right)\right) - z \]
    12. metadata-eval99.9

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

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

Alternative 2: 74.8% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_0 := y + \left(x - \log y \cdot \left(y + 0.5\right)\right)\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+106}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -y, y\right)\\

\mathbf{elif}\;t\_0 \leq -400000:\\
\;\;\;\;x - z\\

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

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


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

    1. Initial program 99.6%

      \[\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. sub-negN/A

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

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

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

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

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

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

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

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

        \[\leadsto \log y \cdot \color{blue}{\left(-1 \cdot y\right)} + 1 \cdot y \]
      10. *-lft-identityN/A

        \[\leadsto \log y \cdot \left(-1 \cdot y\right) + \color{blue}{y} \]
      11. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, -1 \cdot y, y\right)} \]
      12. log-lowering-log.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\log y}, -1 \cdot y, y\right) \]
      13. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(\log y, \color{blue}{\mathsf{neg}\left(y\right)}, y\right) \]
      14. neg-lowering-neg.f6463.6

        \[\leadsto \mathsf{fma}\left(\log y, \color{blue}{-y}, y\right) \]
    5. Simplified63.6%

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

    if -2.00000000000000018e106 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -4e5 or 325 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y)

    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 inf

      \[\leadsto \color{blue}{x} - z \]
    4. Step-by-step derivation
      1. Simplified85.8%

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

      if -4e5 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 325

      1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\log y, \color{blue}{\frac{-1}{2} - y}, y\right) - z \]
        9. --lowering--.f64100.0

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

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

        \[\leadsto \color{blue}{\frac{-1}{2} \cdot \log y} - z \]
      7. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \color{blue}{\log y \cdot \frac{-1}{2}} - z \]
        2. *-lowering-*.f64N/A

          \[\leadsto \color{blue}{\log y \cdot \frac{-1}{2}} - z \]
        3. log-lowering-log.f6497.5

          \[\leadsto \color{blue}{\log y} \cdot -0.5 - z \]
      8. Simplified97.5%

        \[\leadsto \color{blue}{\log y \cdot -0.5} - z \]
    5. Recombined 3 regimes into one program.
    6. Final simplification79.6%

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

    Alternative 3: 74.7% accurate, 0.3× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := y + \left(x - \log y \cdot \left(y + 0.5\right)\right)\\ \mathbf{if}\;t\_0 \leq -2 \cdot 10^{+106}:\\ \;\;\;\;y - y \cdot \log y\\ \mathbf{elif}\;t\_0 \leq -400000:\\ \;\;\;\;x - z\\ \mathbf{elif}\;t\_0 \leq 325:\\ \;\;\;\;\log y \cdot -0.5 - z\\ \mathbf{else}:\\ \;\;\;\;x - z\\ \end{array} \end{array} \]
    (FPCore (x y z)
     :precision binary64
     (let* ((t_0 (+ y (- x (* (log y) (+ y 0.5))))))
       (if (<= t_0 -2e+106)
         (- y (* y (log y)))
         (if (<= t_0 -400000.0)
           (- x z)
           (if (<= t_0 325.0) (- (* (log y) -0.5) z) (- x z))))))
    double code(double x, double y, double z) {
    	double t_0 = y + (x - (log(y) * (y + 0.5)));
    	double tmp;
    	if (t_0 <= -2e+106) {
    		tmp = y - (y * log(y));
    	} else if (t_0 <= -400000.0) {
    		tmp = x - z;
    	} else if (t_0 <= 325.0) {
    		tmp = (log(y) * -0.5) - z;
    	} else {
    		tmp = x - 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 = y + (x - (log(y) * (y + 0.5d0)))
        if (t_0 <= (-2d+106)) then
            tmp = y - (y * log(y))
        else if (t_0 <= (-400000.0d0)) then
            tmp = x - z
        else if (t_0 <= 325.0d0) then
            tmp = (log(y) * (-0.5d0)) - z
        else
            tmp = x - z
        end if
        code = tmp
    end function
    
    public static double code(double x, double y, double z) {
    	double t_0 = y + (x - (Math.log(y) * (y + 0.5)));
    	double tmp;
    	if (t_0 <= -2e+106) {
    		tmp = y - (y * Math.log(y));
    	} else if (t_0 <= -400000.0) {
    		tmp = x - z;
    	} else if (t_0 <= 325.0) {
    		tmp = (Math.log(y) * -0.5) - z;
    	} else {
    		tmp = x - z;
    	}
    	return tmp;
    }
    
    def code(x, y, z):
    	t_0 = y + (x - (math.log(y) * (y + 0.5)))
    	tmp = 0
    	if t_0 <= -2e+106:
    		tmp = y - (y * math.log(y))
    	elif t_0 <= -400000.0:
    		tmp = x - z
    	elif t_0 <= 325.0:
    		tmp = (math.log(y) * -0.5) - z
    	else:
    		tmp = x - z
    	return tmp
    
    function code(x, y, z)
    	t_0 = Float64(y + Float64(x - Float64(log(y) * Float64(y + 0.5))))
    	tmp = 0.0
    	if (t_0 <= -2e+106)
    		tmp = Float64(y - Float64(y * log(y)));
    	elseif (t_0 <= -400000.0)
    		tmp = Float64(x - z);
    	elseif (t_0 <= 325.0)
    		tmp = Float64(Float64(log(y) * -0.5) - z);
    	else
    		tmp = Float64(x - z);
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, y, z)
    	t_0 = y + (x - (log(y) * (y + 0.5)));
    	tmp = 0.0;
    	if (t_0 <= -2e+106)
    		tmp = y - (y * log(y));
    	elseif (t_0 <= -400000.0)
    		tmp = x - z;
    	elseif (t_0 <= 325.0)
    		tmp = (log(y) * -0.5) - z;
    	else
    		tmp = x - z;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_, z_] := Block[{t$95$0 = N[(y + N[(x - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+106], N[(y - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -400000.0], N[(x - z), $MachinePrecision], If[LessEqual[t$95$0, 325.0], N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision], N[(x - z), $MachinePrecision]]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := y + \left(x - \log y \cdot \left(y + 0.5\right)\right)\\
    \mathbf{if}\;t\_0 \leq -2 \cdot 10^{+106}:\\
    \;\;\;\;y - y \cdot \log y\\
    
    \mathbf{elif}\;t\_0 \leq -400000:\\
    \;\;\;\;x - z\\
    
    \mathbf{elif}\;t\_0 \leq 325:\\
    \;\;\;\;\log y \cdot -0.5 - z\\
    
    \mathbf{else}:\\
    \;\;\;\;x - z\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -2.00000000000000018e106

      1. Initial program 99.6%

        \[\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. sub-negN/A

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

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

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

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

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

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

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

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

          \[\leadsto \log y \cdot \color{blue}{\left(-1 \cdot y\right)} + 1 \cdot y \]
        10. *-lft-identityN/A

          \[\leadsto \log y \cdot \left(-1 \cdot y\right) + \color{blue}{y} \]
        11. accelerator-lowering-fma.f64N/A

          \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, -1 \cdot y, y\right)} \]
        12. log-lowering-log.f64N/A

          \[\leadsto \mathsf{fma}\left(\color{blue}{\log y}, -1 \cdot y, y\right) \]
        13. mul-1-negN/A

          \[\leadsto \mathsf{fma}\left(\log y, \color{blue}{\mathsf{neg}\left(y\right)}, y\right) \]
        14. neg-lowering-neg.f6463.6

          \[\leadsto \mathsf{fma}\left(\log y, \color{blue}{-y}, y\right) \]
      5. Simplified63.6%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, -y, y\right)} \]
      6. Step-by-step derivation
        1. +-commutativeN/A

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

          \[\leadsto y + \color{blue}{\left(\mathsf{neg}\left(\log y \cdot y\right)\right)} \]
        3. unsub-negN/A

          \[\leadsto \color{blue}{y - \log y \cdot y} \]
        4. --lowering--.f64N/A

          \[\leadsto \color{blue}{y - \log y \cdot y} \]
        5. *-commutativeN/A

          \[\leadsto y - \color{blue}{y \cdot \log y} \]
        6. *-lowering-*.f64N/A

          \[\leadsto y - \color{blue}{y \cdot \log y} \]
        7. log-lowering-log.f6463.5

          \[\leadsto y - y \cdot \color{blue}{\log y} \]
      7. Applied egg-rr63.5%

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

      if -2.00000000000000018e106 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -4e5 or 325 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y)

      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 inf

        \[\leadsto \color{blue}{x} - z \]
      4. Step-by-step derivation
        1. Simplified85.8%

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

        if -4e5 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 325

        1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\log y, \color{blue}{\frac{-1}{2} - y}, y\right) - z \]
          9. --lowering--.f64100.0

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

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

          \[\leadsto \color{blue}{\frac{-1}{2} \cdot \log y} - z \]
        7. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto \color{blue}{\log y \cdot \frac{-1}{2}} - z \]
          2. *-lowering-*.f64N/A

            \[\leadsto \color{blue}{\log y \cdot \frac{-1}{2}} - z \]
          3. log-lowering-log.f6497.5

            \[\leadsto \color{blue}{\log y} \cdot -0.5 - z \]
        8. Simplified97.5%

          \[\leadsto \color{blue}{\log y \cdot -0.5} - z \]
      5. Recombined 3 regimes into one program.
      6. Final simplification79.6%

        \[\leadsto \begin{array}{l} \mathbf{if}\;y + \left(x - \log y \cdot \left(y + 0.5\right)\right) \leq -2 \cdot 10^{+106}:\\ \;\;\;\;y - y \cdot \log y\\ \mathbf{elif}\;y + \left(x - \log y \cdot \left(y + 0.5\right)\right) \leq -400000:\\ \;\;\;\;x - z\\ \mathbf{elif}\;y + \left(x - \log y \cdot \left(y + 0.5\right)\right) \leq 325:\\ \;\;\;\;\log y \cdot -0.5 - z\\ \mathbf{else}:\\ \;\;\;\;x - z\\ \end{array} \]
      7. Add Preprocessing

      Alternative 4: 89.1% accurate, 0.3× speedup?

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

        1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \left(\color{blue}{\log y \cdot \left(-1 \cdot y\right)} + 1 \cdot y\right) + x \]
          7. *-lft-identityN/A

            \[\leadsto \left(\log y \cdot \left(-1 \cdot y\right) + \color{blue}{y}\right) + x \]
          8. accelerator-lowering-fma.f64N/A

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

            \[\leadsto \mathsf{fma}\left(\color{blue}{\log y}, -1 \cdot y, y\right) + x \]
          10. mul-1-negN/A

            \[\leadsto \mathsf{fma}\left(\log y, \color{blue}{\mathsf{neg}\left(y\right)}, y\right) + x \]
          11. neg-lowering-neg.f6496.4

            \[\leadsto \mathsf{fma}\left(\log y, \color{blue}{-y}, y\right) + x \]
        10. Simplified96.4%

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

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

        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. sub-negN/A

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

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

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

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

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

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

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

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

            \[\leadsto \left(\log y \cdot \color{blue}{\left(-1 \cdot y\right)} + 1 \cdot y\right) - z \]
          10. *-lft-identityN/A

            \[\leadsto \left(\log y \cdot \left(-1 \cdot y\right) + \color{blue}{y}\right) - z \]
          11. accelerator-lowering-fma.f64N/A

            \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, -1 \cdot y, y\right)} - z \]
          12. log-lowering-log.f64N/A

            \[\leadsto \mathsf{fma}\left(\color{blue}{\log y}, -1 \cdot y, y\right) - z \]
          13. mul-1-negN/A

            \[\leadsto \mathsf{fma}\left(\log y, \color{blue}{\mathsf{neg}\left(y\right)}, y\right) - z \]
          14. neg-lowering-neg.f6488.8

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

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

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

        1. Initial program 100.0%

          \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
        2. Add Preprocessing
        3. 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. *-commutativeN/A

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

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

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

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

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

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

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

      Alternative 5: 69.8% accurate, 1.0× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -16600000000000:\\ \;\;\;\;x - z\\ \mathbf{elif}\;z \leq 210:\\ \;\;\;\;\mathsf{fma}\left(\log y, -0.5, x\right)\\ \mathbf{else}:\\ \;\;\;\;x - z\\ \end{array} \end{array} \]
      (FPCore (x y z)
       :precision binary64
       (if (<= z -16600000000000.0)
         (- x z)
         (if (<= z 210.0) (fma (log y) -0.5 x) (- x z))))
      double code(double x, double y, double z) {
      	double tmp;
      	if (z <= -16600000000000.0) {
      		tmp = x - z;
      	} else if (z <= 210.0) {
      		tmp = fma(log(y), -0.5, x);
      	} else {
      		tmp = x - z;
      	}
      	return tmp;
      }
      
      function code(x, y, z)
      	tmp = 0.0
      	if (z <= -16600000000000.0)
      		tmp = Float64(x - z);
      	elseif (z <= 210.0)
      		tmp = fma(log(y), -0.5, x);
      	else
      		tmp = Float64(x - z);
      	end
      	return tmp
      end
      
      code[x_, y_, z_] := If[LessEqual[z, -16600000000000.0], N[(x - z), $MachinePrecision], If[LessEqual[z, 210.0], N[(N[Log[y], $MachinePrecision] * -0.5 + x), $MachinePrecision], N[(x - z), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;z \leq -16600000000000:\\
      \;\;\;\;x - z\\
      
      \mathbf{elif}\;z \leq 210:\\
      \;\;\;\;\mathsf{fma}\left(\log y, -0.5, x\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;x - z\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if z < -1.66e13 or 210 < 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 x around inf

          \[\leadsto \color{blue}{x} - z \]
        4. Step-by-step derivation
          1. Simplified82.7%

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

          if -1.66e13 < z < 210

          1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \left(x + \mathsf{fma}\left(\log y, \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right) - y}, y\right)\right) - z \]
            12. metadata-eval99.8

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{x + \frac{-1}{2} \cdot \log y} \]
          9. Step-by-step derivation
            1. +-commutativeN/A

              \[\leadsto \color{blue}{\frac{-1}{2} \cdot \log y + x} \]
            2. *-commutativeN/A

              \[\leadsto \color{blue}{\log y \cdot \frac{-1}{2}} + x \]
            3. accelerator-lowering-fma.f64N/A

              \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, \frac{-1}{2}, x\right)} \]
            4. log-lowering-log.f6456.7

              \[\leadsto \mathsf{fma}\left(\color{blue}{\log y}, -0.5, x\right) \]
          10. Simplified56.7%

            \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, -0.5, x\right)} \]
        5. Recombined 2 regimes into one program.
        6. Add Preprocessing

        Alternative 6: 90.2% accurate, 1.0× speedup?

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

          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. *-commutativeN/A

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

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

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

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

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

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

          if 1.7e56 < y

          1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \left(\color{blue}{\log y \cdot \left(-1 \cdot y\right)} + 1 \cdot y\right) + x \]
            7. *-lft-identityN/A

              \[\leadsto \left(\log y \cdot \left(-1 \cdot y\right) + \color{blue}{y}\right) + x \]
            8. accelerator-lowering-fma.f64N/A

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

              \[\leadsto \mathsf{fma}\left(\color{blue}{\log y}, -1 \cdot y, y\right) + x \]
            10. mul-1-negN/A

              \[\leadsto \mathsf{fma}\left(\log y, \color{blue}{\mathsf{neg}\left(y\right)}, y\right) + x \]
            11. neg-lowering-neg.f6484.8

              \[\leadsto \mathsf{fma}\left(\log y, \color{blue}{-y}, y\right) + x \]
          10. Simplified84.8%

            \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, -y, y\right)} + x \]
        3. Recombined 2 regimes into one program.
        4. Final simplification91.6%

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

        Alternative 7: 84.1% accurate, 1.0× speedup?

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

          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. *-commutativeN/A

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

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

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

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

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

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

          if 1.1e91 < y

          1. Initial program 99.6%

            \[\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. sub-negN/A

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

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

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

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

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

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

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

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

              \[\leadsto \log y \cdot \color{blue}{\left(-1 \cdot y\right)} + 1 \cdot y \]
            10. *-lft-identityN/A

              \[\leadsto \log y \cdot \left(-1 \cdot y\right) + \color{blue}{y} \]
            11. accelerator-lowering-fma.f64N/A

              \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, -1 \cdot y, y\right)} \]
            12. log-lowering-log.f64N/A

              \[\leadsto \mathsf{fma}\left(\color{blue}{\log y}, -1 \cdot y, y\right) \]
            13. mul-1-negN/A

              \[\leadsto \mathsf{fma}\left(\log y, \color{blue}{\mathsf{neg}\left(y\right)}, y\right) \]
            14. neg-lowering-neg.f6467.1

              \[\leadsto \mathsf{fma}\left(\log y, \color{blue}{-y}, y\right) \]
          5. Simplified67.1%

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

        Alternative 8: 71.2% accurate, 1.0× speedup?

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

          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 inf

            \[\leadsto \left(\color{blue}{x} + y\right) - z \]
          4. Step-by-step derivation
            1. Simplified80.7%

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

            if 4.8000000000000003e69 < y

            1. Initial program 99.6%

              \[\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. sub-negN/A

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

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

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

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

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

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

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

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

                \[\leadsto \log y \cdot \color{blue}{\left(-1 \cdot y\right)} + 1 \cdot y \]
              10. *-lft-identityN/A

                \[\leadsto \log y \cdot \left(-1 \cdot y\right) + \color{blue}{y} \]
              11. accelerator-lowering-fma.f64N/A

                \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, -1 \cdot y, y\right)} \]
              12. log-lowering-log.f64N/A

                \[\leadsto \mathsf{fma}\left(\color{blue}{\log y}, -1 \cdot y, y\right) \]
              13. mul-1-negN/A

                \[\leadsto \mathsf{fma}\left(\log y, \color{blue}{\mathsf{neg}\left(y\right)}, y\right) \]
              14. neg-lowering-neg.f6465.6

                \[\leadsto \mathsf{fma}\left(\log y, \color{blue}{-y}, y\right) \]
            5. Simplified65.6%

              \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, -y, y\right)} \]
            6. Step-by-step derivation
              1. +-commutativeN/A

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

                \[\leadsto y + \color{blue}{\left(\mathsf{neg}\left(\log y \cdot y\right)\right)} \]
              3. unsub-negN/A

                \[\leadsto \color{blue}{y - \log y \cdot y} \]
              4. --lowering--.f64N/A

                \[\leadsto \color{blue}{y - \log y \cdot y} \]
              5. *-commutativeN/A

                \[\leadsto y - \color{blue}{y \cdot \log y} \]
              6. *-lowering-*.f64N/A

                \[\leadsto y - \color{blue}{y \cdot \log y} \]
              7. log-lowering-log.f6465.5

                \[\leadsto y - y \cdot \color{blue}{\log y} \]
            7. Applied egg-rr65.5%

              \[\leadsto \color{blue}{y - y \cdot \log y} \]
          5. Recombined 2 regimes into one program.
          6. Add Preprocessing

          Alternative 9: 48.1% accurate, 7.9× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -8.2 \cdot 10^{+80}:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \leq 3.7 \cdot 10^{+80}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \end{array} \]
          (FPCore (x y z)
           :precision binary64
           (if (<= z -8.2e+80) (- z) (if (<= z 3.7e+80) x (- z))))
          double code(double x, double y, double z) {
          	double tmp;
          	if (z <= -8.2e+80) {
          		tmp = -z;
          	} else if (z <= 3.7e+80) {
          		tmp = x;
          	} 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 <= (-8.2d+80)) then
                  tmp = -z
              else if (z <= 3.7d+80) then
                  tmp = x
              else
                  tmp = -z
              end if
              code = tmp
          end function
          
          public static double code(double x, double y, double z) {
          	double tmp;
          	if (z <= -8.2e+80) {
          		tmp = -z;
          	} else if (z <= 3.7e+80) {
          		tmp = x;
          	} else {
          		tmp = -z;
          	}
          	return tmp;
          }
          
          def code(x, y, z):
          	tmp = 0
          	if z <= -8.2e+80:
          		tmp = -z
          	elif z <= 3.7e+80:
          		tmp = x
          	else:
          		tmp = -z
          	return tmp
          
          function code(x, y, z)
          	tmp = 0.0
          	if (z <= -8.2e+80)
          		tmp = Float64(-z);
          	elseif (z <= 3.7e+80)
          		tmp = x;
          	else
          		tmp = Float64(-z);
          	end
          	return tmp
          end
          
          function tmp_2 = code(x, y, z)
          	tmp = 0.0;
          	if (z <= -8.2e+80)
          		tmp = -z;
          	elseif (z <= 3.7e+80)
          		tmp = x;
          	else
          		tmp = -z;
          	end
          	tmp_2 = tmp;
          end
          
          code[x_, y_, z_] := If[LessEqual[z, -8.2e+80], (-z), If[LessEqual[z, 3.7e+80], x, (-z)]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;z \leq -8.2 \cdot 10^{+80}:\\
          \;\;\;\;-z\\
          
          \mathbf{elif}\;z \leq 3.7 \cdot 10^{+80}:\\
          \;\;\;\;x\\
          
          \mathbf{else}:\\
          \;\;\;\;-z\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if z < -8.20000000000000003e80 or 3.69999999999999996e80 < 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. neg-lowering-neg.f6470.1

                \[\leadsto \color{blue}{-z} \]
            5. Simplified70.1%

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

            if -8.20000000000000003e80 < z < 3.69999999999999996e80

            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 inf

              \[\leadsto \color{blue}{x} \]
            4. Step-by-step derivation
              1. Simplified39.1%

                \[\leadsto \color{blue}{x} \]
            5. Recombined 2 regimes into one program.
            6. Add Preprocessing

            Alternative 10: 57.9% accurate, 29.5× speedup?

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

              \[\leadsto \color{blue}{x} - z \]
            4. Step-by-step derivation
              1. Simplified61.3%

                \[\leadsto \color{blue}{x} - z \]
              2. Add Preprocessing

              Alternative 11: 30.0% accurate, 118.0× speedup?

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

                \[\leadsto \color{blue}{x} \]
              4. Step-by-step derivation
                1. Simplified29.7%

                  \[\leadsto \color{blue}{x} \]
                2. 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 2024199 
                (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))