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

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

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 99.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 0.7× speedup?

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

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

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

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

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

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

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

Alternative 2: 99.1% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \log y - y\\ \mathbf{if}\;t_1 \leq -10000000000:\\ \;\;\;\;t_1 - z\\ \mathbf{elif}\;t_1 \leq 10^{-10}:\\ \;\;\;\;\log t - \left(y + z\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, \log y, -y\right) - z\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- (* x (log y)) y)))
   (if (<= t_1 -10000000000.0)
     (- t_1 z)
     (if (<= t_1 1e-10) (- (log t) (+ y z)) (- (fma x (log y) (- y)) z)))))
double code(double x, double y, double z, double t) {
	double t_1 = (x * log(y)) - y;
	double tmp;
	if (t_1 <= -10000000000.0) {
		tmp = t_1 - z;
	} else if (t_1 <= 1e-10) {
		tmp = log(t) - (y + z);
	} else {
		tmp = fma(x, log(y), -y) - z;
	}
	return tmp;
}
function code(x, y, z, t)
	t_1 = Float64(Float64(x * log(y)) - y)
	tmp = 0.0
	if (t_1 <= -10000000000.0)
		tmp = Float64(t_1 - z);
	elseif (t_1 <= 1e-10)
		tmp = Float64(log(t) - Float64(y + z));
	else
		tmp = Float64(fma(x, log(y), Float64(-y)) - z);
	end
	return tmp
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]}, If[LessEqual[t$95$1, -10000000000.0], N[(t$95$1 - z), $MachinePrecision], If[LessEqual[t$95$1, 1e-10], N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[Log[y], $MachinePrecision] + (-y)), $MachinePrecision] - z), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \log y - y\\
\mathbf{if}\;t_1 \leq -10000000000:\\
\;\;\;\;t_1 - z\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \log y, -y\right) - z\\


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

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

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

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

      \[\leadsto \mathsf{fma}\left(x, \log y, -y\right) - \color{blue}{z} \]
    5. Step-by-step derivation
      1. fma-neg99.6%

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

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

    if -1e10 < (-.f64 (*.f64 x (log.f64 y)) y) < 1.00000000000000004e-10

    1. Initial program 99.9%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Taylor expanded in x around 0 98.8%

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

    if 1.00000000000000004e-10 < (-.f64 (*.f64 x (log.f64 y)) y)

    1. Initial program 99.5%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot \log y - y \leq -10000000000:\\ \;\;\;\;\left(x \cdot \log y - y\right) - z\\ \mathbf{elif}\;x \cdot \log y - y \leq 10^{-10}:\\ \;\;\;\;\log t - \left(y + z\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, \log y, -y\right) - z\\ \end{array} \]

Alternative 3: 99.1% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
t_1 := x \cdot \log y - y\\
\mathbf{if}\;t_1 \leq -10000000000 \lor \neg \left(t_1 \leq 10^{-10}\right):\\
\;\;\;\;t_1 - z\\

\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) < -1e10 or 1.00000000000000004e-10 < (-.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. fma-neg99.8%

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

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

      \[\leadsto \mathsf{fma}\left(x, \log y, -y\right) - \color{blue}{z} \]
    5. Step-by-step derivation
      1. fma-neg99.3%

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

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

    if -1e10 < (-.f64 (*.f64 x (log.f64 y)) y) < 1.00000000000000004e-10

    1. Initial program 99.9%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Taylor expanded in x around 0 98.8%

      \[\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 -10000000000 \lor \neg \left(x \cdot \log y - y \leq 10^{-10}\right):\\ \;\;\;\;\left(x \cdot \log y - y\right) - z\\ \mathbf{else}:\\ \;\;\;\;\log t - \left(y + z\right)\\ \end{array} \]

Alternative 4: 99.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 110:\\ \;\;\;\;\left(\log t + x \cdot \log y\right) - z\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, \log y, -y\right) - z\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= y 110.0) (- (+ (log t) (* x (log y))) z) (- (fma x (log y) (- y)) z)))
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 110.0) {
		tmp = (log(t) + (x * log(y))) - z;
	} else {
		tmp = fma(x, log(y), -y) - z;
	}
	return tmp;
}
function code(x, y, z, t)
	tmp = 0.0
	if (y <= 110.0)
		tmp = Float64(Float64(log(t) + Float64(x * log(y))) - z);
	else
		tmp = Float64(fma(x, log(y), Float64(-y)) - z);
	end
	return tmp
end
code[x_, y_, z_, t_] := If[LessEqual[y, 110.0], N[(N[(N[Log[t], $MachinePrecision] + N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(x * N[Log[y], $MachinePrecision] + (-y)), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \log y, -y\right) - z\\


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

    1. Initial program 99.8%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Taylor expanded in y around 0 98.0%

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

    if 110 < 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. fma-neg99.9%

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

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

      \[\leadsto \mathsf{fma}\left(x, \log y, -y\right) - \color{blue}{z} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 110:\\ \;\;\;\;\left(\log t + x \cdot \log y\right) - z\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, \log y, -y\right) - z\\ \end{array} \]

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

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

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

Alternative 6: 46.7% accurate, 1.9× speedup?

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

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

\mathbf{elif}\;z \leq -3.7 \cdot 10^{-48}:\\
\;\;\;\;-y\\

\mathbf{elif}\;z \leq -1.1 \cdot 10^{-267}:\\
\;\;\;\;\log t\\

\mathbf{elif}\;z \leq 1.45 \cdot 10^{+84}:\\
\;\;\;\;-y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -9.80000000000000056e70 or 1.44999999999999994e84 < z

    1. Initial program 99.9%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Taylor expanded in z around inf 66.5%

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

        \[\leadsto \color{blue}{-z} \]
    4. Simplified66.5%

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

    if -9.80000000000000056e70 < z < -3.6999999999999998e-48 or -1.09999999999999994e-267 < z < 1.44999999999999994e84

    1. Initial program 99.8%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Taylor expanded in y around inf 38.6%

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

        \[\leadsto \color{blue}{-y} \]
    4. Simplified38.6%

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

    if -3.6999999999999998e-48 < z < -1.09999999999999994e-267

    1. Initial program 99.8%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Taylor expanded in x around 0 79.4%

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

      \[\leadsto \color{blue}{\log t - y} \]
    4. Taylor expanded in y around 0 53.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -9.8 \cdot 10^{+70}:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \leq -3.7 \cdot 10^{-48}:\\ \;\;\;\;-y\\ \mathbf{elif}\;z \leq -1.1 \cdot 10^{-267}:\\ \;\;\;\;\log t\\ \mathbf{elif}\;z \leq 1.45 \cdot 10^{+84}:\\ \;\;\;\;-y\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]

Alternative 7: 61.0% accurate, 2.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.9 \cdot 10^{+69} \lor \neg \left(z \leq 1.55 \cdot 10^{+76}\right):\\
\;\;\;\;-z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.8999999999999998e69 or 1.55000000000000006e76 < z

    1. Initial program 99.9%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Taylor expanded in z around inf 66.5%

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

        \[\leadsto \color{blue}{-z} \]
    4. Simplified66.5%

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

    if -2.8999999999999998e69 < z < 1.55000000000000006e76

    1. Initial program 99.8%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Taylor expanded in x around 0 67.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.9 \cdot 10^{+69} \lor \neg \left(z \leq 1.55 \cdot 10^{+76}\right):\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;\log t - y\\ \end{array} \]

Alternative 8: 59.9% accurate, 2.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.2 \cdot 10^{-6}:\\
\;\;\;\;\log t - z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 4.1999999999999996e-6

    1. Initial program 99.8%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Taylor expanded in x around 0 67.6%

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

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

    if 4.1999999999999996e-6 < y

    1. Initial program 99.9%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Taylor expanded in x around 0 77.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 4.2 \cdot 10^{-6}:\\ \;\;\;\;\log t - z\\ \mathbf{else}:\\ \;\;\;\;\log t - y\\ \end{array} \]

Alternative 9: 70.5% accurate, 2.0× speedup?

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

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

    \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
  2. Taylor expanded in x around 0 72.4%

    \[\leadsto \color{blue}{\log t - \left(y + z\right)} \]
  3. Final simplification72.4%

    \[\leadsto \log t - \left(y + z\right) \]

Alternative 10: 48.7% accurate, 34.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.1 \cdot 10^{+65} \lor \neg \left(z \leq 2.35 \cdot 10^{+82}\right):\\
\;\;\;\;-z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.0999999999999999e65 or 2.35e82 < z

    1. Initial program 99.9%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Taylor expanded in z around inf 66.5%

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

        \[\leadsto \color{blue}{-z} \]
    4. Simplified66.5%

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

    if -1.0999999999999999e65 < z < 2.35e82

    1. Initial program 99.8%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Taylor expanded in y around inf 35.2%

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

        \[\leadsto \color{blue}{-y} \]
    4. Simplified35.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.1 \cdot 10^{+65} \lor \neg \left(z \leq 2.35 \cdot 10^{+82}\right):\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;-y\\ \end{array} \]

Alternative 11: 30.1% 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. Taylor expanded in y around inf 28.5%

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

      \[\leadsto \color{blue}{-y} \]
  4. Simplified28.5%

    \[\leadsto \color{blue}{-y} \]
  5. Final simplification28.5%

    \[\leadsto -y \]

Reproduce

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