Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2

Percentage Accurate: 99.8% → 99.9%
Time: 11.8s
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.9%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\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: 84.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 -1000:\\ \;\;\;\;y - \mathsf{fma}\left(y, \log y, z\right)\\ \mathbf{elif}\;t\_0 \leq 354:\\ \;\;\;\;\log y \cdot -0.5 - z\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, \frac{z}{-x}, x\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ y (- x (* (log y) (+ y 0.5))))))
   (if (<= t_0 -1000.0)
     (- y (fma y (log y) z))
     (if (<= t_0 354.0) (- (* (log y) -0.5) z) (fma x (/ z (- x)) x)))))
double code(double x, double y, double z) {
	double t_0 = y + (x - (log(y) * (y + 0.5)));
	double tmp;
	if (t_0 <= -1000.0) {
		tmp = y - fma(y, log(y), z);
	} else if (t_0 <= 354.0) {
		tmp = (log(y) * -0.5) - z;
	} else {
		tmp = fma(x, (z / -x), x);
	}
	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 <= -1000.0)
		tmp = Float64(y - fma(y, log(y), z));
	elseif (t_0 <= 354.0)
		tmp = Float64(Float64(log(y) * -0.5) - z);
	else
		tmp = fma(x, Float64(z / Float64(-x)), x);
	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, -1000.0], N[(y - N[(y * N[Log[y], $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 354.0], N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision], N[(x * N[(z / (-x)), $MachinePrecision] + x), $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 -1000:\\
\;\;\;\;y - \mathsf{fma}\left(y, \log y, z\right)\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{z}{-x}, x\right)\\


\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) < -1e3

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{y \cdot \left(1 - -1 \cdot \log \left(\frac{1}{y}\right)\right)} - 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. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, -1 \cdot y, y\right)} - z \]
      12. lower-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. lower-neg.f6472.6

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto y - \color{blue}{\mathsf{fma}\left(y, \log y, z\right)} \]
      18. lower-log.f6472.5

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

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

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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(y - \log y \cdot \left(\frac{1}{2} + y\right)\right)} - z \]
    6. 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. lower-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. lower-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. lower--.f6498.4

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

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

      \[\leadsto \color{blue}{\frac{-1}{2} \cdot \log y - z} \]
    9. Step-by-step derivation
      1. lower--.f64N/A

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

        \[\leadsto \color{blue}{\frac{-1}{2} \cdot \log y} - z \]
      3. lower-log.f6498.4

        \[\leadsto -0.5 \cdot \color{blue}{\log y} - z \]
    10. Simplified98.4%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(x, \frac{\color{blue}{-1 \cdot z}}{x}, x\right) \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(x, \frac{\color{blue}{\mathsf{neg}\left(z\right)}}{x}, x\right) \]
      2. lower-neg.f6498.3

        \[\leadsto \mathsf{fma}\left(x, \frac{\color{blue}{-z}}{x}, x\right) \]
    8. Simplified98.3%

      \[\leadsto \mathsf{fma}\left(x, \frac{\color{blue}{-z}}{x}, x\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification84.6%

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

Alternative 3: 73.3% 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^{+119}:\\ \;\;\;\;\mathsf{fma}\left(\log y, -y, y\right)\\ \mathbf{elif}\;t\_0 \leq 354:\\ \;\;\;\;\log y \cdot -0.5 - z\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, \frac{z}{-x}, x\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ y (- x (* (log y) (+ y 0.5))))))
   (if (<= t_0 -2e+119)
     (fma (log y) (- y) y)
     (if (<= t_0 354.0) (- (* (log y) -0.5) z) (fma x (/ z (- x)) x)))))
double code(double x, double y, double z) {
	double t_0 = y + (x - (log(y) * (y + 0.5)));
	double tmp;
	if (t_0 <= -2e+119) {
		tmp = fma(log(y), -y, y);
	} else if (t_0 <= 354.0) {
		tmp = (log(y) * -0.5) - z;
	} else {
		tmp = fma(x, (z / -x), x);
	}
	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+119)
		tmp = fma(log(y), Float64(-y), y);
	elseif (t_0 <= 354.0)
		tmp = Float64(Float64(log(y) * -0.5) - z);
	else
		tmp = fma(x, Float64(z / Float64(-x)), x);
	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+119], N[(N[Log[y], $MachinePrecision] * (-y) + y), $MachinePrecision], If[LessEqual[t$95$0, 354.0], N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision], N[(x * N[(z / (-x)), $MachinePrecision] + x), $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^{+119}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -y, y\right)\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{z}{-x}, x\right)\\


\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) < -1.99999999999999989e119

    1. Initial program 99.7%

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

      \[\leadsto \color{blue}{y \cdot \left(1 - -1 \cdot \log \left(\frac{1}{y}\right)\right)} \]
    4. Step-by-step derivation
      1. 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. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, -1 \cdot y, y\right)} \]
      12. lower-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. lower-neg.f6457.4

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

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

    if -1.99999999999999989e119 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 354

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(y - \log y \cdot \left(\frac{1}{2} + y\right)\right)} - z \]
    6. 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. lower-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. lower-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. lower--.f6489.1

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

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

      \[\leadsto \color{blue}{\frac{-1}{2} \cdot \log y - z} \]
    9. Step-by-step derivation
      1. lower--.f64N/A

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

        \[\leadsto \color{blue}{\frac{-1}{2} \cdot \log y} - z \]
      3. lower-log.f6477.4

        \[\leadsto -0.5 \cdot \color{blue}{\log y} - z \]
    10. Simplified77.4%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(x, \frac{\color{blue}{-1 \cdot z}}{x}, x\right) \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(x, \frac{\color{blue}{\mathsf{neg}\left(z\right)}}{x}, x\right) \]
      2. lower-neg.f6498.3

        \[\leadsto \mathsf{fma}\left(x, \frac{\color{blue}{-z}}{x}, x\right) \]
    8. Simplified98.3%

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

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

Alternative 4: 73.3% 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^{+119}:\\ \;\;\;\;y - y \cdot \log y\\ \mathbf{elif}\;t\_0 \leq 354:\\ \;\;\;\;\log y \cdot -0.5 - z\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, \frac{z}{-x}, x\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ y (- x (* (log y) (+ y 0.5))))))
   (if (<= t_0 -2e+119)
     (- y (* y (log y)))
     (if (<= t_0 354.0) (- (* (log y) -0.5) z) (fma x (/ z (- x)) x)))))
double code(double x, double y, double z) {
	double t_0 = y + (x - (log(y) * (y + 0.5)));
	double tmp;
	if (t_0 <= -2e+119) {
		tmp = y - (y * log(y));
	} else if (t_0 <= 354.0) {
		tmp = (log(y) * -0.5) - z;
	} else {
		tmp = fma(x, (z / -x), x);
	}
	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+119)
		tmp = Float64(y - Float64(y * log(y)));
	elseif (t_0 <= 354.0)
		tmp = Float64(Float64(log(y) * -0.5) - z);
	else
		tmp = fma(x, Float64(z / Float64(-x)), x);
	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+119], N[(y - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 354.0], N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision], N[(x * N[(z / (-x)), $MachinePrecision] + x), $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^{+119}:\\
\;\;\;\;y - y \cdot \log y\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{z}{-x}, x\right)\\


\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) < -1.99999999999999989e119

    1. Initial program 99.7%

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

      \[\leadsto \color{blue}{y \cdot \left(1 - -1 \cdot \log \left(\frac{1}{y}\right)\right)} \]
    4. Step-by-step derivation
      1. 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. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, -1 \cdot y, y\right)} \]
      12. lower-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. lower-neg.f6457.4

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

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

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

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

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

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

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

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

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

        \[\leadsto y - \color{blue}{y \cdot \log y} \]
      9. lower-*.f6457.3

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

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

    if -1.99999999999999989e119 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 354

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(y - \log y \cdot \left(\frac{1}{2} + y\right)\right)} - z \]
    6. 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. lower-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. lower-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. lower--.f6489.1

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

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

      \[\leadsto \color{blue}{\frac{-1}{2} \cdot \log y - z} \]
    9. Step-by-step derivation
      1. lower--.f64N/A

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

        \[\leadsto \color{blue}{\frac{-1}{2} \cdot \log y} - z \]
      3. lower-log.f6477.4

        \[\leadsto -0.5 \cdot \color{blue}{\log y} - z \]
    10. Simplified77.4%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(x, \frac{\color{blue}{-1 \cdot z}}{x}, x\right) \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(x, \frac{\color{blue}{\mathsf{neg}\left(z\right)}}{x}, x\right) \]
      2. lower-neg.f6498.3

        \[\leadsto \mathsf{fma}\left(x, \frac{\color{blue}{-z}}{x}, x\right) \]
    8. Simplified98.3%

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

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

Alternative 5: 99.3% accurate, 1.0× speedup?

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

    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. lower-fma.f64N/A

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

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

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

    if 3.4e-8 < y

    1. Initial program 99.8%

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

      \[\leadsto \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. lower-*.f64N/A

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 3.4 \cdot 10^{-8}:\\ \;\;\;\;\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 6: 89.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.8 \cdot 10^{+87}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -0.5, x\right) - z\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -y, y\right) - z\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 1.79999999999999997e87

    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. lower-fma.f64N/A

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

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

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

    if 1.79999999999999997e87 < y

    1. Initial program 99.7%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, -1 \cdot y, y\right)} - z \]
      12. lower-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. lower-neg.f6487.7

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

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

Alternative 7: 89.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 1.8 \cdot 10^{+87}:\\ \;\;\;\;\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 1.8e+87) (- (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 <= 1.8e+87) {
		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 <= 1.8e+87)
		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, 1.8e+87], 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 1.8 \cdot 10^{+87}:\\
\;\;\;\;\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 < 1.79999999999999997e87

    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. lower-fma.f64N/A

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

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

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

    if 1.79999999999999997e87 < y

    1. Initial program 99.7%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, -1 \cdot y, y\right)} - z \]
      12. lower-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. lower-neg.f6487.7

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto y - \color{blue}{\mathsf{fma}\left(y, \log y, z\right)} \]
      18. lower-log.f6487.5

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

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

Alternative 8: 64.5% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 2 \cdot 10^{+151}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{z}{-x}, x\right)\\

\mathbf{else}:\\
\;\;\;\;y - y \cdot \log y\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 2.00000000000000003e151

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(x, \frac{\color{blue}{-1 \cdot z}}{x}, x\right) \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(x, \frac{\color{blue}{\mathsf{neg}\left(z\right)}}{x}, x\right) \]
      2. lower-neg.f6464.3

        \[\leadsto \mathsf{fma}\left(x, \frac{\color{blue}{-z}}{x}, x\right) \]
    8. Simplified64.3%

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

    if 2.00000000000000003e151 < 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. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, -1 \cdot y, y\right)} \]
      12. lower-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. lower-neg.f6474.9

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

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

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

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

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

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

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

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

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

        \[\leadsto y - \color{blue}{y \cdot \log y} \]
      9. lower-*.f6474.8

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

      \[\leadsto \color{blue}{y - y \cdot \log y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification66.8%

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

Alternative 9: 58.6% accurate, 3.7× speedup?

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

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(x, \frac{z}{-x}, x\right)\\
\mathbf{if}\;x \leq -44:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 1.2 \cdot 10^{-61}:\\
\;\;\;\;-z\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -44 or 1.2e-61 < x

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(x, \frac{\color{blue}{-1 \cdot z}}{x}, x\right) \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(x, \frac{\color{blue}{\mathsf{neg}\left(z\right)}}{x}, x\right) \]
      2. lower-neg.f6475.9

        \[\leadsto \mathsf{fma}\left(x, \frac{\color{blue}{-z}}{x}, x\right) \]
    8. Simplified75.9%

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

    if -44 < x < 1.2e-61

    1. Initial program 99.9%

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

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

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

        \[\leadsto \color{blue}{-z} \]
    5. Simplified42.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -44:\\ \;\;\;\;\mathsf{fma}\left(x, \frac{z}{-x}, x\right)\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-61}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, \frac{z}{-x}, x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 48.8% accurate, 7.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.3 \cdot 10^{+80}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{+78}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -1.3e+80) x (if (<= x 1.15e+78) (- z) x)))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -1.3e+80) {
		tmp = x;
	} else if (x <= 1.15e+78) {
		tmp = -z;
	} else {
		tmp = x;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-1.3d+80)) then
        tmp = x
    else if (x <= 1.15d+78) then
        tmp = -z
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -1.3e+80) {
		tmp = x;
	} else if (x <= 1.15e+78) {
		tmp = -z;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -1.3e+80:
		tmp = x
	elif x <= 1.15e+78:
		tmp = -z
	else:
		tmp = x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -1.3e+80)
		tmp = x;
	elseif (x <= 1.15e+78)
		tmp = Float64(-z);
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -1.3e+80)
		tmp = x;
	elseif (x <= 1.15e+78)
		tmp = -z;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -1.3e+80], x, If[LessEqual[x, 1.15e+78], (-z), x]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.3 \cdot 10^{+80}:\\
\;\;\;\;x\\

\mathbf{elif}\;x \leq 1.15 \cdot 10^{+78}:\\
\;\;\;\;-z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.29999999999999991e80 or 1.1500000000000001e78 < x

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto z \cdot \color{blue}{\frac{x}{z}} \]
    7. Step-by-step derivation
      1. lower-/.f6452.8

        \[\leadsto z \cdot \color{blue}{\frac{x}{z}} \]
    8. Simplified52.8%

      \[\leadsto z \cdot \color{blue}{\frac{x}{z}} \]
    9. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto z \cdot \color{blue}{\frac{x}{z}} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{\frac{x}{z} \cdot z} \]
      3. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{x}{z}} \cdot z \]
      4. div-invN/A

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

        \[\leadsto \color{blue}{x \cdot \left(\frac{1}{z} \cdot z\right)} \]
      6. inv-powN/A

        \[\leadsto x \cdot \left(\color{blue}{{z}^{-1}} \cdot z\right) \]
      7. pow-plusN/A

        \[\leadsto x \cdot \color{blue}{{z}^{\left(-1 + 1\right)}} \]
      8. metadata-evalN/A

        \[\leadsto x \cdot {z}^{\color{blue}{0}} \]
      9. metadata-evalN/A

        \[\leadsto x \cdot \color{blue}{1} \]
      10. lower-*.f6472.3

        \[\leadsto \color{blue}{x \cdot 1} \]
    10. Applied egg-rr72.3%

      \[\leadsto \color{blue}{x \cdot 1} \]
    11. Step-by-step derivation
      1. *-rgt-identity72.3

        \[\leadsto \color{blue}{x} \]
    12. Applied egg-rr72.3%

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

    if -1.29999999999999991e80 < x < 1.1500000000000001e78

    1. Initial program 99.9%

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

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

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

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

      \[\leadsto \color{blue}{-z} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto z \cdot \color{blue}{\frac{x}{z}} \]
  7. Step-by-step derivation
    1. lower-/.f6425.7

      \[\leadsto z \cdot \color{blue}{\frac{x}{z}} \]
  8. Simplified25.7%

    \[\leadsto z \cdot \color{blue}{\frac{x}{z}} \]
  9. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto z \cdot \color{blue}{\frac{x}{z}} \]
    2. *-commutativeN/A

      \[\leadsto \color{blue}{\frac{x}{z} \cdot z} \]
    3. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{x}{z}} \cdot z \]
    4. div-invN/A

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{1}{z} \cdot z\right)} \]
    6. inv-powN/A

      \[\leadsto x \cdot \left(\color{blue}{{z}^{-1}} \cdot z\right) \]
    7. pow-plusN/A

      \[\leadsto x \cdot \color{blue}{{z}^{\left(-1 + 1\right)}} \]
    8. metadata-evalN/A

      \[\leadsto x \cdot {z}^{\color{blue}{0}} \]
    9. metadata-evalN/A

      \[\leadsto x \cdot \color{blue}{1} \]
    10. lower-*.f6433.7

      \[\leadsto \color{blue}{x \cdot 1} \]
  10. Applied egg-rr33.7%

    \[\leadsto \color{blue}{x \cdot 1} \]
  11. Step-by-step derivation
    1. *-rgt-identity33.7

      \[\leadsto \color{blue}{x} \]
  12. Applied egg-rr33.7%

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