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

Percentage Accurate: 99.9% → 99.9%
Time: 12.9s
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. Final simplification99.9%

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

Alternative 2: 88.2% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.65e47 or 1.24999999999999998e149 < z

    1. Initial program 100.0%

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

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

    if -2.65e47 < z < 1.24999999999999998e149

    1. Initial program 99.8%

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

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

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

Alternative 3: 89.1% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 99.8%

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

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

    if 1.90000000000000011e27 < y

    1. Initial program 99.9%

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

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

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

Alternative 4: 48.7% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.3 \cdot 10^{-298}:\\
\;\;\;\;\log t\\

\mathbf{elif}\;y \leq 2 \cdot 10^{-94}:\\
\;\;\;\;-z\\

\mathbf{elif}\;y \leq 1.75 \cdot 10^{-9}:\\
\;\;\;\;x \cdot \log y\\

\mathbf{elif}\;y \leq 2.3 \cdot 10^{+44}:\\
\;\;\;\;-z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < 3.3000000000000002e-298

    1. Initial program 99.7%

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

      \[\leadsto \color{blue}{z \cdot \left(\frac{x \cdot \log y}{z} - \left(1 + \frac{y}{z}\right)\right)} + \log t \]
    4. Step-by-step derivation
      1. associate-/l*99.7%

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \log y} + \log t \]
    9. Taylor expanded in x around 0 90.0%

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

    if 3.3000000000000002e-298 < y < 1.9999999999999999e-94 or 1.75e-9 < y < 2.30000000000000004e44

    1. Initial program 99.9%

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

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

        \[\leadsto \color{blue}{-z} \]
    5. Simplified46.0%

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

    if 1.9999999999999999e-94 < y < 1.75e-9

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

    if 2.30000000000000004e44 < y

    1. Initial program 99.9%

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

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

        \[\leadsto \color{blue}{-y} \]
    5. Simplified70.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 3.3 \cdot 10^{-298}:\\ \;\;\;\;\log t\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-94}:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq 1.75 \cdot 10^{-9}:\\ \;\;\;\;x \cdot \log y\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{+44}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;-y\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 58.7% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
t_1 := \log t - z\\
\mathbf{if}\;y \leq 6.5 \cdot 10^{-60}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 5 \cdot 10^{-15}:\\
\;\;\;\;x \cdot \log y\\

\mathbf{elif}\;y \leq 3.4 \cdot 10^{+44}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 6.49999999999999995e-60 or 4.99999999999999999e-15 < y < 3.4e44

    1. Initial program 99.9%

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

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

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

    if 6.49999999999999995e-60 < y < 4.99999999999999999e-15

    1. Initial program 99.5%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Add Preprocessing
    3. 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. sub-neg99.5%

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

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

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

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

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

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

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

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

    if 3.4e44 < y

    1. Initial program 99.9%

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

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

        \[\leadsto \color{blue}{-y} \]
    5. Simplified70.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 6.5 \cdot 10^{-60}:\\ \;\;\;\;\log t - z\\ \mathbf{elif}\;y \leq 5 \cdot 10^{-15}:\\ \;\;\;\;x \cdot \log y\\ \mathbf{elif}\;y \leq 3.4 \cdot 10^{+44}:\\ \;\;\;\;\log t - z\\ \mathbf{else}:\\ \;\;\;\;-y\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 58.7% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
t_1 := \log t - z\\
\mathbf{if}\;y \leq 1.15 \cdot 10^{-59}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 5.8 \cdot 10^{-15}:\\
\;\;\;\;x \cdot \log y\\

\mathbf{elif}\;y \leq 3.4 \cdot 10^{+44}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 1.1499999999999999e-59 or 5.80000000000000037e-15 < y < 3.4e44

    1. Initial program 99.9%

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

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

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

    if 1.1499999999999999e-59 < y < 5.80000000000000037e-15

    1. Initial program 99.5%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Add Preprocessing
    3. 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. sub-neg99.5%

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

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

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

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

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

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

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

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

    if 3.4e44 < y

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{z \cdot \left(\frac{x \cdot \log y}{z} - \left(1 + \frac{y}{z}\right)\right)} + \log t \]
    4. Step-by-step derivation
      1. associate-/l*70.6%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.15 \cdot 10^{-59}:\\ \;\;\;\;\log t - z\\ \mathbf{elif}\;y \leq 5.8 \cdot 10^{-15}:\\ \;\;\;\;x \cdot \log y\\ \mathbf{elif}\;y \leq 3.4 \cdot 10^{+44}:\\ \;\;\;\;\log t - z\\ \mathbf{else}:\\ \;\;\;\;\log t - y\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 47.5% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 6 \cdot 10^{-298}:\\
\;\;\;\;\log t\\

\mathbf{elif}\;y \leq 2.1 \cdot 10^{-95}:\\
\;\;\;\;-z\\

\mathbf{elif}\;y \leq 2.4 \cdot 10^{-46}:\\
\;\;\;\;\log t\\

\mathbf{elif}\;y \leq 2.5 \cdot 10^{+44}:\\
\;\;\;\;-z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 5.9999999999999999e-298 or 2.1e-95 < y < 2.40000000000000013e-46

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{z \cdot \left(\frac{x \cdot \log y}{z} - \left(1 + \frac{y}{z}\right)\right)} + \log t \]
    4. Step-by-step derivation
      1. associate-/l*91.0%

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \log y} + \log t \]
    9. Taylor expanded in x around 0 62.7%

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

    if 5.9999999999999999e-298 < y < 2.1e-95 or 2.40000000000000013e-46 < y < 2.4999999999999998e44

    1. Initial program 99.8%

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

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

        \[\leadsto \color{blue}{-z} \]
    5. Simplified43.8%

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

    if 2.4999999999999998e44 < y

    1. Initial program 99.9%

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

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

        \[\leadsto \color{blue}{-y} \]
    5. Simplified70.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 6 \cdot 10^{-298}:\\ \;\;\;\;\log t\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{-95}:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{-46}:\\ \;\;\;\;\log t\\ \mathbf{elif}\;y \leq 2.5 \cdot 10^{+44}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;-y\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 83.6% accurate, 1.8× speedup?

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

    1. Initial program 99.6%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Add Preprocessing
    3. 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. sub-neg99.6%

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

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

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

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

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

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

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

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

    if -5.2000000000000003e200 < x < 1.8499999999999999e157

    1. Initial program 99.9%

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

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

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

Alternative 9: 48.6% accurate, 29.8× speedup?

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

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

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


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

    1. Initial program 99.8%

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

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

        \[\leadsto \color{blue}{-z} \]
    5. Simplified38.1%

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

    if 2.19999999999999996e44 < y

    1. Initial program 99.9%

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

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

        \[\leadsto \color{blue}{-y} \]
    5. Simplified70.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 2.2 \cdot 10^{+44}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;-y\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 30.1% 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. Add Preprocessing
  3. Taylor expanded in y around inf 34.0%

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

      \[\leadsto \color{blue}{-y} \]
  5. Simplified34.0%

    \[\leadsto \color{blue}{-y} \]
  6. Final simplification34.0%

    \[\leadsto -y \]
  7. Add Preprocessing

Reproduce

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