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

Percentage Accurate: 99.9% → 99.9%
Time: 10.4s
Alternatives: 10
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 10 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. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 60.3% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
t_1 := x \cdot \log y\\
\mathbf{if}\;x \leq -2.2 \cdot 10^{+27}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq -5.6 \cdot 10^{-17}:\\
\;\;\;\;-z\\

\mathbf{elif}\;x \leq 2.2 \cdot 10^{+69}:\\
\;\;\;\;\log t - y\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.1999999999999999e27 or 2.2000000000000002e69 < x

    1. Initial program 99.7%

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

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

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

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

      \[\leadsto x \cdot \log y - \color{blue}{z} \]
    6. Taylor expanded in x around inf 68.4%

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

    if -2.1999999999999999e27 < x < -5.5999999999999998e-17

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto \color{blue}{-z} \]
    7. Simplified71.3%

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

    if -5.5999999999999998e-17 < x < 2.2000000000000002e69

    1. Initial program 100.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\log t - y} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 3: 89.8% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{+25} \lor \neg \left(x \leq 3.05 \cdot 10^{+66}\right):\\
\;\;\;\;x \cdot \log y - y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -4.00000000000000036e25 or 3.0500000000000001e66 < x

    1. Initial program 99.7%

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

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

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

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

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

    if -4.00000000000000036e25 < x < 3.0500000000000001e66

    1. Initial program 100.0%

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

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

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

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

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

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

Alternative 4: 84.0% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{+154} \lor \neg \left(x \leq 1.9 \cdot 10^{+69}\right):\\
\;\;\;\;x \cdot \log y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.69999999999999987e154 or 1.90000000000000014e69 < x

    1. Initial program 99.7%

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

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

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

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

      \[\leadsto x \cdot \log y - \color{blue}{z} \]
    6. Taylor expanded in x around inf 77.3%

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

    if -1.69999999999999987e154 < x < 1.90000000000000014e69

    1. Initial program 100.0%

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

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

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

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

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

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

Alternative 5: 90.0% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
t_1 := x \cdot \log y\\
\mathbf{if}\;x \leq -4.4 \cdot 10^{+25}:\\
\;\;\;\;t\_1 - z\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -4.4000000000000001e25

    1. Initial program 99.7%

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

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

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

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

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

    if -4.4000000000000001e25 < x < 2.89999999999999986e66

    1. Initial program 100.0%

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

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

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

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

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

    if 2.89999999999999986e66 < x

    1. Initial program 99.7%

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

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

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

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

      \[\leadsto x \cdot \log y - \color{blue}{y} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 6: 45.5% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.4 \cdot 10^{-236}:\\
\;\;\;\;-z\\

\mathbf{elif}\;y \leq 1.6 \cdot 10^{-112}:\\
\;\;\;\;\log t\\

\mathbf{elif}\;y \leq 2.65 \cdot 10^{+14}:\\
\;\;\;\;-z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 2.4000000000000002e-236 or 1.59999999999999997e-112 < y < 2.65e14

    1. Initial program 99.9%

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

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

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

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

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

        \[\leadsto \color{blue}{-z} \]
    7. Simplified48.2%

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

    if 2.4000000000000002e-236 < y < 1.59999999999999997e-112

    1. Initial program 99.9%

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

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

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

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

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

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

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

    if 2.65e14 < y

    1. Initial program 99.9%

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

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

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

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

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

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

      \[\leadsto \color{blue}{-y} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 7: 60.0% accurate, 1.9× speedup?

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

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

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


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

    1. Initial program 99.9%

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

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

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

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

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

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

    if 1.1e16 < y

    1. Initial program 99.9%

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

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

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

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

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

        \[\leadsto \color{blue}{-y} \]
    7. Simplified67.1%

      \[\leadsto \color{blue}{-y} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 8: 47.9% accurate, 29.8× speedup?

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

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

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


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

    1. Initial program 99.9%

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

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

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

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

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

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

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

    if 1.65e14 < y

    1. Initial program 99.9%

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

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

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

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

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

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

      \[\leadsto \color{blue}{-y} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 29.6% 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. associate-+l-99.9%

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

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

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

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

      \[\leadsto \color{blue}{-y} \]
  7. Simplified29.6%

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

Alternative 10: 2.2% accurate, 209.0× speedup?

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

\\
z
\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. associate-+l-99.9%

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

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

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

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

      \[\leadsto \color{blue}{-z} \]
  7. Simplified30.2%

    \[\leadsto \color{blue}{-z} \]
  8. Step-by-step derivation
    1. neg-sub030.2%

      \[\leadsto \color{blue}{0 - z} \]
    2. sub-neg30.2%

      \[\leadsto \color{blue}{0 + \left(-z\right)} \]
    3. add-sqr-sqrt16.2%

      \[\leadsto 0 + \color{blue}{\sqrt{-z} \cdot \sqrt{-z}} \]
    4. sqrt-unprod7.1%

      \[\leadsto 0 + \color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}} \]
    5. sqr-neg7.1%

      \[\leadsto 0 + \sqrt{\color{blue}{z \cdot z}} \]
    6. sqrt-unprod0.9%

      \[\leadsto 0 + \color{blue}{\sqrt{z} \cdot \sqrt{z}} \]
    7. add-sqr-sqrt2.1%

      \[\leadsto 0 + \color{blue}{z} \]
  9. Applied egg-rr2.1%

    \[\leadsto \color{blue}{0 + z} \]
  10. Step-by-step derivation
    1. +-lft-identity2.1%

      \[\leadsto \color{blue}{z} \]
  11. Simplified2.1%

    \[\leadsto \color{blue}{z} \]
  12. Add Preprocessing

Reproduce

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