Numeric.SpecFunctions:incompleteGamma from math-functions-0.1.5.2, A

Percentage Accurate: 99.9% → 99.9%
Time: 10.4s
Alternatives: 11
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 99.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 1.0× speedup?

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

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

    \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
  2. Step-by-step derivation
    1. sub-neg99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 82.0% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_1 := x \cdot \log y - y\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+62} \lor \neg \left(t\_1 \leq 4 \cdot 10^{+24}\right):\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (*.f64 x (log.f64 y)) y) < -1.00000000000000004e62 or 3.9999999999999999e24 < (-.f64 (*.f64 x (log.f64 y)) y)

    1. Initial program 99.8%

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

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

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

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

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

    if -1.00000000000000004e62 < (-.f64 (*.f64 x (log.f64 y)) y) < 3.9999999999999999e24

    1. Initial program 100.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x \cdot \log y + \left(-\left(z - \log t\right)\right)\right) - y} \]
      8. fma-undefine100.0%

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

        \[\leadsto \mathsf{fma}\left(x, \log y, \color{blue}{0 - \left(z - \log t\right)}\right) - y \]
      10. associate-+l-100.0%

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

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

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

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

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

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

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

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

Alternative 3: 85.0% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \log y\\ t_2 := t\_1 - y\\ \mathbf{if}\;t\_2 \leq -1 \cdot 10^{+62}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_2 \leq 4 \cdot 10^{-48}:\\ \;\;\;\;\log t - z\\ \mathbf{else}:\\ \;\;\;\;t\_1 - z\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (log y))) (t_2 (- t_1 y)))
   (if (<= t_2 -1e+62) t_2 (if (<= t_2 4e-48) (- (log t) z) (- t_1 z)))))
double code(double x, double y, double z, double t) {
	double t_1 = x * log(y);
	double t_2 = t_1 - y;
	double tmp;
	if (t_2 <= -1e+62) {
		tmp = t_2;
	} else if (t_2 <= 4e-48) {
		tmp = log(t) - z;
	} else {
		tmp = t_1 - z;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = x * log(y)
    t_2 = t_1 - y
    if (t_2 <= (-1d+62)) then
        tmp = t_2
    else if (t_2 <= 4d-48) then
        tmp = log(t) - z
    else
        tmp = t_1 - z
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = x * Math.log(y);
	double t_2 = t_1 - y;
	double tmp;
	if (t_2 <= -1e+62) {
		tmp = t_2;
	} else if (t_2 <= 4e-48) {
		tmp = Math.log(t) - z;
	} else {
		tmp = t_1 - z;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x * math.log(y)
	t_2 = t_1 - y
	tmp = 0
	if t_2 <= -1e+62:
		tmp = t_2
	elif t_2 <= 4e-48:
		tmp = math.log(t) - z
	else:
		tmp = t_1 - z
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x * log(y))
	t_2 = Float64(t_1 - y)
	tmp = 0.0
	if (t_2 <= -1e+62)
		tmp = t_2;
	elseif (t_2 <= 4e-48)
		tmp = Float64(log(t) - z);
	else
		tmp = Float64(t_1 - z);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = x * log(y);
	t_2 = t_1 - y;
	tmp = 0.0;
	if (t_2 <= -1e+62)
		tmp = t_2;
	elseif (t_2 <= 4e-48)
		tmp = log(t) - z;
	else
		tmp = t_1 - z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 - y), $MachinePrecision]}, If[LessEqual[t$95$2, -1e+62], t$95$2, If[LessEqual[t$95$2, 4e-48], N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision], N[(t$95$1 - z), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \log y\\
t_2 := t\_1 - y\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{+62}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{-48}:\\
\;\;\;\;\log t - z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (*.f64 x (log.f64 y)) y) < -1.00000000000000004e62

    1. Initial program 99.8%

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

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

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

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

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

    if -1.00000000000000004e62 < (-.f64 (*.f64 x (log.f64 y)) y) < 3.9999999999999999e-48

    1. Initial program 100.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x \cdot \log y + \left(-\left(z - \log t\right)\right)\right) - y} \]
      8. fma-undefine100.0%

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

        \[\leadsto \mathsf{fma}\left(x, \log y, \color{blue}{0 - \left(z - \log t\right)}\right) - y \]
      10. associate-+l-100.0%

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

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

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

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

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

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

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

    if 3.9999999999999999e-48 < (-.f64 (*.f64 x (log.f64 y)) y)

    1. Initial program 99.6%

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

        \[\leadsto \color{blue}{\left(x \cdot \log y - y\right) - \left(z - \log t\right)} \]
      2. associate--l-99.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot \log y - y \leq -1 \cdot 10^{+62}:\\ \;\;\;\;x \cdot \log y - y\\ \mathbf{elif}\;x \cdot \log y - y \leq 4 \cdot 10^{-48}:\\ \;\;\;\;\log t - z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \log y - z\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 89.4% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_1 := x \cdot \log y\\
t_2 := t\_1 - y\\
\mathbf{if}\;t\_2 \leq -2.5 \cdot 10^{+155}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{-48}:\\
\;\;\;\;\left(\log t - z\right) - y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (*.f64 x (log.f64 y)) y) < -2.5e155

    1. Initial program 99.8%

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

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

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

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

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

    if -2.5e155 < (-.f64 (*.f64 x (log.f64 y)) y) < 3.9999999999999999e-48

    1. Initial program 100.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x \cdot \log y + \left(-\left(z - \log t\right)\right)\right) - y} \]
      8. fma-undefine100.0%

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

        \[\leadsto \mathsf{fma}\left(x, \log y, \color{blue}{0 - \left(z - \log t\right)}\right) - y \]
      10. associate-+l-100.0%

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

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

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

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

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

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

    if 3.9999999999999999e-48 < (-.f64 (*.f64 x (log.f64 y)) y)

    1. Initial program 99.6%

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

        \[\leadsto \color{blue}{\left(x \cdot \log y - y\right) - \left(z - \log t\right)} \]
      2. associate--l-99.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot \log y - y \leq -2.5 \cdot 10^{+155}:\\ \;\;\;\;x \cdot \log y - y\\ \mathbf{elif}\;x \cdot \log y - y \leq 4 \cdot 10^{-48}:\\ \;\;\;\;\left(\log t - z\right) - y\\ \mathbf{else}:\\ \;\;\;\;x \cdot \log y - z\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 89.4% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_1 := x \cdot \log y\\
t_2 := t\_1 - y\\
\mathbf{if}\;t\_2 \leq -2.5 \cdot 10^{+155}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{-48}:\\
\;\;\;\;\left(\log t - y\right) - z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (*.f64 x (log.f64 y)) y) < -2.5e155

    1. Initial program 99.8%

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

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

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

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

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

    if -2.5e155 < (-.f64 (*.f64 x (log.f64 y)) y) < 3.9999999999999999e-48

    1. Initial program 100.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x \cdot \log y + \left(-\left(z - \log t\right)\right)\right) - y} \]
      8. fma-undefine100.0%

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

        \[\leadsto \mathsf{fma}\left(x, \log y, \color{blue}{0 - \left(z - \log t\right)}\right) - y \]
      10. associate-+l-100.0%

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

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

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

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

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

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

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

    if 3.9999999999999999e-48 < (-.f64 (*.f64 x (log.f64 y)) y)

    1. Initial program 99.6%

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

        \[\leadsto \color{blue}{\left(x \cdot \log y - y\right) - \left(z - \log t\right)} \]
      2. associate--l-99.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot \log y - y \leq -2.5 \cdot 10^{+155}:\\ \;\;\;\;x \cdot \log y - y\\ \mathbf{elif}\;x \cdot \log y - y \leq 4 \cdot 10^{-48}:\\ \;\;\;\;\left(\log t - y\right) - z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \log y - z\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 99.9% accurate, 1.0× speedup?

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

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

    \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
  2. Add Preprocessing
  3. Final simplification99.8%

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

Alternative 7: 55.5% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \log t - y\\ t_2 := x \cdot \log y\\ \mathbf{if}\;z \leq -1.72 \cdot 10^{+19}:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \leq -1.2 \cdot 10^{-25}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;z \leq -1.5 \cdot 10^{-164}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{-218}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{+32}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- (log t) y)) (t_2 (* x (log y))))
   (if (<= z -1.72e+19)
     (- z)
     (if (<= z -1.2e-25)
       t_2
       (if (<= z -1.5e-164)
         t_1
         (if (<= z 6.2e-218) t_2 (if (<= z 4.8e+32) t_1 (- z))))))))
double code(double x, double y, double z, double t) {
	double t_1 = log(t) - y;
	double t_2 = x * log(y);
	double tmp;
	if (z <= -1.72e+19) {
		tmp = -z;
	} else if (z <= -1.2e-25) {
		tmp = t_2;
	} else if (z <= -1.5e-164) {
		tmp = t_1;
	} else if (z <= 6.2e-218) {
		tmp = t_2;
	} else if (z <= 4.8e+32) {
		tmp = t_1;
	} else {
		tmp = -z;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = log(t) - y
    t_2 = x * log(y)
    if (z <= (-1.72d+19)) then
        tmp = -z
    else if (z <= (-1.2d-25)) then
        tmp = t_2
    else if (z <= (-1.5d-164)) then
        tmp = t_1
    else if (z <= 6.2d-218) then
        tmp = t_2
    else if (z <= 4.8d+32) then
        tmp = t_1
    else
        tmp = -z
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = Math.log(t) - y;
	double t_2 = x * Math.log(y);
	double tmp;
	if (z <= -1.72e+19) {
		tmp = -z;
	} else if (z <= -1.2e-25) {
		tmp = t_2;
	} else if (z <= -1.5e-164) {
		tmp = t_1;
	} else if (z <= 6.2e-218) {
		tmp = t_2;
	} else if (z <= 4.8e+32) {
		tmp = t_1;
	} else {
		tmp = -z;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = math.log(t) - y
	t_2 = x * math.log(y)
	tmp = 0
	if z <= -1.72e+19:
		tmp = -z
	elif z <= -1.2e-25:
		tmp = t_2
	elif z <= -1.5e-164:
		tmp = t_1
	elif z <= 6.2e-218:
		tmp = t_2
	elif z <= 4.8e+32:
		tmp = t_1
	else:
		tmp = -z
	return tmp
function code(x, y, z, t)
	t_1 = Float64(log(t) - y)
	t_2 = Float64(x * log(y))
	tmp = 0.0
	if (z <= -1.72e+19)
		tmp = Float64(-z);
	elseif (z <= -1.2e-25)
		tmp = t_2;
	elseif (z <= -1.5e-164)
		tmp = t_1;
	elseif (z <= 6.2e-218)
		tmp = t_2;
	elseif (z <= 4.8e+32)
		tmp = t_1;
	else
		tmp = Float64(-z);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = log(t) - y;
	t_2 = x * log(y);
	tmp = 0.0;
	if (z <= -1.72e+19)
		tmp = -z;
	elseif (z <= -1.2e-25)
		tmp = t_2;
	elseif (z <= -1.5e-164)
		tmp = t_1;
	elseif (z <= 6.2e-218)
		tmp = t_2;
	elseif (z <= 4.8e+32)
		tmp = t_1;
	else
		tmp = -z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision]}, Block[{t$95$2 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.72e+19], (-z), If[LessEqual[z, -1.2e-25], t$95$2, If[LessEqual[z, -1.5e-164], t$95$1, If[LessEqual[z, 6.2e-218], t$95$2, If[LessEqual[z, 4.8e+32], t$95$1, (-z)]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \log t - y\\
t_2 := x \cdot \log y\\
\mathbf{if}\;z \leq -1.72 \cdot 10^{+19}:\\
\;\;\;\;-z\\

\mathbf{elif}\;z \leq -1.2 \cdot 10^{-25}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;z \leq -1.5 \cdot 10^{-164}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 6.2 \cdot 10^{-218}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;z \leq 4.8 \cdot 10^{+32}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.72e19 or 4.79999999999999983e32 < z

    1. Initial program 99.9%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Step-by-step derivation
      1. sub-neg99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.72e19 < z < -1.20000000000000005e-25 or -1.5e-164 < z < 6.19999999999999994e-218

    1. Initial program 99.7%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Step-by-step derivation
      1. sub-neg99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.20000000000000005e-25 < z < -1.5e-164 or 6.19999999999999994e-218 < z < 4.79999999999999983e32

    1. Initial program 99.9%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x \cdot \log y + \left(-\left(z - \log t\right)\right)\right) - y} \]
      8. fma-undefine99.9%

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

        \[\leadsto \mathsf{fma}\left(x, \log y, \color{blue}{0 - \left(z - \log t\right)}\right) - y \]
      10. associate-+l-99.9%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.72 \cdot 10^{+19}:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \leq -1.2 \cdot 10^{-25}:\\ \;\;\;\;x \cdot \log y\\ \mathbf{elif}\;z \leq -1.5 \cdot 10^{-164}:\\ \;\;\;\;\log t - y\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{-218}:\\ \;\;\;\;x \cdot \log y\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{+32}:\\ \;\;\;\;\log t - y\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 60.9% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \log y\\ t_2 := \log t - z\\ \mathbf{if}\;x \leq -1.45 \cdot 10^{+54}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq -1.02 \cdot 10^{-57}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;x \leq -1.7 \cdot 10^{-303}:\\ \;\;\;\;\log t - y\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{+82}:\\ \;\;\;\;t\_2\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (log y))) (t_2 (- (log t) z)))
   (if (<= x -1.45e+54)
     t_1
     (if (<= x -1.02e-57)
       t_2
       (if (<= x -1.7e-303) (- (log t) y) (if (<= x 1.15e+82) t_2 t_1))))))
double code(double x, double y, double z, double t) {
	double t_1 = x * log(y);
	double t_2 = log(t) - z;
	double tmp;
	if (x <= -1.45e+54) {
		tmp = t_1;
	} else if (x <= -1.02e-57) {
		tmp = t_2;
	} else if (x <= -1.7e-303) {
		tmp = log(t) - y;
	} else if (x <= 1.15e+82) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = x * log(y)
    t_2 = log(t) - z
    if (x <= (-1.45d+54)) then
        tmp = t_1
    else if (x <= (-1.02d-57)) then
        tmp = t_2
    else if (x <= (-1.7d-303)) then
        tmp = log(t) - y
    else if (x <= 1.15d+82) then
        tmp = t_2
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = x * Math.log(y);
	double t_2 = Math.log(t) - z;
	double tmp;
	if (x <= -1.45e+54) {
		tmp = t_1;
	} else if (x <= -1.02e-57) {
		tmp = t_2;
	} else if (x <= -1.7e-303) {
		tmp = Math.log(t) - y;
	} else if (x <= 1.15e+82) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x * math.log(y)
	t_2 = math.log(t) - z
	tmp = 0
	if x <= -1.45e+54:
		tmp = t_1
	elif x <= -1.02e-57:
		tmp = t_2
	elif x <= -1.7e-303:
		tmp = math.log(t) - y
	elif x <= 1.15e+82:
		tmp = t_2
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x * log(y))
	t_2 = Float64(log(t) - z)
	tmp = 0.0
	if (x <= -1.45e+54)
		tmp = t_1;
	elseif (x <= -1.02e-57)
		tmp = t_2;
	elseif (x <= -1.7e-303)
		tmp = Float64(log(t) - y);
	elseif (x <= 1.15e+82)
		tmp = t_2;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = x * log(y);
	t_2 = log(t) - z;
	tmp = 0.0;
	if (x <= -1.45e+54)
		tmp = t_1;
	elseif (x <= -1.02e-57)
		tmp = t_2;
	elseif (x <= -1.7e-303)
		tmp = log(t) - y;
	elseif (x <= 1.15e+82)
		tmp = t_2;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[x, -1.45e+54], t$95$1, If[LessEqual[x, -1.02e-57], t$95$2, If[LessEqual[x, -1.7e-303], N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision], If[LessEqual[x, 1.15e+82], t$95$2, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \log y\\
t_2 := \log t - z\\
\mathbf{if}\;x \leq -1.45 \cdot 10^{+54}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq -1.02 \cdot 10^{-57}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \leq -1.7 \cdot 10^{-303}:\\
\;\;\;\;\log t - y\\

\mathbf{elif}\;x \leq 1.15 \cdot 10^{+82}:\\
\;\;\;\;t\_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.4499999999999999e54 or 1.14999999999999994e82 < x

    1. Initial program 99.7%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Step-by-step derivation
      1. sub-neg99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.4499999999999999e54 < x < -1.02e-57 or -1.7e-303 < x < 1.14999999999999994e82

    1. Initial program 100.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x \cdot \log y + \left(-\left(z - \log t\right)\right)\right) - y} \]
      8. fma-undefine100.0%

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

        \[\leadsto \mathsf{fma}\left(x, \log y, \color{blue}{0 - \left(z - \log t\right)}\right) - y \]
      10. associate-+l-100.0%

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

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

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

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

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

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

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

    if -1.02e-57 < x < -1.7e-303

    1. Initial program 100.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x \cdot \log y + \left(-\left(z - \log t\right)\right)\right) - y} \]
      8. fma-undefine100.0%

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

        \[\leadsto \mathsf{fma}\left(x, \log y, \color{blue}{0 - \left(z - \log t\right)}\right) - y \]
      10. associate-+l-100.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\log t - y} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification68.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.45 \cdot 10^{+54}:\\ \;\;\;\;x \cdot \log y\\ \mathbf{elif}\;x \leq -1.02 \cdot 10^{-57}:\\ \;\;\;\;\log t - z\\ \mathbf{elif}\;x \leq -1.7 \cdot 10^{-303}:\\ \;\;\;\;\log t - y\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{+82}:\\ \;\;\;\;\log t - z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \log y\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 48.9% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -8.2 \cdot 10^{+18}:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \leq 3.1 \cdot 10^{-127}:\\ \;\;\;\;x \cdot \log y\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{+30}:\\ \;\;\;\;-y\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= z -8.2e+18)
   (- z)
   (if (<= z 3.1e-127) (* x (log y)) (if (<= z 8.5e+30) (- y) (- z)))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -8.2e+18) {
		tmp = -z;
	} else if (z <= 3.1e-127) {
		tmp = x * log(y);
	} else if (z <= 8.5e+30) {
		tmp = -y;
	} else {
		tmp = -z;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (z <= (-8.2d+18)) then
        tmp = -z
    else if (z <= 3.1d-127) then
        tmp = x * log(y)
    else if (z <= 8.5d+30) then
        tmp = -y
    else
        tmp = -z
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -8.2e+18) {
		tmp = -z;
	} else if (z <= 3.1e-127) {
		tmp = x * Math.log(y);
	} else if (z <= 8.5e+30) {
		tmp = -y;
	} else {
		tmp = -z;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if z <= -8.2e+18:
		tmp = -z
	elif z <= 3.1e-127:
		tmp = x * math.log(y)
	elif z <= 8.5e+30:
		tmp = -y
	else:
		tmp = -z
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (z <= -8.2e+18)
		tmp = Float64(-z);
	elseif (z <= 3.1e-127)
		tmp = Float64(x * log(y));
	elseif (z <= 8.5e+30)
		tmp = Float64(-y);
	else
		tmp = Float64(-z);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (z <= -8.2e+18)
		tmp = -z;
	elseif (z <= 3.1e-127)
		tmp = x * log(y);
	elseif (z <= 8.5e+30)
		tmp = -y;
	else
		tmp = -z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[z, -8.2e+18], (-z), If[LessEqual[z, 3.1e-127], N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 8.5e+30], (-y), (-z)]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.2 \cdot 10^{+18}:\\
\;\;\;\;-z\\

\mathbf{elif}\;z \leq 3.1 \cdot 10^{-127}:\\
\;\;\;\;x \cdot \log y\\

\mathbf{elif}\;z \leq 8.5 \cdot 10^{+30}:\\
\;\;\;\;-y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -8.2e18 or 8.4999999999999995e30 < z

    1. Initial program 99.9%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Step-by-step derivation
      1. sub-neg99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.2e18 < z < 3.1e-127

    1. Initial program 99.8%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Step-by-step derivation
      1. sub-neg99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.1e-127 < z < 8.4999999999999995e30

    1. Initial program 99.8%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Step-by-step derivation
      1. sub-neg99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-y} \]
    9. Simplified49.4%

      \[\leadsto \color{blue}{-y} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification57.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -8.2 \cdot 10^{+18}:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \leq 3.1 \cdot 10^{-127}:\\ \;\;\;\;x \cdot \log y\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{+30}:\\ \;\;\;\;-y\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 48.5% accurate, 29.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.5 \cdot 10^{+57}:\\
\;\;\;\;-z\\

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


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

    1. Initial program 99.8%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Step-by-step derivation
      1. sub-neg99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.5000000000000006e57 < y

    1. Initial program 99.8%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Step-by-step derivation
      1. sub-neg99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-y} \]
    9. Simplified55.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 7.5 \cdot 10^{+57}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;-y\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 30.2% accurate, 104.5× speedup?

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

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

    \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
  2. Step-by-step derivation
    1. sub-neg99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-y} \]
  9. Simplified25.3%

    \[\leadsto \color{blue}{-y} \]
  10. Final simplification25.3%

    \[\leadsto -y \]
  11. Add Preprocessing

Reproduce

?
herbie shell --seed 2024077 
(FPCore (x y z t)
  :name "Numeric.SpecFunctions:incompleteGamma from math-functions-0.1.5.2, A"
  :precision binary64
  (+ (- (- (* x (log y)) y) z) (log t)))