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

Percentage Accurate: 99.9% → 99.9%
Time: 8.1s
Alternatives: 7
Speedup: 1.0×

Specification

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

\\
\left(\left(x \cdot \log y - y\right) - z\right) + \log t
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 7 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.9% accurate, 1.0× speedup?

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

\\
\left(\left(x \cdot \log y - y\right) - z\right) + \log t
\end{array}

Alternative 1: 99.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\log y, x, \left(\log t - y\right) - z\right) \end{array} \]
(FPCore (x y z t) :precision binary64 (fma (log y) x (- (- (log t) y) z)))
double code(double x, double y, double z, double t) {
	return fma(log(y), x, ((log(t) - y) - z));
}
function code(x, y, z, t)
	return fma(log(y), x, Float64(Float64(log(t) - y) - z))
end
code[x_, y_, z_, t_] := N[(N[Log[y], $MachinePrecision] * x + N[(N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\log y, x, \left(\log t - 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. Taylor expanded in x around 0

    \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - \left(y + z\right)} \]
  4. Step-by-step derivation
    1. +-commutativeN/A

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

      \[\leadsto \color{blue}{x \cdot \log y + \left(\log t - \left(y + z\right)\right)} \]
    3. *-rgt-identityN/A

      \[\leadsto x \cdot \log y + \color{blue}{\left(\log t - \left(y + z\right)\right) \cdot 1} \]
    4. *-inversesN/A

      \[\leadsto x \cdot \log y + \left(\log t - \left(y + z\right)\right) \cdot \color{blue}{\frac{x}{x}} \]
    5. fp-cancel-sign-subN/A

      \[\leadsto \color{blue}{x \cdot \log y - \left(\mathsf{neg}\left(\left(\log t - \left(y + z\right)\right)\right)\right) \cdot \frac{x}{x}} \]
    6. mul-1-negN/A

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

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

      \[\leadsto x \cdot \log y - \color{blue}{\frac{-1 \cdot \left(\log t - \left(y + z\right)\right)}{x} \cdot x} \]
    9. associate-*r/N/A

      \[\leadsto x \cdot \log y - \color{blue}{\left(-1 \cdot \frac{\log t - \left(y + z\right)}{x}\right)} \cdot x \]
    10. *-commutativeN/A

      \[\leadsto x \cdot \log y - \color{blue}{x \cdot \left(-1 \cdot \frac{\log t - \left(y + z\right)}{x}\right)} \]
    11. remove-double-negN/A

      \[\leadsto x \cdot \log y - \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)} \cdot \left(-1 \cdot \frac{\log t - \left(y + z\right)}{x}\right) \]
    12. fp-cancel-sign-subN/A

      \[\leadsto \color{blue}{x \cdot \log y + \left(\mathsf{neg}\left(x\right)\right) \cdot \left(-1 \cdot \frac{\log t - \left(y + z\right)}{x}\right)} \]
    13. mul-1-negN/A

      \[\leadsto x \cdot \log y + \color{blue}{\left(-1 \cdot x\right)} \cdot \left(-1 \cdot \frac{\log t - \left(y + z\right)}{x}\right) \]
    14. *-commutativeN/A

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, x, \left(\log t - y\right) - z\right)} \]
  6. Add Preprocessing

Alternative 2: 68.5% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_1 := x \cdot \log y - y\\
\mathbf{if}\;t\_1 \leq -10000:\\
\;\;\;\;\log t - y\\

\mathbf{elif}\;t\_1 \leq 10^{+23}:\\
\;\;\;\;\left(-z\right) + \log t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (*.f64 x (log.f64 y)) y) < -1e4

    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 0

      \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - y} \]
    4. Step-by-step derivation
      1. lower--.f64N/A

        \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - y} \]
      2. +-commutativeN/A

        \[\leadsto \color{blue}{\left(x \cdot \log y + \log t\right)} - y \]
      3. *-commutativeN/A

        \[\leadsto \left(\color{blue}{\log y \cdot x} + \log t\right) - y \]
      4. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, x, \log t\right)} - y \]
      5. lower-log.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\log y}, x, \log t\right) - y \]
      6. lower-log.f6473.4

        \[\leadsto \mathsf{fma}\left(\log y, x, \color{blue}{\log t}\right) - y \]
    5. Applied rewrites73.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, x, \log t\right) - y} \]
    6. Taylor expanded in x around 0

      \[\leadsto \log t - y \]
    7. Step-by-step derivation
      1. Applied rewrites51.4%

        \[\leadsto \log t - y \]

      if -1e4 < (-.f64 (*.f64 x (log.f64 y)) y) < 9.9999999999999992e22

      1. Initial program 100.0%

        \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. lift--.f64N/A

          \[\leadsto \left(\color{blue}{\left(x \cdot \log y - y\right)} - z\right) + \log t \]
        2. flip--N/A

          \[\leadsto \left(\color{blue}{\frac{\left(x \cdot \log y\right) \cdot \left(x \cdot \log y\right) - y \cdot y}{x \cdot \log y + y}} - z\right) + \log t \]
        3. fp-cancel-sub-sign-invN/A

          \[\leadsto \left(\frac{\color{blue}{\left(x \cdot \log y\right) \cdot \left(x \cdot \log y\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot y}}{x \cdot \log y + y} - z\right) + \log t \]
        4. div-addN/A

          \[\leadsto \left(\color{blue}{\left(\frac{\left(x \cdot \log y\right) \cdot \left(x \cdot \log y\right)}{x \cdot \log y + y} + \frac{\left(\mathsf{neg}\left(y\right)\right) \cdot y}{x \cdot \log y + y}\right)} - z\right) + \log t \]
        5. lift-*.f64N/A

          \[\leadsto \left(\left(\frac{\color{blue}{\left(x \cdot \log y\right)} \cdot \left(x \cdot \log y\right)}{x \cdot \log y + y} + \frac{\left(\mathsf{neg}\left(y\right)\right) \cdot y}{x \cdot \log y + y}\right) - z\right) + \log t \]
        6. associate-*l*N/A

          \[\leadsto \left(\left(\frac{\color{blue}{x \cdot \left(\log y \cdot \left(x \cdot \log y\right)\right)}}{x \cdot \log y + y} + \frac{\left(\mathsf{neg}\left(y\right)\right) \cdot y}{x \cdot \log y + y}\right) - z\right) + \log t \]
        7. associate-/l*N/A

          \[\leadsto \left(\left(\color{blue}{x \cdot \frac{\log y \cdot \left(x \cdot \log y\right)}{x \cdot \log y + y}} + \frac{\left(\mathsf{neg}\left(y\right)\right) \cdot y}{x \cdot \log y + y}\right) - z\right) + \log t \]
        8. lower-fma.f64N/A

          \[\leadsto \left(\color{blue}{\mathsf{fma}\left(x, \frac{\log y \cdot \left(x \cdot \log y\right)}{x \cdot \log y + y}, \frac{\left(\mathsf{neg}\left(y\right)\right) \cdot y}{x \cdot \log y + y}\right)} - z\right) + \log t \]
      4. Applied rewrites100.0%

        \[\leadsto \left(\color{blue}{\mathsf{fma}\left(x, \frac{{\log y}^{2} \cdot x}{\mathsf{fma}\left(\log y, x, y\right)}, \frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)}\right)} - z\right) + \log t \]
      5. Step-by-step derivation
        1. lift--.f64N/A

          \[\leadsto \color{blue}{\left(\mathsf{fma}\left(x, \frac{{\log y}^{2} \cdot x}{\mathsf{fma}\left(\log y, x, y\right)}, \frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)}\right) - z\right)} + \log t \]
        2. lift-fma.f64N/A

          \[\leadsto \left(\color{blue}{\left(x \cdot \frac{{\log y}^{2} \cdot x}{\mathsf{fma}\left(\log y, x, y\right)} + \frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)}\right)} - z\right) + \log t \]
        3. associate--l+N/A

          \[\leadsto \color{blue}{\left(x \cdot \frac{{\log y}^{2} \cdot x}{\mathsf{fma}\left(\log y, x, y\right)} + \left(\frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)} - z\right)\right)} + \log t \]
        4. lift-/.f64N/A

          \[\leadsto \left(x \cdot \color{blue}{\frac{{\log y}^{2} \cdot x}{\mathsf{fma}\left(\log y, x, y\right)}} + \left(\frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)} - z\right)\right) + \log t \]
        5. lift-*.f64N/A

          \[\leadsto \left(x \cdot \frac{\color{blue}{{\log y}^{2} \cdot x}}{\mathsf{fma}\left(\log y, x, y\right)} + \left(\frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)} - z\right)\right) + \log t \]
        6. associate-/l*N/A

          \[\leadsto \left(x \cdot \color{blue}{\left({\log y}^{2} \cdot \frac{x}{\mathsf{fma}\left(\log y, x, y\right)}\right)} + \left(\frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)} - z\right)\right) + \log t \]
        7. associate-*r*N/A

          \[\leadsto \left(\color{blue}{\left(x \cdot {\log y}^{2}\right) \cdot \frac{x}{\mathsf{fma}\left(\log y, x, y\right)}} + \left(\frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)} - z\right)\right) + \log t \]
        8. *-commutativeN/A

          \[\leadsto \left(\color{blue}{\left({\log y}^{2} \cdot x\right)} \cdot \frac{x}{\mathsf{fma}\left(\log y, x, y\right)} + \left(\frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)} - z\right)\right) + \log t \]
        9. lift-*.f64N/A

          \[\leadsto \left(\color{blue}{\left({\log y}^{2} \cdot x\right)} \cdot \frac{x}{\mathsf{fma}\left(\log y, x, y\right)} + \left(\frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)} - z\right)\right) + \log t \]
        10. lower-fma.f64N/A

          \[\leadsto \color{blue}{\mathsf{fma}\left({\log y}^{2} \cdot x, \frac{x}{\mathsf{fma}\left(\log y, x, y\right)}, \frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)} - z\right)} + \log t \]
        11. lower-/.f64N/A

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

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

        \[\leadsto \color{blue}{-1 \cdot z} + \log t \]
      8. Step-by-step derivation
        1. mul-1-negN/A

          \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z\right)\right)} + \log t \]
        2. lower-neg.f6498.5

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

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

      if 9.9999999999999992e22 < (-.f64 (*.f64 x (log.f64 y)) y)

      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. lift--.f64N/A

          \[\leadsto \left(\color{blue}{\left(x \cdot \log y - y\right)} - z\right) + \log t \]
        2. flip--N/A

          \[\leadsto \left(\color{blue}{\frac{\left(x \cdot \log y\right) \cdot \left(x \cdot \log y\right) - y \cdot y}{x \cdot \log y + y}} - z\right) + \log t \]
        3. fp-cancel-sub-sign-invN/A

          \[\leadsto \left(\frac{\color{blue}{\left(x \cdot \log y\right) \cdot \left(x \cdot \log y\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot y}}{x \cdot \log y + y} - z\right) + \log t \]
        4. div-addN/A

          \[\leadsto \left(\color{blue}{\left(\frac{\left(x \cdot \log y\right) \cdot \left(x \cdot \log y\right)}{x \cdot \log y + y} + \frac{\left(\mathsf{neg}\left(y\right)\right) \cdot y}{x \cdot \log y + y}\right)} - z\right) + \log t \]
        5. lift-*.f64N/A

          \[\leadsto \left(\left(\frac{\color{blue}{\left(x \cdot \log y\right)} \cdot \left(x \cdot \log y\right)}{x \cdot \log y + y} + \frac{\left(\mathsf{neg}\left(y\right)\right) \cdot y}{x \cdot \log y + y}\right) - z\right) + \log t \]
        6. associate-*l*N/A

          \[\leadsto \left(\left(\frac{\color{blue}{x \cdot \left(\log y \cdot \left(x \cdot \log y\right)\right)}}{x \cdot \log y + y} + \frac{\left(\mathsf{neg}\left(y\right)\right) \cdot y}{x \cdot \log y + y}\right) - z\right) + \log t \]
        7. associate-/l*N/A

          \[\leadsto \left(\left(\color{blue}{x \cdot \frac{\log y \cdot \left(x \cdot \log y\right)}{x \cdot \log y + y}} + \frac{\left(\mathsf{neg}\left(y\right)\right) \cdot y}{x \cdot \log y + y}\right) - z\right) + \log t \]
        8. lower-fma.f64N/A

          \[\leadsto \left(\color{blue}{\mathsf{fma}\left(x, \frac{\log y \cdot \left(x \cdot \log y\right)}{x \cdot \log y + y}, \frac{\left(\mathsf{neg}\left(y\right)\right) \cdot y}{x \cdot \log y + y}\right)} - z\right) + \log t \]
      4. Applied rewrites91.7%

        \[\leadsto \left(\color{blue}{\mathsf{fma}\left(x, \frac{{\log y}^{2} \cdot x}{\mathsf{fma}\left(\log y, x, y\right)}, \frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)}\right)} - z\right) + \log t \]
      5. Step-by-step derivation
        1. lift--.f64N/A

          \[\leadsto \color{blue}{\left(\mathsf{fma}\left(x, \frac{{\log y}^{2} \cdot x}{\mathsf{fma}\left(\log y, x, y\right)}, \frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)}\right) - z\right)} + \log t \]
        2. lift-fma.f64N/A

          \[\leadsto \left(\color{blue}{\left(x \cdot \frac{{\log y}^{2} \cdot x}{\mathsf{fma}\left(\log y, x, y\right)} + \frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)}\right)} - z\right) + \log t \]
        3. associate--l+N/A

          \[\leadsto \color{blue}{\left(x \cdot \frac{{\log y}^{2} \cdot x}{\mathsf{fma}\left(\log y, x, y\right)} + \left(\frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)} - z\right)\right)} + \log t \]
        4. lift-/.f64N/A

          \[\leadsto \left(x \cdot \color{blue}{\frac{{\log y}^{2} \cdot x}{\mathsf{fma}\left(\log y, x, y\right)}} + \left(\frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)} - z\right)\right) + \log t \]
        5. lift-*.f64N/A

          \[\leadsto \left(x \cdot \frac{\color{blue}{{\log y}^{2} \cdot x}}{\mathsf{fma}\left(\log y, x, y\right)} + \left(\frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)} - z\right)\right) + \log t \]
        6. associate-/l*N/A

          \[\leadsto \left(x \cdot \color{blue}{\left({\log y}^{2} \cdot \frac{x}{\mathsf{fma}\left(\log y, x, y\right)}\right)} + \left(\frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)} - z\right)\right) + \log t \]
        7. associate-*r*N/A

          \[\leadsto \left(\color{blue}{\left(x \cdot {\log y}^{2}\right) \cdot \frac{x}{\mathsf{fma}\left(\log y, x, y\right)}} + \left(\frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)} - z\right)\right) + \log t \]
        8. *-commutativeN/A

          \[\leadsto \left(\color{blue}{\left({\log y}^{2} \cdot x\right)} \cdot \frac{x}{\mathsf{fma}\left(\log y, x, y\right)} + \left(\frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)} - z\right)\right) + \log t \]
        9. lift-*.f64N/A

          \[\leadsto \left(\color{blue}{\left({\log y}^{2} \cdot x\right)} \cdot \frac{x}{\mathsf{fma}\left(\log y, x, y\right)} + \left(\frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)} - z\right)\right) + \log t \]
        10. lower-fma.f64N/A

          \[\leadsto \color{blue}{\mathsf{fma}\left({\log y}^{2} \cdot x, \frac{x}{\mathsf{fma}\left(\log y, x, y\right)}, \frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)} - z\right)} + \log t \]
        11. lower-/.f64N/A

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

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

        \[\leadsto \mathsf{fma}\left({\log y}^{2} \cdot x, \color{blue}{\frac{1}{\log y}}, \frac{y}{\mathsf{fma}\left(\log y, x, y\right)} \cdot \left(-y\right) - z\right) + \log t \]
      8. Step-by-step derivation
        1. lower-/.f64N/A

          \[\leadsto \mathsf{fma}\left({\log y}^{2} \cdot x, \color{blue}{\frac{1}{\log y}}, \frac{y}{\mathsf{fma}\left(\log y, x, y\right)} \cdot \left(-y\right) - z\right) + \log t \]
        2. lower-log.f6499.3

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

        \[\leadsto \mathsf{fma}\left({\log y}^{2} \cdot x, \color{blue}{\frac{1}{\log y}}, \frac{y}{\mathsf{fma}\left(\log y, x, y\right)} \cdot \left(-y\right) - z\right) + \log t \]
      10. Taylor expanded in x around inf

        \[\leadsto \color{blue}{x \cdot \log y} \]
      11. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \color{blue}{\log y \cdot x} \]
        2. lower-*.f64N/A

          \[\leadsto \color{blue}{\log y \cdot x} \]
        3. lower-log.f6479.0

          \[\leadsto \color{blue}{\log y} \cdot x \]
      12. Applied rewrites79.0%

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

    Alternative 3: 99.3% accurate, 1.0× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -120000000 \lor \neg \left(z \leq 1.4 \cdot 10^{-7}\right):\\ \;\;\;\;\mathsf{fma}\left(\log y, x, \left(\frac{-y}{z} - 1\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\log y, x, \log t\right) - y\\ \end{array} \end{array} \]
    (FPCore (x y z t)
     :precision binary64
     (if (or (<= z -120000000.0) (not (<= z 1.4e-7)))
       (fma (log y) x (* (- (/ (- y) z) 1.0) z))
       (- (fma (log y) x (log t)) y)))
    double code(double x, double y, double z, double t) {
    	double tmp;
    	if ((z <= -120000000.0) || !(z <= 1.4e-7)) {
    		tmp = fma(log(y), x, (((-y / z) - 1.0) * z));
    	} else {
    		tmp = fma(log(y), x, log(t)) - y;
    	}
    	return tmp;
    }
    
    function code(x, y, z, t)
    	tmp = 0.0
    	if ((z <= -120000000.0) || !(z <= 1.4e-7))
    		tmp = fma(log(y), x, Float64(Float64(Float64(Float64(-y) / z) - 1.0) * z));
    	else
    		tmp = Float64(fma(log(y), x, log(t)) - y);
    	end
    	return tmp
    end
    
    code[x_, y_, z_, t_] := If[Or[LessEqual[z, -120000000.0], N[Not[LessEqual[z, 1.4e-7]], $MachinePrecision]], N[(N[Log[y], $MachinePrecision] * x + N[(N[(N[((-y) / z), $MachinePrecision] - 1.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * x + N[Log[t], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;z \leq -120000000 \lor \neg \left(z \leq 1.4 \cdot 10^{-7}\right):\\
    \;\;\;\;\mathsf{fma}\left(\log y, x, \left(\frac{-y}{z} - 1\right) \cdot z\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\mathsf{fma}\left(\log y, x, \log t\right) - y\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if z < -1.2e8 or 1.4000000000000001e-7 < z

      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

        \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - \left(y + z\right)} \]
      4. Step-by-step derivation
        1. +-commutativeN/A

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

          \[\leadsto \color{blue}{x \cdot \log y + \left(\log t - \left(y + z\right)\right)} \]
        3. *-rgt-identityN/A

          \[\leadsto x \cdot \log y + \color{blue}{\left(\log t - \left(y + z\right)\right) \cdot 1} \]
        4. *-inversesN/A

          \[\leadsto x \cdot \log y + \left(\log t - \left(y + z\right)\right) \cdot \color{blue}{\frac{x}{x}} \]
        5. fp-cancel-sign-subN/A

          \[\leadsto \color{blue}{x \cdot \log y - \left(\mathsf{neg}\left(\left(\log t - \left(y + z\right)\right)\right)\right) \cdot \frac{x}{x}} \]
        6. mul-1-negN/A

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

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

          \[\leadsto x \cdot \log y - \color{blue}{\frac{-1 \cdot \left(\log t - \left(y + z\right)\right)}{x} \cdot x} \]
        9. associate-*r/N/A

          \[\leadsto x \cdot \log y - \color{blue}{\left(-1 \cdot \frac{\log t - \left(y + z\right)}{x}\right)} \cdot x \]
        10. *-commutativeN/A

          \[\leadsto x \cdot \log y - \color{blue}{x \cdot \left(-1 \cdot \frac{\log t - \left(y + z\right)}{x}\right)} \]
        11. remove-double-negN/A

          \[\leadsto x \cdot \log y - \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)} \cdot \left(-1 \cdot \frac{\log t - \left(y + z\right)}{x}\right) \]
        12. fp-cancel-sign-subN/A

          \[\leadsto \color{blue}{x \cdot \log y + \left(\mathsf{neg}\left(x\right)\right) \cdot \left(-1 \cdot \frac{\log t - \left(y + z\right)}{x}\right)} \]
        13. mul-1-negN/A

          \[\leadsto x \cdot \log y + \color{blue}{\left(-1 \cdot x\right)} \cdot \left(-1 \cdot \frac{\log t - \left(y + z\right)}{x}\right) \]
        14. *-commutativeN/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, x, \left(\log t - y\right) - z\right)} \]
      6. Taylor expanded in y around 0

        \[\leadsto \mathsf{fma}\left(\log y, x, \log t - z\right) \]
      7. Step-by-step derivation
        1. Applied rewrites84.8%

          \[\leadsto \mathsf{fma}\left(\log y, x, \log t - z\right) \]
        2. Taylor expanded in z around inf

          \[\leadsto \mathsf{fma}\left(\log y, x, z \cdot \left(\frac{\log t}{z} - \left(1 + \frac{y}{z}\right)\right)\right) \]
        3. Step-by-step derivation
          1. Applied rewrites99.9%

            \[\leadsto \mathsf{fma}\left(\log y, x, \left(\frac{\log t - y}{z} - 1\right) \cdot z\right) \]
          2. Taylor expanded in y around inf

            \[\leadsto \mathsf{fma}\left(\log y, x, \left(-1 \cdot \frac{y}{z} - 1\right) \cdot z\right) \]
          3. Step-by-step derivation
            1. Applied rewrites99.4%

              \[\leadsto \mathsf{fma}\left(\log y, x, \left(\frac{-y}{z} - 1\right) \cdot z\right) \]

            if -1.2e8 < z < 1.4000000000000001e-7

            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 0

              \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - y} \]
            4. Step-by-step derivation
              1. lower--.f64N/A

                \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - y} \]
              2. +-commutativeN/A

                \[\leadsto \color{blue}{\left(x \cdot \log y + \log t\right)} - y \]
              3. *-commutativeN/A

                \[\leadsto \left(\color{blue}{\log y \cdot x} + \log t\right) - y \]
              4. lower-fma.f64N/A

                \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, x, \log t\right)} - y \]
              5. lower-log.f64N/A

                \[\leadsto \mathsf{fma}\left(\color{blue}{\log y}, x, \log t\right) - y \]
              6. lower-log.f6498.9

                \[\leadsto \mathsf{fma}\left(\log y, x, \color{blue}{\log t}\right) - y \]
            5. Applied rewrites98.9%

              \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, x, \log t\right) - y} \]
          4. Recombined 2 regimes into one program.
          5. Final simplification99.2%

            \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -120000000 \lor \neg \left(z \leq 1.4 \cdot 10^{-7}\right):\\ \;\;\;\;\mathsf{fma}\left(\log y, x, \left(\frac{-y}{z} - 1\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\log y, x, \log t\right) - y\\ \end{array} \]
          6. Add Preprocessing

          Alternative 4: 92.5% accurate, 1.5× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -4 \cdot 10^{+20} \lor \neg \left(x \leq 2 \cdot 10^{+21}\right):\\ \;\;\;\;\mathsf{fma}\left(\log y, x, \left(\frac{-y}{z} - 1\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\log t - y\right) - z\\ \end{array} \end{array} \]
          (FPCore (x y z t)
           :precision binary64
           (if (or (<= x -4e+20) (not (<= x 2e+21)))
             (fma (log y) x (* (- (/ (- y) z) 1.0) z))
             (- (- (log t) y) z)))
          double code(double x, double y, double z, double t) {
          	double tmp;
          	if ((x <= -4e+20) || !(x <= 2e+21)) {
          		tmp = fma(log(y), x, (((-y / z) - 1.0) * z));
          	} else {
          		tmp = (log(t) - y) - z;
          	}
          	return tmp;
          }
          
          function code(x, y, z, t)
          	tmp = 0.0
          	if ((x <= -4e+20) || !(x <= 2e+21))
          		tmp = fma(log(y), x, Float64(Float64(Float64(Float64(-y) / z) - 1.0) * z));
          	else
          		tmp = Float64(Float64(log(t) - y) - z);
          	end
          	return tmp
          end
          
          code[x_, y_, z_, t_] := If[Or[LessEqual[x, -4e+20], N[Not[LessEqual[x, 2e+21]], $MachinePrecision]], N[(N[Log[y], $MachinePrecision] * x + N[(N[(N[((-y) / z), $MachinePrecision] - 1.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;x \leq -4 \cdot 10^{+20} \lor \neg \left(x \leq 2 \cdot 10^{+21}\right):\\
          \;\;\;\;\mathsf{fma}\left(\log y, x, \left(\frac{-y}{z} - 1\right) \cdot z\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;\left(\log t - y\right) - z\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if x < -4e20 or 2e21 < x

            1. Initial program 99.8%

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

              \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - \left(y + z\right)} \]
            4. Step-by-step derivation
              1. +-commutativeN/A

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

                \[\leadsto \color{blue}{x \cdot \log y + \left(\log t - \left(y + z\right)\right)} \]
              3. *-rgt-identityN/A

                \[\leadsto x \cdot \log y + \color{blue}{\left(\log t - \left(y + z\right)\right) \cdot 1} \]
              4. *-inversesN/A

                \[\leadsto x \cdot \log y + \left(\log t - \left(y + z\right)\right) \cdot \color{blue}{\frac{x}{x}} \]
              5. fp-cancel-sign-subN/A

                \[\leadsto \color{blue}{x \cdot \log y - \left(\mathsf{neg}\left(\left(\log t - \left(y + z\right)\right)\right)\right) \cdot \frac{x}{x}} \]
              6. mul-1-negN/A

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

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

                \[\leadsto x \cdot \log y - \color{blue}{\frac{-1 \cdot \left(\log t - \left(y + z\right)\right)}{x} \cdot x} \]
              9. associate-*r/N/A

                \[\leadsto x \cdot \log y - \color{blue}{\left(-1 \cdot \frac{\log t - \left(y + z\right)}{x}\right)} \cdot x \]
              10. *-commutativeN/A

                \[\leadsto x \cdot \log y - \color{blue}{x \cdot \left(-1 \cdot \frac{\log t - \left(y + z\right)}{x}\right)} \]
              11. remove-double-negN/A

                \[\leadsto x \cdot \log y - \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)} \cdot \left(-1 \cdot \frac{\log t - \left(y + z\right)}{x}\right) \]
              12. fp-cancel-sign-subN/A

                \[\leadsto \color{blue}{x \cdot \log y + \left(\mathsf{neg}\left(x\right)\right) \cdot \left(-1 \cdot \frac{\log t - \left(y + z\right)}{x}\right)} \]
              13. mul-1-negN/A

                \[\leadsto x \cdot \log y + \color{blue}{\left(-1 \cdot x\right)} \cdot \left(-1 \cdot \frac{\log t - \left(y + z\right)}{x}\right) \]
              14. *-commutativeN/A

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, x, \left(\log t - y\right) - z\right)} \]
            6. Taylor expanded in y around 0

              \[\leadsto \mathsf{fma}\left(\log y, x, \log t - z\right) \]
            7. Step-by-step derivation
              1. Applied rewrites81.4%

                \[\leadsto \mathsf{fma}\left(\log y, x, \log t - z\right) \]
              2. Taylor expanded in z around inf

                \[\leadsto \mathsf{fma}\left(\log y, x, z \cdot \left(\frac{\log t}{z} - \left(1 + \frac{y}{z}\right)\right)\right) \]
              3. Step-by-step derivation
                1. Applied rewrites90.4%

                  \[\leadsto \mathsf{fma}\left(\log y, x, \left(\frac{\log t - y}{z} - 1\right) \cdot z\right) \]
                2. Taylor expanded in y around inf

                  \[\leadsto \mathsf{fma}\left(\log y, x, \left(-1 \cdot \frac{y}{z} - 1\right) \cdot z\right) \]
                3. Step-by-step derivation
                  1. Applied rewrites90.4%

                    \[\leadsto \mathsf{fma}\left(\log y, x, \left(\frac{-y}{z} - 1\right) \cdot z\right) \]

                  if -4e20 < x < 2e21

                  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

                    \[\leadsto \color{blue}{\log t - \left(y + z\right)} \]
                  4. Step-by-step derivation
                    1. associate--r+N/A

                      \[\leadsto \color{blue}{\left(\log t - y\right) - z} \]
                    2. *-lft-identityN/A

                      \[\leadsto \left(\log t - \color{blue}{1 \cdot y}\right) - z \]
                    3. metadata-evalN/A

                      \[\leadsto \left(\log t - \color{blue}{\left(\mathsf{neg}\left(-1\right)\right)} \cdot y\right) - z \]
                    4. fp-cancel-sign-sub-invN/A

                      \[\leadsto \color{blue}{\left(\log t + -1 \cdot y\right)} - z \]
                    5. lower--.f64N/A

                      \[\leadsto \color{blue}{\left(\log t + -1 \cdot y\right) - z} \]
                    6. fp-cancel-sign-sub-invN/A

                      \[\leadsto \color{blue}{\left(\log t - \left(\mathsf{neg}\left(-1\right)\right) \cdot y\right)} - z \]
                    7. metadata-evalN/A

                      \[\leadsto \left(\log t - \color{blue}{1} \cdot y\right) - z \]
                    8. *-lft-identityN/A

                      \[\leadsto \left(\log t - \color{blue}{y}\right) - z \]
                    9. lower--.f64N/A

                      \[\leadsto \color{blue}{\left(\log t - y\right)} - z \]
                    10. lower-log.f6498.3

                      \[\leadsto \left(\color{blue}{\log t} - y\right) - z \]
                  5. Applied rewrites98.3%

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

                  \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4 \cdot 10^{+20} \lor \neg \left(x \leq 2 \cdot 10^{+21}\right):\\ \;\;\;\;\mathsf{fma}\left(\log y, x, \left(\frac{-y}{z} - 1\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\log t - y\right) - z\\ \end{array} \]
                6. Add Preprocessing

                Alternative 5: 83.7% accurate, 1.8× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -8 \cdot 10^{+107} \lor \neg \left(x \leq 10^{+126}\right):\\ \;\;\;\;\log y \cdot x\\ \mathbf{else}:\\ \;\;\;\;\left(\log t - y\right) - z\\ \end{array} \end{array} \]
                (FPCore (x y z t)
                 :precision binary64
                 (if (or (<= x -8e+107) (not (<= x 1e+126)))
                   (* (log y) x)
                   (- (- (log t) y) z)))
                double code(double x, double y, double z, double t) {
                	double tmp;
                	if ((x <= -8e+107) || !(x <= 1e+126)) {
                		tmp = log(y) * x;
                	} 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 <= (-8d+107)) .or. (.not. (x <= 1d+126))) then
                        tmp = log(y) * x
                    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 <= -8e+107) || !(x <= 1e+126)) {
                		tmp = Math.log(y) * x;
                	} else {
                		tmp = (Math.log(t) - y) - z;
                	}
                	return tmp;
                }
                
                def code(x, y, z, t):
                	tmp = 0
                	if (x <= -8e+107) or not (x <= 1e+126):
                		tmp = math.log(y) * x
                	else:
                		tmp = (math.log(t) - y) - z
                	return tmp
                
                function code(x, y, z, t)
                	tmp = 0.0
                	if ((x <= -8e+107) || !(x <= 1e+126))
                		tmp = Float64(log(y) * x);
                	else
                		tmp = Float64(Float64(log(t) - y) - z);
                	end
                	return tmp
                end
                
                function tmp_2 = code(x, y, z, t)
                	tmp = 0.0;
                	if ((x <= -8e+107) || ~((x <= 1e+126)))
                		tmp = log(y) * x;
                	else
                		tmp = (log(t) - y) - z;
                	end
                	tmp_2 = tmp;
                end
                
                code[x_, y_, z_, t_] := If[Or[LessEqual[x, -8e+107], N[Not[LessEqual[x, 1e+126]], $MachinePrecision]], N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision], N[(N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;x \leq -8 \cdot 10^{+107} \lor \neg \left(x \leq 10^{+126}\right):\\
                \;\;\;\;\log y \cdot x\\
                
                \mathbf{else}:\\
                \;\;\;\;\left(\log t - y\right) - z\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if x < -7.9999999999999998e107 or 9.99999999999999925e125 < 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. lift--.f64N/A

                      \[\leadsto \left(\color{blue}{\left(x \cdot \log y - y\right)} - z\right) + \log t \]
                    2. flip--N/A

                      \[\leadsto \left(\color{blue}{\frac{\left(x \cdot \log y\right) \cdot \left(x \cdot \log y\right) - y \cdot y}{x \cdot \log y + y}} - z\right) + \log t \]
                    3. fp-cancel-sub-sign-invN/A

                      \[\leadsto \left(\frac{\color{blue}{\left(x \cdot \log y\right) \cdot \left(x \cdot \log y\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot y}}{x \cdot \log y + y} - z\right) + \log t \]
                    4. div-addN/A

                      \[\leadsto \left(\color{blue}{\left(\frac{\left(x \cdot \log y\right) \cdot \left(x \cdot \log y\right)}{x \cdot \log y + y} + \frac{\left(\mathsf{neg}\left(y\right)\right) \cdot y}{x \cdot \log y + y}\right)} - z\right) + \log t \]
                    5. lift-*.f64N/A

                      \[\leadsto \left(\left(\frac{\color{blue}{\left(x \cdot \log y\right)} \cdot \left(x \cdot \log y\right)}{x \cdot \log y + y} + \frac{\left(\mathsf{neg}\left(y\right)\right) \cdot y}{x \cdot \log y + y}\right) - z\right) + \log t \]
                    6. associate-*l*N/A

                      \[\leadsto \left(\left(\frac{\color{blue}{x \cdot \left(\log y \cdot \left(x \cdot \log y\right)\right)}}{x \cdot \log y + y} + \frac{\left(\mathsf{neg}\left(y\right)\right) \cdot y}{x \cdot \log y + y}\right) - z\right) + \log t \]
                    7. associate-/l*N/A

                      \[\leadsto \left(\left(\color{blue}{x \cdot \frac{\log y \cdot \left(x \cdot \log y\right)}{x \cdot \log y + y}} + \frac{\left(\mathsf{neg}\left(y\right)\right) \cdot y}{x \cdot \log y + y}\right) - z\right) + \log t \]
                    8. lower-fma.f64N/A

                      \[\leadsto \left(\color{blue}{\mathsf{fma}\left(x, \frac{\log y \cdot \left(x \cdot \log y\right)}{x \cdot \log y + y}, \frac{\left(\mathsf{neg}\left(y\right)\right) \cdot y}{x \cdot \log y + y}\right)} - z\right) + \log t \]
                  4. Applied rewrites81.6%

                    \[\leadsto \left(\color{blue}{\mathsf{fma}\left(x, \frac{{\log y}^{2} \cdot x}{\mathsf{fma}\left(\log y, x, y\right)}, \frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)}\right)} - z\right) + \log t \]
                  5. Step-by-step derivation
                    1. lift--.f64N/A

                      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(x, \frac{{\log y}^{2} \cdot x}{\mathsf{fma}\left(\log y, x, y\right)}, \frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)}\right) - z\right)} + \log t \]
                    2. lift-fma.f64N/A

                      \[\leadsto \left(\color{blue}{\left(x \cdot \frac{{\log y}^{2} \cdot x}{\mathsf{fma}\left(\log y, x, y\right)} + \frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)}\right)} - z\right) + \log t \]
                    3. associate--l+N/A

                      \[\leadsto \color{blue}{\left(x \cdot \frac{{\log y}^{2} \cdot x}{\mathsf{fma}\left(\log y, x, y\right)} + \left(\frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)} - z\right)\right)} + \log t \]
                    4. lift-/.f64N/A

                      \[\leadsto \left(x \cdot \color{blue}{\frac{{\log y}^{2} \cdot x}{\mathsf{fma}\left(\log y, x, y\right)}} + \left(\frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)} - z\right)\right) + \log t \]
                    5. lift-*.f64N/A

                      \[\leadsto \left(x \cdot \frac{\color{blue}{{\log y}^{2} \cdot x}}{\mathsf{fma}\left(\log y, x, y\right)} + \left(\frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)} - z\right)\right) + \log t \]
                    6. associate-/l*N/A

                      \[\leadsto \left(x \cdot \color{blue}{\left({\log y}^{2} \cdot \frac{x}{\mathsf{fma}\left(\log y, x, y\right)}\right)} + \left(\frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)} - z\right)\right) + \log t \]
                    7. associate-*r*N/A

                      \[\leadsto \left(\color{blue}{\left(x \cdot {\log y}^{2}\right) \cdot \frac{x}{\mathsf{fma}\left(\log y, x, y\right)}} + \left(\frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)} - z\right)\right) + \log t \]
                    8. *-commutativeN/A

                      \[\leadsto \left(\color{blue}{\left({\log y}^{2} \cdot x\right)} \cdot \frac{x}{\mathsf{fma}\left(\log y, x, y\right)} + \left(\frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)} - z\right)\right) + \log t \]
                    9. lift-*.f64N/A

                      \[\leadsto \left(\color{blue}{\left({\log y}^{2} \cdot x\right)} \cdot \frac{x}{\mathsf{fma}\left(\log y, x, y\right)} + \left(\frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)} - z\right)\right) + \log t \]
                    10. lower-fma.f64N/A

                      \[\leadsto \color{blue}{\mathsf{fma}\left({\log y}^{2} \cdot x, \frac{x}{\mathsf{fma}\left(\log y, x, y\right)}, \frac{\left(-y\right) \cdot y}{\mathsf{fma}\left(\log y, x, y\right)} - z\right)} + \log t \]
                    11. lower-/.f64N/A

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

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

                    \[\leadsto \mathsf{fma}\left({\log y}^{2} \cdot x, \color{blue}{\frac{1}{\log y}}, \frac{y}{\mathsf{fma}\left(\log y, x, y\right)} \cdot \left(-y\right) - z\right) + \log t \]
                  8. Step-by-step derivation
                    1. lower-/.f64N/A

                      \[\leadsto \mathsf{fma}\left({\log y}^{2} \cdot x, \color{blue}{\frac{1}{\log y}}, \frac{y}{\mathsf{fma}\left(\log y, x, y\right)} \cdot \left(-y\right) - z\right) + \log t \]
                    2. lower-log.f6498.5

                      \[\leadsto \mathsf{fma}\left({\log y}^{2} \cdot x, \frac{1}{\color{blue}{\log y}}, \frac{y}{\mathsf{fma}\left(\log y, x, y\right)} \cdot \left(-y\right) - z\right) + \log t \]
                  9. Applied rewrites98.5%

                    \[\leadsto \mathsf{fma}\left({\log y}^{2} \cdot x, \color{blue}{\frac{1}{\log y}}, \frac{y}{\mathsf{fma}\left(\log y, x, y\right)} \cdot \left(-y\right) - z\right) + \log t \]
                  10. Taylor expanded in x around inf

                    \[\leadsto \color{blue}{x \cdot \log y} \]
                  11. Step-by-step derivation
                    1. *-commutativeN/A

                      \[\leadsto \color{blue}{\log y \cdot x} \]
                    2. lower-*.f64N/A

                      \[\leadsto \color{blue}{\log y \cdot x} \]
                    3. lower-log.f6478.1

                      \[\leadsto \color{blue}{\log y} \cdot x \]
                  12. Applied rewrites78.1%

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

                  if -7.9999999999999998e107 < x < 9.99999999999999925e125

                  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

                    \[\leadsto \color{blue}{\log t - \left(y + z\right)} \]
                  4. Step-by-step derivation
                    1. associate--r+N/A

                      \[\leadsto \color{blue}{\left(\log t - y\right) - z} \]
                    2. *-lft-identityN/A

                      \[\leadsto \left(\log t - \color{blue}{1 \cdot y}\right) - z \]
                    3. metadata-evalN/A

                      \[\leadsto \left(\log t - \color{blue}{\left(\mathsf{neg}\left(-1\right)\right)} \cdot y\right) - z \]
                    4. fp-cancel-sign-sub-invN/A

                      \[\leadsto \color{blue}{\left(\log t + -1 \cdot y\right)} - z \]
                    5. lower--.f64N/A

                      \[\leadsto \color{blue}{\left(\log t + -1 \cdot y\right) - z} \]
                    6. fp-cancel-sign-sub-invN/A

                      \[\leadsto \color{blue}{\left(\log t - \left(\mathsf{neg}\left(-1\right)\right) \cdot y\right)} - z \]
                    7. metadata-evalN/A

                      \[\leadsto \left(\log t - \color{blue}{1} \cdot y\right) - z \]
                    8. *-lft-identityN/A

                      \[\leadsto \left(\log t - \color{blue}{y}\right) - z \]
                    9. lower--.f64N/A

                      \[\leadsto \color{blue}{\left(\log t - y\right)} - z \]
                    10. lower-log.f6492.1

                      \[\leadsto \left(\color{blue}{\log t} - y\right) - z \]
                  5. Applied rewrites92.1%

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

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

                Alternative 6: 59.5% accurate, 1.9× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.15 \cdot 10^{+27} \lor \neg \left(z \leq 2.6 \cdot 10^{+142}\right):\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;\log t - y\\ \end{array} \end{array} \]
                (FPCore (x y z t)
                 :precision binary64
                 (if (or (<= z -1.15e+27) (not (<= z 2.6e+142))) (- z) (- (log t) y)))
                double code(double x, double y, double z, double t) {
                	double tmp;
                	if ((z <= -1.15e+27) || !(z <= 2.6e+142)) {
                		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.15d+27)) .or. (.not. (z <= 2.6d+142))) 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.15e+27) || !(z <= 2.6e+142)) {
                		tmp = -z;
                	} else {
                		tmp = Math.log(t) - y;
                	}
                	return tmp;
                }
                
                def code(x, y, z, t):
                	tmp = 0
                	if (z <= -1.15e+27) or not (z <= 2.6e+142):
                		tmp = -z
                	else:
                		tmp = math.log(t) - y
                	return tmp
                
                function code(x, y, z, t)
                	tmp = 0.0
                	if ((z <= -1.15e+27) || !(z <= 2.6e+142))
                		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.15e+27) || ~((z <= 2.6e+142)))
                		tmp = -z;
                	else
                		tmp = log(t) - y;
                	end
                	tmp_2 = tmp;
                end
                
                code[x_, y_, z_, t_] := If[Or[LessEqual[z, -1.15e+27], N[Not[LessEqual[z, 2.6e+142]], $MachinePrecision]], (-z), N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;z \leq -1.15 \cdot 10^{+27} \lor \neg \left(z \leq 2.6 \cdot 10^{+142}\right):\\
                \;\;\;\;-z\\
                
                \mathbf{else}:\\
                \;\;\;\;\log t - y\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if z < -1.15e27 or 2.60000000000000021e142 < z

                  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

                    \[\leadsto \color{blue}{-1 \cdot z} \]
                  4. Step-by-step derivation
                    1. mul-1-negN/A

                      \[\leadsto \color{blue}{\mathsf{neg}\left(z\right)} \]
                    2. lower-neg.f6476.1

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

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

                  if -1.15e27 < z < 2.60000000000000021e142

                  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 0

                    \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - y} \]
                  4. Step-by-step derivation
                    1. lower--.f64N/A

                      \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - y} \]
                    2. +-commutativeN/A

                      \[\leadsto \color{blue}{\left(x \cdot \log y + \log t\right)} - y \]
                    3. *-commutativeN/A

                      \[\leadsto \left(\color{blue}{\log y \cdot x} + \log t\right) - y \]
                    4. lower-fma.f64N/A

                      \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, x, \log t\right)} - y \]
                    5. lower-log.f64N/A

                      \[\leadsto \mathsf{fma}\left(\color{blue}{\log y}, x, \log t\right) - y \]
                    6. lower-log.f6493.5

                      \[\leadsto \mathsf{fma}\left(\log y, x, \color{blue}{\log t}\right) - y \]
                  5. Applied rewrites93.5%

                    \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, x, \log t\right) - y} \]
                  6. Taylor expanded in x around 0

                    \[\leadsto \log t - y \]
                  7. Step-by-step derivation
                    1. Applied rewrites58.3%

                      \[\leadsto \log t - y \]
                  8. Recombined 2 regimes into one program.
                  9. Final simplification65.5%

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

                  Alternative 7: 28.8% accurate, 71.7× speedup?

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

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

                    \[\leadsto \color{blue}{-1 \cdot z} \]
                  4. Step-by-step derivation
                    1. mul-1-negN/A

                      \[\leadsto \color{blue}{\mathsf{neg}\left(z\right)} \]
                    2. lower-neg.f6435.6

                      \[\leadsto \color{blue}{-z} \]
                  5. Applied rewrites35.6%

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

                  Reproduce

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