Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2

Percentage Accurate: 99.8% → 99.9%
Time: 11.0s
Alternatives: 13
Speedup: 0.5×

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 13 alternatives:

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

Initial Program: 99.8% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 0.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 76.8% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(1 - \log y\right)\\ t_1 := x + t\_0\\ \mathbf{if}\;z \leq -1.6 \cdot 10^{+119}:\\ \;\;\;\;t\_0 - z\\ \mathbf{elif}\;z \leq -2600000000000:\\ \;\;\;\;x - z\\ \mathbf{elif}\;z \leq -3.8 \cdot 10^{-103}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq -3.6 \cdot 10^{-138}:\\ \;\;\;\;y - \log y \cdot \left(y + 0.5\right)\\ \mathbf{elif}\;z \leq 2.3 \cdot 10^{+57}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;x - z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (- 1.0 (log y)))) (t_1 (+ x t_0)))
   (if (<= z -1.6e+119)
     (- t_0 z)
     (if (<= z -2600000000000.0)
       (- x z)
       (if (<= z -3.8e-103)
         t_1
         (if (<= z -3.6e-138)
           (- y (* (log y) (+ y 0.5)))
           (if (<= z 2.3e+57) t_1 (- x z))))))))
double code(double x, double y, double z) {
	double t_0 = y * (1.0 - log(y));
	double t_1 = x + t_0;
	double tmp;
	if (z <= -1.6e+119) {
		tmp = t_0 - z;
	} else if (z <= -2600000000000.0) {
		tmp = x - z;
	} else if (z <= -3.8e-103) {
		tmp = t_1;
	} else if (z <= -3.6e-138) {
		tmp = y - (log(y) * (y + 0.5));
	} else if (z <= 2.3e+57) {
		tmp = t_1;
	} else {
		tmp = x - z;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = y * (1.0d0 - log(y))
    t_1 = x + t_0
    if (z <= (-1.6d+119)) then
        tmp = t_0 - z
    else if (z <= (-2600000000000.0d0)) then
        tmp = x - z
    else if (z <= (-3.8d-103)) then
        tmp = t_1
    else if (z <= (-3.6d-138)) then
        tmp = y - (log(y) * (y + 0.5d0))
    else if (z <= 2.3d+57) then
        tmp = t_1
    else
        tmp = x - z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = y * (1.0 - Math.log(y));
	double t_1 = x + t_0;
	double tmp;
	if (z <= -1.6e+119) {
		tmp = t_0 - z;
	} else if (z <= -2600000000000.0) {
		tmp = x - z;
	} else if (z <= -3.8e-103) {
		tmp = t_1;
	} else if (z <= -3.6e-138) {
		tmp = y - (Math.log(y) * (y + 0.5));
	} else if (z <= 2.3e+57) {
		tmp = t_1;
	} else {
		tmp = x - z;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (1.0 - math.log(y))
	t_1 = x + t_0
	tmp = 0
	if z <= -1.6e+119:
		tmp = t_0 - z
	elif z <= -2600000000000.0:
		tmp = x - z
	elif z <= -3.8e-103:
		tmp = t_1
	elif z <= -3.6e-138:
		tmp = y - (math.log(y) * (y + 0.5))
	elif z <= 2.3e+57:
		tmp = t_1
	else:
		tmp = x - z
	return tmp
function code(x, y, z)
	t_0 = Float64(y * Float64(1.0 - log(y)))
	t_1 = Float64(x + t_0)
	tmp = 0.0
	if (z <= -1.6e+119)
		tmp = Float64(t_0 - z);
	elseif (z <= -2600000000000.0)
		tmp = Float64(x - z);
	elseif (z <= -3.8e-103)
		tmp = t_1;
	elseif (z <= -3.6e-138)
		tmp = Float64(y - Float64(log(y) * Float64(y + 0.5)));
	elseif (z <= 2.3e+57)
		tmp = t_1;
	else
		tmp = Float64(x - z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y * (1.0 - log(y));
	t_1 = x + t_0;
	tmp = 0.0;
	if (z <= -1.6e+119)
		tmp = t_0 - z;
	elseif (z <= -2600000000000.0)
		tmp = x - z;
	elseif (z <= -3.8e-103)
		tmp = t_1;
	elseif (z <= -3.6e-138)
		tmp = y - (log(y) * (y + 0.5));
	elseif (z <= 2.3e+57)
		tmp = t_1;
	else
		tmp = x - z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x + t$95$0), $MachinePrecision]}, If[LessEqual[z, -1.6e+119], N[(t$95$0 - z), $MachinePrecision], If[LessEqual[z, -2600000000000.0], N[(x - z), $MachinePrecision], If[LessEqual[z, -3.8e-103], t$95$1, If[LessEqual[z, -3.6e-138], N[(y - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.3e+57], t$95$1, N[(x - z), $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y \cdot \left(1 - \log y\right)\\
t_1 := x + t\_0\\
\mathbf{if}\;z \leq -1.6 \cdot 10^{+119}:\\
\;\;\;\;t\_0 - z\\

\mathbf{elif}\;z \leq -2600000000000:\\
\;\;\;\;x - z\\

\mathbf{elif}\;z \leq -3.8 \cdot 10^{-103}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;z \leq 2.3 \cdot 10^{+57}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -1.59999999999999995e119

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.59999999999999995e119 < z < -2.6e12 or 2.2999999999999999e57 < z

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.6e12 < z < -3.8000000000000001e-103 or -3.60000000000000018e-138 < z < 2.2999999999999999e57

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.8000000000000001e-103 < z < -3.60000000000000018e-138

    1. Initial program 99.7%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.6 \cdot 10^{+119}:\\ \;\;\;\;y \cdot \left(1 - \log y\right) - z\\ \mathbf{elif}\;z \leq -2600000000000:\\ \;\;\;\;x - z\\ \mathbf{elif}\;z \leq -3.8 \cdot 10^{-103}:\\ \;\;\;\;x + y \cdot \left(1 - \log y\right)\\ \mathbf{elif}\;z \leq -3.6 \cdot 10^{-138}:\\ \;\;\;\;y - \log y \cdot \left(y + 0.5\right)\\ \mathbf{elif}\;z \leq 2.3 \cdot 10^{+57}:\\ \;\;\;\;x + y \cdot \left(1 - \log y\right)\\ \mathbf{else}:\\ \;\;\;\;x - z\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 69.8% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 3.6 \cdot 10^{-248}:\\ \;\;\;\;x - z\\ \mathbf{elif}\;y \leq 4.4 \cdot 10^{-209}:\\ \;\;\;\;x - \log y \cdot 0.5\\ \mathbf{elif}\;y \leq 2.85 \cdot 10^{+137} \lor \neg \left(y \leq 1.35 \cdot 10^{+174}\right) \land y \leq 9 \cdot 10^{+183}:\\ \;\;\;\;x - z\\ \mathbf{else}:\\ \;\;\;\;y - y \cdot \log y\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y 3.6e-248)
   (- x z)
   (if (<= y 4.4e-209)
     (- x (* (log y) 0.5))
     (if (or (<= y 2.85e+137) (and (not (<= y 1.35e+174)) (<= y 9e+183)))
       (- x z)
       (- y (* y (log y)))))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= 3.6e-248) {
		tmp = x - z;
	} else if (y <= 4.4e-209) {
		tmp = x - (log(y) * 0.5);
	} else if ((y <= 2.85e+137) || (!(y <= 1.35e+174) && (y <= 9e+183))) {
		tmp = x - z;
	} else {
		tmp = y - (y * log(y));
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= 3.6d-248) then
        tmp = x - z
    else if (y <= 4.4d-209) then
        tmp = x - (log(y) * 0.5d0)
    else if ((y <= 2.85d+137) .or. (.not. (y <= 1.35d+174)) .and. (y <= 9d+183)) then
        tmp = x - z
    else
        tmp = y - (y * log(y))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= 3.6e-248) {
		tmp = x - z;
	} else if (y <= 4.4e-209) {
		tmp = x - (Math.log(y) * 0.5);
	} else if ((y <= 2.85e+137) || (!(y <= 1.35e+174) && (y <= 9e+183))) {
		tmp = x - z;
	} else {
		tmp = y - (y * Math.log(y));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= 3.6e-248:
		tmp = x - z
	elif y <= 4.4e-209:
		tmp = x - (math.log(y) * 0.5)
	elif (y <= 2.85e+137) or (not (y <= 1.35e+174) and (y <= 9e+183)):
		tmp = x - z
	else:
		tmp = y - (y * math.log(y))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= 3.6e-248)
		tmp = Float64(x - z);
	elseif (y <= 4.4e-209)
		tmp = Float64(x - Float64(log(y) * 0.5));
	elseif ((y <= 2.85e+137) || (!(y <= 1.35e+174) && (y <= 9e+183)))
		tmp = Float64(x - z);
	else
		tmp = Float64(y - Float64(y * log(y)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= 3.6e-248)
		tmp = x - z;
	elseif (y <= 4.4e-209)
		tmp = x - (log(y) * 0.5);
	elseif ((y <= 2.85e+137) || (~((y <= 1.35e+174)) && (y <= 9e+183)))
		tmp = x - z;
	else
		tmp = y - (y * log(y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, 3.6e-248], N[(x - z), $MachinePrecision], If[LessEqual[y, 4.4e-209], N[(x - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 2.85e+137], And[N[Not[LessEqual[y, 1.35e+174]], $MachinePrecision], LessEqual[y, 9e+183]]], N[(x - z), $MachinePrecision], N[(y - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.6 \cdot 10^{-248}:\\
\;\;\;\;x - z\\

\mathbf{elif}\;y \leq 4.4 \cdot 10^{-209}:\\
\;\;\;\;x - \log y \cdot 0.5\\

\mathbf{elif}\;y \leq 2.85 \cdot 10^{+137} \lor \neg \left(y \leq 1.35 \cdot 10^{+174}\right) \land y \leq 9 \cdot 10^{+183}:\\
\;\;\;\;x - z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 3.59999999999999985e-248 or 4.40000000000000019e-209 < y < 2.8499999999999999e137 or 1.35e174 < y < 9.00000000000000034e183

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.59999999999999985e-248 < y < 4.40000000000000019e-209

    1. Initial program 100.0%

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

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

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

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

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

    if 2.8499999999999999e137 < y < 1.35e174 or 9.00000000000000034e183 < y

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 3.6 \cdot 10^{-248}:\\ \;\;\;\;x - z\\ \mathbf{elif}\;y \leq 4.4 \cdot 10^{-209}:\\ \;\;\;\;x - \log y \cdot 0.5\\ \mathbf{elif}\;y \leq 2.85 \cdot 10^{+137} \lor \neg \left(y \leq 1.35 \cdot 10^{+174}\right) \land y \leq 9 \cdot 10^{+183}:\\ \;\;\;\;x - z\\ \mathbf{else}:\\ \;\;\;\;y - y \cdot \log y\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 76.6% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x + y \cdot \left(1 - \log y\right)\\ \mathbf{if}\;z \leq -700000000000:\\ \;\;\;\;x - z\\ \mathbf{elif}\;z \leq -3.8 \cdot 10^{-103}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq -3 \cdot 10^{-138}:\\ \;\;\;\;y - \log y \cdot \left(y + 0.5\right)\\ \mathbf{elif}\;z \leq 7 \cdot 10^{+56}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;x - z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ x (* y (- 1.0 (log y))))))
   (if (<= z -700000000000.0)
     (- x z)
     (if (<= z -3.8e-103)
       t_0
       (if (<= z -3e-138)
         (- y (* (log y) (+ y 0.5)))
         (if (<= z 7e+56) t_0 (- x z)))))))
double code(double x, double y, double z) {
	double t_0 = x + (y * (1.0 - log(y)));
	double tmp;
	if (z <= -700000000000.0) {
		tmp = x - z;
	} else if (z <= -3.8e-103) {
		tmp = t_0;
	} else if (z <= -3e-138) {
		tmp = y - (log(y) * (y + 0.5));
	} else if (z <= 7e+56) {
		tmp = t_0;
	} else {
		tmp = x - z;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = x + (y * (1.0d0 - log(y)))
    if (z <= (-700000000000.0d0)) then
        tmp = x - z
    else if (z <= (-3.8d-103)) then
        tmp = t_0
    else if (z <= (-3d-138)) then
        tmp = y - (log(y) * (y + 0.5d0))
    else if (z <= 7d+56) then
        tmp = t_0
    else
        tmp = x - z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = x + (y * (1.0 - Math.log(y)));
	double tmp;
	if (z <= -700000000000.0) {
		tmp = x - z;
	} else if (z <= -3.8e-103) {
		tmp = t_0;
	} else if (z <= -3e-138) {
		tmp = y - (Math.log(y) * (y + 0.5));
	} else if (z <= 7e+56) {
		tmp = t_0;
	} else {
		tmp = x - z;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x + (y * (1.0 - math.log(y)))
	tmp = 0
	if z <= -700000000000.0:
		tmp = x - z
	elif z <= -3.8e-103:
		tmp = t_0
	elif z <= -3e-138:
		tmp = y - (math.log(y) * (y + 0.5))
	elif z <= 7e+56:
		tmp = t_0
	else:
		tmp = x - z
	return tmp
function code(x, y, z)
	t_0 = Float64(x + Float64(y * Float64(1.0 - log(y))))
	tmp = 0.0
	if (z <= -700000000000.0)
		tmp = Float64(x - z);
	elseif (z <= -3.8e-103)
		tmp = t_0;
	elseif (z <= -3e-138)
		tmp = Float64(y - Float64(log(y) * Float64(y + 0.5)));
	elseif (z <= 7e+56)
		tmp = t_0;
	else
		tmp = Float64(x - z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x + (y * (1.0 - log(y)));
	tmp = 0.0;
	if (z <= -700000000000.0)
		tmp = x - z;
	elseif (z <= -3.8e-103)
		tmp = t_0;
	elseif (z <= -3e-138)
		tmp = y - (log(y) * (y + 0.5));
	elseif (z <= 7e+56)
		tmp = t_0;
	else
		tmp = x - z;
	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[z, -700000000000.0], N[(x - z), $MachinePrecision], If[LessEqual[z, -3.8e-103], t$95$0, If[LessEqual[z, -3e-138], N[(y - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 7e+56], t$95$0, N[(x - z), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -3.8 \cdot 10^{-103}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;z \leq 7 \cdot 10^{+56}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -7e11 or 6.99999999999999999e56 < z

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7e11 < z < -3.8000000000000001e-103 or -3.0000000000000001e-138 < z < 6.99999999999999999e56

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.8000000000000001e-103 < z < -3.0000000000000001e-138

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

Alternative 5: 76.9% accurate, 0.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.6e12 or 6.4999999999999997e57 < z

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.6e12 < z < 6.4999999999999997e57

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 88.4% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;y \leq 4.2 \cdot 10^{+183}:\\
\;\;\;\;x + t\_0\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0019 < y < 4.2e183

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.2e183 < y

    1. Initial program 99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 70.5% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -8500 \lor \neg \left(x \leq 360000000\right):\\
\;\;\;\;x - z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -8500 or 3.6e8 < x

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8500 < x < 3.6e8

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.5 \cdot \log y} - z \]
    9. Step-by-step derivation
      1. *-commutative66.2%

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

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

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

Alternative 8: 70.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -14000000000 \lor \neg \left(z \leq 200\right):\\ \;\;\;\;x - z\\ \mathbf{else}:\\ \;\;\;\;x - \log y \cdot 0.5\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -14000000000.0) (not (<= z 200.0)))
   (- x z)
   (- x (* (log y) 0.5))))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -14000000000.0) || !(z <= 200.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 <= (-14000000000.0d0)) .or. (.not. (z <= 200.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 <= -14000000000.0) || !(z <= 200.0)) {
		tmp = x - z;
	} else {
		tmp = x - (Math.log(y) * 0.5);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -14000000000.0) or not (z <= 200.0):
		tmp = x - z
	else:
		tmp = x - (math.log(y) * 0.5)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -14000000000.0) || !(z <= 200.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 <= -14000000000.0) || ~((z <= 200.0)))
		tmp = x - z;
	else
		tmp = x - (log(y) * 0.5);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -14000000000.0], N[Not[LessEqual[z, 200.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 -14000000000 \lor \neg \left(z \leq 200\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.4e10 or 200 < z

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.4e10 < z < 200

    1. Initial program 99.8%

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

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

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

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

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

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

Alternative 9: 99.3% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0019 < y

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 99.8% accurate, 1.0× speedup?

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

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

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

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

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

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

Alternative 11: 47.9% accurate, 9.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.009 \lor \neg \left(z \leq 1.7 \cdot 10^{+19}\right):\\
\;\;\;\;-z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -0.00899999999999999932 or 1.7e19 < z

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-z} \]
    7. Simplified67.4%

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

    if -0.00899999999999999932 < z < 1.7e19

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 58.0% accurate, 37.0× speedup?

\[\begin{array}{l} \\ x - z \end{array} \]
(FPCore (x y z) :precision binary64 (- x z))
double code(double x, double y, double z) {
	return x - z;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x - z
end function
public static double code(double x, double y, double z) {
	return x - z;
}
def code(x, y, z):
	return x - z
function code(x, y, z)
	return Float64(x - z)
end
function tmp = code(x, y, z)
	tmp = x - z;
end
code[x_, y_, z_] := N[(x - z), $MachinePrecision]
\begin{array}{l}

\\
x - z
\end{array}
Derivation
  1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 29.9% accurate, 111.0× speedup?

\[\begin{array}{l} \\ x \end{array} \]
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
	return x;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x
end function
public static double code(double x, double y, double z) {
	return x;
}
def code(x, y, z):
	return x
function code(x, y, z)
	return x
end
function tmp = code(x, y, z)
	tmp = x;
end
code[x_, y_, z_] := x
\begin{array}{l}

\\
x
\end{array}
Derivation
  1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{x} \]
  6. 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 2024081 
(FPCore (x y z)
  :name "Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2"
  :precision binary64

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

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