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

Percentage Accurate: 99.9% → 99.8%
Time: 12.0s
Alternatives: 12
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 12 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.8% accurate, 1.0× speedup?

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

\\
\left(\left(\log t - z\right) - y\right) - x \cdot \log \left(\frac{1}{y}\right)
\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 99.9%

    \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \log \left(\frac{1}{y}\right)\right)} - \left(y + \left(z - \log t\right)\right) \]
  6. Final simplification99.9%

    \[\leadsto \left(\left(\log t - z\right) - y\right) - x \cdot \log \left(\frac{1}{y}\right) \]
  7. Add Preprocessing

Alternative 2: 99.9% accurate, 1.0× speedup?

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

\\
\log t + \left(\left(x \cdot \log y - y\right) - z\right)
\end{array}
Derivation
  1. Initial program 99.9%

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

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

Alternative 3: 61.2% accurate, 1.8× speedup?

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

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

\mathbf{elif}\;x \leq -1.5 \cdot 10^{-131}:\\
\;\;\;\;\log t - y\\

\mathbf{elif}\;x \leq 1.35 \cdot 10^{+76}:\\
\;\;\;\;\log t - z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -3.8e92 or 1.34999999999999995e76 < x

    1. Initial program 99.6%

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

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

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

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

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

      \[\leadsto \color{blue}{z \cdot \left(\frac{x \cdot \log y}{z} - \left(1 + \frac{y}{z}\right)\right)} + \log t \]
    6. Step-by-step derivation
      1. associate--r+65.2%

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

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

      \[\leadsto \color{blue}{z \cdot \left(\left(x \cdot \frac{\log y}{z} - 1\right) - \frac{y}{z}\right)} + \log t \]
    8. Step-by-step derivation
      1. clear-num65.0%

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

        \[\leadsto z \cdot \left(\left(\color{blue}{\frac{x}{\frac{z}{\log y}}} - 1\right) - \frac{y}{z}\right) + \log t \]
    9. Applied egg-rr65.1%

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

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

        \[\leadsto z \cdot \left(\left(\frac{x}{\color{blue}{{\left(\frac{\log y}{z}\right)}^{-1}}} - 1\right) - \frac{y}{z}\right) + \log t \]
    11. Applied egg-rr65.1%

      \[\leadsto z \cdot \left(\left(\frac{x}{\color{blue}{{\left(\frac{\log y}{z}\right)}^{-1}}} - 1\right) - \frac{y}{z}\right) + \log t \]
    12. Step-by-step derivation
      1. unpow-165.1%

        \[\leadsto z \cdot \left(\left(\frac{x}{\color{blue}{\frac{1}{\frac{\log y}{z}}}} - 1\right) - \frac{y}{z}\right) + \log t \]
    13. Simplified65.1%

      \[\leadsto z \cdot \left(\left(\frac{x}{\color{blue}{\frac{1}{\frac{\log y}{z}}}} - 1\right) - \frac{y}{z}\right) + \log t \]
    14. Taylor expanded in x around inf 70.3%

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

    if -3.8e92 < x < -1.49999999999999998e-131

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\log t - y} \]
    10. Simplified72.6%

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

    if -1.49999999999999998e-131 < x < 1.34999999999999995e76

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.8 \cdot 10^{+92}:\\ \;\;\;\;x \cdot \log y\\ \mathbf{elif}\;x \leq -1.5 \cdot 10^{-131}:\\ \;\;\;\;\log t - y\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{+76}:\\ \;\;\;\;\log t - z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \log y\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 49.0% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \log y\\ \mathbf{if}\;x \leq -1.8 \cdot 10^{+91}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq -1.45 \cdot 10^{-129}:\\ \;\;\;\;-y\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{+76}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (log y))))
   (if (<= x -1.8e+91)
     t_1
     (if (<= x -1.45e-129) (- y) (if (<= x 1.35e+76) (- z) t_1)))))
double code(double x, double y, double z, double t) {
	double t_1 = x * log(y);
	double tmp;
	if (x <= -1.8e+91) {
		tmp = t_1;
	} else if (x <= -1.45e-129) {
		tmp = -y;
	} else if (x <= 1.35e+76) {
		tmp = -z;
	} 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 <= (-1.8d+91)) then
        tmp = t_1
    else if (x <= (-1.45d-129)) then
        tmp = -y
    else if (x <= 1.35d+76) then
        tmp = -z
    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 <= -1.8e+91) {
		tmp = t_1;
	} else if (x <= -1.45e-129) {
		tmp = -y;
	} else if (x <= 1.35e+76) {
		tmp = -z;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x * math.log(y)
	tmp = 0
	if x <= -1.8e+91:
		tmp = t_1
	elif x <= -1.45e-129:
		tmp = -y
	elif x <= 1.35e+76:
		tmp = -z
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x * log(y))
	tmp = 0.0
	if (x <= -1.8e+91)
		tmp = t_1;
	elseif (x <= -1.45e-129)
		tmp = Float64(-y);
	elseif (x <= 1.35e+76)
		tmp = Float64(-z);
	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 <= -1.8e+91)
		tmp = t_1;
	elseif (x <= -1.45e-129)
		tmp = -y;
	elseif (x <= 1.35e+76)
		tmp = -z;
	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, -1.8e+91], t$95$1, If[LessEqual[x, -1.45e-129], (-y), If[LessEqual[x, 1.35e+76], (-z), t$95$1]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -1.45 \cdot 10^{-129}:\\
\;\;\;\;-y\\

\mathbf{elif}\;x \leq 1.35 \cdot 10^{+76}:\\
\;\;\;\;-z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.8e91 or 1.34999999999999995e76 < x

    1. Initial program 99.6%

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

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

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

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

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

      \[\leadsto \color{blue}{z \cdot \left(\frac{x \cdot \log y}{z} - \left(1 + \frac{y}{z}\right)\right)} + \log t \]
    6. Step-by-step derivation
      1. associate--r+65.2%

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

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

      \[\leadsto \color{blue}{z \cdot \left(\left(x \cdot \frac{\log y}{z} - 1\right) - \frac{y}{z}\right)} + \log t \]
    8. Step-by-step derivation
      1. clear-num65.0%

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

        \[\leadsto z \cdot \left(\left(\color{blue}{\frac{x}{\frac{z}{\log y}}} - 1\right) - \frac{y}{z}\right) + \log t \]
    9. Applied egg-rr65.1%

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

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

        \[\leadsto z \cdot \left(\left(\frac{x}{\color{blue}{{\left(\frac{\log y}{z}\right)}^{-1}}} - 1\right) - \frac{y}{z}\right) + \log t \]
    11. Applied egg-rr65.1%

      \[\leadsto z \cdot \left(\left(\frac{x}{\color{blue}{{\left(\frac{\log y}{z}\right)}^{-1}}} - 1\right) - \frac{y}{z}\right) + \log t \]
    12. Step-by-step derivation
      1. unpow-165.1%

        \[\leadsto z \cdot \left(\left(\frac{x}{\color{blue}{\frac{1}{\frac{\log y}{z}}}} - 1\right) - \frac{y}{z}\right) + \log t \]
    13. Simplified65.1%

      \[\leadsto z \cdot \left(\left(\frac{x}{\color{blue}{\frac{1}{\frac{\log y}{z}}}} - 1\right) - \frac{y}{z}\right) + \log t \]
    14. Taylor expanded in x around inf 70.3%

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

    if -1.8e91 < x < -1.45000000000000008e-129

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-y} \]
    10. Simplified57.1%

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

    if -1.45000000000000008e-129 < x < 1.34999999999999995e76

    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 48.9%

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

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

        \[\leadsto \color{blue}{-z} \]
    8. Simplified44.9%

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

Alternative 5: 89.8% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.1 \cdot 10^{+91} \lor \neg \left(x \leq 3.3 \cdot 10^{+63}\right):\\
\;\;\;\;x \cdot \log y - z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.09999999999999998e91 or 3.3000000000000002e63 < x

    1. Initial program 99.6%

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

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

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

      \[\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.9%

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

    if -3.09999999999999998e91 < x < 3.3000000000000002e63

    1. Initial program 100.0%

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

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

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

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

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

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

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

Alternative 6: 89.0% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.8 \cdot 10^{+93} \lor \neg \left(x \leq 3.6 \cdot 10^{+75}\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 -2.8e+93) (not (<= x 3.6e+75)))
   (- (* x (log y)) y)
   (- (log t) (+ y z))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((x <= -2.8e+93) || !(x <= 3.6e+75)) {
		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 <= (-2.8d+93)) .or. (.not. (x <= 3.6d+75))) 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 <= -2.8e+93) || !(x <= 3.6e+75)) {
		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 <= -2.8e+93) or not (x <= 3.6e+75):
		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 <= -2.8e+93) || !(x <= 3.6e+75))
		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 <= -2.8e+93) || ~((x <= 3.6e+75)))
		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, -2.8e+93], N[Not[LessEqual[x, 3.6e+75]], $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 -2.8 \cdot 10^{+93} \lor \neg \left(x \leq 3.6 \cdot 10^{+75}\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 < -2.79999999999999989e93 or 3.6e75 < x

    1. Initial program 99.6%

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

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

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

      \[\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.6%

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

    if -2.79999999999999989e93 < x < 3.6e75

    1. Initial program 100.0%

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

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

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

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

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

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

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

Alternative 7: 82.4% accurate, 1.8× speedup?

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

    1. Initial program 99.6%

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

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

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

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

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

      \[\leadsto \color{blue}{z \cdot \left(\frac{x \cdot \log y}{z} - \left(1 + \frac{y}{z}\right)\right)} + \log t \]
    6. Step-by-step derivation
      1. associate--r+63.6%

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

        \[\leadsto z \cdot \left(\left(\color{blue}{x \cdot \frac{\log y}{z}} - 1\right) - \frac{y}{z}\right) + \log t \]
    7. Simplified63.5%

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

        \[\leadsto z \cdot \left(\left(x \cdot \color{blue}{\frac{1}{\frac{z}{\log y}}} - 1\right) - \frac{y}{z}\right) + \log t \]
      2. un-div-inv63.5%

        \[\leadsto z \cdot \left(\left(\color{blue}{\frac{x}{\frac{z}{\log y}}} - 1\right) - \frac{y}{z}\right) + \log t \]
    9. Applied egg-rr63.5%

      \[\leadsto z \cdot \left(\left(\color{blue}{\frac{x}{\frac{z}{\log y}}} - 1\right) - \frac{y}{z}\right) + \log t \]
    10. Step-by-step derivation
      1. clear-num63.5%

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

        \[\leadsto z \cdot \left(\left(\frac{x}{\color{blue}{{\left(\frac{\log y}{z}\right)}^{-1}}} - 1\right) - \frac{y}{z}\right) + \log t \]
    11. Applied egg-rr63.5%

      \[\leadsto z \cdot \left(\left(\frac{x}{\color{blue}{{\left(\frac{\log y}{z}\right)}^{-1}}} - 1\right) - \frac{y}{z}\right) + \log t \]
    12. Step-by-step derivation
      1. unpow-163.5%

        \[\leadsto z \cdot \left(\left(\frac{x}{\color{blue}{\frac{1}{\frac{\log y}{z}}}} - 1\right) - \frac{y}{z}\right) + \log t \]
    13. Simplified63.5%

      \[\leadsto z \cdot \left(\left(\frac{x}{\color{blue}{\frac{1}{\frac{\log y}{z}}}} - 1\right) - \frac{y}{z}\right) + \log t \]
    14. Taylor expanded in x around inf 76.4%

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

    if -2.7999999999999999e91 < x < 5.89999999999999972e190

    1. Initial program 100.0%

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

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

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

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

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

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

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

Alternative 8: 89.3% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6 \cdot 10^{+108}:\\
\;\;\;\;\log \left(\frac{1}{y}\right) \cdot \left(-x\right) - z\\

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

\mathbf{else}:\\
\;\;\;\;x \cdot \log y - z\\


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

    1. Initial program 99.5%

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

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

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

      \[\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.9%

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

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

    if -1.6e108 < x < 3.3000000000000002e63

    1. Initial program 100.0%

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

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

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

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

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

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

    if 3.3000000000000002e63 < x

    1. Initial program 99.8%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{+108}:\\ \;\;\;\;\log \left(\frac{1}{y}\right) \cdot \left(-x\right) - z\\ \mathbf{elif}\;x \leq 3.3 \cdot 10^{+63}:\\ \;\;\;\;\log t - \left(y + z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \log y - z\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 59.5% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.02 \cdot 10^{+22} \lor \neg \left(z \leq 20000000\right):\\
\;\;\;\;-z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.02e22 or 2e7 < z

    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 81.7%

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

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

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

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

    if -1.02e22 < z < 2e7

    1. Initial program 99.8%

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, \log y, \left(-y\right) - z\right)} + \log t \]
    3. Simplified99.8%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\log t - y} \]
    10. Simplified65.0%

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

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

Alternative 10: 47.6% accurate, 29.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 126000000:\\
\;\;\;\;-z\\

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


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

    1. Initial program 99.8%

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

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

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

      \[\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 76.0%

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

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

        \[\leadsto \color{blue}{-z} \]
    8. Simplified41.2%

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

    if 1.26e8 < y

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-y} \]
    10. Simplified60.1%

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

Alternative 11: 29.7% accurate, 104.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-y} \]
  10. Simplified30.1%

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

Alternative 12: 2.3% accurate, 209.0× 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 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. sub-neg99.9%

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

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

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

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

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

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

    \[\leadsto \color{blue}{\left(-y\right)} + \log t \]
  8. Step-by-step derivation
    1. *-un-lft-identity43.2%

      \[\leadsto \color{blue}{1 \cdot \left(\left(-y\right) + \log t\right)} \]
    2. add-sqr-sqrt0.0%

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

      \[\leadsto 1 \cdot \left(\color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}} + \log t\right) \]
    4. sqr-neg13.6%

      \[\leadsto 1 \cdot \left(\sqrt{\color{blue}{y \cdot y}} + \log t\right) \]
    5. sqrt-unprod13.5%

      \[\leadsto 1 \cdot \left(\color{blue}{\sqrt{y} \cdot \sqrt{y}} + \log t\right) \]
    6. add-sqr-sqrt13.5%

      \[\leadsto 1 \cdot \left(\color{blue}{y} + \log t\right) \]
  9. Applied egg-rr13.5%

    \[\leadsto \color{blue}{1 \cdot \left(y + \log t\right)} \]
  10. Step-by-step derivation
    1. *-lft-identity13.5%

      \[\leadsto \color{blue}{y + \log t} \]
  11. Simplified13.5%

    \[\leadsto \color{blue}{y + \log t} \]
  12. Taylor expanded in y around inf 2.3%

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

Reproduce

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