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

Percentage Accurate: 99.9% → 99.9%
Time: 10.8s
Alternatives: 7
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 7 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. Final simplification99.8%

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

Alternative 2: 89.8% accurate, 1.0× speedup?

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

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

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

\mathbf{elif}\;x \leq 8.6 \cdot 10^{+154}:\\
\;\;\;\;t_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.49999999999999988e70 or 1.25000000000000002e42 < x < 8.5999999999999995e154

    1. Initial program 99.7%

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

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

    if -1.49999999999999988e70 < x < 1.25000000000000002e42

    1. Initial program 100.0%

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

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

    if 8.5999999999999995e154 < 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. sub-neg99.7%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(\sqrt[3]{x \cdot \log y}\right)}^{2}}, \sqrt[3]{x \cdot \log y}, \left(-y\right) - \left(z - \log t\right)\right) \]
    3. Applied egg-rr98.5%

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

      \[\leadsto \mathsf{fma}\left({\left(\sqrt[3]{x \cdot \log y}\right)}^{2}, \sqrt[3]{x \cdot \log y}, \color{blue}{-1 \cdot z}\right) \]
    5. Step-by-step derivation
      1. neg-mul-193.3%

        \[\leadsto \mathsf{fma}\left({\left(\sqrt[3]{x \cdot \log y}\right)}^{2}, \sqrt[3]{x \cdot \log y}, \color{blue}{-z}\right) \]
    6. Simplified93.3%

      \[\leadsto \mathsf{fma}\left({\left(\sqrt[3]{x \cdot \log y}\right)}^{2}, \sqrt[3]{x \cdot \log y}, \color{blue}{-z}\right) \]
    7. Step-by-step derivation
      1. fma-udef93.3%

        \[\leadsto \color{blue}{{\left(\sqrt[3]{x \cdot \log y}\right)}^{2} \cdot \sqrt[3]{x \cdot \log y} + \left(-z\right)} \]
      2. unpow293.3%

        \[\leadsto \color{blue}{\left(\sqrt[3]{x \cdot \log y} \cdot \sqrt[3]{x \cdot \log y}\right)} \cdot \sqrt[3]{x \cdot \log y} + \left(-z\right) \]
      3. add-cube-cbrt94.4%

        \[\leadsto \color{blue}{x \cdot \log y} + \left(-z\right) \]
      4. *-commutative94.4%

        \[\leadsto \color{blue}{\log y \cdot x} + \left(-z\right) \]
      5. unsub-neg94.4%

        \[\leadsto \color{blue}{\log y \cdot x - z} \]
    8. Applied egg-rr94.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.5 \cdot 10^{+70}:\\ \;\;\;\;\left(\log t + x \cdot \log y\right) - y\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{+42}:\\ \;\;\;\;\log t - \left(y + z\right)\\ \mathbf{elif}\;x \leq 8.6 \cdot 10^{+154}:\\ \;\;\;\;\left(\log t + x \cdot \log y\right) - y\\ \mathbf{else}:\\ \;\;\;\;x \cdot \log y - z\\ \end{array} \]

Alternative 3: 88.8% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.2 \cdot 10^{+106} \lor \neg \left(x \leq 2.3 \cdot 10^{+96}\right):\\
\;\;\;\;x \cdot \log y - z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.1999999999999998e106 or 2.30000000000000015e96 < 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. sub-neg99.7%

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

        \[\leadsto \color{blue}{x \cdot \log y + \left(\left(-y\right) - \left(z - \log t\right)\right)} \]
      4. add-cube-cbrt98.4%

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(\sqrt[3]{x \cdot \log y}\right)}^{2}}, \sqrt[3]{x \cdot \log y}, \left(-y\right) - \left(z - \log t\right)\right) \]
    3. Applied egg-rr98.4%

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

      \[\leadsto \mathsf{fma}\left({\left(\sqrt[3]{x \cdot \log y}\right)}^{2}, \sqrt[3]{x \cdot \log y}, \color{blue}{-1 \cdot z}\right) \]
    5. Step-by-step derivation
      1. neg-mul-187.7%

        \[\leadsto \mathsf{fma}\left({\left(\sqrt[3]{x \cdot \log y}\right)}^{2}, \sqrt[3]{x \cdot \log y}, \color{blue}{-z}\right) \]
    6. Simplified87.7%

      \[\leadsto \mathsf{fma}\left({\left(\sqrt[3]{x \cdot \log y}\right)}^{2}, \sqrt[3]{x \cdot \log y}, \color{blue}{-z}\right) \]
    7. Step-by-step derivation
      1. fma-udef87.7%

        \[\leadsto \color{blue}{{\left(\sqrt[3]{x \cdot \log y}\right)}^{2} \cdot \sqrt[3]{x \cdot \log y} + \left(-z\right)} \]
      2. unpow287.7%

        \[\leadsto \color{blue}{\left(\sqrt[3]{x \cdot \log y} \cdot \sqrt[3]{x \cdot \log y}\right)} \cdot \sqrt[3]{x \cdot \log y} + \left(-z\right) \]
      3. add-cube-cbrt88.9%

        \[\leadsto \color{blue}{x \cdot \log y} + \left(-z\right) \]
      4. *-commutative88.9%

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

        \[\leadsto \color{blue}{\log y \cdot x - z} \]
    8. Applied egg-rr88.9%

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

    if -3.1999999999999998e106 < x < 2.30000000000000015e96

    1. Initial program 99.9%

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

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

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

Alternative 4: 60.4% accurate, 2.0× speedup?

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

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

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


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

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

    if 1.49999999999999988e27 < 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 59.1%

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

        \[\leadsto \color{blue}{-y} \]
    4. Simplified59.1%

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

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

Alternative 5: 70.0% 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 71.3%

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

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

Alternative 6: 48.0% accurate, 51.4× speedup?

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

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

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


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

    1. Initial program 99.8%

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

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

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

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

    if 1.05e26 < 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 59.1%

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

        \[\leadsto \color{blue}{-y} \]
    4. Simplified59.1%

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

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

Alternative 7: 29.3% accurate, 104.5× speedup?

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

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

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

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

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

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

    \[\leadsto -y \]

Reproduce

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