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

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

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

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

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


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

    1. Initial program 99.8%

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

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

    if 2.55e-8 < y

    1. Initial program 99.9%

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

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

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

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

      \[\leadsto \color{blue}{\log \left(t \cdot {y}^{x}\right) - \left(y + z\right)} \]
    5. Step-by-step derivation
      1. *-commutative54.2%

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

        \[\leadsto \color{blue}{\left(\log \left({y}^{x}\right) + \log t\right)} - \left(y + z\right) \]
      3. pow-to-exp54.2%

        \[\leadsto \left(\log \color{blue}{\left(e^{\log y \cdot x}\right)} + \log t\right) - \left(y + z\right) \]
      4. rem-log-exp99.9%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(1 \cdot x\right) \cdot \log y} - \left(y + z\right) \]
      3. *-lft-identity99.8%

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

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

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

Alternative 3: 48.4% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \log y\\ \mathbf{if}\;y \leq 1.6 \cdot 10^{-251}:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq 2.95 \cdot 10^{-210}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{-120}:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq 5.5 \cdot 10^{-75}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{-57}:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq 2.5 \cdot 10^{-33}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3400000000000:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq 6.1 \cdot 10^{+28}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{+104}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;-y\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (log y))))
   (if (<= y 1.6e-251)
     (- z)
     (if (<= y 2.95e-210)
       t_1
       (if (<= y 2.6e-120)
         (- z)
         (if (<= y 5.5e-75)
           t_1
           (if (<= y 3.5e-57)
             (- z)
             (if (<= y 2.5e-33)
               t_1
               (if (<= y 3400000000000.0)
                 (- z)
                 (if (<= y 6.1e+28)
                   t_1
                   (if (<= y 1.6e+104) (- z) (- y))))))))))))
double code(double x, double y, double z, double t) {
	double t_1 = x * log(y);
	double tmp;
	if (y <= 1.6e-251) {
		tmp = -z;
	} else if (y <= 2.95e-210) {
		tmp = t_1;
	} else if (y <= 2.6e-120) {
		tmp = -z;
	} else if (y <= 5.5e-75) {
		tmp = t_1;
	} else if (y <= 3.5e-57) {
		tmp = -z;
	} else if (y <= 2.5e-33) {
		tmp = t_1;
	} else if (y <= 3400000000000.0) {
		tmp = -z;
	} else if (y <= 6.1e+28) {
		tmp = t_1;
	} else if (y <= 1.6e+104) {
		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) :: t_1
    real(8) :: tmp
    t_1 = x * log(y)
    if (y <= 1.6d-251) then
        tmp = -z
    else if (y <= 2.95d-210) then
        tmp = t_1
    else if (y <= 2.6d-120) then
        tmp = -z
    else if (y <= 5.5d-75) then
        tmp = t_1
    else if (y <= 3.5d-57) then
        tmp = -z
    else if (y <= 2.5d-33) then
        tmp = t_1
    else if (y <= 3400000000000.0d0) then
        tmp = -z
    else if (y <= 6.1d+28) then
        tmp = t_1
    else if (y <= 1.6d+104) 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 t_1 = x * Math.log(y);
	double tmp;
	if (y <= 1.6e-251) {
		tmp = -z;
	} else if (y <= 2.95e-210) {
		tmp = t_1;
	} else if (y <= 2.6e-120) {
		tmp = -z;
	} else if (y <= 5.5e-75) {
		tmp = t_1;
	} else if (y <= 3.5e-57) {
		tmp = -z;
	} else if (y <= 2.5e-33) {
		tmp = t_1;
	} else if (y <= 3400000000000.0) {
		tmp = -z;
	} else if (y <= 6.1e+28) {
		tmp = t_1;
	} else if (y <= 1.6e+104) {
		tmp = -z;
	} else {
		tmp = -y;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x * math.log(y)
	tmp = 0
	if y <= 1.6e-251:
		tmp = -z
	elif y <= 2.95e-210:
		tmp = t_1
	elif y <= 2.6e-120:
		tmp = -z
	elif y <= 5.5e-75:
		tmp = t_1
	elif y <= 3.5e-57:
		tmp = -z
	elif y <= 2.5e-33:
		tmp = t_1
	elif y <= 3400000000000.0:
		tmp = -z
	elif y <= 6.1e+28:
		tmp = t_1
	elif y <= 1.6e+104:
		tmp = -z
	else:
		tmp = -y
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x * log(y))
	tmp = 0.0
	if (y <= 1.6e-251)
		tmp = Float64(-z);
	elseif (y <= 2.95e-210)
		tmp = t_1;
	elseif (y <= 2.6e-120)
		tmp = Float64(-z);
	elseif (y <= 5.5e-75)
		tmp = t_1;
	elseif (y <= 3.5e-57)
		tmp = Float64(-z);
	elseif (y <= 2.5e-33)
		tmp = t_1;
	elseif (y <= 3400000000000.0)
		tmp = Float64(-z);
	elseif (y <= 6.1e+28)
		tmp = t_1;
	elseif (y <= 1.6e+104)
		tmp = Float64(-z);
	else
		tmp = Float64(-y);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = x * log(y);
	tmp = 0.0;
	if (y <= 1.6e-251)
		tmp = -z;
	elseif (y <= 2.95e-210)
		tmp = t_1;
	elseif (y <= 2.6e-120)
		tmp = -z;
	elseif (y <= 5.5e-75)
		tmp = t_1;
	elseif (y <= 3.5e-57)
		tmp = -z;
	elseif (y <= 2.5e-33)
		tmp = t_1;
	elseif (y <= 3400000000000.0)
		tmp = -z;
	elseif (y <= 6.1e+28)
		tmp = t_1;
	elseif (y <= 1.6e+104)
		tmp = -z;
	else
		tmp = -y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 1.6e-251], (-z), If[LessEqual[y, 2.95e-210], t$95$1, If[LessEqual[y, 2.6e-120], (-z), If[LessEqual[y, 5.5e-75], t$95$1, If[LessEqual[y, 3.5e-57], (-z), If[LessEqual[y, 2.5e-33], t$95$1, If[LessEqual[y, 3400000000000.0], (-z), If[LessEqual[y, 6.1e+28], t$95$1, If[LessEqual[y, 1.6e+104], (-z), (-y)]]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \log y\\
\mathbf{if}\;y \leq 1.6 \cdot 10^{-251}:\\
\;\;\;\;-z\\

\mathbf{elif}\;y \leq 2.95 \cdot 10^{-210}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 2.6 \cdot 10^{-120}:\\
\;\;\;\;-z\\

\mathbf{elif}\;y \leq 5.5 \cdot 10^{-75}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 3.5 \cdot 10^{-57}:\\
\;\;\;\;-z\\

\mathbf{elif}\;y \leq 2.5 \cdot 10^{-33}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 3400000000000:\\
\;\;\;\;-z\\

\mathbf{elif}\;y \leq 6.1 \cdot 10^{+28}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 1.6 \cdot 10^{+104}:\\
\;\;\;\;-z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 1.59999999999999991e-251 or 2.9499999999999999e-210 < y < 2.6000000000000001e-120 or 5.50000000000000026e-75 < y < 3.49999999999999991e-57 or 2.50000000000000014e-33 < y < 3.4e12 or 6.1000000000000002e28 < y < 1.6e104

    1. Initial program 99.9%

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

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

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

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

    if 1.59999999999999991e-251 < y < 2.9499999999999999e-210 or 2.6000000000000001e-120 < y < 5.50000000000000026e-75 or 3.49999999999999991e-57 < y < 2.50000000000000014e-33 or 3.4e12 < y < 6.1000000000000002e28

    1. Initial program 99.7%

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

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

    if 1.6e104 < 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 72.9%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.6 \cdot 10^{-251}:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq 2.95 \cdot 10^{-210}:\\ \;\;\;\;x \cdot \log y\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{-120}:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq 5.5 \cdot 10^{-75}:\\ \;\;\;\;x \cdot \log y\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{-57}:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq 2.5 \cdot 10^{-33}:\\ \;\;\;\;x \cdot \log y\\ \mathbf{elif}\;y \leq 3400000000000:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq 6.1 \cdot 10^{+28}:\\ \;\;\;\;x \cdot \log y\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{+104}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;-y\\ \end{array} \]

Alternative 4: 98.4% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.52 \cdot 10^{+47} \lor \neg \left(x \leq 2.4\right):\\
\;\;\;\;x \cdot \log y - \left(y + z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.52e47 or 2.39999999999999991 < x

    1. Initial program 99.8%

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

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

        \[\leadsto \left(\log t + \color{blue}{\log \left({y}^{x}\right)}\right) - \left(y + z\right) \]
      2. log-prod5.7%

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

      \[\leadsto \color{blue}{\log \left(t \cdot {y}^{x}\right) - \left(y + z\right)} \]
    5. Step-by-step derivation
      1. *-commutative5.7%

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

        \[\leadsto \color{blue}{\left(\log \left({y}^{x}\right) + \log t\right)} - \left(y + z\right) \]
      3. pow-to-exp5.7%

        \[\leadsto \left(\log \color{blue}{\left(e^{\log y \cdot x}\right)} + \log t\right) - \left(y + z\right) \]
      4. rem-log-exp99.8%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(1 \cdot x\right) \cdot \log y} - \left(y + z\right) \]
      3. *-lft-identity99.3%

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

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

    if -1.52e47 < x < 2.39999999999999991

    1. Initial program 99.9%

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

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

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

Alternative 5: 83.6% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -8.2 \cdot 10^{+145} \lor \neg \left(x \leq 6.2 \cdot 10^{+176}\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 -8.2e+145) (not (<= x 6.2e+176)))
   (* x (log y))
   (- (log t) (+ y z))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((x <= -8.2e+145) || !(x <= 6.2e+176)) {
		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 <= (-8.2d+145)) .or. (.not. (x <= 6.2d+176))) 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 <= -8.2e+145) || !(x <= 6.2e+176)) {
		tmp = x * Math.log(y);
	} else {
		tmp = Math.log(t) - (y + z);
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (x <= -8.2e+145) or not (x <= 6.2e+176):
		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 <= -8.2e+145) || !(x <= 6.2e+176))
		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 <= -8.2e+145) || ~((x <= 6.2e+176)))
		tmp = x * log(y);
	else
		tmp = log(t) - (y + z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -8.2e+145], N[Not[LessEqual[x, 6.2e+176]], $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 -8.2 \cdot 10^{+145} \lor \neg \left(x \leq 6.2 \cdot 10^{+176}\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 < -8.2000000000000003e145 or 6.1999999999999998e176 < x

    1. Initial program 99.6%

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

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

    if -8.2000000000000003e145 < x < 6.1999999999999998e176

    1. Initial program 99.9%

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

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

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

Alternative 6: 48.5% accurate, 51.4× speedup?

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

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

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


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

    1. Initial program 99.8%

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

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

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

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

    if 2.80000000000000008e103 < 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 72.9%

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

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

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

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

Alternative 7: 30.0% accurate, 104.5× speedup?

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

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

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

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

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

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

    \[\leadsto -y \]

Reproduce

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