Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2

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

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

    \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z \]
  2. 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. *-commutative99.9%

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

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

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

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

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

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

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

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

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

Alternative 2: 70.8% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;x \leq 2.3 \cdot 10^{-284}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 3.5 \cdot 10^{-106}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 5.8 \cdot 10^{-49}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 1850:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -6.0000000000000003e-12

    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. *-commutative99.9%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(\log y, -0.5 - y, y - z\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(y - z\right) + x\right) - \color{blue}{{\left(\sqrt[3]{\log y \cdot \left(y + 0.5\right)}\right)}^{3}} \]
    8. Applied egg-rr99.5%

      \[\leadsto \left(\left(y - z\right) + x\right) - \color{blue}{{\left(\sqrt[3]{\log y \cdot \left(y + 0.5\right)}\right)}^{3}} \]
    9. Taylor expanded in y around inf 98.3%

      \[\leadsto \left(\left(y - z\right) + x\right) - {\left(\sqrt[3]{\color{blue}{-1 \cdot \left(y \cdot \log \left(\frac{1}{y}\right)\right)}}\right)}^{3} \]
    10. Step-by-step derivation
      1. mul-1-neg98.3%

        \[\leadsto \left(\left(y - z\right) + x\right) - {\left(\sqrt[3]{\color{blue}{-y \cdot \log \left(\frac{1}{y}\right)}}\right)}^{3} \]
      2. distribute-rgt-neg-in98.3%

        \[\leadsto \left(\left(y - z\right) + x\right) - {\left(\sqrt[3]{\color{blue}{y \cdot \left(-\log \left(\frac{1}{y}\right)\right)}}\right)}^{3} \]
      3. log-rec98.3%

        \[\leadsto \left(\left(y - z\right) + x\right) - {\left(\sqrt[3]{y \cdot \left(-\color{blue}{\left(-\log y\right)}\right)}\right)}^{3} \]
      4. remove-double-neg98.3%

        \[\leadsto \left(\left(y - z\right) + x\right) - {\left(\sqrt[3]{y \cdot \color{blue}{\log y}}\right)}^{3} \]
    11. Simplified98.3%

      \[\leadsto \left(\left(y - z\right) + x\right) - {\left(\sqrt[3]{\color{blue}{y \cdot \log y}}\right)}^{3} \]
    12. Taylor expanded in y around 0 79.1%

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

    if -6.0000000000000003e-12 < x < 2.3e-284 or 3.5e-106 < x < 5.8e-49

    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. *-commutative99.8%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(x + y\right) + \left(-\log y\right) \cdot \color{blue}{\left(y + 0.5\right)} \]
      5. cancel-sign-sub-inv77.1%

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

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

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

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

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

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

    if 2.3e-284 < x < 3.5e-106 or 5.8e-49 < x < 1850

    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. *-commutative99.9%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(\log y, -0.5 - y, y - z\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(z + 0.5 \cdot \log y\right)} \]
    11. Step-by-step derivation
      1. mul-1-neg79.3%

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

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

    if 1850 < 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. *-commutative99.9%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6 \cdot 10^{-12}:\\ \;\;\;\;x - z\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{-284}:\\ \;\;\;\;y - \log y \cdot \left(y + 0.5\right)\\ \mathbf{elif}\;x \leq 3.5 \cdot 10^{-106}:\\ \;\;\;\;\log y \cdot \left(-0.5\right) - z\\ \mathbf{elif}\;x \leq 5.8 \cdot 10^{-49}:\\ \;\;\;\;y - \log y \cdot \left(y + 0.5\right)\\ \mathbf{elif}\;x \leq 1850:\\ \;\;\;\;\log y \cdot \left(-0.5\right) - z\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(1 - \log y\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 88.4% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;y \leq 1.65 \cdot 10^{+44}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 5.8 \cdot 10^{+97}:\\
\;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\

\mathbf{elif}\;y \leq 1.15 \cdot 10^{+161}:\\
\;\;\;\;t\_0\\

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


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

    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. *-commutative100.0%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(\log y, -0.5 - y, y - z\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1200 < y < 1.65000000000000007e44 or 5.79999999999999974e97 < y < 1.15e161

    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. *-commutative99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.65000000000000007e44 < y < 5.79999999999999974e97

    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. *-commutative99.9%

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

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

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

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

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

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

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

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

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

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

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

    if 1.15e161 < 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 y around inf 90.7%

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

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

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

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

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

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

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

        \[\leadsto y + \left(-1 \cdot z + -1 \cdot \color{blue}{\log \left({y}^{y}\right)}\right) \]
      2. distribute-lft-out5.9%

        \[\leadsto y + \color{blue}{-1 \cdot \left(z + \log \left({y}^{y}\right)\right)} \]
      3. mul-1-neg5.9%

        \[\leadsto y + \color{blue}{\left(-\left(z + \log \left({y}^{y}\right)\right)\right)} \]
      4. sub-neg5.9%

        \[\leadsto \color{blue}{y - \left(z + \log \left({y}^{y}\right)\right)} \]
      5. associate--l-5.9%

        \[\leadsto \color{blue}{\left(y - z\right) - \log \left({y}^{y}\right)} \]
      6. log-pow90.7%

        \[\leadsto \left(y - z\right) - \color{blue}{y \cdot \log y} \]
    10. Simplified90.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1200:\\ \;\;\;\;\left(x - z\right) - \log y \cdot 0.5\\ \mathbf{elif}\;y \leq 1.65 \cdot 10^{+44}:\\ \;\;\;\;\left(x + y\right) - \log y \cdot \left(y + 0.5\right)\\ \mathbf{elif}\;y \leq 5.8 \cdot 10^{+97}:\\ \;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{+161}:\\ \;\;\;\;\left(x + y\right) - \log y \cdot \left(y + 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y - z\right) - y \cdot \log y\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 68.8% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_0 := \log y \cdot \left(-0.5\right) - z\\
t_1 := y \cdot \left(1 - \log y\right)\\
t_2 := x + t\_1\\
\mathbf{if}\;x \leq -240000000:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \leq -7.5 \cdot 10^{-268}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 2.3 \cdot 10^{-293}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 95:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.4e8 or 95 < 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. *-commutative99.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.4e8 < x < -7.4999999999999999e-268 or 2.29999999999999995e-293 < x < 95

    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. *-commutative99.9%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(\log y, -0.5 - y, y - z\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.4999999999999999e-268 < x < 2.29999999999999995e-293

    1. Initial program 99.2%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(\log y, -0.5 - y, y - z\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine99.2%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(y - z\right) + x\right) - \color{blue}{\log y \cdot \left(y + 0.5\right)} \]
    6. Applied egg-rr99.2%

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

      \[\leadsto \color{blue}{y \cdot \left(1 - -1 \cdot \log \left(\frac{1}{y}\right)\right)} \]
    8. Step-by-step derivation
      1. *-commutative87.1%

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

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

        \[\leadsto y \cdot \color{blue}{\left(1 + \log y \cdot -1\right)} \]
      4. *-commutative87.1%

        \[\leadsto y \cdot \left(1 + \color{blue}{-1 \cdot \log y}\right) \]
      5. neg-mul-187.1%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -240000000:\\ \;\;\;\;x + y \cdot \left(1 - \log y\right)\\ \mathbf{elif}\;x \leq -7.5 \cdot 10^{-268}:\\ \;\;\;\;\log y \cdot \left(-0.5\right) - z\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{-293}:\\ \;\;\;\;y \cdot \left(1 - \log y\right)\\ \mathbf{elif}\;x \leq 95:\\ \;\;\;\;\log y \cdot \left(-0.5\right) - z\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(1 - \log y\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 88.2% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;y \leq 4 \cdot 10^{+44}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 5.8 \cdot 10^{+97}:\\
\;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\

\mathbf{elif}\;y \leq 6.2 \cdot 10^{+160}:\\
\;\;\;\;t\_0\\

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


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

    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. *-commutative100.0%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(\log y, -0.5 - y, y - z\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1200 < y < 4.0000000000000004e44 or 5.79999999999999974e97 < y < 6.1999999999999996e160

    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. *-commutative99.7%

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.0000000000000004e44 < y < 5.79999999999999974e97

    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. *-commutative99.9%

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

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

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

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

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

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

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

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

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

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

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

    if 6.1999999999999996e160 < 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 y around inf 90.7%

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

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

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

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

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

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

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

        \[\leadsto y + \left(-1 \cdot z + -1 \cdot \color{blue}{\log \left({y}^{y}\right)}\right) \]
      2. distribute-lft-out5.9%

        \[\leadsto y + \color{blue}{-1 \cdot \left(z + \log \left({y}^{y}\right)\right)} \]
      3. mul-1-neg5.9%

        \[\leadsto y + \color{blue}{\left(-\left(z + \log \left({y}^{y}\right)\right)\right)} \]
      4. sub-neg5.9%

        \[\leadsto \color{blue}{y - \left(z + \log \left({y}^{y}\right)\right)} \]
      5. associate--l-5.9%

        \[\leadsto \color{blue}{\left(y - z\right) - \log \left({y}^{y}\right)} \]
      6. log-pow90.7%

        \[\leadsto \left(y - z\right) - \color{blue}{y \cdot \log y} \]
    10. Simplified90.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1200:\\ \;\;\;\;\left(x - z\right) - \log y \cdot 0.5\\ \mathbf{elif}\;y \leq 4 \cdot 10^{+44}:\\ \;\;\;\;x + y \cdot \left(1 - \log y\right)\\ \mathbf{elif}\;y \leq 5.8 \cdot 10^{+97}:\\ \;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\ \mathbf{elif}\;y \leq 6.2 \cdot 10^{+160}:\\ \;\;\;\;x + y \cdot \left(1 - \log y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y - z\right) - y \cdot \log y\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 88.1% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 1200 \lor \neg \left(y \leq 7.2 \cdot 10^{+43}\right) \land y \leq 5.8 \cdot 10^{+97}:\\
\;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 1200 or 7.2000000000000002e43 < y < 5.79999999999999974e97

    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. *-commutative100.0%

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

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

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

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

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

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

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

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

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

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

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

    if 1200 < y < 7.2000000000000002e43 or 5.79999999999999974e97 < 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. *-commutative99.7%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1200 \lor \neg \left(y \leq 7.2 \cdot 10^{+43}\right) \land y \leq 5.8 \cdot 10^{+97}:\\ \;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(1 - \log y\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 88.1% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;y \leq 3.8 \cdot 10^{+44} \lor \neg \left(y \leq 5.8 \cdot 10^{+97}\right):\\
\;\;\;\;x + y \cdot \left(1 - \log y\right)\\

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


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

    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. *-commutative100.0%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(\log y, -0.5 - y, y - z\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1200 < y < 3.8000000000000002e44 or 5.79999999999999974e97 < 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. *-commutative99.7%

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.8000000000000002e44 < y < 5.79999999999999974e97

    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. *-commutative99.9%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1200:\\ \;\;\;\;\left(x - z\right) - \log y \cdot 0.5\\ \mathbf{elif}\;y \leq 3.8 \cdot 10^{+44} \lor \neg \left(y \leq 5.8 \cdot 10^{+97}\right):\\ \;\;\;\;x + y \cdot \left(1 - \log y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 70.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.5 \cdot 10^{+28} \lor \neg \left(z \leq 210\right):\\ \;\;\;\;x - z\\ \mathbf{else}:\\ \;\;\;\;x - \log y \cdot 0.5\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -1.5e+28) (not (<= z 210.0))) (- x z) (- x (* (log y) 0.5))))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.5e+28) || !(z <= 210.0)) {
		tmp = x - z;
	} else {
		tmp = x - (log(y) * 0.5);
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((z <= (-1.5d+28)) .or. (.not. (z <= 210.0d0))) then
        tmp = x - z
    else
        tmp = x - (log(y) * 0.5d0)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.5e+28) || !(z <= 210.0)) {
		tmp = x - z;
	} else {
		tmp = x - (Math.log(y) * 0.5);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -1.5e+28) or not (z <= 210.0):
		tmp = x - z
	else:
		tmp = x - (math.log(y) * 0.5)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -1.5e+28) || !(z <= 210.0))
		tmp = Float64(x - z);
	else
		tmp = Float64(x - Float64(log(y) * 0.5));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= -1.5e+28) || ~((z <= 210.0)))
		tmp = x - z;
	else
		tmp = x - (log(y) * 0.5);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.5e+28], N[Not[LessEqual[z, 210.0]], $MachinePrecision]], N[(x - z), $MachinePrecision], N[(x - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.5 \cdot 10^{+28} \lor \neg \left(z \leq 210\right):\\
\;\;\;\;x - z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.5e28 or 210 < 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. *-commutative99.9%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(\log y, -0.5 - y, y - z\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(y - z\right) + x\right) - \color{blue}{{\left(\sqrt[3]{\log y \cdot \left(y + 0.5\right)}\right)}^{3}} \]
    8. Applied egg-rr99.5%

      \[\leadsto \left(\left(y - z\right) + x\right) - \color{blue}{{\left(\sqrt[3]{\log y \cdot \left(y + 0.5\right)}\right)}^{3}} \]
    9. Taylor expanded in y around inf 98.5%

      \[\leadsto \left(\left(y - z\right) + x\right) - {\left(\sqrt[3]{\color{blue}{-1 \cdot \left(y \cdot \log \left(\frac{1}{y}\right)\right)}}\right)}^{3} \]
    10. Step-by-step derivation
      1. mul-1-neg98.5%

        \[\leadsto \left(\left(y - z\right) + x\right) - {\left(\sqrt[3]{\color{blue}{-y \cdot \log \left(\frac{1}{y}\right)}}\right)}^{3} \]
      2. distribute-rgt-neg-in98.5%

        \[\leadsto \left(\left(y - z\right) + x\right) - {\left(\sqrt[3]{\color{blue}{y \cdot \left(-\log \left(\frac{1}{y}\right)\right)}}\right)}^{3} \]
      3. log-rec98.5%

        \[\leadsto \left(\left(y - z\right) + x\right) - {\left(\sqrt[3]{y \cdot \left(-\color{blue}{\left(-\log y\right)}\right)}\right)}^{3} \]
      4. remove-double-neg98.5%

        \[\leadsto \left(\left(y - z\right) + x\right) - {\left(\sqrt[3]{y \cdot \color{blue}{\log y}}\right)}^{3} \]
    11. Simplified98.5%

      \[\leadsto \left(\left(y - z\right) + x\right) - {\left(\sqrt[3]{\color{blue}{y \cdot \log y}}\right)}^{3} \]
    12. Taylor expanded in y around 0 74.7%

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

    if -1.5e28 < z < 210

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(\log y, -0.5 - y, y - z\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.5 \cdot 10^{+28} \lor \neg \left(z \leq 210\right):\\ \;\;\;\;x - z\\ \mathbf{else}:\\ \;\;\;\;x - \log y \cdot 0.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 55.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -3.5 \cdot 10^{-15} \lor \neg \left(x \leq 1.75 \cdot 10^{-276}\right):\\ \;\;\;\;x - z\\ \mathbf{else}:\\ \;\;\;\;\log y \cdot -0.5\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -3.5e-15) (not (<= x 1.75e-276))) (- x z) (* (log y) -0.5)))
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -3.5e-15) || !(x <= 1.75e-276)) {
		tmp = x - z;
	} else {
		tmp = log(y) * -0.5;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((x <= (-3.5d-15)) .or. (.not. (x <= 1.75d-276))) then
        tmp = x - z
    else
        tmp = log(y) * (-0.5d0)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((x <= -3.5e-15) || !(x <= 1.75e-276)) {
		tmp = x - z;
	} else {
		tmp = Math.log(y) * -0.5;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (x <= -3.5e-15) or not (x <= 1.75e-276):
		tmp = x - z
	else:
		tmp = math.log(y) * -0.5
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((x <= -3.5e-15) || !(x <= 1.75e-276))
		tmp = Float64(x - z);
	else
		tmp = Float64(log(y) * -0.5);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x <= -3.5e-15) || ~((x <= 1.75e-276)))
		tmp = x - z;
	else
		tmp = log(y) * -0.5;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.5e-15], N[Not[LessEqual[x, 1.75e-276]], $MachinePrecision]], N[(x - z), $MachinePrecision], N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.5 \cdot 10^{-15} \lor \neg \left(x \leq 1.75 \cdot 10^{-276}\right):\\
\;\;\;\;x - z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.5000000000000001e-15 or 1.74999999999999996e-276 < 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. *-commutative99.9%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(\log y, -0.5 - y, y - z\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\left(y - z\right) + x\right) - \color{blue}{{\left(\sqrt[3]{\log y \cdot \left(y + 0.5\right)}\right)}^{3}} \]
    9. Taylor expanded in y around inf 90.6%

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

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

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

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

        \[\leadsto \left(\left(y - z\right) + x\right) - {\left(\sqrt[3]{y \cdot \color{blue}{\log y}}\right)}^{3} \]
    11. Simplified90.6%

      \[\leadsto \left(\left(y - z\right) + x\right) - {\left(\sqrt[3]{\color{blue}{y \cdot \log y}}\right)}^{3} \]
    12. Taylor expanded in y around 0 68.0%

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

    if -3.5000000000000001e-15 < x < 1.74999999999999996e-276

    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. *-commutative99.8%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(\log y, -0.5 - y, y - z\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x - 0.5 \cdot \log y} \]
    11. Taylor expanded in x around 0 40.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.5 \cdot 10^{-15} \lor \neg \left(x \leq 1.75 \cdot 10^{-276}\right):\\ \;\;\;\;x - z\\ \mathbf{else}:\\ \;\;\;\;\log y \cdot -0.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 99.8% accurate, 1.0× speedup?

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

\\
\left(y - z\right) + \left(x - \log y \cdot \left(y + 0.5\right)\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.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. Final simplification99.9%

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

Alternative 11: 99.8% accurate, 1.0× speedup?

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

\\
\left(x + \left(y - z\right)\right) - \log y \cdot \left(y + 0.5\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.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. *-commutative99.9%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{x + \mathsf{fma}\left(\log y, -0.5 - y, y - z\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. fma-undefine99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 71.0% accurate, 1.0× speedup?

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

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

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


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

    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+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. *-commutative100.0%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(\log y, -0.5 - y, y - z\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(y - z\right) + x\right) - \color{blue}{\left(\sqrt[3]{\log y \cdot \left(y + 0.5\right)} \cdot \sqrt[3]{\log y \cdot \left(y + 0.5\right)}\right) \cdot \sqrt[3]{\log y \cdot \left(y + 0.5\right)}} \]
      2. pow399.4%

        \[\leadsto \left(\left(y - z\right) + x\right) - \color{blue}{{\left(\sqrt[3]{\log y \cdot \left(y + 0.5\right)}\right)}^{3}} \]
    8. Applied egg-rr99.4%

      \[\leadsto \left(\left(y - z\right) + x\right) - \color{blue}{{\left(\sqrt[3]{\log y \cdot \left(y + 0.5\right)}\right)}^{3}} \]
    9. Taylor expanded in y around inf 69.6%

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

    if 5.90000000000000009e97 < 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. *-commutative99.7%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(\log y, -0.5 - y, y - z\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{y \cdot \left(1 - -1 \cdot \log \left(\frac{1}{y}\right)\right)} \]
    8. Step-by-step derivation
      1. *-commutative65.6%

        \[\leadsto y \cdot \left(1 - \color{blue}{\log \left(\frac{1}{y}\right) \cdot -1}\right) \]
      2. log-rec65.6%

        \[\leadsto y \cdot \left(1 - \color{blue}{\left(-\log y\right)} \cdot -1\right) \]
      3. cancel-sign-sub65.6%

        \[\leadsto y \cdot \color{blue}{\left(1 + \log y \cdot -1\right)} \]
      4. *-commutative65.6%

        \[\leadsto y \cdot \left(1 + \color{blue}{-1 \cdot \log y}\right) \]
      5. neg-mul-165.6%

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

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

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

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

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

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

Alternative 13: 47.8% accurate, 9.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.2 \cdot 10^{+29} \lor \neg \left(z \leq 8.8 \cdot 10^{+17}\right):\\
\;\;\;\;-z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -6.1999999999999998e29 or 8.8e17 < 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. *-commutative99.9%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(\log y, -0.5 - y, y - z\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-z} \]
    9. Simplified62.9%

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

    if -6.1999999999999998e29 < z < 8.8e17

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 57.7% 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.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. *-commutative99.9%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{x + \mathsf{fma}\left(\log y, -0.5 - y, y - z\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. fma-undefine99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\left(y - z\right) + x\right) - \color{blue}{\left(\sqrt[3]{\log y \cdot \left(y + 0.5\right)} \cdot \sqrt[3]{\log y \cdot \left(y + 0.5\right)}\right) \cdot \sqrt[3]{\log y \cdot \left(y + 0.5\right)}} \]
    2. pow399.1%

      \[\leadsto \left(\left(y - z\right) + x\right) - \color{blue}{{\left(\sqrt[3]{\log y \cdot \left(y + 0.5\right)}\right)}^{3}} \]
  8. Applied egg-rr99.1%

    \[\leadsto \left(\left(y - z\right) + x\right) - \color{blue}{{\left(\sqrt[3]{\log y \cdot \left(y + 0.5\right)}\right)}^{3}} \]
  9. Taylor expanded in y around inf 82.1%

    \[\leadsto \left(\left(y - z\right) + x\right) - {\left(\sqrt[3]{\color{blue}{-1 \cdot \left(y \cdot \log \left(\frac{1}{y}\right)\right)}}\right)}^{3} \]
  10. Step-by-step derivation
    1. mul-1-neg82.1%

      \[\leadsto \left(\left(y - z\right) + x\right) - {\left(\sqrt[3]{\color{blue}{-y \cdot \log \left(\frac{1}{y}\right)}}\right)}^{3} \]
    2. distribute-rgt-neg-in82.1%

      \[\leadsto \left(\left(y - z\right) + x\right) - {\left(\sqrt[3]{\color{blue}{y \cdot \left(-\log \left(\frac{1}{y}\right)\right)}}\right)}^{3} \]
    3. log-rec82.1%

      \[\leadsto \left(\left(y - z\right) + x\right) - {\left(\sqrt[3]{y \cdot \left(-\color{blue}{\left(-\log y\right)}\right)}\right)}^{3} \]
    4. remove-double-neg82.1%

      \[\leadsto \left(\left(y - z\right) + x\right) - {\left(\sqrt[3]{y \cdot \color{blue}{\log y}}\right)}^{3} \]
  11. Simplified82.1%

    \[\leadsto \left(\left(y - z\right) + x\right) - {\left(\sqrt[3]{\color{blue}{y \cdot \log y}}\right)}^{3} \]
  12. Taylor expanded in y around 0 56.6%

    \[\leadsto \color{blue}{x - z} \]
  13. Final simplification56.6%

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

Alternative 15: 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.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. *-commutative99.9%

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{x} \]
  6. Final simplification30.2%

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

  :herbie-target
  (- (- (+ y x) z) (* (+ y 0.5) (log y)))

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