Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2

Percentage Accurate: 99.8% → 99.9%
Time: 10.1s
Alternatives: 12
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 12 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} \\ x + \mathsf{fma}\left(\log y, -0.5 - y, y - z\right) \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(x + fma(log(y), Float64(-0.5 - y), Float64(y - z)))
end
code[x_, y_, z_] := N[(x + N[(N[Log[y], $MachinePrecision] * N[(-0.5 - y), $MachinePrecision] + N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 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 - z\right) \]
    11. unsub-negN/A

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

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

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

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

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

Alternative 2: 74.5% 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 -1 \cdot 10^{+75}:\\ \;\;\;\;\mathsf{fma}\left(\log y, -y, y\right)\\ \mathbf{elif}\;t\_0 \leq -1 \cdot 10^{+14}:\\ \;\;\;\;x - z\\ \mathbf{elif}\;t\_0 \leq 500:\\ \;\;\;\;\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 -1e+75)
     (fma (log y) (- y) y)
     (if (<= t_0 -1e+14)
       (- x z)
       (if (<= t_0 500.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 <= -1e+75) {
		tmp = fma(log(y), -y, y);
	} else if (t_0 <= -1e+14) {
		tmp = x - z;
	} else if (t_0 <= 500.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 <= -1e+75)
		tmp = fma(log(y), Float64(-y), y);
	elseif (t_0 <= -1e+14)
		tmp = Float64(x - z);
	elseif (t_0 <= 500.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, -1e+75], N[(N[Log[y], $MachinePrecision] * (-y) + y), $MachinePrecision], If[LessEqual[t$95$0, -1e+14], N[(x - z), $MachinePrecision], If[LessEqual[t$95$0, 500.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 -1 \cdot 10^{+75}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -y, y\right)\\

\mathbf{elif}\;t\_0 \leq -1 \cdot 10^{+14}:\\
\;\;\;\;x - z\\

\mathbf{elif}\;t\_0 \leq 500:\\
\;\;\;\;\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) < -9.99999999999999927e74

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

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

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

    if -9.99999999999999927e74 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -1e14 or 500 < (+.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. Simplified89.0%

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

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

      1. Initial program 99.9%

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

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

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

        \[\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. metadata-evalN/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;y + \left(x - \log y \cdot \left(y + 0.5\right)\right) \leq -1 \cdot 10^{+75}:\\ \;\;\;\;\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^{+14}:\\ \;\;\;\;x - z\\ \mathbf{elif}\;y + \left(x - \log y \cdot \left(y + 0.5\right)\right) \leq 500:\\ \;\;\;\;\log y \cdot -0.5 - z\\ \mathbf{else}:\\ \;\;\;\;x - z\\ \end{array} \]
    7. Add Preprocessing

    Alternative 3: 74.5% 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 -1 \cdot 10^{+75}:\\ \;\;\;\;y - y \cdot \log y\\ \mathbf{elif}\;t\_0 \leq -1 \cdot 10^{+14}:\\ \;\;\;\;x - z\\ \mathbf{elif}\;t\_0 \leq 500:\\ \;\;\;\;\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 -1e+75)
         (- y (* y (log y)))
         (if (<= t_0 -1e+14)
           (- x z)
           (if (<= t_0 500.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 <= -1e+75) {
    		tmp = y - (y * log(y));
    	} else if (t_0 <= -1e+14) {
    		tmp = x - z;
    	} else if (t_0 <= 500.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 <= (-1d+75)) then
            tmp = y - (y * log(y))
        else if (t_0 <= (-1d+14)) then
            tmp = x - z
        else if (t_0 <= 500.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 <= -1e+75) {
    		tmp = y - (y * Math.log(y));
    	} else if (t_0 <= -1e+14) {
    		tmp = x - z;
    	} else if (t_0 <= 500.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 <= -1e+75:
    		tmp = y - (y * math.log(y))
    	elif t_0 <= -1e+14:
    		tmp = x - z
    	elif t_0 <= 500.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 <= -1e+75)
    		tmp = Float64(y - Float64(y * log(y)));
    	elseif (t_0 <= -1e+14)
    		tmp = Float64(x - z);
    	elseif (t_0 <= 500.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 <= -1e+75)
    		tmp = y - (y * log(y));
    	elseif (t_0 <= -1e+14)
    		tmp = x - z;
    	elseif (t_0 <= 500.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, -1e+75], N[(y - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -1e+14], N[(x - z), $MachinePrecision], If[LessEqual[t$95$0, 500.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 -1 \cdot 10^{+75}:\\
    \;\;\;\;y - y \cdot \log y\\
    
    \mathbf{elif}\;t\_0 \leq -1 \cdot 10^{+14}:\\
    \;\;\;\;x - z\\
    
    \mathbf{elif}\;t\_0 \leq 500:\\
    \;\;\;\;\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) < -9.99999999999999927e74

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

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

        \[\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.4

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

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

      if -9.99999999999999927e74 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -1e14 or 500 < (+.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. Simplified89.0%

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

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

        1. Initial program 99.9%

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

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

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

          \[\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. metadata-evalN/A

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

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

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

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

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

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

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

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

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

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

      Alternative 4: 70.0% accurate, 0.3× speedup?

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

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

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

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

          1. Initial program 99.9%

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

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

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

            \[\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. metadata-evalN/A

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

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

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

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

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

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

              \[\leadsto \color{blue}{\log y \cdot \frac{-1}{2}} - z \]
            8. log-lowering-log.f6489.2

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

            \[\leadsto \color{blue}{\log y \cdot -0.5 - z} \]
          9. Taylor expanded in z around 0

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

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

              \[\leadsto \color{blue}{\log y \cdot \frac{-1}{2}} \]
            3. log-lowering-log.f6486.6

              \[\leadsto \color{blue}{\log y} \cdot -0.5 \]
          11. Simplified86.6%

            \[\leadsto \color{blue}{\log y \cdot -0.5} \]
        5. Recombined 2 regimes into one program.
        6. Final simplification64.1%

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

        Alternative 5: 84.0% 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 -2000000000:\\ \;\;\;\;y - \mathsf{fma}\left(y, \log y, z\right)\\ \mathbf{elif}\;t\_0 \leq 500:\\ \;\;\;\;\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 -2000000000.0)
             (- y (fma y (log y) z))
             (if (<= t_0 500.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 <= -2000000000.0) {
        		tmp = y - fma(y, log(y), z);
        	} else if (t_0 <= 500.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 <= -2000000000.0)
        		tmp = Float64(y - fma(y, log(y), z));
        	elseif (t_0 <= 500.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, -2000000000.0], N[(y - N[(y * N[Log[y], $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 500.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 -2000000000:\\
        \;\;\;\;y - \mathsf{fma}\left(y, \log y, z\right)\\
        
        \mathbf{elif}\;t\_0 \leq 500:\\
        \;\;\;\;\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) < -2e9

          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)} - 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.f6475.0

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

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

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

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

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

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

              \[\leadsto y \cdot \color{blue}{\left(1 - \log y\right)} - z \]
            5. distribute-lft-out--N/A

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

              \[\leadsto \left(\color{blue}{y} - y \cdot \log y\right) - z \]
            7. associate--l-N/A

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

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

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

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

              \[\leadsto y - \color{blue}{\mathsf{fma}\left(y, \log y, z\right)} \]
            12. log-lowering-log.f6474.9

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

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

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

          1. Initial program 100.0%

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

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

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

            \[\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. metadata-evalN/A

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

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

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

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

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

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

              \[\leadsto \color{blue}{\log y \cdot \frac{-1}{2}} - z \]
            8. log-lowering-log.f6496.1

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

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

          if 500 < (+.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 x around inf

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

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

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

          Alternative 6: 99.3% accurate, 1.0× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 0.28:\\ \;\;\;\;\mathsf{fma}\left(\log y, -0.5, x\right) - z\\ \mathbf{else}:\\ \;\;\;\;\left(y + \left(x - y \cdot \log y\right)\right) - z\\ \end{array} \end{array} \]
          (FPCore (x y z)
           :precision binary64
           (if (<= y 0.28) (- (fma (log y) -0.5 x) z) (- (+ y (- x (* y (log y)))) z)))
          double code(double x, double y, double z) {
          	double tmp;
          	if (y <= 0.28) {
          		tmp = fma(log(y), -0.5, x) - z;
          	} else {
          		tmp = (y + (x - (y * log(y)))) - z;
          	}
          	return tmp;
          }
          
          function code(x, y, z)
          	tmp = 0.0
          	if (y <= 0.28)
          		tmp = Float64(fma(log(y), -0.5, x) - z);
          	else
          		tmp = Float64(Float64(y + Float64(x - Float64(y * log(y)))) - z);
          	end
          	return tmp
          end
          
          code[x_, y_, z_] := If[LessEqual[y, 0.28], N[(N[(N[Log[y], $MachinePrecision] * -0.5 + x), $MachinePrecision] - z), $MachinePrecision], N[(N[(y + N[(x - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;y \leq 0.28:\\
          \;\;\;\;\mathsf{fma}\left(\log y, -0.5, x\right) - z\\
          
          \mathbf{else}:\\
          \;\;\;\;\left(y + \left(x - y \cdot \log y\right)\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}{\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.f6498.9

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

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

            if 0.28000000000000003 < 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 \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. mul-1-negN/A

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

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

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

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

                \[\leadsto \left(\left(x - \color{blue}{y \cdot \log y}\right) + y\right) - z \]
              6. log-lowering-log.f6499.4

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

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

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

          Alternative 7: 89.5% accurate, 1.0× speedup?

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

            1. Initial program 99.9%

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

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

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

                \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2} \cdot \log y\right)\right) + x\right)} - z \]
              3. *-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.f6494.1

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \left(\left(x - \frac{\log y}{\color{blue}{\frac{1}{y + \frac{1}{2}}}}\right) + y\right) - z \]
              10. +-lowering-+.f6499.5

                \[\leadsto \left(\left(x - \frac{\log y}{\frac{1}{\color{blue}{y + 0.5}}}\right) + y\right) - z \]
            4. Applied egg-rr99.5%

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

              \[\leadsto \left(\left(x - \frac{\log y}{\color{blue}{\frac{1}{y}}}\right) + y\right) - z \]
            6. Step-by-step derivation
              1. /-lowering-/.f6499.5

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

              \[\leadsto \left(\left(x - \frac{\log y}{\color{blue}{\frac{1}{y}}}\right) + y\right) - z \]
            8. Taylor expanded in z around 0

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{fma}\left(y, \color{blue}{1 - \log y}, x\right) \]
              11. log-lowering-log.f6491.6

                \[\leadsto \mathsf{fma}\left(y, 1 - \color{blue}{\log y}, x\right) \]
            10. Simplified91.6%

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

          Alternative 8: 89.2% accurate, 1.0× speedup?

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

            1. Initial program 99.9%

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

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

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

                \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{2} \cdot \log y\right)\right) + x\right)} - z \]
              3. *-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.f6489.0

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

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

            if 9.5e104 < y

            1. Initial program 99.5%

              \[\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.f6483.2

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

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

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

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

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

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

                \[\leadsto y \cdot \color{blue}{\left(1 - \log y\right)} - z \]
              5. distribute-lft-out--N/A

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

                \[\leadsto \left(\color{blue}{y} - y \cdot \log y\right) - z \]
              7. associate--l-N/A

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

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

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

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

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

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

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

          Alternative 9: 71.9% accurate, 1.0× speedup?

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

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

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

              if 1.1500000000000001e132 < y

              1. Initial program 99.5%

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

                  \[\leadsto \mathsf{fma}\left(\log y, \color{blue}{-y}, y\right) \]
              5. Simplified77.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.f6477.5

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

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

            Alternative 10: 47.7% accurate, 7.9× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.05 \cdot 10^{+121}:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \leq 10^{+144}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \end{array} \]
            (FPCore (x y z)
             :precision binary64
             (if (<= z -1.05e+121) (- z) (if (<= z 1e+144) x (- z))))
            double code(double x, double y, double z) {
            	double tmp;
            	if (z <= -1.05e+121) {
            		tmp = -z;
            	} else if (z <= 1e+144) {
            		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 <= (-1.05d+121)) then
                    tmp = -z
                else if (z <= 1d+144) 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 <= -1.05e+121) {
            		tmp = -z;
            	} else if (z <= 1e+144) {
            		tmp = x;
            	} else {
            		tmp = -z;
            	}
            	return tmp;
            }
            
            def code(x, y, z):
            	tmp = 0
            	if z <= -1.05e+121:
            		tmp = -z
            	elif z <= 1e+144:
            		tmp = x
            	else:
            		tmp = -z
            	return tmp
            
            function code(x, y, z)
            	tmp = 0.0
            	if (z <= -1.05e+121)
            		tmp = Float64(-z);
            	elseif (z <= 1e+144)
            		tmp = x;
            	else
            		tmp = Float64(-z);
            	end
            	return tmp
            end
            
            function tmp_2 = code(x, y, z)
            	tmp = 0.0;
            	if (z <= -1.05e+121)
            		tmp = -z;
            	elseif (z <= 1e+144)
            		tmp = x;
            	else
            		tmp = -z;
            	end
            	tmp_2 = tmp;
            end
            
            code[x_, y_, z_] := If[LessEqual[z, -1.05e+121], (-z), If[LessEqual[z, 1e+144], x, (-z)]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;z \leq -1.05 \cdot 10^{+121}:\\
            \;\;\;\;-z\\
            
            \mathbf{elif}\;z \leq 10^{+144}:\\
            \;\;\;\;x\\
            
            \mathbf{else}:\\
            \;\;\;\;-z\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if z < -1.0500000000000001e121 or 1.00000000000000002e144 < z

              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. neg-lowering-neg.f6467.2

                  \[\leadsto \color{blue}{-z} \]
              5. Simplified67.2%

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

              if -1.0500000000000001e121 < z < 1.00000000000000002e144

              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. Simplified40.2%

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

              Alternative 11: 58.8% 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. Simplified55.2%

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

                Alternative 12: 30.7% 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. Simplified32.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 2024204 
                  (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))