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

Percentage Accurate: 99.9% → 99.9%
Time: 8.6s
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.3% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.25 \cdot 10^{+114} \lor \neg \left(z \leq 1.65 \cdot 10^{+111}\right):\\
\;\;\;\;\log t - \left(y + z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.25e114 or 1.6500000000000001e111 < z

    1. Initial program 100.0%

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

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

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

        \[\leadsto \left(-\color{blue}{\left(z + y\right)}\right) + \log t \]
      3. distribute-neg-in87.9%

        \[\leadsto \color{blue}{\left(\left(-z\right) + \left(-y\right)\right)} + \log t \]
      4. sub-neg87.9%

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

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

    if -1.25e114 < z < 1.6500000000000001e111

    1. Initial program 99.8%

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

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

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

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

      \[\leadsto \color{blue}{\left({1}^{0.3333333333333333} \cdot \left(x \cdot \log y\right) - y\right)} + \log t \]
    5. Step-by-step derivation
      1. pow-base-194.9%

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

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

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

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

Alternative 3: 89.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \log y\\ \mathbf{if}\;y \leq 9.6 \cdot 10^{+14}:\\ \;\;\;\;\log t + \left(t_1 - z\right)\\ \mathbf{elif}\;y \leq 4.8 \cdot 10^{+141}:\\ \;\;\;\;\left(t_1 - y\right) + \log t\\ \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))))
   (if (<= y 9.6e+14)
     (+ (log t) (- t_1 z))
     (if (<= y 4.8e+141) (+ (- t_1 y) (log t)) (- (log t) (+ y z))))))
double code(double x, double y, double z, double t) {
	double t_1 = x * log(y);
	double tmp;
	if (y <= 9.6e+14) {
		tmp = log(t) + (t_1 - z);
	} else if (y <= 4.8e+141) {
		tmp = (t_1 - y) + log(t);
	} 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)
    if (y <= 9.6d+14) then
        tmp = log(t) + (t_1 - z)
    else if (y <= 4.8d+141) then
        tmp = (t_1 - y) + log(t)
    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 tmp;
	if (y <= 9.6e+14) {
		tmp = Math.log(t) + (t_1 - z);
	} else if (y <= 4.8e+141) {
		tmp = (t_1 - y) + Math.log(t);
	} else {
		tmp = Math.log(t) - (y + z);
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x * math.log(y)
	tmp = 0
	if y <= 9.6e+14:
		tmp = math.log(t) + (t_1 - z)
	elif y <= 4.8e+141:
		tmp = (t_1 - y) + math.log(t)
	else:
		tmp = math.log(t) - (y + z)
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x * log(y))
	tmp = 0.0
	if (y <= 9.6e+14)
		tmp = Float64(log(t) + Float64(t_1 - z));
	elseif (y <= 4.8e+141)
		tmp = Float64(Float64(t_1 - y) + log(t));
	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);
	tmp = 0.0;
	if (y <= 9.6e+14)
		tmp = log(t) + (t_1 - z);
	elseif (y <= 4.8e+141)
		tmp = (t_1 - y) + log(t);
	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]}, If[LessEqual[y, 9.6e+14], N[(N[Log[t], $MachinePrecision] + N[(t$95$1 - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.8e+141], N[(N[(t$95$1 - y), $MachinePrecision] + N[Log[t], $MachinePrecision]), $MachinePrecision], N[(N[Log[t], $MachinePrecision] - N[(y + z), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

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

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


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

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

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

    if 9.6e14 < y < 4.79999999999999995e141

    1. Initial program 99.9%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Step-by-step derivation
      1. add-cube-cbrt99.4%

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

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

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

      \[\leadsto \color{blue}{\left({1}^{0.3333333333333333} \cdot \left(x \cdot \log y\right) - y\right)} + \log t \]
    5. Step-by-step derivation
      1. pow-base-184.1%

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

        \[\leadsto \left(\color{blue}{x \cdot \log y} - y\right) + \log t \]
    6. Simplified84.1%

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

    if 4.79999999999999995e141 < y

    1. Initial program 100.0%

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

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

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

        \[\leadsto \left(-\color{blue}{\left(z + y\right)}\right) + \log t \]
      3. distribute-neg-in94.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 9.6 \cdot 10^{+14}:\\ \;\;\;\;\log t + \left(x \cdot \log y - z\right)\\ \mathbf{elif}\;y \leq 4.8 \cdot 10^{+141}:\\ \;\;\;\;\left(x \cdot \log y - y\right) + \log t\\ \mathbf{else}:\\ \;\;\;\;\log t - \left(y + z\right)\\ \end{array} \]

Alternative 4: 84.3% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.2 \cdot 10^{+79} \lor \neg \left(x \leq 2.3 \cdot 10^{+101}\right):\\
\;\;\;\;x \cdot \log y + \log t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -6.1999999999999998e79 or 2.3000000000000001e101 < x

    1. Initial program 99.7%

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

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

      \[\leadsto \color{blue}{\log t + x \cdot \log y} \]
    4. Step-by-step derivation
      1. +-commutative74.6%

        \[\leadsto \color{blue}{x \cdot \log y + \log t} \]
    5. Simplified74.6%

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

    if -6.1999999999999998e79 < x < 2.3000000000000001e101

    1. Initial program 100.0%

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

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

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

        \[\leadsto \left(-\color{blue}{\left(z + y\right)}\right) + \log t \]
      3. distribute-neg-in95.1%

        \[\leadsto \color{blue}{\left(\left(-z\right) + \left(-y\right)\right)} + \log t \]
      4. sub-neg95.1%

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

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

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

Alternative 5: 60.8% accurate, 2.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.5 \cdot 10^{+100} \lor \neg \left(z \leq 2.7 \cdot 10^{+99}\right):\\
\;\;\;\;\log t - z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -7.49999999999999983e100 or 2.69999999999999989e99 < 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 71.9%

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

        \[\leadsto \color{blue}{\left(-z\right)} + \log t \]
    4. Simplified71.9%

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

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

        \[\leadsto \log t + \color{blue}{\left(-z\right)} \]
      2. sub-neg71.9%

        \[\leadsto \color{blue}{\log t - z} \]
    7. Simplified71.9%

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

    if -7.49999999999999983e100 < z < 2.69999999999999989e99

    1. Initial program 99.9%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot y} + \log t \]
    5. Step-by-step derivation
      1. neg-mul-158.6%

        \[\leadsto \color{blue}{\left(-y\right)} + \log t \]
    6. Simplified58.6%

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

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

        \[\leadsto \log t + \color{blue}{\left(-y\right)} \]
      2. sub-neg58.6%

        \[\leadsto \color{blue}{\log t - y} \]
    9. Simplified58.6%

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

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

Alternative 6: 70.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 68.9%

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

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

      \[\leadsto \left(-\color{blue}{\left(z + y\right)}\right) + \log t \]
    3. distribute-neg-in68.9%

      \[\leadsto \color{blue}{\left(\left(-z\right) + \left(-y\right)\right)} + \log t \]
    4. sub-neg68.9%

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

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

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

Alternative 7: 42.8% accurate, 2.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 105:\\
\;\;\;\;\log t\\

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


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

    1. Initial program 99.8%

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

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

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

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

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

    if 105 < y

    1. Initial program 100.0%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Step-by-step derivation
      1. add-cube-cbrt99.7%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot y} + \log t \]
    5. Step-by-step derivation
      1. neg-mul-163.9%

        \[\leadsto \color{blue}{\left(-y\right)} + \log t \]
    6. Simplified63.9%

      \[\leadsto \color{blue}{\left(-y\right)} + \log t \]
    7. Taylor expanded in y around inf 62.9%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 105:\\ \;\;\;\;\log t\\ \mathbf{else}:\\ \;\;\;\;-y\\ \end{array} \]

Alternative 8: 43.3% accurate, 2.0× speedup?

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

\\
\log t - y
\end{array}
Derivation
  1. Initial program 99.9%

    \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
  2. Step-by-step derivation
    1. add-cube-cbrt99.4%

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

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

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

    \[\leadsto \color{blue}{-1 \cdot y} + \log t \]
  5. Step-by-step derivation
    1. neg-mul-143.2%

      \[\leadsto \color{blue}{\left(-y\right)} + \log t \]
  6. Simplified43.2%

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

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

      \[\leadsto \log t + \color{blue}{\left(-y\right)} \]
    2. sub-neg43.2%

      \[\leadsto \color{blue}{\log t - y} \]
  9. Simplified43.2%

    \[\leadsto \color{blue}{\log t - y} \]
  10. Final simplification43.2%

    \[\leadsto \log t - y \]

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

    \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
  2. Step-by-step derivation
    1. add-cube-cbrt99.4%

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

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

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

    \[\leadsto \color{blue}{-1 \cdot y} + \log t \]
  5. Step-by-step derivation
    1. neg-mul-143.2%

      \[\leadsto \color{blue}{\left(-y\right)} + \log t \]
  6. Simplified43.2%

    \[\leadsto \color{blue}{\left(-y\right)} + \log t \]
  7. Taylor expanded in y around inf 29.4%

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

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

    \[\leadsto \color{blue}{-y} \]
  10. Final simplification29.4%

    \[\leadsto -y \]

Reproduce

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