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

Percentage Accurate: 99.9% → 99.9%
Time: 10.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.9%

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

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

Alternative 2: 89.2% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1300000 \lor \neg \left(x \leq 1.95 \cdot 10^{+63}\right):\\
\;\;\;\;\left(\log t + x \cdot \log y\right) - y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.3e6 or 1.95e63 < x

    1. Initial program 99.7%

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

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

    if -1.3e6 < x < 1.95e63

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1300000 \lor \neg \left(x \leq 1.95 \cdot 10^{+63}\right):\\ \;\;\;\;\left(\log t + x \cdot \log y\right) - y\\ \mathbf{else}:\\ \;\;\;\;\log t - \left(y + z\right)\\ \end{array} \]

Alternative 3: 88.5% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_1 := \log t + x \cdot \log y\\
\mathbf{if}\;z \leq -7.5 \cdot 10^{+132} \lor \neg \left(z \leq 1.45 \cdot 10^{+83}\right):\\
\;\;\;\;t_1 - z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -7.50000000000000017e132 or 1.45e83 < z

    1. Initial program 99.9%

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

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

    if -7.50000000000000017e132 < z < 1.45e83

    1. Initial program 99.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -7.5 \cdot 10^{+132} \lor \neg \left(z \leq 1.45 \cdot 10^{+83}\right):\\ \;\;\;\;\left(\log t + x \cdot \log y\right) - z\\ \mathbf{else}:\\ \;\;\;\;\left(\log t + x \cdot \log y\right) - y\\ \end{array} \]

Alternative 4: 83.3% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -7 \cdot 10^{+101} \lor \neg \left(x \leq 8 \cdot 10^{+127}\right):\\
\;\;\;\;\log t + 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 < -7.00000000000000046e101 or 7.99999999999999964e127 < x

    1. Initial program 99.6%

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

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

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

    if -7.00000000000000046e101 < x < 7.99999999999999964e127

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7 \cdot 10^{+101} \lor \neg \left(x \leq 8 \cdot 10^{+127}\right):\\ \;\;\;\;\log t + x \cdot \log y\\ \mathbf{else}:\\ \;\;\;\;\log t - \left(y + z\right)\\ \end{array} \]

Alternative 5: 58.9% accurate, 2.0× speedup?

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

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

\mathbf{elif}\;z \leq 4.6 \cdot 10^{+83}:\\
\;\;\;\;\log t - y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.35000000000000015e133 or 4.5999999999999999e83 < 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 73.5%

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

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

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

    if -3.35000000000000015e133 < z < 4.5999999999999999e83

    1. Initial program 99.8%

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

        \[\leadsto \color{blue}{\log t + \left(\left(x \cdot \log y - y\right) - z\right)} \]
      2. add-log-exp20.5%

        \[\leadsto \log t + \color{blue}{\log \left(e^{\left(x \cdot \log y - y\right) - z}\right)} \]
      3. sum-log20.5%

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

        \[\leadsto \log \left(t \cdot e^{\color{blue}{x \cdot \log y - \left(y + z\right)}}\right) \]
      5. exp-diff19.7%

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

        \[\leadsto \log \left(t \cdot \frac{e^{\color{blue}{\log y \cdot x}}}{e^{y + z}}\right) \]
      7. exp-to-pow19.7%

        \[\leadsto \log \left(t \cdot \frac{\color{blue}{{y}^{x}}}{e^{y + z}}\right) \]
    3. Applied egg-rr19.7%

      \[\leadsto \color{blue}{\log \left(t \cdot \frac{{y}^{x}}{e^{y + z}}\right)} \]
    4. Taylor expanded in x around 0 19.5%

      \[\leadsto \color{blue}{\log \left(\frac{t}{e^{y + z}}\right)} \]
    5. Taylor expanded in z around 0 19.3%

      \[\leadsto \color{blue}{\log \left(\frac{t}{e^{y}}\right)} \]
    6. Step-by-step derivation
      1. log-div19.3%

        \[\leadsto \color{blue}{\log t - \log \left(e^{y}\right)} \]
      2. rem-log-exp60.3%

        \[\leadsto \log t - \color{blue}{y} \]
    7. Simplified60.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.35 \cdot 10^{+133}:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \leq 4.6 \cdot 10^{+83}:\\ \;\;\;\;\log t - y\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]

Alternative 6: 59.4% accurate, 2.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.2 \cdot 10^{+86}:\\
\;\;\;\;\log t - z\\

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


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

    1. Initial program 99.8%

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

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

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

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

        \[\leadsto \left(\log t + \color{blue}{\log \left({y}^{x}\right)}\right) - z \]
      4. log-prod45.0%

        \[\leadsto \color{blue}{\log \left(t \cdot {y}^{x}\right)} - z \]
    4. Simplified45.0%

      \[\leadsto \color{blue}{\log \left(t \cdot {y}^{x}\right) - z} \]
    5. Taylor expanded in x around 0 59.2%

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

    if 1.2e86 < y

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

Alternative 8: 47.7% accurate, 51.4× speedup?

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

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

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


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

    1. Initial program 99.8%

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

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

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

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

    if 9.1999999999999996e85 < y

    1. Initial program 99.9%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 9.2 \cdot 10^{+85}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;-y\\ \end{array} \]

Alternative 9: 29.7% 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. Taylor expanded in y around inf 32.6%

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

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

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

    \[\leadsto -y \]

Reproduce

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