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

Percentage Accurate: 99.9% → 99.9%
Time: 11.3s
Alternatives: 9
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 9 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} \\ \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}
Derivation
  1. Initial program 99.8%

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

Alternative 2: 99.1% 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 -40000000000 \lor \neg \left(t\_2 \leq 2 \cdot 10^{-7}\right):\\ \;\;\;\;t\_1 - \left(y + z\right)\\ \mathbf{else}:\\ \;\;\;\;\log t - \left(y + z\right)\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (log y))) (t_2 (- t_1 y)))
   (if (or (<= t_2 -40000000000.0) (not (<= t_2 2e-7)))
     (- t_1 (+ y z))
     (- (log t) (+ y 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 <= -40000000000.0) || !(t_2 <= 2e-7)) {
		tmp = t_1 - (y + z);
	} else {
		tmp = log(t) - (y + 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 <= (-40000000000.0d0)) .or. (.not. (t_2 <= 2d-7))) then
        tmp = t_1 - (y + z)
    else
        tmp = log(t) - (y + 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 <= -40000000000.0) || !(t_2 <= 2e-7)) {
		tmp = t_1 - (y + z);
	} else {
		tmp = Math.log(t) - (y + 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 <= -40000000000.0) or not (t_2 <= 2e-7):
		tmp = t_1 - (y + z)
	else:
		tmp = math.log(t) - (y + 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 <= -40000000000.0) || !(t_2 <= 2e-7))
		tmp = Float64(t_1 - Float64(y + z));
	else
		tmp = Float64(log(t) - Float64(y + 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 <= -40000000000.0) || ~((t_2 <= 2e-7)))
		tmp = t_1 - (y + z);
	else
		tmp = log(t) - (y + 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[Or[LessEqual[t$95$2, -40000000000.0], N[Not[LessEqual[t$95$2, 2e-7]], $MachinePrecision]], N[(t$95$1 - N[(y + z), $MachinePrecision]), $MachinePrecision], N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \log y\\
t_2 := t\_1 - y\\
\mathbf{if}\;t\_2 \leq -40000000000 \lor \neg \left(t\_2 \leq 2 \cdot 10^{-7}\right):\\
\;\;\;\;t\_1 - \left(y + z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (*.f64 x (log.f64 y)) y) < -4e10 or 1.9999999999999999e-7 < (-.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.0%

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

    if -4e10 < (-.f64 (*.f64 x (log.f64 y)) y) < 1.9999999999999999e-7

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

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

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

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

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

Alternative 3: 99.3% accurate, 1.0× speedup?

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

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

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


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

    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 0 99.3%

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

    if 0.10000000000000001 < 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) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.6%

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

Alternative 4: 67.4% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.5 \cdot 10^{+132} \lor \neg \left(x \leq -2.05 \cdot 10^{+86} \lor \neg \left(x \leq -1.9 \cdot 10^{+17}\right) \land x \leq 102000000\right):\\
\;\;\;\;x \cdot \log y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -6.4999999999999994e132 or -2.05e86 < x < -1.9e17 or 1.02e8 < 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 76.1%

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

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

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

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

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

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

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

    if -6.4999999999999994e132 < x < -2.05e86 or -1.9e17 < x < 1.02e8

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(-z\right) \cdot \left(1 + \left(-\color{blue}{-1 \cdot \frac{y}{z}}\right)\right) \]
    9. Step-by-step derivation
      1. associate-*r/67.2%

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

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

      \[\leadsto \left(-z\right) \cdot \left(1 + \left(-\color{blue}{\frac{-y}{z}}\right)\right) \]
    11. Taylor expanded in z around 0 80.6%

      \[\leadsto \color{blue}{-1 \cdot y + -1 \cdot z} \]
    12. Step-by-step derivation
      1. mul-1-neg80.6%

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

        \[\leadsto \color{blue}{-1 \cdot y - z} \]
      3. mul-1-neg80.6%

        \[\leadsto \color{blue}{\left(-y\right)} - z \]
    13. Simplified80.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6.5 \cdot 10^{+132} \lor \neg \left(x \leq -2.05 \cdot 10^{+86} \lor \neg \left(x \leq -1.9 \cdot 10^{+17}\right) \land x \leq 102000000\right):\\ \;\;\;\;x \cdot \log y\\ \mathbf{else}:\\ \;\;\;\;\left(-y\right) - z\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 88.2% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -130 \lor \neg \left(x \leq 40000000\right):\\
\;\;\;\;x \cdot \log y - y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -130 or 4e7 < 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 y around inf 82.4%

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

    if -130 < x < 4e7

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

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

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

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

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

Alternative 6: 81.5% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.2 \cdot 10^{+132} \lor \neg \left(x \leq 102000000\right):\\
\;\;\;\;x \cdot \log y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -4.19999999999999987e132 or 1.02e8 < 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 78.3%

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

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

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

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

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

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

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

    if -4.19999999999999987e132 < x < 1.02e8

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

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

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

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

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

Alternative 7: 49.0% accurate, 17.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.05 \cdot 10^{+60} \lor \neg \left(z \leq 1.9 \cdot 10^{+71}\right):\\
\;\;\;\;-z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.05e60 or 1.9e71 < 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 72.5%

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

        \[\leadsto \color{blue}{-z} \]
    7. Simplified72.5%

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

    if -3.05e60 < z < 1.9e71

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

      \[\leadsto \color{blue}{-1 \cdot y} \]
    6. Step-by-step derivation
      1. mul-1-neg40.5%

        \[\leadsto \color{blue}{-y} \]
    7. Simplified40.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.05 \cdot 10^{+60} \lor \neg \left(z \leq 1.9 \cdot 10^{+71}\right):\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;-y\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 58.4% accurate, 52.3× speedup?

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

\\
\left(-y\right) - z
\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. 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 82.0%

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

      \[\leadsto \color{blue}{\left(-1 \cdot z\right) \cdot \left(1 + -1 \cdot \frac{\left(\log t + x \cdot \log y\right) - y}{z}\right)} \]
    2. mul-1-neg82.0%

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

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

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

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

    \[\leadsto \left(-z\right) \cdot \left(1 + \left(-\color{blue}{-1 \cdot \frac{y}{z}}\right)\right) \]
  9. Step-by-step derivation
    1. associate-*r/49.4%

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

      \[\leadsto \left(-z\right) \cdot \left(1 + \left(-\frac{\color{blue}{-y}}{z}\right)\right) \]
  10. Simplified49.4%

    \[\leadsto \left(-z\right) \cdot \left(1 + \left(-\color{blue}{\frac{-y}{z}}\right)\right) \]
  11. Taylor expanded in z around 0 58.5%

    \[\leadsto \color{blue}{-1 \cdot y + -1 \cdot z} \]
  12. Step-by-step derivation
    1. mul-1-neg58.5%

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

      \[\leadsto \color{blue}{-1 \cdot y - z} \]
    3. mul-1-neg58.5%

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

    \[\leadsto \color{blue}{\left(-y\right) - z} \]
  14. Add Preprocessing

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

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

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

    \[\leadsto \color{blue}{-y} \]
  8. Add Preprocessing

Reproduce

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