Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2

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

\[\begin{array}{l} \\ x + \left(\mathsf{fma}\left(\log y, -0.5 - y, y\right) - 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 + Float64(fma(log(y), Float64(-0.5 - y), y) - z))
end
code[x_, y_, z_] := N[(x + N[(N[(N[Log[y], $MachinePrecision] * N[(-0.5 - y), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \left(\mathsf{fma}\left(\log y, -0.5 - y, y\right) - 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. Step-by-step derivation
    1. associate--l+99.8%

      \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
    2. sub-neg99.8%

      \[\leadsto \color{blue}{\left(x + \left(-\left(y + 0.5\right) \cdot \log y\right)\right)} + \left(y - z\right) \]
    3. associate-+l+99.8%

      \[\leadsto \color{blue}{x + \left(\left(-\left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)\right)} \]
    4. associate-+r-99.8%

      \[\leadsto x + \color{blue}{\left(\left(\left(-\left(y + 0.5\right) \cdot \log y\right) + y\right) - z\right)} \]
    5. *-commutative99.8%

      \[\leadsto x + \left(\left(\left(-\color{blue}{\log y \cdot \left(y + 0.5\right)}\right) + y\right) - z\right) \]
    6. distribute-rgt-neg-in99.8%

      \[\leadsto x + \left(\left(\color{blue}{\log y \cdot \left(-\left(y + 0.5\right)\right)} + y\right) - z\right) \]
    7. fma-define99.9%

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

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

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

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

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

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

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

Alternative 2: 74.4% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x + \left(y - z\right)\\ \mathbf{if}\;y \leq 1.45 \cdot 10^{-154}:\\ \;\;\;\;x - \log y \cdot 0.5\\ \mathbf{elif}\;y \leq 6 \cdot 10^{-46}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{-20}:\\ \;\;\;\;\log y \cdot -0.5 - z\\ \mathbf{elif}\;y \leq 3.8 \cdot 10^{+22}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{+41} \lor \neg \left(y \leq 2.35 \cdot 10^{+65}\right):\\ \;\;\;\;\left(x + y\right) - y \cdot \log y\\ \mathbf{else}:\\ \;\;\;\;x - z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ x (- y z))))
   (if (<= y 1.45e-154)
     (- x (* (log y) 0.5))
     (if (<= y 6e-46)
       t_0
       (if (<= y 6.5e-20)
         (- (* (log y) -0.5) z)
         (if (<= y 3.8e+22)
           t_0
           (if (or (<= y 1.1e+41) (not (<= y 2.35e+65)))
             (- (+ x y) (* y (log y)))
             (- x z))))))))
double code(double x, double y, double z) {
	double t_0 = x + (y - z);
	double tmp;
	if (y <= 1.45e-154) {
		tmp = x - (log(y) * 0.5);
	} else if (y <= 6e-46) {
		tmp = t_0;
	} else if (y <= 6.5e-20) {
		tmp = (log(y) * -0.5) - z;
	} else if (y <= 3.8e+22) {
		tmp = t_0;
	} else if ((y <= 1.1e+41) || !(y <= 2.35e+65)) {
		tmp = (x + y) - (y * log(y));
	} 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 = x + (y - z)
    if (y <= 1.45d-154) then
        tmp = x - (log(y) * 0.5d0)
    else if (y <= 6d-46) then
        tmp = t_0
    else if (y <= 6.5d-20) then
        tmp = (log(y) * (-0.5d0)) - z
    else if (y <= 3.8d+22) then
        tmp = t_0
    else if ((y <= 1.1d+41) .or. (.not. (y <= 2.35d+65))) then
        tmp = (x + y) - (y * log(y))
    else
        tmp = x - z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = x + (y - z);
	double tmp;
	if (y <= 1.45e-154) {
		tmp = x - (Math.log(y) * 0.5);
	} else if (y <= 6e-46) {
		tmp = t_0;
	} else if (y <= 6.5e-20) {
		tmp = (Math.log(y) * -0.5) - z;
	} else if (y <= 3.8e+22) {
		tmp = t_0;
	} else if ((y <= 1.1e+41) || !(y <= 2.35e+65)) {
		tmp = (x + y) - (y * Math.log(y));
	} else {
		tmp = x - z;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x + (y - z)
	tmp = 0
	if y <= 1.45e-154:
		tmp = x - (math.log(y) * 0.5)
	elif y <= 6e-46:
		tmp = t_0
	elif y <= 6.5e-20:
		tmp = (math.log(y) * -0.5) - z
	elif y <= 3.8e+22:
		tmp = t_0
	elif (y <= 1.1e+41) or not (y <= 2.35e+65):
		tmp = (x + y) - (y * math.log(y))
	else:
		tmp = x - z
	return tmp
function code(x, y, z)
	t_0 = Float64(x + Float64(y - z))
	tmp = 0.0
	if (y <= 1.45e-154)
		tmp = Float64(x - Float64(log(y) * 0.5));
	elseif (y <= 6e-46)
		tmp = t_0;
	elseif (y <= 6.5e-20)
		tmp = Float64(Float64(log(y) * -0.5) - z);
	elseif (y <= 3.8e+22)
		tmp = t_0;
	elseif ((y <= 1.1e+41) || !(y <= 2.35e+65))
		tmp = Float64(Float64(x + y) - Float64(y * log(y)));
	else
		tmp = Float64(x - z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x + (y - z);
	tmp = 0.0;
	if (y <= 1.45e-154)
		tmp = x - (log(y) * 0.5);
	elseif (y <= 6e-46)
		tmp = t_0;
	elseif (y <= 6.5e-20)
		tmp = (log(y) * -0.5) - z;
	elseif (y <= 3.8e+22)
		tmp = t_0;
	elseif ((y <= 1.1e+41) || ~((y <= 2.35e+65)))
		tmp = (x + y) - (y * log(y));
	else
		tmp = x - z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[(y - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 1.45e-154], N[(x - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6e-46], t$95$0, If[LessEqual[y, 6.5e-20], N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[y, 3.8e+22], t$95$0, If[Or[LessEqual[y, 1.1e+41], N[Not[LessEqual[y, 2.35e+65]], $MachinePrecision]], N[(N[(x + y), $MachinePrecision] - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - z), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x + \left(y - z\right)\\
\mathbf{if}\;y \leq 1.45 \cdot 10^{-154}:\\
\;\;\;\;x - \log y \cdot 0.5\\

\mathbf{elif}\;y \leq 6 \cdot 10^{-46}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 6.5 \cdot 10^{-20}:\\
\;\;\;\;\log y \cdot -0.5 - z\\

\mathbf{elif}\;y \leq 3.8 \cdot 10^{+22}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 1.1 \cdot 10^{+41} \lor \neg \left(y \leq 2.35 \cdot 10^{+65}\right):\\
\;\;\;\;\left(x + y\right) - y \cdot \log y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if y < 1.45e-154

    1. Initial program 100.0%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Step-by-step derivation
      1. associate--l+100.0%

        \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in z around 0 72.8%

      \[\leadsto \color{blue}{\left(x + y\right) - \log y \cdot \left(0.5 + y\right)} \]
    6. Taylor expanded in y around 0 72.8%

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

    if 1.45e-154 < y < 5.99999999999999975e-46 or 6.50000000000000032e-20 < y < 3.8000000000000004e22

    1. Initial program 100.0%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Step-by-step derivation
      1. associate--l+100.0%

        \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{\left(x + -1 \cdot \left(\log y \cdot \left(0.5 + y\right)\right)\right)} + \left(y - z\right) \]
    6. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{\left(-1 \cdot \left(\log y \cdot \left(0.5 + y\right)\right) + x\right)} + \left(y - z\right) \]
      2. distribute-rgt-in100.0%

        \[\leadsto \left(-1 \cdot \color{blue}{\left(0.5 \cdot \log y + y \cdot \log y\right)} + x\right) + \left(y - z\right) \]
      3. distribute-lft-in100.0%

        \[\leadsto \left(\color{blue}{\left(-1 \cdot \left(0.5 \cdot \log y\right) + -1 \cdot \left(y \cdot \log y\right)\right)} + x\right) + \left(y - z\right) \]
      4. neg-mul-1100.0%

        \[\leadsto \left(\left(\color{blue}{\left(-0.5 \cdot \log y\right)} + -1 \cdot \left(y \cdot \log y\right)\right) + x\right) + \left(y - z\right) \]
      5. distribute-lft-neg-in100.0%

        \[\leadsto \left(\left(\color{blue}{\left(-0.5\right) \cdot \log y} + -1 \cdot \left(y \cdot \log y\right)\right) + x\right) + \left(y - z\right) \]
      6. metadata-eval100.0%

        \[\leadsto \left(\left(\color{blue}{-0.5} \cdot \log y + -1 \cdot \left(y \cdot \log y\right)\right) + x\right) + \left(y - z\right) \]
      7. associate-*r*100.0%

        \[\leadsto \left(\left(-0.5 \cdot \log y + \color{blue}{\left(-1 \cdot y\right) \cdot \log y}\right) + x\right) + \left(y - z\right) \]
      8. distribute-rgt-in100.0%

        \[\leadsto \left(\color{blue}{\log y \cdot \left(-0.5 + -1 \cdot y\right)} + x\right) + \left(y - z\right) \]
      9. neg-mul-1100.0%

        \[\leadsto \left(\log y \cdot \left(-0.5 + \color{blue}{\left(-y\right)}\right) + x\right) + \left(y - z\right) \]
      10. sub-neg100.0%

        \[\leadsto \left(\log y \cdot \color{blue}{\left(-0.5 - y\right)} + x\right) + \left(y - z\right) \]
      11. *-rgt-identity100.0%

        \[\leadsto \left(\log y \cdot \color{blue}{\left(\left(-0.5 - y\right) \cdot 1\right)} + x\right) + \left(y - z\right) \]
      12. fma-define100.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, \left(-0.5 - y\right) \cdot 1, x\right)} + \left(y - z\right) \]
      13. *-rgt-identity100.0%

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

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

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

    if 5.99999999999999975e-46 < y < 6.50000000000000032e-20

    1. Initial program 100.0%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Step-by-step derivation
      1. associate--l+100.0%

        \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
      2. sub-neg100.0%

        \[\leadsto \color{blue}{\left(x + \left(-\left(y + 0.5\right) \cdot \log y\right)\right)} + \left(y - z\right) \]
      3. associate-+l+100.0%

        \[\leadsto \color{blue}{x + \left(\left(-\left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)\right)} \]
      4. associate-+r-100.0%

        \[\leadsto x + \color{blue}{\left(\left(\left(-\left(y + 0.5\right) \cdot \log y\right) + y\right) - z\right)} \]
      5. *-commutative100.0%

        \[\leadsto x + \left(\left(\left(-\color{blue}{\log y \cdot \left(y + 0.5\right)}\right) + y\right) - z\right) \]
      6. distribute-rgt-neg-in100.0%

        \[\leadsto x + \left(\left(\color{blue}{\log y \cdot \left(-\left(y + 0.5\right)\right)} + y\right) - z\right) \]
      7. fma-define100.0%

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

        \[\leadsto x + \left(\mathsf{fma}\left(\log y, -\color{blue}{\left(0.5 + y\right)}, y\right) - z\right) \]
      9. distribute-neg-in100.0%

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

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

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

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

      \[\leadsto \color{blue}{\left(x + -0.5 \cdot \log y\right) - z} \]
    6. Taylor expanded in x around 0 100.0%

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

    if 3.8000000000000004e22 < y < 1.09999999999999995e41 or 2.3500000000000001e65 < y

    1. Initial program 99.7%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Step-by-step derivation
      1. associate--l+99.7%

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

      \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in z around 0 87.6%

      \[\leadsto \color{blue}{\left(x + y\right) - \log y \cdot \left(0.5 + y\right)} \]
    6. Taylor expanded in y around inf 87.6%

      \[\leadsto \left(x + y\right) - \color{blue}{-1 \cdot \left(y \cdot \log \left(\frac{1}{y}\right)\right)} \]
    7. Step-by-step derivation
      1. mul-1-neg87.6%

        \[\leadsto \left(x + y\right) - \color{blue}{\left(-y \cdot \log \left(\frac{1}{y}\right)\right)} \]
      2. distribute-rgt-neg-in87.6%

        \[\leadsto \left(x + y\right) - \color{blue}{y \cdot \left(-\log \left(\frac{1}{y}\right)\right)} \]
      3. log-rec87.6%

        \[\leadsto \left(x + y\right) - y \cdot \left(-\color{blue}{\left(-\log y\right)}\right) \]
      4. remove-double-neg87.6%

        \[\leadsto \left(x + y\right) - y \cdot \color{blue}{\log y} \]
    8. Simplified87.6%

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

    if 1.09999999999999995e41 < y < 2.3500000000000001e65

    1. Initial program 99.8%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Step-by-step derivation
      1. associate--l+99.8%

        \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
      2. sub-neg99.8%

        \[\leadsto \color{blue}{\left(x + \left(-\left(y + 0.5\right) \cdot \log y\right)\right)} + \left(y - z\right) \]
      3. associate-+l+99.8%

        \[\leadsto \color{blue}{x + \left(\left(-\left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)\right)} \]
      4. associate-+r-99.8%

        \[\leadsto x + \color{blue}{\left(\left(\left(-\left(y + 0.5\right) \cdot \log y\right) + y\right) - z\right)} \]
      5. *-commutative99.8%

        \[\leadsto x + \left(\left(\left(-\color{blue}{\log y \cdot \left(y + 0.5\right)}\right) + y\right) - z\right) \]
      6. distribute-rgt-neg-in99.8%

        \[\leadsto x + \left(\left(\color{blue}{\log y \cdot \left(-\left(y + 0.5\right)\right)} + y\right) - z\right) \]
      7. fma-define99.8%

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

        \[\leadsto x + \left(\mathsf{fma}\left(\log y, -\color{blue}{\left(0.5 + y\right)}, y\right) - z\right) \]
      9. distribute-neg-in99.8%

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

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

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

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

      \[\leadsto \color{blue}{\left(x + -0.5 \cdot \log y\right) - z} \]
    6. Taylor expanded in x around inf 83.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.45 \cdot 10^{-154}:\\ \;\;\;\;x - \log y \cdot 0.5\\ \mathbf{elif}\;y \leq 6 \cdot 10^{-46}:\\ \;\;\;\;x + \left(y - z\right)\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{-20}:\\ \;\;\;\;\log y \cdot -0.5 - z\\ \mathbf{elif}\;y \leq 3.8 \cdot 10^{+22}:\\ \;\;\;\;x + \left(y - z\right)\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{+41} \lor \neg \left(y \leq 2.35 \cdot 10^{+65}\right):\\ \;\;\;\;\left(x + y\right) - y \cdot \log y\\ \mathbf{else}:\\ \;\;\;\;x - z\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 69.1% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_0 := y - \log y \cdot \left(y + 0.5\right)\\
\mathbf{if}\;x \leq -2.5 \cdot 10^{+36}:\\
\;\;\;\;x - z\\

\mathbf{elif}\;x \leq 1.6 \cdot 10^{-280}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 2.9 \cdot 10^{-139}:\\
\;\;\;\;\log y \cdot -0.5 - z\\

\mathbf{elif}\;x \leq 6.2 \cdot 10^{+26}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.49999999999999988e36 or 6.1999999999999999e26 < x

    1. Initial program 99.9%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Step-by-step derivation
      1. associate--l+99.9%

        \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
      2. sub-neg99.9%

        \[\leadsto \color{blue}{\left(x + \left(-\left(y + 0.5\right) \cdot \log y\right)\right)} + \left(y - z\right) \]
      3. associate-+l+99.9%

        \[\leadsto \color{blue}{x + \left(\left(-\left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)\right)} \]
      4. associate-+r-99.9%

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

        \[\leadsto x + \left(\left(\left(-\color{blue}{\log y \cdot \left(y + 0.5\right)}\right) + y\right) - z\right) \]
      6. distribute-rgt-neg-in99.9%

        \[\leadsto x + \left(\left(\color{blue}{\log y \cdot \left(-\left(y + 0.5\right)\right)} + y\right) - z\right) \]
      7. fma-define99.9%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(x + -0.5 \cdot \log y\right) - z} \]
    6. Taylor expanded in x around inf 77.9%

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

    if -2.49999999999999988e36 < x < 1.6e-280 or 2.8999999999999999e-139 < x < 6.1999999999999999e26

    1. Initial program 99.8%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Step-by-step derivation
      1. associate--l+99.8%

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

      \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in z around 0 76.2%

      \[\leadsto \color{blue}{\left(x + y\right) - \log y \cdot \left(0.5 + y\right)} \]
    6. Taylor expanded in x around 0 74.4%

      \[\leadsto \color{blue}{y - \log y \cdot \left(0.5 + y\right)} \]
    7. Step-by-step derivation
      1. cancel-sign-sub-inv74.4%

        \[\leadsto \color{blue}{y + \left(-\log y\right) \cdot \left(0.5 + y\right)} \]
      2. +-commutative74.4%

        \[\leadsto y + \left(-\log y\right) \cdot \color{blue}{\left(y + 0.5\right)} \]
      3. cancel-sign-sub-inv74.4%

        \[\leadsto \color{blue}{y - \log y \cdot \left(y + 0.5\right)} \]
    8. Simplified74.4%

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

    if 1.6e-280 < x < 2.8999999999999999e-139

    1. Initial program 99.8%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Step-by-step derivation
      1. associate--l+99.8%

        \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
      2. sub-neg99.8%

        \[\leadsto \color{blue}{\left(x + \left(-\left(y + 0.5\right) \cdot \log y\right)\right)} + \left(y - z\right) \]
      3. associate-+l+99.8%

        \[\leadsto \color{blue}{x + \left(\left(-\left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)\right)} \]
      4. associate-+r-99.8%

        \[\leadsto x + \color{blue}{\left(\left(\left(-\left(y + 0.5\right) \cdot \log y\right) + y\right) - z\right)} \]
      5. *-commutative99.8%

        \[\leadsto x + \left(\left(\left(-\color{blue}{\log y \cdot \left(y + 0.5\right)}\right) + y\right) - z\right) \]
      6. distribute-rgt-neg-in99.8%

        \[\leadsto x + \left(\left(\color{blue}{\log y \cdot \left(-\left(y + 0.5\right)\right)} + y\right) - z\right) \]
      7. fma-define99.9%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(x + -0.5 \cdot \log y\right) - z} \]
    6. Taylor expanded in x around 0 74.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.5 \cdot 10^{+36}:\\ \;\;\;\;x - z\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{-280}:\\ \;\;\;\;y - \log y \cdot \left(y + 0.5\right)\\ \mathbf{elif}\;x \leq 2.9 \cdot 10^{-139}:\\ \;\;\;\;\log y \cdot -0.5 - z\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{+26}:\\ \;\;\;\;y - \log y \cdot \left(y + 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;x - z\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 67.5% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 1.55 \cdot 10^{-154}:\\ \;\;\;\;x - \log y \cdot 0.5\\ \mathbf{elif}\;y \leq 1.42 \cdot 10^{+78}:\\ \;\;\;\;x + \left(y - z\right)\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{+150} \lor \neg \left(y \leq 1.22 \cdot 10^{+178}\right):\\ \;\;\;\;y \cdot \left(1 - \log y\right)\\ \mathbf{else}:\\ \;\;\;\;x - z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y 1.55e-154)
   (- x (* (log y) 0.5))
   (if (<= y 1.42e+78)
     (+ x (- y z))
     (if (or (<= y 1.1e+150) (not (<= y 1.22e+178)))
       (* y (- 1.0 (log y)))
       (- x z)))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= 1.55e-154) {
		tmp = x - (log(y) * 0.5);
	} else if (y <= 1.42e+78) {
		tmp = x + (y - z);
	} else if ((y <= 1.1e+150) || !(y <= 1.22e+178)) {
		tmp = y * (1.0 - log(y));
	} 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) :: tmp
    if (y <= 1.55d-154) then
        tmp = x - (log(y) * 0.5d0)
    else if (y <= 1.42d+78) then
        tmp = x + (y - z)
    else if ((y <= 1.1d+150) .or. (.not. (y <= 1.22d+178))) then
        tmp = y * (1.0d0 - log(y))
    else
        tmp = x - z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= 1.55e-154) {
		tmp = x - (Math.log(y) * 0.5);
	} else if (y <= 1.42e+78) {
		tmp = x + (y - z);
	} else if ((y <= 1.1e+150) || !(y <= 1.22e+178)) {
		tmp = y * (1.0 - Math.log(y));
	} else {
		tmp = x - z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= 1.55e-154:
		tmp = x - (math.log(y) * 0.5)
	elif y <= 1.42e+78:
		tmp = x + (y - z)
	elif (y <= 1.1e+150) or not (y <= 1.22e+178):
		tmp = y * (1.0 - math.log(y))
	else:
		tmp = x - z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= 1.55e-154)
		tmp = Float64(x - Float64(log(y) * 0.5));
	elseif (y <= 1.42e+78)
		tmp = Float64(x + Float64(y - z));
	elseif ((y <= 1.1e+150) || !(y <= 1.22e+178))
		tmp = Float64(y * Float64(1.0 - log(y)));
	else
		tmp = Float64(x - z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= 1.55e-154)
		tmp = x - (log(y) * 0.5);
	elseif (y <= 1.42e+78)
		tmp = x + (y - z);
	elseif ((y <= 1.1e+150) || ~((y <= 1.22e+178)))
		tmp = y * (1.0 - log(y));
	else
		tmp = x - z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, 1.55e-154], N[(x - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.42e+78], N[(x + N[(y - z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 1.1e+150], N[Not[LessEqual[y, 1.22e+178]], $MachinePrecision]], N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - z), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.55 \cdot 10^{-154}:\\
\;\;\;\;x - \log y \cdot 0.5\\

\mathbf{elif}\;y \leq 1.42 \cdot 10^{+78}:\\
\;\;\;\;x + \left(y - z\right)\\

\mathbf{elif}\;y \leq 1.1 \cdot 10^{+150} \lor \neg \left(y \leq 1.22 \cdot 10^{+178}\right):\\
\;\;\;\;y \cdot \left(1 - \log y\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < 1.54999999999999991e-154

    1. Initial program 100.0%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Step-by-step derivation
      1. associate--l+100.0%

        \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in z around 0 72.8%

      \[\leadsto \color{blue}{\left(x + y\right) - \log y \cdot \left(0.5 + y\right)} \]
    6. Taylor expanded in y around 0 72.8%

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

    if 1.54999999999999991e-154 < y < 1.42e78

    1. Initial program 99.9%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Step-by-step derivation
      1. associate--l+99.9%

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

      \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 99.9%

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

        \[\leadsto \color{blue}{\left(-1 \cdot \left(\log y \cdot \left(0.5 + y\right)\right) + x\right)} + \left(y - z\right) \]
      2. distribute-rgt-in99.9%

        \[\leadsto \left(-1 \cdot \color{blue}{\left(0.5 \cdot \log y + y \cdot \log y\right)} + x\right) + \left(y - z\right) \]
      3. distribute-lft-in99.9%

        \[\leadsto \left(\color{blue}{\left(-1 \cdot \left(0.5 \cdot \log y\right) + -1 \cdot \left(y \cdot \log y\right)\right)} + x\right) + \left(y - z\right) \]
      4. neg-mul-199.9%

        \[\leadsto \left(\left(\color{blue}{\left(-0.5 \cdot \log y\right)} + -1 \cdot \left(y \cdot \log y\right)\right) + x\right) + \left(y - z\right) \]
      5. distribute-lft-neg-in99.9%

        \[\leadsto \left(\left(\color{blue}{\left(-0.5\right) \cdot \log y} + -1 \cdot \left(y \cdot \log y\right)\right) + x\right) + \left(y - z\right) \]
      6. metadata-eval99.9%

        \[\leadsto \left(\left(\color{blue}{-0.5} \cdot \log y + -1 \cdot \left(y \cdot \log y\right)\right) + x\right) + \left(y - z\right) \]
      7. associate-*r*99.9%

        \[\leadsto \left(\left(-0.5 \cdot \log y + \color{blue}{\left(-1 \cdot y\right) \cdot \log y}\right) + x\right) + \left(y - z\right) \]
      8. distribute-rgt-in99.9%

        \[\leadsto \left(\color{blue}{\log y \cdot \left(-0.5 + -1 \cdot y\right)} + x\right) + \left(y - z\right) \]
      9. neg-mul-199.9%

        \[\leadsto \left(\log y \cdot \left(-0.5 + \color{blue}{\left(-y\right)}\right) + x\right) + \left(y - z\right) \]
      10. sub-neg99.9%

        \[\leadsto \left(\log y \cdot \color{blue}{\left(-0.5 - y\right)} + x\right) + \left(y - z\right) \]
      11. *-rgt-identity99.9%

        \[\leadsto \left(\log y \cdot \color{blue}{\left(\left(-0.5 - y\right) \cdot 1\right)} + x\right) + \left(y - z\right) \]
      12. fma-define99.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, \left(-0.5 - y\right) \cdot 1, x\right)} + \left(y - z\right) \]
      13. *-rgt-identity99.9%

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

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

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

    if 1.42e78 < y < 1.1e150 or 1.2199999999999999e178 < y

    1. Initial program 99.7%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Step-by-step derivation
      1. associate--l+99.7%

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

      \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 99.7%

      \[\leadsto \color{blue}{\left(x + -1 \cdot \left(\log y \cdot \left(0.5 + y\right)\right)\right)} + \left(y - z\right) \]
    6. Step-by-step derivation
      1. +-commutative99.7%

        \[\leadsto \color{blue}{\left(-1 \cdot \left(\log y \cdot \left(0.5 + y\right)\right) + x\right)} + \left(y - z\right) \]
      2. distribute-rgt-in99.7%

        \[\leadsto \left(-1 \cdot \color{blue}{\left(0.5 \cdot \log y + y \cdot \log y\right)} + x\right) + \left(y - z\right) \]
      3. distribute-lft-in99.7%

        \[\leadsto \left(\color{blue}{\left(-1 \cdot \left(0.5 \cdot \log y\right) + -1 \cdot \left(y \cdot \log y\right)\right)} + x\right) + \left(y - z\right) \]
      4. neg-mul-199.7%

        \[\leadsto \left(\left(\color{blue}{\left(-0.5 \cdot \log y\right)} + -1 \cdot \left(y \cdot \log y\right)\right) + x\right) + \left(y - z\right) \]
      5. distribute-lft-neg-in99.7%

        \[\leadsto \left(\left(\color{blue}{\left(-0.5\right) \cdot \log y} + -1 \cdot \left(y \cdot \log y\right)\right) + x\right) + \left(y - z\right) \]
      6. metadata-eval99.7%

        \[\leadsto \left(\left(\color{blue}{-0.5} \cdot \log y + -1 \cdot \left(y \cdot \log y\right)\right) + x\right) + \left(y - z\right) \]
      7. associate-*r*99.7%

        \[\leadsto \left(\left(-0.5 \cdot \log y + \color{blue}{\left(-1 \cdot y\right) \cdot \log y}\right) + x\right) + \left(y - z\right) \]
      8. distribute-rgt-in99.7%

        \[\leadsto \left(\color{blue}{\log y \cdot \left(-0.5 + -1 \cdot y\right)} + x\right) + \left(y - z\right) \]
      9. neg-mul-199.7%

        \[\leadsto \left(\log y \cdot \left(-0.5 + \color{blue}{\left(-y\right)}\right) + x\right) + \left(y - z\right) \]
      10. sub-neg99.7%

        \[\leadsto \left(\log y \cdot \color{blue}{\left(-0.5 - y\right)} + x\right) + \left(y - z\right) \]
      11. *-rgt-identity99.7%

        \[\leadsto \left(\log y \cdot \color{blue}{\left(\left(-0.5 - y\right) \cdot 1\right)} + x\right) + \left(y - z\right) \]
      12. fma-define99.7%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, \left(-0.5 - y\right) \cdot 1, x\right)} + \left(y - z\right) \]
      13. *-rgt-identity99.7%

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

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

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

        \[\leadsto y \cdot \left(1 + \color{blue}{\left(-\log y\right)}\right) \]
      2. sub-neg66.5%

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

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

    if 1.1e150 < y < 1.2199999999999999e178

    1. Initial program 99.9%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Step-by-step derivation
      1. associate--l+99.9%

        \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
      2. sub-neg99.9%

        \[\leadsto \color{blue}{\left(x + \left(-\left(y + 0.5\right) \cdot \log y\right)\right)} + \left(y - z\right) \]
      3. associate-+l+99.9%

        \[\leadsto \color{blue}{x + \left(\left(-\left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)\right)} \]
      4. associate-+r-99.9%

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

        \[\leadsto x + \left(\left(\left(-\color{blue}{\log y \cdot \left(y + 0.5\right)}\right) + y\right) - z\right) \]
      6. distribute-rgt-neg-in99.9%

        \[\leadsto x + \left(\left(\color{blue}{\log y \cdot \left(-\left(y + 0.5\right)\right)} + y\right) - z\right) \]
      7. fma-define100.0%

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

        \[\leadsto x + \left(\mathsf{fma}\left(\log y, -\color{blue}{\left(0.5 + y\right)}, y\right) - z\right) \]
      9. distribute-neg-in100.0%

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

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

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

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

      \[\leadsto \color{blue}{\left(x + -0.5 \cdot \log y\right) - z} \]
    6. Taylor expanded in x around inf 70.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.55 \cdot 10^{-154}:\\ \;\;\;\;x - \log y \cdot 0.5\\ \mathbf{elif}\;y \leq 1.42 \cdot 10^{+78}:\\ \;\;\;\;x + \left(y - z\right)\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{+150} \lor \neg \left(y \leq 1.22 \cdot 10^{+178}\right):\\ \;\;\;\;y \cdot \left(1 - \log y\right)\\ \mathbf{else}:\\ \;\;\;\;x - z\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 66.7% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 6.5 \cdot 10^{-153}:\\ \;\;\;\;x - \log y \cdot 0.5\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{-52}:\\ \;\;\;\;x + \left(y - z\right)\\ \mathbf{elif}\;y \leq 1.06 \cdot 10^{-19}:\\ \;\;\;\;\log y \cdot -0.5 - z\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{+178}:\\ \;\;\;\;x - z\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(1 - \log y\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y 6.5e-153)
   (- x (* (log y) 0.5))
   (if (<= y 1.35e-52)
     (+ x (- y z))
     (if (<= y 1.06e-19)
       (- (* (log y) -0.5) z)
       (if (<= y 1.3e+178) (- x z) (* y (- 1.0 (log y))))))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= 6.5e-153) {
		tmp = x - (log(y) * 0.5);
	} else if (y <= 1.35e-52) {
		tmp = x + (y - z);
	} else if (y <= 1.06e-19) {
		tmp = (log(y) * -0.5) - z;
	} else if (y <= 1.3e+178) {
		tmp = x - z;
	} else {
		tmp = y * (1.0 - 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 <= 6.5d-153) then
        tmp = x - (log(y) * 0.5d0)
    else if (y <= 1.35d-52) then
        tmp = x + (y - z)
    else if (y <= 1.06d-19) then
        tmp = (log(y) * (-0.5d0)) - z
    else if (y <= 1.3d+178) then
        tmp = x - z
    else
        tmp = y * (1.0d0 - log(y))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= 6.5e-153) {
		tmp = x - (Math.log(y) * 0.5);
	} else if (y <= 1.35e-52) {
		tmp = x + (y - z);
	} else if (y <= 1.06e-19) {
		tmp = (Math.log(y) * -0.5) - z;
	} else if (y <= 1.3e+178) {
		tmp = x - z;
	} else {
		tmp = y * (1.0 - Math.log(y));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= 6.5e-153:
		tmp = x - (math.log(y) * 0.5)
	elif y <= 1.35e-52:
		tmp = x + (y - z)
	elif y <= 1.06e-19:
		tmp = (math.log(y) * -0.5) - z
	elif y <= 1.3e+178:
		tmp = x - z
	else:
		tmp = y * (1.0 - math.log(y))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= 6.5e-153)
		tmp = Float64(x - Float64(log(y) * 0.5));
	elseif (y <= 1.35e-52)
		tmp = Float64(x + Float64(y - z));
	elseif (y <= 1.06e-19)
		tmp = Float64(Float64(log(y) * -0.5) - z);
	elseif (y <= 1.3e+178)
		tmp = Float64(x - z);
	else
		tmp = Float64(y * Float64(1.0 - log(y)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= 6.5e-153)
		tmp = x - (log(y) * 0.5);
	elseif (y <= 1.35e-52)
		tmp = x + (y - z);
	elseif (y <= 1.06e-19)
		tmp = (log(y) * -0.5) - z;
	elseif (y <= 1.3e+178)
		tmp = x - z;
	else
		tmp = y * (1.0 - log(y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, 6.5e-153], N[(x - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.35e-52], N[(x + N[(y - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.06e-19], N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[y, 1.3e+178], N[(x - z), $MachinePrecision], N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.5 \cdot 10^{-153}:\\
\;\;\;\;x - \log y \cdot 0.5\\

\mathbf{elif}\;y \leq 1.35 \cdot 10^{-52}:\\
\;\;\;\;x + \left(y - z\right)\\

\mathbf{elif}\;y \leq 1.06 \cdot 10^{-19}:\\
\;\;\;\;\log y \cdot -0.5 - z\\

\mathbf{elif}\;y \leq 1.3 \cdot 10^{+178}:\\
\;\;\;\;x - z\\

\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \log y\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if y < 6.50000000000000032e-153

    1. Initial program 100.0%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Step-by-step derivation
      1. associate--l+100.0%

        \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in z around 0 72.8%

      \[\leadsto \color{blue}{\left(x + y\right) - \log y \cdot \left(0.5 + y\right)} \]
    6. Taylor expanded in y around 0 72.8%

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

    if 6.50000000000000032e-153 < y < 1.35000000000000005e-52

    1. Initial program 100.0%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Step-by-step derivation
      1. associate--l+100.0%

        \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{\left(x + -1 \cdot \left(\log y \cdot \left(0.5 + y\right)\right)\right)} + \left(y - z\right) \]
    6. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{\left(-1 \cdot \left(\log y \cdot \left(0.5 + y\right)\right) + x\right)} + \left(y - z\right) \]
      2. distribute-rgt-in100.0%

        \[\leadsto \left(-1 \cdot \color{blue}{\left(0.5 \cdot \log y + y \cdot \log y\right)} + x\right) + \left(y - z\right) \]
      3. distribute-lft-in100.0%

        \[\leadsto \left(\color{blue}{\left(-1 \cdot \left(0.5 \cdot \log y\right) + -1 \cdot \left(y \cdot \log y\right)\right)} + x\right) + \left(y - z\right) \]
      4. neg-mul-1100.0%

        \[\leadsto \left(\left(\color{blue}{\left(-0.5 \cdot \log y\right)} + -1 \cdot \left(y \cdot \log y\right)\right) + x\right) + \left(y - z\right) \]
      5. distribute-lft-neg-in100.0%

        \[\leadsto \left(\left(\color{blue}{\left(-0.5\right) \cdot \log y} + -1 \cdot \left(y \cdot \log y\right)\right) + x\right) + \left(y - z\right) \]
      6. metadata-eval100.0%

        \[\leadsto \left(\left(\color{blue}{-0.5} \cdot \log y + -1 \cdot \left(y \cdot \log y\right)\right) + x\right) + \left(y - z\right) \]
      7. associate-*r*100.0%

        \[\leadsto \left(\left(-0.5 \cdot \log y + \color{blue}{\left(-1 \cdot y\right) \cdot \log y}\right) + x\right) + \left(y - z\right) \]
      8. distribute-rgt-in100.0%

        \[\leadsto \left(\color{blue}{\log y \cdot \left(-0.5 + -1 \cdot y\right)} + x\right) + \left(y - z\right) \]
      9. neg-mul-1100.0%

        \[\leadsto \left(\log y \cdot \left(-0.5 + \color{blue}{\left(-y\right)}\right) + x\right) + \left(y - z\right) \]
      10. sub-neg100.0%

        \[\leadsto \left(\log y \cdot \color{blue}{\left(-0.5 - y\right)} + x\right) + \left(y - z\right) \]
      11. *-rgt-identity100.0%

        \[\leadsto \left(\log y \cdot \color{blue}{\left(\left(-0.5 - y\right) \cdot 1\right)} + x\right) + \left(y - z\right) \]
      12. fma-define100.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, \left(-0.5 - y\right) \cdot 1, x\right)} + \left(y - z\right) \]
      13. *-rgt-identity100.0%

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

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

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

    if 1.35000000000000005e-52 < y < 1.06e-19

    1. Initial program 100.0%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Step-by-step derivation
      1. associate--l+100.0%

        \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
      2. sub-neg100.0%

        \[\leadsto \color{blue}{\left(x + \left(-\left(y + 0.5\right) \cdot \log y\right)\right)} + \left(y - z\right) \]
      3. associate-+l+100.0%

        \[\leadsto \color{blue}{x + \left(\left(-\left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)\right)} \]
      4. associate-+r-100.0%

        \[\leadsto x + \color{blue}{\left(\left(\left(-\left(y + 0.5\right) \cdot \log y\right) + y\right) - z\right)} \]
      5. *-commutative100.0%

        \[\leadsto x + \left(\left(\left(-\color{blue}{\log y \cdot \left(y + 0.5\right)}\right) + y\right) - z\right) \]
      6. distribute-rgt-neg-in100.0%

        \[\leadsto x + \left(\left(\color{blue}{\log y \cdot \left(-\left(y + 0.5\right)\right)} + y\right) - z\right) \]
      7. fma-define100.0%

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

        \[\leadsto x + \left(\mathsf{fma}\left(\log y, -\color{blue}{\left(0.5 + y\right)}, y\right) - z\right) \]
      9. distribute-neg-in100.0%

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

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

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

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

      \[\leadsto \color{blue}{\left(x + -0.5 \cdot \log y\right) - z} \]
    6. Taylor expanded in x around 0 100.0%

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

    if 1.06e-19 < y < 1.3e178

    1. Initial program 99.8%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Step-by-step derivation
      1. associate--l+99.8%

        \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
      2. sub-neg99.8%

        \[\leadsto \color{blue}{\left(x + \left(-\left(y + 0.5\right) \cdot \log y\right)\right)} + \left(y - z\right) \]
      3. associate-+l+99.8%

        \[\leadsto \color{blue}{x + \left(\left(-\left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)\right)} \]
      4. associate-+r-99.8%

        \[\leadsto x + \color{blue}{\left(\left(\left(-\left(y + 0.5\right) \cdot \log y\right) + y\right) - z\right)} \]
      5. *-commutative99.8%

        \[\leadsto x + \left(\left(\left(-\color{blue}{\log y \cdot \left(y + 0.5\right)}\right) + y\right) - z\right) \]
      6. distribute-rgt-neg-in99.8%

        \[\leadsto x + \left(\left(\color{blue}{\log y \cdot \left(-\left(y + 0.5\right)\right)} + y\right) - z\right) \]
      7. fma-define99.9%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(x + -0.5 \cdot \log y\right) - z} \]
    6. Taylor expanded in x around inf 60.7%

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

    if 1.3e178 < y

    1. Initial program 99.6%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Step-by-step derivation
      1. associate--l+99.6%

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

      \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 99.6%

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

        \[\leadsto \color{blue}{\left(-1 \cdot \left(\log y \cdot \left(0.5 + y\right)\right) + x\right)} + \left(y - z\right) \]
      2. distribute-rgt-in99.6%

        \[\leadsto \left(-1 \cdot \color{blue}{\left(0.5 \cdot \log y + y \cdot \log y\right)} + x\right) + \left(y - z\right) \]
      3. distribute-lft-in99.6%

        \[\leadsto \left(\color{blue}{\left(-1 \cdot \left(0.5 \cdot \log y\right) + -1 \cdot \left(y \cdot \log y\right)\right)} + x\right) + \left(y - z\right) \]
      4. neg-mul-199.6%

        \[\leadsto \left(\left(\color{blue}{\left(-0.5 \cdot \log y\right)} + -1 \cdot \left(y \cdot \log y\right)\right) + x\right) + \left(y - z\right) \]
      5. distribute-lft-neg-in99.6%

        \[\leadsto \left(\left(\color{blue}{\left(-0.5\right) \cdot \log y} + -1 \cdot \left(y \cdot \log y\right)\right) + x\right) + \left(y - z\right) \]
      6. metadata-eval99.6%

        \[\leadsto \left(\left(\color{blue}{-0.5} \cdot \log y + -1 \cdot \left(y \cdot \log y\right)\right) + x\right) + \left(y - z\right) \]
      7. associate-*r*99.6%

        \[\leadsto \left(\left(-0.5 \cdot \log y + \color{blue}{\left(-1 \cdot y\right) \cdot \log y}\right) + x\right) + \left(y - z\right) \]
      8. distribute-rgt-in99.6%

        \[\leadsto \left(\color{blue}{\log y \cdot \left(-0.5 + -1 \cdot y\right)} + x\right) + \left(y - z\right) \]
      9. neg-mul-199.6%

        \[\leadsto \left(\log y \cdot \left(-0.5 + \color{blue}{\left(-y\right)}\right) + x\right) + \left(y - z\right) \]
      10. sub-neg99.6%

        \[\leadsto \left(\log y \cdot \color{blue}{\left(-0.5 - y\right)} + x\right) + \left(y - z\right) \]
      11. *-rgt-identity99.6%

        \[\leadsto \left(\log y \cdot \color{blue}{\left(\left(-0.5 - y\right) \cdot 1\right)} + x\right) + \left(y - z\right) \]
      12. fma-define99.6%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, \left(-0.5 - y\right) \cdot 1, x\right)} + \left(y - z\right) \]
      13. *-rgt-identity99.6%

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

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

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

        \[\leadsto y \cdot \left(1 + \color{blue}{\left(-\log y\right)}\right) \]
      2. sub-neg74.3%

        \[\leadsto y \cdot \color{blue}{\left(1 - \log y\right)} \]
    10. Simplified74.3%

      \[\leadsto \color{blue}{y \cdot \left(1 - \log y\right)} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification71.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 6.5 \cdot 10^{-153}:\\ \;\;\;\;x - \log y \cdot 0.5\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{-52}:\\ \;\;\;\;x + \left(y - z\right)\\ \mathbf{elif}\;y \leq 1.06 \cdot 10^{-19}:\\ \;\;\;\;\log y \cdot -0.5 - z\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{+178}:\\ \;\;\;\;x - z\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(1 - \log y\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 90.0% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 3.55 \cdot 10^{+22} \lor \neg \left(y \leq 7.6 \cdot 10^{+42}\right) \land y \leq 1.4 \cdot 10^{+70}:\\ \;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\ \mathbf{else}:\\ \;\;\;\;\left(x + y\right) - y \cdot \log y\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= y 3.55e+22) (and (not (<= y 7.6e+42)) (<= y 1.4e+70)))
   (- (+ x (* (log y) -0.5)) z)
   (- (+ x y) (* y (log y)))))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= 3.55e+22) || (!(y <= 7.6e+42) && (y <= 1.4e+70))) {
		tmp = (x + (log(y) * -0.5)) - z;
	} else {
		tmp = (x + 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 <= 3.55d+22) .or. (.not. (y <= 7.6d+42)) .and. (y <= 1.4d+70)) then
        tmp = (x + (log(y) * (-0.5d0))) - z
    else
        tmp = (x + y) - (y * log(y))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((y <= 3.55e+22) || (!(y <= 7.6e+42) && (y <= 1.4e+70))) {
		tmp = (x + (Math.log(y) * -0.5)) - z;
	} else {
		tmp = (x + y) - (y * Math.log(y));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= 3.55e+22) or (not (y <= 7.6e+42) and (y <= 1.4e+70)):
		tmp = (x + (math.log(y) * -0.5)) - z
	else:
		tmp = (x + y) - (y * math.log(y))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= 3.55e+22) || (!(y <= 7.6e+42) && (y <= 1.4e+70)))
		tmp = Float64(Float64(x + Float64(log(y) * -0.5)) - z);
	else
		tmp = Float64(Float64(x + y) - Float64(y * log(y)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y <= 3.55e+22) || (~((y <= 7.6e+42)) && (y <= 1.4e+70)))
		tmp = (x + (log(y) * -0.5)) - z;
	else
		tmp = (x + y) - (y * log(y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, 3.55e+22], And[N[Not[LessEqual[y, 7.6e+42]], $MachinePrecision], LessEqual[y, 1.4e+70]]], N[(N[(x + N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(x + y), $MachinePrecision] - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.55 \cdot 10^{+22} \lor \neg \left(y \leq 7.6 \cdot 10^{+42}\right) \land y \leq 1.4 \cdot 10^{+70}:\\
\;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\

\mathbf{else}:\\
\;\;\;\;\left(x + y\right) - y \cdot \log y\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 3.5500000000000001e22 or 7.5999999999999997e42 < y < 1.39999999999999995e70

    1. Initial program 100.0%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Step-by-step derivation
      1. associate--l+100.0%

        \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
      2. sub-neg100.0%

        \[\leadsto \color{blue}{\left(x + \left(-\left(y + 0.5\right) \cdot \log y\right)\right)} + \left(y - z\right) \]
      3. associate-+l+100.0%

        \[\leadsto \color{blue}{x + \left(\left(-\left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)\right)} \]
      4. associate-+r-100.0%

        \[\leadsto x + \color{blue}{\left(\left(\left(-\left(y + 0.5\right) \cdot \log y\right) + y\right) - z\right)} \]
      5. *-commutative100.0%

        \[\leadsto x + \left(\left(\left(-\color{blue}{\log y \cdot \left(y + 0.5\right)}\right) + y\right) - z\right) \]
      6. distribute-rgt-neg-in100.0%

        \[\leadsto x + \left(\left(\color{blue}{\log y \cdot \left(-\left(y + 0.5\right)\right)} + y\right) - z\right) \]
      7. fma-define100.0%

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

        \[\leadsto x + \left(\mathsf{fma}\left(\log y, -\color{blue}{\left(0.5 + y\right)}, y\right) - z\right) \]
      9. distribute-neg-in100.0%

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

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

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

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

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

    if 3.5500000000000001e22 < y < 7.5999999999999997e42 or 1.39999999999999995e70 < y

    1. Initial program 99.7%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Step-by-step derivation
      1. associate--l+99.7%

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

      \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in z around 0 87.6%

      \[\leadsto \color{blue}{\left(x + y\right) - \log y \cdot \left(0.5 + y\right)} \]
    6. Taylor expanded in y around inf 87.6%

      \[\leadsto \left(x + y\right) - \color{blue}{-1 \cdot \left(y \cdot \log \left(\frac{1}{y}\right)\right)} \]
    7. Step-by-step derivation
      1. mul-1-neg87.6%

        \[\leadsto \left(x + y\right) - \color{blue}{\left(-y \cdot \log \left(\frac{1}{y}\right)\right)} \]
      2. distribute-rgt-neg-in87.6%

        \[\leadsto \left(x + y\right) - \color{blue}{y \cdot \left(-\log \left(\frac{1}{y}\right)\right)} \]
      3. log-rec87.6%

        \[\leadsto \left(x + y\right) - y \cdot \left(-\color{blue}{\left(-\log y\right)}\right) \]
      4. remove-double-neg87.6%

        \[\leadsto \left(x + y\right) - y \cdot \color{blue}{\log y} \]
    8. Simplified87.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 3.55 \cdot 10^{+22} \lor \neg \left(y \leq 7.6 \cdot 10^{+42}\right) \land y \leq 1.4 \cdot 10^{+70}:\\ \;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\ \mathbf{else}:\\ \;\;\;\;\left(x + y\right) - y \cdot \log y\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 70.6% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 1.2 \cdot 10^{+78}:\\ \;\;\;\;x + \left(y - z\right)\\ \mathbf{elif}\;y \leq 1.16 \cdot 10^{+149} \lor \neg \left(y \leq 9.5 \cdot 10^{+177}\right):\\ \;\;\;\;y \cdot \left(1 - \log y\right)\\ \mathbf{else}:\\ \;\;\;\;x - z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y 1.2e+78)
   (+ x (- y z))
   (if (or (<= y 1.16e+149) (not (<= y 9.5e+177)))
     (* y (- 1.0 (log y)))
     (- x z))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= 1.2e+78) {
		tmp = x + (y - z);
	} else if ((y <= 1.16e+149) || !(y <= 9.5e+177)) {
		tmp = y * (1.0 - log(y));
	} 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) :: tmp
    if (y <= 1.2d+78) then
        tmp = x + (y - z)
    else if ((y <= 1.16d+149) .or. (.not. (y <= 9.5d+177))) then
        tmp = y * (1.0d0 - log(y))
    else
        tmp = x - z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= 1.2e+78) {
		tmp = x + (y - z);
	} else if ((y <= 1.16e+149) || !(y <= 9.5e+177)) {
		tmp = y * (1.0 - Math.log(y));
	} else {
		tmp = x - z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= 1.2e+78:
		tmp = x + (y - z)
	elif (y <= 1.16e+149) or not (y <= 9.5e+177):
		tmp = y * (1.0 - math.log(y))
	else:
		tmp = x - z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= 1.2e+78)
		tmp = Float64(x + Float64(y - z));
	elseif ((y <= 1.16e+149) || !(y <= 9.5e+177))
		tmp = Float64(y * Float64(1.0 - log(y)));
	else
		tmp = Float64(x - z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= 1.2e+78)
		tmp = x + (y - z);
	elseif ((y <= 1.16e+149) || ~((y <= 9.5e+177)))
		tmp = y * (1.0 - log(y));
	else
		tmp = x - z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, 1.2e+78], N[(x + N[(y - z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 1.16e+149], N[Not[LessEqual[y, 9.5e+177]], $MachinePrecision]], N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - z), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.2 \cdot 10^{+78}:\\
\;\;\;\;x + \left(y - z\right)\\

\mathbf{elif}\;y \leq 1.16 \cdot 10^{+149} \lor \neg \left(y \leq 9.5 \cdot 10^{+177}\right):\\
\;\;\;\;y \cdot \left(1 - \log y\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 1.1999999999999999e78

    1. Initial program 100.0%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Step-by-step derivation
      1. associate--l+100.0%

        \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{\left(x + -1 \cdot \left(\log y \cdot \left(0.5 + y\right)\right)\right)} + \left(y - z\right) \]
    6. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{\left(-1 \cdot \left(\log y \cdot \left(0.5 + y\right)\right) + x\right)} + \left(y - z\right) \]
      2. distribute-rgt-in100.0%

        \[\leadsto \left(-1 \cdot \color{blue}{\left(0.5 \cdot \log y + y \cdot \log y\right)} + x\right) + \left(y - z\right) \]
      3. distribute-lft-in100.0%

        \[\leadsto \left(\color{blue}{\left(-1 \cdot \left(0.5 \cdot \log y\right) + -1 \cdot \left(y \cdot \log y\right)\right)} + x\right) + \left(y - z\right) \]
      4. neg-mul-1100.0%

        \[\leadsto \left(\left(\color{blue}{\left(-0.5 \cdot \log y\right)} + -1 \cdot \left(y \cdot \log y\right)\right) + x\right) + \left(y - z\right) \]
      5. distribute-lft-neg-in100.0%

        \[\leadsto \left(\left(\color{blue}{\left(-0.5\right) \cdot \log y} + -1 \cdot \left(y \cdot \log y\right)\right) + x\right) + \left(y - z\right) \]
      6. metadata-eval100.0%

        \[\leadsto \left(\left(\color{blue}{-0.5} \cdot \log y + -1 \cdot \left(y \cdot \log y\right)\right) + x\right) + \left(y - z\right) \]
      7. associate-*r*100.0%

        \[\leadsto \left(\left(-0.5 \cdot \log y + \color{blue}{\left(-1 \cdot y\right) \cdot \log y}\right) + x\right) + \left(y - z\right) \]
      8. distribute-rgt-in100.0%

        \[\leadsto \left(\color{blue}{\log y \cdot \left(-0.5 + -1 \cdot y\right)} + x\right) + \left(y - z\right) \]
      9. neg-mul-1100.0%

        \[\leadsto \left(\log y \cdot \left(-0.5 + \color{blue}{\left(-y\right)}\right) + x\right) + \left(y - z\right) \]
      10. sub-neg100.0%

        \[\leadsto \left(\log y \cdot \color{blue}{\left(-0.5 - y\right)} + x\right) + \left(y - z\right) \]
      11. *-rgt-identity100.0%

        \[\leadsto \left(\log y \cdot \color{blue}{\left(\left(-0.5 - y\right) \cdot 1\right)} + x\right) + \left(y - z\right) \]
      12. fma-define100.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, \left(-0.5 - y\right) \cdot 1, x\right)} + \left(y - z\right) \]
      13. *-rgt-identity100.0%

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

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

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

    if 1.1999999999999999e78 < y < 1.16e149 or 9.49999999999999996e177 < y

    1. Initial program 99.7%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Step-by-step derivation
      1. associate--l+99.7%

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

      \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 99.7%

      \[\leadsto \color{blue}{\left(x + -1 \cdot \left(\log y \cdot \left(0.5 + y\right)\right)\right)} + \left(y - z\right) \]
    6. Step-by-step derivation
      1. +-commutative99.7%

        \[\leadsto \color{blue}{\left(-1 \cdot \left(\log y \cdot \left(0.5 + y\right)\right) + x\right)} + \left(y - z\right) \]
      2. distribute-rgt-in99.7%

        \[\leadsto \left(-1 \cdot \color{blue}{\left(0.5 \cdot \log y + y \cdot \log y\right)} + x\right) + \left(y - z\right) \]
      3. distribute-lft-in99.7%

        \[\leadsto \left(\color{blue}{\left(-1 \cdot \left(0.5 \cdot \log y\right) + -1 \cdot \left(y \cdot \log y\right)\right)} + x\right) + \left(y - z\right) \]
      4. neg-mul-199.7%

        \[\leadsto \left(\left(\color{blue}{\left(-0.5 \cdot \log y\right)} + -1 \cdot \left(y \cdot \log y\right)\right) + x\right) + \left(y - z\right) \]
      5. distribute-lft-neg-in99.7%

        \[\leadsto \left(\left(\color{blue}{\left(-0.5\right) \cdot \log y} + -1 \cdot \left(y \cdot \log y\right)\right) + x\right) + \left(y - z\right) \]
      6. metadata-eval99.7%

        \[\leadsto \left(\left(\color{blue}{-0.5} \cdot \log y + -1 \cdot \left(y \cdot \log y\right)\right) + x\right) + \left(y - z\right) \]
      7. associate-*r*99.7%

        \[\leadsto \left(\left(-0.5 \cdot \log y + \color{blue}{\left(-1 \cdot y\right) \cdot \log y}\right) + x\right) + \left(y - z\right) \]
      8. distribute-rgt-in99.7%

        \[\leadsto \left(\color{blue}{\log y \cdot \left(-0.5 + -1 \cdot y\right)} + x\right) + \left(y - z\right) \]
      9. neg-mul-199.7%

        \[\leadsto \left(\log y \cdot \left(-0.5 + \color{blue}{\left(-y\right)}\right) + x\right) + \left(y - z\right) \]
      10. sub-neg99.7%

        \[\leadsto \left(\log y \cdot \color{blue}{\left(-0.5 - y\right)} + x\right) + \left(y - z\right) \]
      11. *-rgt-identity99.7%

        \[\leadsto \left(\log y \cdot \color{blue}{\left(\left(-0.5 - y\right) \cdot 1\right)} + x\right) + \left(y - z\right) \]
      12. fma-define99.7%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, \left(-0.5 - y\right) \cdot 1, x\right)} + \left(y - z\right) \]
      13. *-rgt-identity99.7%

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

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

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

        \[\leadsto y \cdot \left(1 + \color{blue}{\left(-\log y\right)}\right) \]
      2. sub-neg66.5%

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

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

    if 1.16e149 < y < 9.49999999999999996e177

    1. Initial program 99.9%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Step-by-step derivation
      1. associate--l+99.9%

        \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
      2. sub-neg99.9%

        \[\leadsto \color{blue}{\left(x + \left(-\left(y + 0.5\right) \cdot \log y\right)\right)} + \left(y - z\right) \]
      3. associate-+l+99.9%

        \[\leadsto \color{blue}{x + \left(\left(-\left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)\right)} \]
      4. associate-+r-99.9%

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

        \[\leadsto x + \left(\left(\left(-\color{blue}{\log y \cdot \left(y + 0.5\right)}\right) + y\right) - z\right) \]
      6. distribute-rgt-neg-in99.9%

        \[\leadsto x + \left(\left(\color{blue}{\log y \cdot \left(-\left(y + 0.5\right)\right)} + y\right) - z\right) \]
      7. fma-define100.0%

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

        \[\leadsto x + \left(\mathsf{fma}\left(\log y, -\color{blue}{\left(0.5 + y\right)}, y\right) - z\right) \]
      9. distribute-neg-in100.0%

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

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

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

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

      \[\leadsto \color{blue}{\left(x + -0.5 \cdot \log y\right) - z} \]
    6. Taylor expanded in x around inf 70.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.2 \cdot 10^{+78}:\\ \;\;\;\;x + \left(y - z\right)\\ \mathbf{elif}\;y \leq 1.16 \cdot 10^{+149} \lor \neg \left(y \leq 9.5 \cdot 10^{+177}\right):\\ \;\;\;\;y \cdot \left(1 - \log y\right)\\ \mathbf{else}:\\ \;\;\;\;x - z\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 99.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 0.027:\\ \;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\ \mathbf{else}:\\ \;\;\;\;x + \left(y \cdot \left(1 - \log y\right) - z\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y 0.027)
   (- (+ x (* (log y) -0.5)) z)
   (+ x (- (* y (- 1.0 (log y))) z))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= 0.027) {
		tmp = (x + (log(y) * -0.5)) - z;
	} else {
		tmp = x + ((y * (1.0 - log(y))) - 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 (y <= 0.027d0) then
        tmp = (x + (log(y) * (-0.5d0))) - z
    else
        tmp = x + ((y * (1.0d0 - log(y))) - z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= 0.027) {
		tmp = (x + (Math.log(y) * -0.5)) - z;
	} else {
		tmp = x + ((y * (1.0 - Math.log(y))) - z);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= 0.027:
		tmp = (x + (math.log(y) * -0.5)) - z
	else:
		tmp = x + ((y * (1.0 - math.log(y))) - z)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= 0.027)
		tmp = Float64(Float64(x + Float64(log(y) * -0.5)) - z);
	else
		tmp = Float64(x + Float64(Float64(y * Float64(1.0 - log(y))) - z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= 0.027)
		tmp = (x + (log(y) * -0.5)) - z;
	else
		tmp = x + ((y * (1.0 - log(y))) - z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, 0.027], N[(N[(x + N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(x + N[(N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.027:\\
\;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\

\mathbf{else}:\\
\;\;\;\;x + \left(y \cdot \left(1 - \log y\right) - z\right)\\


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

    1. Initial program 100.0%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Step-by-step derivation
      1. associate--l+100.0%

        \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
      2. sub-neg100.0%

        \[\leadsto \color{blue}{\left(x + \left(-\left(y + 0.5\right) \cdot \log y\right)\right)} + \left(y - z\right) \]
      3. associate-+l+100.0%

        \[\leadsto \color{blue}{x + \left(\left(-\left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)\right)} \]
      4. associate-+r-100.0%

        \[\leadsto x + \color{blue}{\left(\left(\left(-\left(y + 0.5\right) \cdot \log y\right) + y\right) - z\right)} \]
      5. *-commutative100.0%

        \[\leadsto x + \left(\left(\left(-\color{blue}{\log y \cdot \left(y + 0.5\right)}\right) + y\right) - z\right) \]
      6. distribute-rgt-neg-in100.0%

        \[\leadsto x + \left(\left(\color{blue}{\log y \cdot \left(-\left(y + 0.5\right)\right)} + y\right) - z\right) \]
      7. fma-define100.0%

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

        \[\leadsto x + \left(\mathsf{fma}\left(\log y, -\color{blue}{\left(0.5 + y\right)}, y\right) - z\right) \]
      9. distribute-neg-in100.0%

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

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

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

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

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

    if 0.0269999999999999997 < y

    1. Initial program 99.7%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Step-by-step derivation
      1. associate--l+99.7%

        \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
      2. sub-neg99.7%

        \[\leadsto \color{blue}{\left(x + \left(-\left(y + 0.5\right) \cdot \log y\right)\right)} + \left(y - z\right) \]
      3. associate-+l+99.7%

        \[\leadsto \color{blue}{x + \left(\left(-\left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)\right)} \]
      4. associate-+r-99.7%

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

        \[\leadsto x + \left(\left(\left(-\color{blue}{\log y \cdot \left(y + 0.5\right)}\right) + y\right) - z\right) \]
      6. distribute-rgt-neg-in99.7%

        \[\leadsto x + \left(\left(\color{blue}{\log y \cdot \left(-\left(y + 0.5\right)\right)} + y\right) - z\right) \]
      7. fma-define99.8%

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

        \[\leadsto x + \left(\mathsf{fma}\left(\log y, -\color{blue}{\left(0.5 + y\right)}, y\right) - z\right) \]
      9. distribute-neg-in99.8%

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

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

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

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

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

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

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

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

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

Alternative 9: 99.8% accurate, 1.0× speedup?

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

\\
\left(x - \log y \cdot \left(y + 0.5\right)\right) + \left(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. Step-by-step derivation
    1. associate--l+99.8%

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

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

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

Alternative 10: 47.6% accurate, 9.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -3 \cdot 10^{+50} \lor \neg \left(z \leq 8.5 \cdot 10^{-10}\right):\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -3e+50) (not (<= z 8.5e-10))) (- z) x))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -3e+50) || !(z <= 8.5e-10)) {
		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 ((z <= (-3d+50)) .or. (.not. (z <= 8.5d-10))) 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 ((z <= -3e+50) || !(z <= 8.5e-10)) {
		tmp = -z;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -3e+50) or not (z <= 8.5e-10):
		tmp = -z
	else:
		tmp = x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -3e+50) || !(z <= 8.5e-10))
		tmp = Float64(-z);
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= -3e+50) || ~((z <= 8.5e-10)))
		tmp = -z;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -3e+50], N[Not[LessEqual[z, 8.5e-10]], $MachinePrecision]], (-z), x]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -3 \cdot 10^{+50} \lor \neg \left(z \leq 8.5 \cdot 10^{-10}\right):\\
\;\;\;\;-z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.9999999999999998e50 or 8.4999999999999996e-10 < z

    1. Initial program 99.9%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Step-by-step derivation
      1. associate--l+99.9%

        \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
      2. sub-neg99.9%

        \[\leadsto \color{blue}{\left(x + \left(-\left(y + 0.5\right) \cdot \log y\right)\right)} + \left(y - z\right) \]
      3. associate-+l+99.9%

        \[\leadsto \color{blue}{x + \left(\left(-\left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)\right)} \]
      4. associate-+r-99.9%

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

        \[\leadsto x + \left(\left(\left(-\color{blue}{\log y \cdot \left(y + 0.5\right)}\right) + y\right) - z\right) \]
      6. distribute-rgt-neg-in99.9%

        \[\leadsto x + \left(\left(\color{blue}{\log y \cdot \left(-\left(y + 0.5\right)\right)} + y\right) - z\right) \]
      7. fma-define99.9%

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot z} \]
    6. Step-by-step derivation
      1. neg-mul-159.6%

        \[\leadsto \color{blue}{-z} \]
    7. Simplified59.6%

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

    if -2.9999999999999998e50 < z < 8.4999999999999996e-10

    1. Initial program 99.8%

      \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
    2. Step-by-step derivation
      1. associate--l+99.8%

        \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
      2. sub-neg99.8%

        \[\leadsto \color{blue}{\left(x + \left(-\left(y + 0.5\right) \cdot \log y\right)\right)} + \left(y - z\right) \]
      3. associate-+l+99.8%

        \[\leadsto \color{blue}{x + \left(\left(-\left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)\right)} \]
      4. associate-+r-99.8%

        \[\leadsto x + \color{blue}{\left(\left(\left(-\left(y + 0.5\right) \cdot \log y\right) + y\right) - z\right)} \]
      5. *-commutative99.8%

        \[\leadsto x + \left(\left(\left(-\color{blue}{\log y \cdot \left(y + 0.5\right)}\right) + y\right) - z\right) \]
      6. distribute-rgt-neg-in99.8%

        \[\leadsto x + \left(\left(\color{blue}{\log y \cdot \left(-\left(y + 0.5\right)\right)} + y\right) - z\right) \]
      7. fma-define99.8%

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

        \[\leadsto x + \left(\mathsf{fma}\left(\log y, -\color{blue}{\left(0.5 + y\right)}, y\right) - z\right) \]
      9. distribute-neg-in99.8%

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

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

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

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

      \[\leadsto \color{blue}{x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification49.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3 \cdot 10^{+50} \lor \neg \left(z \leq 8.5 \cdot 10^{-10}\right):\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 57.5% accurate, 37.0× 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. Step-by-step derivation
    1. associate--l+99.8%

      \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
    2. sub-neg99.8%

      \[\leadsto \color{blue}{\left(x + \left(-\left(y + 0.5\right) \cdot \log y\right)\right)} + \left(y - z\right) \]
    3. associate-+l+99.8%

      \[\leadsto \color{blue}{x + \left(\left(-\left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)\right)} \]
    4. associate-+r-99.8%

      \[\leadsto x + \color{blue}{\left(\left(\left(-\left(y + 0.5\right) \cdot \log y\right) + y\right) - z\right)} \]
    5. *-commutative99.8%

      \[\leadsto x + \left(\left(\left(-\color{blue}{\log y \cdot \left(y + 0.5\right)}\right) + y\right) - z\right) \]
    6. distribute-rgt-neg-in99.8%

      \[\leadsto x + \left(\left(\color{blue}{\log y \cdot \left(-\left(y + 0.5\right)\right)} + y\right) - z\right) \]
    7. fma-define99.9%

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

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

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

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

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

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

    \[\leadsto \color{blue}{\left(x + -0.5 \cdot \log y\right) - z} \]
  6. Taylor expanded in x around inf 55.9%

    \[\leadsto \color{blue}{x} - z \]
  7. Final simplification55.9%

    \[\leadsto x - z \]
  8. Add Preprocessing

Alternative 12: 30.0% accurate, 111.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. Step-by-step derivation
    1. associate--l+99.8%

      \[\leadsto \color{blue}{\left(x - \left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)} \]
    2. sub-neg99.8%

      \[\leadsto \color{blue}{\left(x + \left(-\left(y + 0.5\right) \cdot \log y\right)\right)} + \left(y - z\right) \]
    3. associate-+l+99.8%

      \[\leadsto \color{blue}{x + \left(\left(-\left(y + 0.5\right) \cdot \log y\right) + \left(y - z\right)\right)} \]
    4. associate-+r-99.8%

      \[\leadsto x + \color{blue}{\left(\left(\left(-\left(y + 0.5\right) \cdot \log y\right) + y\right) - z\right)} \]
    5. *-commutative99.8%

      \[\leadsto x + \left(\left(\left(-\color{blue}{\log y \cdot \left(y + 0.5\right)}\right) + y\right) - z\right) \]
    6. distribute-rgt-neg-in99.8%

      \[\leadsto x + \left(\left(\color{blue}{\log y \cdot \left(-\left(y + 0.5\right)\right)} + y\right) - z\right) \]
    7. fma-define99.9%

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

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

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

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

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

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

    \[\leadsto \color{blue}{x} \]
  6. Final simplification33.0%

    \[\leadsto x \]
  7. Add Preprocessing

Developer target: 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 2024053 
(FPCore (x y z)
  :name "Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2"
  :precision binary64

  :alt
  (- (- (+ y x) z) (* (+ y 0.5) (log y)))

  (- (+ (- x (* (+ y 0.5) (log y))) y) z))