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

Percentage Accurate: 99.9% → 99.9%
Time: 10.2s
Alternatives: 12
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 12 alternatives:

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

Initial Program: 99.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, 0.7× speedup?

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

\\
\mathsf{fma}\left(x, \log y, \left(-z\right) - y\right) + \log t
\end{array}
Derivation
  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. Final simplification99.9%

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

Alternative 2: 84.6% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \log y - y\\ t_2 := \left(-z\right) - y\\ \mathbf{if}\;t\_1 \leq -5 \cdot 10^{+169}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_1 \leq -5 \cdot 10^{+129}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_1 \leq -4 \cdot 10^{+88}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_1 \leq -4 \cdot 10^{+15}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_1 \leq 10^{+44}:\\ \;\;\;\;\log t - z\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- (* x (log y)) y)) (t_2 (- (- z) y)))
   (if (<= t_1 -5e+169)
     t_1
     (if (<= t_1 -5e+129)
       t_2
       (if (<= t_1 -4e+88)
         t_1
         (if (<= t_1 -4e+15) t_2 (if (<= t_1 1e+44) (- (log t) z) t_1)))))))
double code(double x, double y, double z, double t) {
	double t_1 = (x * log(y)) - y;
	double t_2 = -z - y;
	double tmp;
	if (t_1 <= -5e+169) {
		tmp = t_1;
	} else if (t_1 <= -5e+129) {
		tmp = t_2;
	} else if (t_1 <= -4e+88) {
		tmp = t_1;
	} else if (t_1 <= -4e+15) {
		tmp = t_2;
	} else if (t_1 <= 1e+44) {
		tmp = log(t) - z;
	} 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)) - y
    t_2 = -z - y
    if (t_1 <= (-5d+169)) then
        tmp = t_1
    else if (t_1 <= (-5d+129)) then
        tmp = t_2
    else if (t_1 <= (-4d+88)) then
        tmp = t_1
    else if (t_1 <= (-4d+15)) then
        tmp = t_2
    else if (t_1 <= 1d+44) then
        tmp = log(t) - z
    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)) - y;
	double t_2 = -z - y;
	double tmp;
	if (t_1 <= -5e+169) {
		tmp = t_1;
	} else if (t_1 <= -5e+129) {
		tmp = t_2;
	} else if (t_1 <= -4e+88) {
		tmp = t_1;
	} else if (t_1 <= -4e+15) {
		tmp = t_2;
	} else if (t_1 <= 1e+44) {
		tmp = Math.log(t) - z;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = (x * math.log(y)) - y
	t_2 = -z - y
	tmp = 0
	if t_1 <= -5e+169:
		tmp = t_1
	elif t_1 <= -5e+129:
		tmp = t_2
	elif t_1 <= -4e+88:
		tmp = t_1
	elif t_1 <= -4e+15:
		tmp = t_2
	elif t_1 <= 1e+44:
		tmp = math.log(t) - z
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(Float64(x * log(y)) - y)
	t_2 = Float64(Float64(-z) - y)
	tmp = 0.0
	if (t_1 <= -5e+169)
		tmp = t_1;
	elseif (t_1 <= -5e+129)
		tmp = t_2;
	elseif (t_1 <= -4e+88)
		tmp = t_1;
	elseif (t_1 <= -4e+15)
		tmp = t_2;
	elseif (t_1 <= 1e+44)
		tmp = Float64(log(t) - z);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = (x * log(y)) - y;
	t_2 = -z - y;
	tmp = 0.0;
	if (t_1 <= -5e+169)
		tmp = t_1;
	elseif (t_1 <= -5e+129)
		tmp = t_2;
	elseif (t_1 <= -4e+88)
		tmp = t_1;
	elseif (t_1 <= -4e+15)
		tmp = t_2;
	elseif (t_1 <= 1e+44)
		tmp = log(t) - z;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]}, Block[{t$95$2 = N[((-z) - y), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+169], t$95$1, If[LessEqual[t$95$1, -5e+129], t$95$2, If[LessEqual[t$95$1, -4e+88], t$95$1, If[LessEqual[t$95$1, -4e+15], t$95$2, If[LessEqual[t$95$1, 1e+44], N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \log y - y\\
t_2 := \left(-z\right) - y\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+169}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_1 \leq -5 \cdot 10^{+129}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_1 \leq -4 \cdot 10^{+88}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_1 \leq -4 \cdot 10^{+15}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_1 \leq 10^{+44}:\\
\;\;\;\;\log t - z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (*.f64 x (log.f64 y)) y) < -5.00000000000000017e169 or -5.0000000000000003e129 < (-.f64 (*.f64 x (log.f64 y)) y) < -3.99999999999999984e88 or 1.0000000000000001e44 < (-.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 z around inf 99.8%

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

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

    if -5.00000000000000017e169 < (-.f64 (*.f64 x (log.f64 y)) y) < -5.0000000000000003e129 or -3.99999999999999984e88 < (-.f64 (*.f64 x (log.f64 y)) y) < -4e15

    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. associate--l-99.9%

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

      \[\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 99.6%

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

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

        \[\leadsto \color{blue}{-\left(y + z\right)} \]
      2. neg-sub076.7%

        \[\leadsto \color{blue}{0 - \left(y + z\right)} \]
      3. +-commutative76.7%

        \[\leadsto 0 - \color{blue}{\left(z + y\right)} \]
      4. associate--r+76.7%

        \[\leadsto \color{blue}{\left(0 - z\right) - y} \]
      5. neg-sub076.7%

        \[\leadsto \color{blue}{\left(-z\right)} - y \]
    8. Simplified76.7%

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

    if -4e15 < (-.f64 (*.f64 x (log.f64 y)) y) < 1.0000000000000001e44

    1. Initial program 100.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(-z\right)} + \log t \]
    7. Simplified97.3%

      \[\leadsto \color{blue}{\left(-z\right)} + \log t \]
  3. Recombined 3 regimes into one program.
  4. Final simplification88.3%

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

Alternative 3: 88.4% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \log y\\ t_2 := t\_1 - y\\ t_3 := \left(-z\right) - y\\ \mathbf{if}\;t\_2 \leq -5 \cdot 10^{+169}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_2 \leq -5 \cdot 10^{+129}:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;t\_2 \leq -4 \cdot 10^{+88}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_2 \leq -4 \cdot 10^{+15}:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;t\_2 \leq 10^{-27}:\\ \;\;\;\;\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)) (t_3 (- (- z) y)))
   (if (<= t_2 -5e+169)
     t_2
     (if (<= t_2 -5e+129)
       t_3
       (if (<= t_2 -4e+88)
         t_2
         (if (<= t_2 -4e+15)
           t_3
           (if (<= t_2 1e-27) (- (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 t_3 = -z - y;
	double tmp;
	if (t_2 <= -5e+169) {
		tmp = t_2;
	} else if (t_2 <= -5e+129) {
		tmp = t_3;
	} else if (t_2 <= -4e+88) {
		tmp = t_2;
	} else if (t_2 <= -4e+15) {
		tmp = t_3;
	} else if (t_2 <= 1e-27) {
		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) :: t_3
    real(8) :: tmp
    t_1 = x * log(y)
    t_2 = t_1 - y
    t_3 = -z - y
    if (t_2 <= (-5d+169)) then
        tmp = t_2
    else if (t_2 <= (-5d+129)) then
        tmp = t_3
    else if (t_2 <= (-4d+88)) then
        tmp = t_2
    else if (t_2 <= (-4d+15)) then
        tmp = t_3
    else if (t_2 <= 1d-27) 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 t_3 = -z - y;
	double tmp;
	if (t_2 <= -5e+169) {
		tmp = t_2;
	} else if (t_2 <= -5e+129) {
		tmp = t_3;
	} else if (t_2 <= -4e+88) {
		tmp = t_2;
	} else if (t_2 <= -4e+15) {
		tmp = t_3;
	} else if (t_2 <= 1e-27) {
		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
	t_3 = -z - y
	tmp = 0
	if t_2 <= -5e+169:
		tmp = t_2
	elif t_2 <= -5e+129:
		tmp = t_3
	elif t_2 <= -4e+88:
		tmp = t_2
	elif t_2 <= -4e+15:
		tmp = t_3
	elif t_2 <= 1e-27:
		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)
	t_3 = Float64(Float64(-z) - y)
	tmp = 0.0
	if (t_2 <= -5e+169)
		tmp = t_2;
	elseif (t_2 <= -5e+129)
		tmp = t_3;
	elseif (t_2 <= -4e+88)
		tmp = t_2;
	elseif (t_2 <= -4e+15)
		tmp = t_3;
	elseif (t_2 <= 1e-27)
		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;
	t_3 = -z - y;
	tmp = 0.0;
	if (t_2 <= -5e+169)
		tmp = t_2;
	elseif (t_2 <= -5e+129)
		tmp = t_3;
	elseif (t_2 <= -4e+88)
		tmp = t_2;
	elseif (t_2 <= -4e+15)
		tmp = t_3;
	elseif (t_2 <= 1e-27)
		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]}, Block[{t$95$3 = N[((-z) - y), $MachinePrecision]}, If[LessEqual[t$95$2, -5e+169], t$95$2, If[LessEqual[t$95$2, -5e+129], t$95$3, If[LessEqual[t$95$2, -4e+88], t$95$2, If[LessEqual[t$95$2, -4e+15], t$95$3, If[LessEqual[t$95$2, 1e-27], 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\\
t_3 := \left(-z\right) - y\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+169}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_2 \leq -5 \cdot 10^{+129}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;t\_2 \leq -4 \cdot 10^{+88}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_2 \leq -4 \cdot 10^{+15}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;t\_2 \leq 10^{-27}:\\
\;\;\;\;\log t - z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (-.f64 (*.f64 x (log.f64 y)) y) < -5.00000000000000017e169 or -5.0000000000000003e129 < (-.f64 (*.f64 x (log.f64 y)) y) < -3.99999999999999984e88

    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 z around inf 99.8%

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

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

    if -5.00000000000000017e169 < (-.f64 (*.f64 x (log.f64 y)) y) < -5.0000000000000003e129 or -3.99999999999999984e88 < (-.f64 (*.f64 x (log.f64 y)) y) < -4e15

    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. associate--l-99.9%

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

      \[\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 99.6%

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

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

        \[\leadsto \color{blue}{-\left(y + z\right)} \]
      2. neg-sub076.7%

        \[\leadsto \color{blue}{0 - \left(y + z\right)} \]
      3. +-commutative76.7%

        \[\leadsto 0 - \color{blue}{\left(z + y\right)} \]
      4. associate--r+76.7%

        \[\leadsto \color{blue}{\left(0 - z\right) - y} \]
      5. neg-sub076.7%

        \[\leadsto \color{blue}{\left(-z\right)} - y \]
    8. Simplified76.7%

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

    if -4e15 < (-.f64 (*.f64 x (log.f64 y)) y) < 1e-27

    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. Taylor expanded in z around inf 98.7%

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

        \[\leadsto \color{blue}{\left(-z\right)} + \log t \]
    7. Simplified98.7%

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

    if 1e-27 < (-.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 z around inf 99.8%

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

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

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

Alternative 4: 98.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 \cdot 10^{+26}:\\ \;\;\;\;t\_1 - \left(y + z\right)\\ \mathbf{elif}\;t\_2 \leq 10^{-27}:\\ \;\;\;\;\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 -2e+26)
     (- t_1 (+ y z))
     (if (<= t_2 1e-27) (- (- (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 <= -2e+26) {
		tmp = t_1 - (y + z);
	} else if (t_2 <= 1e-27) {
		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 <= (-2d+26)) then
        tmp = t_1 - (y + z)
    else if (t_2 <= 1d-27) 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 <= -2e+26) {
		tmp = t_1 - (y + z);
	} else if (t_2 <= 1e-27) {
		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 <= -2e+26:
		tmp = t_1 - (y + z)
	elif t_2 <= 1e-27:
		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 <= -2e+26)
		tmp = Float64(t_1 - Float64(y + z));
	elseif (t_2 <= 1e-27)
		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 <= -2e+26)
		tmp = t_1 - (y + z);
	elseif (t_2 <= 1e-27)
		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, -2e+26], N[(t$95$1 - N[(y + z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1e-27], 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 \cdot 10^{+26}:\\
\;\;\;\;t\_1 - \left(y + z\right)\\

\mathbf{elif}\;t\_2 \leq 10^{-27}:\\
\;\;\;\;\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.0000000000000001e26

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

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

      \[\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 99.9%

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

    if -2.0000000000000001e26 < (-.f64 (*.f64 x (log.f64 y)) y) < 1e-27

    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 99.2%

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

    if 1e-27 < (-.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 z around inf 99.8%

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

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

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

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

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

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

Alternative 6: 99.9% accurate, 1.0× speedup?

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

\\
x \cdot \log y + \left(\left(\log t - z\right) - y\right)
\end{array}
Derivation
  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. associate--l-99.9%

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

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

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

Alternative 7: 89.8% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \log y\\ \mathbf{if}\;x \leq -9.8 \cdot 10^{+51}:\\ \;\;\;\;t\_1 - y\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{+23}:\\ \;\;\;\;\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))))
   (if (<= x -9.8e+51)
     (- t_1 y)
     (if (<= x 2.1e+23) (- (- (log t) z) y) (- t_1 z)))))
double code(double x, double y, double z, double t) {
	double t_1 = x * log(y);
	double tmp;
	if (x <= -9.8e+51) {
		tmp = t_1 - y;
	} else if (x <= 2.1e+23) {
		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) :: tmp
    t_1 = x * log(y)
    if (x <= (-9.8d+51)) then
        tmp = t_1 - y
    else if (x <= 2.1d+23) 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 tmp;
	if (x <= -9.8e+51) {
		tmp = t_1 - y;
	} else if (x <= 2.1e+23) {
		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)
	tmp = 0
	if x <= -9.8e+51:
		tmp = t_1 - y
	elif x <= 2.1e+23:
		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))
	tmp = 0.0
	if (x <= -9.8e+51)
		tmp = Float64(t_1 - y);
	elseif (x <= 2.1e+23)
		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);
	tmp = 0.0;
	if (x <= -9.8e+51)
		tmp = t_1 - y;
	elseif (x <= 2.1e+23)
		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]}, If[LessEqual[x, -9.8e+51], N[(t$95$1 - y), $MachinePrecision], If[LessEqual[x, 2.1e+23], 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\\
\mathbf{if}\;x \leq -9.8 \cdot 10^{+51}:\\
\;\;\;\;t\_1 - y\\

\mathbf{elif}\;x \leq 2.1 \cdot 10^{+23}:\\
\;\;\;\;\left(\log t - z\right) - y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -9.79999999999999967e51

    1. Initial program 99.7%

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

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

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

      \[\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 99.7%

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

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

    if -9.79999999999999967e51 < x < 2.1000000000000001e23

    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 99.0%

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

    if 2.1000000000000001e23 < x

    1. Initial program 99.7%

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

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

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

      \[\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 99.7%

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

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

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

Alternative 8: 69.0% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.4 \cdot 10^{+21} \lor \neg \left(z \leq 3.6 \cdot 10^{-41}\right):\\
\;\;\;\;\left(-z\right) - y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -5.4e21 or 3.6e-41 < z

    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. associate--l-99.9%

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

      \[\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 99.9%

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

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

        \[\leadsto \color{blue}{-\left(y + z\right)} \]
      2. neg-sub078.7%

        \[\leadsto \color{blue}{0 - \left(y + z\right)} \]
      3. +-commutative78.7%

        \[\leadsto 0 - \color{blue}{\left(z + y\right)} \]
      4. associate--r+78.7%

        \[\leadsto \color{blue}{\left(0 - z\right) - y} \]
      5. neg-sub078.7%

        \[\leadsto \color{blue}{\left(-z\right)} - y \]
    8. Simplified78.7%

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

    if -5.4e21 < z < 3.6e-41

    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. Taylor expanded in y around inf 62.8%

      \[\leadsto \color{blue}{-1 \cdot y} + \log t \]
    6. Step-by-step derivation
      1. mul-1-neg62.8%

        \[\leadsto \color{blue}{\left(-y\right)} + \log t \]
    7. Simplified62.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5.4 \cdot 10^{+21} \lor \neg \left(z \leq 3.6 \cdot 10^{-41}\right):\\ \;\;\;\;\left(-z\right) - y\\ \mathbf{else}:\\ \;\;\;\;\log t - y\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 69.8% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 6100000:\\
\;\;\;\;\log t - z\\

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


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

    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. Taylor expanded in z around inf 62.3%

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

        \[\leadsto \color{blue}{\left(-z\right)} + \log t \]
    7. Simplified62.3%

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

    if 6.1e6 < y

    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. associate--l-99.9%

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

      \[\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 99.7%

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

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

        \[\leadsto \color{blue}{-\left(y + z\right)} \]
      2. neg-sub078.2%

        \[\leadsto \color{blue}{0 - \left(y + z\right)} \]
      3. +-commutative78.2%

        \[\leadsto 0 - \color{blue}{\left(z + y\right)} \]
      4. associate--r+78.2%

        \[\leadsto \color{blue}{\left(0 - z\right) - y} \]
      5. neg-sub078.2%

        \[\leadsto \color{blue}{\left(-z\right)} - y \]
    8. Simplified78.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 6100000:\\ \;\;\;\;\log t - z\\ \mathbf{else}:\\ \;\;\;\;\left(-z\right) - y\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 48.6% accurate, 29.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 2.65 \cdot 10^{+57}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;-y\\ \end{array} \end{array} \]
(FPCore (x y z t) :precision binary64 (if (<= y 2.65e+57) (- z) (- y)))
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 2.65e+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 <= 2.65d+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 <= 2.65e+57) {
		tmp = -z;
	} else {
		tmp = -y;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if y <= 2.65e+57:
		tmp = -z
	else:
		tmp = -y
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (y <= 2.65e+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 <= 2.65e+57)
		tmp = -z;
	else
		tmp = -y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.65e+57], (-z), (-y)]
\begin{array}{l}

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

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


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

    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 z around inf 76.5%

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

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

        \[\leadsto \color{blue}{-z} \]
    8. Simplified35.7%

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

    if 2.64999999999999993e57 < y

    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. associate--l-99.9%

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

      \[\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 99.9%

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

      \[\leadsto \color{blue}{-1 \cdot y} \]
    7. Step-by-step derivation
      1. mul-1-neg65.2%

        \[\leadsto \color{blue}{-y} \]
    8. Simplified65.2%

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

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

Alternative 11: 58.3% accurate, 52.3× speedup?

\[\begin{array}{l} \\ \left(-z\right) - y \end{array} \]
(FPCore (x y z t) :precision binary64 (- (- z) y))
double code(double x, double y, double z, double t) {
	return -z - 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 = -z - y
end function
public static double code(double x, double y, double z, double t) {
	return -z - y;
}
def code(x, y, z, t):
	return -z - y
function code(x, y, z, t)
	return Float64(Float64(-z) - y)
end
function tmp = code(x, y, z, t)
	tmp = -z - y;
end
code[x_, y_, z_, t_] := N[((-z) - y), $MachinePrecision]
\begin{array}{l}

\\
\left(-z\right) - y
\end{array}
Derivation
  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. associate--l-99.9%

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

    \[\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 86.7%

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

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

      \[\leadsto \color{blue}{-\left(y + z\right)} \]
    2. neg-sub057.5%

      \[\leadsto \color{blue}{0 - \left(y + z\right)} \]
    3. +-commutative57.5%

      \[\leadsto 0 - \color{blue}{\left(z + y\right)} \]
    4. associate--r+57.5%

      \[\leadsto \color{blue}{\left(0 - z\right) - y} \]
    5. neg-sub057.5%

      \[\leadsto \color{blue}{\left(-z\right)} - y \]
  8. Simplified57.5%

    \[\leadsto \color{blue}{\left(-z\right) - y} \]
  9. Final simplification57.5%

    \[\leadsto \left(-z\right) - y \]
  10. Add Preprocessing

Alternative 12: 30.3% 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.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. associate--l-99.9%

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

    \[\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 86.7%

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

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

      \[\leadsto \color{blue}{-y} \]
  8. Simplified30.8%

    \[\leadsto \color{blue}{-y} \]
  9. Final simplification30.8%

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

Reproduce

?
herbie shell --seed 2024078 
(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)))