Numeric.SpecFunctions:logGamma from math-functions-0.1.5.2

Percentage Accurate: 55.9% → 84.1%
Time: 18.3s
Alternatives: 15
Speedup: 1.4×

Specification

?
\[\begin{array}{l} \\ \frac{\left(\left(\left(x \cdot y + z\right) \cdot y + 27464.7644705\right) \cdot y + 230661.510616\right) \cdot y + t}{\left(\left(\left(y + a\right) \cdot y + b\right) \cdot y + c\right) \cdot y + i} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (/
  (+ (* (+ (* (+ (* (+ (* x y) z) y) 27464.7644705) y) 230661.510616) y) t)
  (+ (* (+ (* (+ (* (+ y a) y) b) y) c) y) i)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return ((((((((x * y) + z) * y) + 27464.7644705) * y) + 230661.510616) * y) + t) / (((((((y + a) * y) + b) * y) + c) * y) + i);
}
real(8) function code(x, y, z, t, a, b, c, i)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: i
    code = ((((((((x * y) + z) * y) + 27464.7644705d0) * y) + 230661.510616d0) * y) + t) / (((((((y + a) * y) + b) * y) + c) * y) + i)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return ((((((((x * y) + z) * y) + 27464.7644705) * y) + 230661.510616) * y) + t) / (((((((y + a) * y) + b) * y) + c) * y) + i);
}
def code(x, y, z, t, a, b, c, i):
	return ((((((((x * y) + z) * y) + 27464.7644705) * y) + 230661.510616) * y) + t) / (((((((y + a) * y) + b) * y) + c) * y) + i)
function code(x, y, z, t, a, b, c, i)
	return Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(x * y) + z) * y) + 27464.7644705) * y) + 230661.510616) * y) + t) / Float64(Float64(Float64(Float64(Float64(Float64(Float64(y + a) * y) + b) * y) + c) * y) + i))
end
function tmp = code(x, y, z, t, a, b, c, i)
	tmp = ((((((((x * y) + z) * y) + 27464.7644705) * y) + 230661.510616) * y) + t) / (((((((y + a) * y) + b) * y) + c) * y) + i);
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(N[(N[(N[(N[(N[(x * y), $MachinePrecision] + z), $MachinePrecision] * y), $MachinePrecision] + 27464.7644705), $MachinePrecision] * y), $MachinePrecision] + 230661.510616), $MachinePrecision] * y), $MachinePrecision] + t), $MachinePrecision] / N[(N[(N[(N[(N[(N[(N[(y + a), $MachinePrecision] * y), $MachinePrecision] + b), $MachinePrecision] * y), $MachinePrecision] + c), $MachinePrecision] * y), $MachinePrecision] + i), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\left(\left(\left(x \cdot y + z\right) \cdot y + 27464.7644705\right) \cdot y + 230661.510616\right) \cdot y + t}{\left(\left(\left(y + a\right) \cdot y + b\right) \cdot y + c\right) \cdot y + i}
\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 15 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: 55.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\left(\left(\left(x \cdot y + z\right) \cdot y + 27464.7644705\right) \cdot y + 230661.510616\right) \cdot y + t}{\left(\left(\left(y + a\right) \cdot y + b\right) \cdot y + c\right) \cdot y + i} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (/
  (+ (* (+ (* (+ (* (+ (* x y) z) y) 27464.7644705) y) 230661.510616) y) t)
  (+ (* (+ (* (+ (* (+ y a) y) b) y) c) y) i)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return ((((((((x * y) + z) * y) + 27464.7644705) * y) + 230661.510616) * y) + t) / (((((((y + a) * y) + b) * y) + c) * y) + i);
}
real(8) function code(x, y, z, t, a, b, c, i)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: i
    code = ((((((((x * y) + z) * y) + 27464.7644705d0) * y) + 230661.510616d0) * y) + t) / (((((((y + a) * y) + b) * y) + c) * y) + i)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return ((((((((x * y) + z) * y) + 27464.7644705) * y) + 230661.510616) * y) + t) / (((((((y + a) * y) + b) * y) + c) * y) + i);
}
def code(x, y, z, t, a, b, c, i):
	return ((((((((x * y) + z) * y) + 27464.7644705) * y) + 230661.510616) * y) + t) / (((((((y + a) * y) + b) * y) + c) * y) + i)
function code(x, y, z, t, a, b, c, i)
	return Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(x * y) + z) * y) + 27464.7644705) * y) + 230661.510616) * y) + t) / Float64(Float64(Float64(Float64(Float64(Float64(Float64(y + a) * y) + b) * y) + c) * y) + i))
end
function tmp = code(x, y, z, t, a, b, c, i)
	tmp = ((((((((x * y) + z) * y) + 27464.7644705) * y) + 230661.510616) * y) + t) / (((((((y + a) * y) + b) * y) + c) * y) + i);
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(N[(N[(N[(N[(N[(x * y), $MachinePrecision] + z), $MachinePrecision] * y), $MachinePrecision] + 27464.7644705), $MachinePrecision] * y), $MachinePrecision] + 230661.510616), $MachinePrecision] * y), $MachinePrecision] + t), $MachinePrecision] / N[(N[(N[(N[(N[(N[(N[(y + a), $MachinePrecision] * y), $MachinePrecision] + b), $MachinePrecision] * y), $MachinePrecision] + c), $MachinePrecision] * y), $MachinePrecision] + i), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\left(\left(\left(x \cdot y + z\right) \cdot y + 27464.7644705\right) \cdot y + 230661.510616\right) \cdot y + t}{\left(\left(\left(y + a\right) \cdot y + b\right) \cdot y + c\right) \cdot y + i}
\end{array}

Alternative 1: 84.1% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(a + y, y, b\right), y, c\right), y, i\right)\\ \mathbf{if}\;\frac{t + \left(230661.510616 + \left(27464.7644705 + \left(z + y \cdot x\right) \cdot y\right) \cdot y\right) \cdot y}{i + \left(c + \left(b + \left(a + y\right) \cdot y\right) \cdot y\right) \cdot y} \leq \infty:\\ \;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(z, y, 27464.7644705\right), y, 230661.510616\right)}{t\_1}, y, \mathsf{fma}\left(\frac{\left(\left(y \cdot y\right) \cdot y\right) \cdot y}{t\_1}, x, \frac{t}{t\_1}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1 + \frac{a}{y}}{x}}\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (let* ((t_1 (fma (fma (fma (+ a y) y b) y c) y i)))
   (if (<=
        (/
         (+
          t
          (* (+ 230661.510616 (* (+ 27464.7644705 (* (+ z (* y x)) y)) y)) y))
         (+ i (* (+ c (* (+ b (* (+ a y) y)) y)) y)))
        INFINITY)
     (fma
      (/ (fma (fma z y 27464.7644705) y 230661.510616) t_1)
      y
      (fma (/ (* (* (* y y) y) y) t_1) x (/ t t_1)))
     (/ 1.0 (/ (+ 1.0 (/ a y)) x)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double t_1 = fma(fma(fma((a + y), y, b), y, c), y, i);
	double tmp;
	if (((t + ((230661.510616 + ((27464.7644705 + ((z + (y * x)) * y)) * y)) * y)) / (i + ((c + ((b + ((a + y) * y)) * y)) * y))) <= ((double) INFINITY)) {
		tmp = fma((fma(fma(z, y, 27464.7644705), y, 230661.510616) / t_1), y, fma(((((y * y) * y) * y) / t_1), x, (t / t_1)));
	} else {
		tmp = 1.0 / ((1.0 + (a / y)) / x);
	}
	return tmp;
}
function code(x, y, z, t, a, b, c, i)
	t_1 = fma(fma(fma(Float64(a + y), y, b), y, c), y, i)
	tmp = 0.0
	if (Float64(Float64(t + Float64(Float64(230661.510616 + Float64(Float64(27464.7644705 + Float64(Float64(z + Float64(y * x)) * y)) * y)) * y)) / Float64(i + Float64(Float64(c + Float64(Float64(b + Float64(Float64(a + y) * y)) * y)) * y))) <= Inf)
		tmp = fma(Float64(fma(fma(z, y, 27464.7644705), y, 230661.510616) / t_1), y, fma(Float64(Float64(Float64(Float64(y * y) * y) * y) / t_1), x, Float64(t / t_1)));
	else
		tmp = Float64(1.0 / Float64(Float64(1.0 + Float64(a / y)) / x));
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(N[(N[(a + y), $MachinePrecision] * y + b), $MachinePrecision] * y + c), $MachinePrecision] * y + i), $MachinePrecision]}, If[LessEqual[N[(N[(t + N[(N[(230661.510616 + N[(N[(27464.7644705 + N[(N[(z + N[(y * x), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] / N[(i + N[(N[(c + N[(N[(b + N[(N[(a + y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[(N[(z * y + 27464.7644705), $MachinePrecision] * y + 230661.510616), $MachinePrecision] / t$95$1), $MachinePrecision] * y + N[(N[(N[(N[(N[(y * y), $MachinePrecision] * y), $MachinePrecision] * y), $MachinePrecision] / t$95$1), $MachinePrecision] * x + N[(t / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(1.0 + N[(a / y), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(a + y, y, b\right), y, c\right), y, i\right)\\
\mathbf{if}\;\frac{t + \left(230661.510616 + \left(27464.7644705 + \left(z + y \cdot x\right) \cdot y\right) \cdot y\right) \cdot y}{i + \left(c + \left(b + \left(a + y\right) \cdot y\right) \cdot y\right) \cdot y} \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(z, y, 27464.7644705\right), y, 230661.510616\right)}{t\_1}, y, \mathsf{fma}\left(\frac{\left(\left(y \cdot y\right) \cdot y\right) \cdot y}{t\_1}, x, \frac{t}{t\_1}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1 + \frac{a}{y}}{x}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 x y) z) y) #s(literal 54929528941/2000000 binary64)) y) #s(literal 28832688827/125000 binary64)) y) t) (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 y a) y) b) y) c) y) i)) < +inf.0

    1. Initial program 89.5%

      \[\frac{\left(\left(\left(x \cdot y + z\right) \cdot y + 27464.7644705\right) \cdot y + 230661.510616\right) \cdot y + t}{\left(\left(\left(y + a\right) \cdot y + b\right) \cdot y + c\right) \cdot y + i} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{t}{i + y \cdot \left(c + y \cdot \left(b + y \cdot \left(a + y\right)\right)\right)} + \left(\frac{x \cdot {y}^{4}}{i + y \cdot \left(c + y \cdot \left(b + y \cdot \left(a + y\right)\right)\right)} + \frac{y \cdot \left(\frac{28832688827}{125000} + y \cdot \left(\frac{54929528941}{2000000} + y \cdot z\right)\right)}{i + y \cdot \left(c + y \cdot \left(b + y \cdot \left(a + y\right)\right)\right)}\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\frac{x \cdot {y}^{4}}{i + y \cdot \left(c + y \cdot \left(b + y \cdot \left(a + y\right)\right)\right)} + \frac{y \cdot \left(\frac{28832688827}{125000} + y \cdot \left(\frac{54929528941}{2000000} + y \cdot z\right)\right)}{i + y \cdot \left(c + y \cdot \left(b + y \cdot \left(a + y\right)\right)\right)}\right) + \frac{t}{i + y \cdot \left(c + y \cdot \left(b + y \cdot \left(a + y\right)\right)\right)}} \]
      2. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\frac{y \cdot \left(\frac{28832688827}{125000} + y \cdot \left(\frac{54929528941}{2000000} + y \cdot z\right)\right)}{i + y \cdot \left(c + y \cdot \left(b + y \cdot \left(a + y\right)\right)\right)} + \frac{x \cdot {y}^{4}}{i + y \cdot \left(c + y \cdot \left(b + y \cdot \left(a + y\right)\right)\right)}\right)} + \frac{t}{i + y \cdot \left(c + y \cdot \left(b + y \cdot \left(a + y\right)\right)\right)} \]
      3. associate-+l+N/A

        \[\leadsto \color{blue}{\frac{y \cdot \left(\frac{28832688827}{125000} + y \cdot \left(\frac{54929528941}{2000000} + y \cdot z\right)\right)}{i + y \cdot \left(c + y \cdot \left(b + y \cdot \left(a + y\right)\right)\right)} + \left(\frac{x \cdot {y}^{4}}{i + y \cdot \left(c + y \cdot \left(b + y \cdot \left(a + y\right)\right)\right)} + \frac{t}{i + y \cdot \left(c + y \cdot \left(b + y \cdot \left(a + y\right)\right)\right)}\right)} \]
    5. Applied rewrites91.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{\mathsf{fma}\left(\mathsf{fma}\left(z, y, 27464.7644705\right), y, 230661.510616\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(a + y, y, b\right), y, c\right), y, i\right)}, \mathsf{fma}\left(x, \frac{{y}^{4}}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(a + y, y, b\right), y, c\right), y, i\right)}, \frac{t}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(a + y, y, b\right), y, c\right), y, i\right)}\right)\right)} \]
    6. Step-by-step derivation
      1. Applied rewrites91.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(z, y, 27464.7644705\right), y, 230661.510616\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(a + y, y, b\right), y, c\right), y, i\right)}, y, \mathsf{fma}\left(\frac{\left(y \cdot y\right) \cdot \left(y \cdot y\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(a + y, y, b\right), y, c\right), y, i\right)}, x, \frac{t}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(a + y, y, b\right), y, c\right), y, i\right)}\right)\right)} \]
      2. Step-by-step derivation
        1. Applied rewrites91.2%

          \[\leadsto \mathsf{fma}\left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(z, y, 27464.7644705\right), y, 230661.510616\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(a + y, y, b\right), y, c\right), y, i\right)}, y, \mathsf{fma}\left(\frac{\left(\left(y \cdot y\right) \cdot y\right) \cdot y}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(a + y, y, b\right), y, c\right), y, i\right)}, x, \frac{t}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(a + y, y, b\right), y, c\right), y, i\right)}\right)\right) \]

        if +inf.0 < (/.f64 (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 x y) z) y) #s(literal 54929528941/2000000 binary64)) y) #s(literal 28832688827/125000 binary64)) y) t) (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 y a) y) b) y) c) y) i))

        1. Initial program 0.0%

          \[\frac{\left(\left(\left(x \cdot y + z\right) \cdot y + 27464.7644705\right) \cdot y + 230661.510616\right) \cdot y + t}{\left(\left(\left(y + a\right) \cdot y + b\right) \cdot y + c\right) \cdot y + i} \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. lift-/.f64N/A

            \[\leadsto \color{blue}{\frac{\left(\left(\left(x \cdot y + z\right) \cdot y + \frac{54929528941}{2000000}\right) \cdot y + \frac{28832688827}{125000}\right) \cdot y + t}{\left(\left(\left(y + a\right) \cdot y + b\right) \cdot y + c\right) \cdot y + i}} \]
          2. clear-numN/A

            \[\leadsto \color{blue}{\frac{1}{\frac{\left(\left(\left(y + a\right) \cdot y + b\right) \cdot y + c\right) \cdot y + i}{\left(\left(\left(x \cdot y + z\right) \cdot y + \frac{54929528941}{2000000}\right) \cdot y + \frac{28832688827}{125000}\right) \cdot y + t}}} \]
          3. lower-/.f64N/A

            \[\leadsto \color{blue}{\frac{1}{\frac{\left(\left(\left(y + a\right) \cdot y + b\right) \cdot y + c\right) \cdot y + i}{\left(\left(\left(x \cdot y + z\right) \cdot y + \frac{54929528941}{2000000}\right) \cdot y + \frac{28832688827}{125000}\right) \cdot y + t}}} \]
          4. lower-/.f640.0

            \[\leadsto \frac{1}{\color{blue}{\frac{\left(\left(\left(y + a\right) \cdot y + b\right) \cdot y + c\right) \cdot y + i}{\left(\left(\left(x \cdot y + z\right) \cdot y + 27464.7644705\right) \cdot y + 230661.510616\right) \cdot y + t}}} \]
        4. Applied rewrites0.0%

          \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(a + y, y, b\right), y, c\right), y, i\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(y, x, z\right), y, 27464.7644705\right), y, 230661.510616\right), y, t\right)}}} \]
        5. Taylor expanded in y around -inf

          \[\leadsto \frac{1}{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{a}{x} - -1 \cdot \frac{z}{{x}^{2}}}{y} + \frac{1}{x}}} \]
        6. Step-by-step derivation
          1. lower-+.f64N/A

            \[\leadsto \frac{1}{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{a}{x} - -1 \cdot \frac{z}{{x}^{2}}}{y} + \frac{1}{x}}} \]
          2. mul-1-negN/A

            \[\leadsto \frac{1}{\color{blue}{\left(\mathsf{neg}\left(\frac{-1 \cdot \frac{a}{x} - -1 \cdot \frac{z}{{x}^{2}}}{y}\right)\right)} + \frac{1}{x}} \]
          3. lower-neg.f64N/A

            \[\leadsto \frac{1}{\color{blue}{\left(\mathsf{neg}\left(\frac{-1 \cdot \frac{a}{x} - -1 \cdot \frac{z}{{x}^{2}}}{y}\right)\right)} + \frac{1}{x}} \]
          4. lower-/.f64N/A

            \[\leadsto \frac{1}{\left(\mathsf{neg}\left(\color{blue}{\frac{-1 \cdot \frac{a}{x} - -1 \cdot \frac{z}{{x}^{2}}}{y}}\right)\right) + \frac{1}{x}} \]
          5. lower--.f64N/A

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

            \[\leadsto \frac{1}{\left(\mathsf{neg}\left(\frac{\color{blue}{\left(\mathsf{neg}\left(\frac{a}{x}\right)\right)} - -1 \cdot \frac{z}{{x}^{2}}}{y}\right)\right) + \frac{1}{x}} \]
          7. lower-neg.f64N/A

            \[\leadsto \frac{1}{\left(\mathsf{neg}\left(\frac{\color{blue}{\left(\mathsf{neg}\left(\frac{a}{x}\right)\right)} - -1 \cdot \frac{z}{{x}^{2}}}{y}\right)\right) + \frac{1}{x}} \]
          8. lower-/.f64N/A

            \[\leadsto \frac{1}{\left(\mathsf{neg}\left(\frac{\left(\mathsf{neg}\left(\color{blue}{\frac{a}{x}}\right)\right) - -1 \cdot \frac{z}{{x}^{2}}}{y}\right)\right) + \frac{1}{x}} \]
          9. mul-1-negN/A

            \[\leadsto \frac{1}{\left(\mathsf{neg}\left(\frac{\left(\mathsf{neg}\left(\frac{a}{x}\right)\right) - \color{blue}{\left(\mathsf{neg}\left(\frac{z}{{x}^{2}}\right)\right)}}{y}\right)\right) + \frac{1}{x}} \]
          10. lower-neg.f64N/A

            \[\leadsto \frac{1}{\left(\mathsf{neg}\left(\frac{\left(\mathsf{neg}\left(\frac{a}{x}\right)\right) - \color{blue}{\left(\mathsf{neg}\left(\frac{z}{{x}^{2}}\right)\right)}}{y}\right)\right) + \frac{1}{x}} \]
          11. lower-/.f64N/A

            \[\leadsto \frac{1}{\left(\mathsf{neg}\left(\frac{\left(\mathsf{neg}\left(\frac{a}{x}\right)\right) - \left(\mathsf{neg}\left(\color{blue}{\frac{z}{{x}^{2}}}\right)\right)}{y}\right)\right) + \frac{1}{x}} \]
          12. unpow2N/A

            \[\leadsto \frac{1}{\left(\mathsf{neg}\left(\frac{\left(\mathsf{neg}\left(\frac{a}{x}\right)\right) - \left(\mathsf{neg}\left(\frac{z}{\color{blue}{x \cdot x}}\right)\right)}{y}\right)\right) + \frac{1}{x}} \]
          13. lower-*.f64N/A

            \[\leadsto \frac{1}{\left(\mathsf{neg}\left(\frac{\left(\mathsf{neg}\left(\frac{a}{x}\right)\right) - \left(\mathsf{neg}\left(\frac{z}{\color{blue}{x \cdot x}}\right)\right)}{y}\right)\right) + \frac{1}{x}} \]
          14. lower-/.f6459.5

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

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

          \[\leadsto \frac{1}{\frac{1 + \frac{a}{y}}{\color{blue}{x}}} \]
        9. Step-by-step derivation
          1. Applied rewrites66.7%

            \[\leadsto \frac{1}{\frac{1 + \frac{a}{y}}{\color{blue}{x}}} \]
        10. Recombined 2 regimes into one program.
        11. Final simplification82.1%

          \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{t + \left(230661.510616 + \left(27464.7644705 + \left(z + y \cdot x\right) \cdot y\right) \cdot y\right) \cdot y}{i + \left(c + \left(b + \left(a + y\right) \cdot y\right) \cdot y\right) \cdot y} \leq \infty:\\ \;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(z, y, 27464.7644705\right), y, 230661.510616\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(a + y, y, b\right), y, c\right), y, i\right)}, y, \mathsf{fma}\left(\frac{\left(\left(y \cdot y\right) \cdot y\right) \cdot y}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(a + y, y, b\right), y, c\right), y, i\right)}, x, \frac{t}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(a + y, y, b\right), y, c\right), y, i\right)}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1 + \frac{a}{y}}{x}}\\ \end{array} \]
        12. Add Preprocessing

        Alternative 2: 69.2% accurate, 0.3× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{t}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(a + y, y, b\right), y, c\right), y, i\right)}\\ t_2 := \frac{t + \left(230661.510616 + \left(27464.7644705 + \left(z + y \cdot x\right) \cdot y\right) \cdot y\right) \cdot y}{i + \left(c + \left(b + \left(a + y\right) \cdot y\right) \cdot y\right) \cdot y}\\ \mathbf{if}\;t\_2 \leq -4 \cdot 10^{-94}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-11}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(27464.7644705, y, 230661.510616\right), y, t\right)}{c \cdot y + i}\\ \mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+288}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;\frac{z - a \cdot x}{y} + x\\ \end{array} \end{array} \]
        (FPCore (x y z t a b c i)
         :precision binary64
         (let* ((t_1 (/ t (fma (fma (fma (+ a y) y b) y c) y i)))
                (t_2
                 (/
                  (+
                   t
                   (* (+ 230661.510616 (* (+ 27464.7644705 (* (+ z (* y x)) y)) y)) y))
                  (+ i (* (+ c (* (+ b (* (+ a y) y)) y)) y)))))
           (if (<= t_2 -4e-94)
             t_1
             (if (<= t_2 5e-11)
               (/ (fma (fma 27464.7644705 y 230661.510616) y t) (+ (* c y) i))
               (if (<= t_2 5e+288) t_1 (+ (/ (- z (* a x)) y) x))))))
        double code(double x, double y, double z, double t, double a, double b, double c, double i) {
        	double t_1 = t / fma(fma(fma((a + y), y, b), y, c), y, i);
        	double t_2 = (t + ((230661.510616 + ((27464.7644705 + ((z + (y * x)) * y)) * y)) * y)) / (i + ((c + ((b + ((a + y) * y)) * y)) * y));
        	double tmp;
        	if (t_2 <= -4e-94) {
        		tmp = t_1;
        	} else if (t_2 <= 5e-11) {
        		tmp = fma(fma(27464.7644705, y, 230661.510616), y, t) / ((c * y) + i);
        	} else if (t_2 <= 5e+288) {
        		tmp = t_1;
        	} else {
        		tmp = ((z - (a * x)) / y) + x;
        	}
        	return tmp;
        }
        
        function code(x, y, z, t, a, b, c, i)
        	t_1 = Float64(t / fma(fma(fma(Float64(a + y), y, b), y, c), y, i))
        	t_2 = Float64(Float64(t + Float64(Float64(230661.510616 + Float64(Float64(27464.7644705 + Float64(Float64(z + Float64(y * x)) * y)) * y)) * y)) / Float64(i + Float64(Float64(c + Float64(Float64(b + Float64(Float64(a + y) * y)) * y)) * y)))
        	tmp = 0.0
        	if (t_2 <= -4e-94)
        		tmp = t_1;
        	elseif (t_2 <= 5e-11)
        		tmp = Float64(fma(fma(27464.7644705, y, 230661.510616), y, t) / Float64(Float64(c * y) + i));
        	elseif (t_2 <= 5e+288)
        		tmp = t_1;
        	else
        		tmp = Float64(Float64(Float64(z - Float64(a * x)) / y) + x);
        	end
        	return tmp
        end
        
        code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(t / N[(N[(N[(N[(a + y), $MachinePrecision] * y + b), $MachinePrecision] * y + c), $MachinePrecision] * y + i), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t + N[(N[(230661.510616 + N[(N[(27464.7644705 + N[(N[(z + N[(y * x), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] / N[(i + N[(N[(c + N[(N[(b + N[(N[(a + y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -4e-94], t$95$1, If[LessEqual[t$95$2, 5e-11], N[(N[(N[(27464.7644705 * y + 230661.510616), $MachinePrecision] * y + t), $MachinePrecision] / N[(N[(c * y), $MachinePrecision] + i), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e+288], t$95$1, N[(N[(N[(z - N[(a * x), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] + x), $MachinePrecision]]]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_1 := \frac{t}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(a + y, y, b\right), y, c\right), y, i\right)}\\
        t_2 := \frac{t + \left(230661.510616 + \left(27464.7644705 + \left(z + y \cdot x\right) \cdot y\right) \cdot y\right) \cdot y}{i + \left(c + \left(b + \left(a + y\right) \cdot y\right) \cdot y\right) \cdot y}\\
        \mathbf{if}\;t\_2 \leq -4 \cdot 10^{-94}:\\
        \;\;\;\;t\_1\\
        
        \mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-11}:\\
        \;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(27464.7644705, y, 230661.510616\right), y, t\right)}{c \cdot y + i}\\
        
        \mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+288}:\\
        \;\;\;\;t\_1\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{z - a \cdot x}{y} + x\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if (/.f64 (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 x y) z) y) #s(literal 54929528941/2000000 binary64)) y) #s(literal 28832688827/125000 binary64)) y) t) (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 y a) y) b) y) c) y) i)) < -3.9999999999999998e-94 or 5.00000000000000018e-11 < (/.f64 (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 x y) z) y) #s(literal 54929528941/2000000 binary64)) y) #s(literal 28832688827/125000 binary64)) y) t) (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 y a) y) b) y) c) y) i)) < 5.0000000000000003e288

          1. Initial program 95.1%

            \[\frac{\left(\left(\left(x \cdot y + z\right) \cdot y + 27464.7644705\right) \cdot y + 230661.510616\right) \cdot y + t}{\left(\left(\left(y + a\right) \cdot y + b\right) \cdot y + c\right) \cdot y + i} \]
          2. Add Preprocessing
          3. Taylor expanded in t around inf

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

              \[\leadsto \color{blue}{\frac{t}{i + y \cdot \left(c + y \cdot \left(b + y \cdot \left(a + y\right)\right)\right)}} \]
            2. +-commutativeN/A

              \[\leadsto \frac{t}{\color{blue}{y \cdot \left(c + y \cdot \left(b + y \cdot \left(a + y\right)\right)\right) + i}} \]
            3. *-commutativeN/A

              \[\leadsto \frac{t}{\color{blue}{\left(c + y \cdot \left(b + y \cdot \left(a + y\right)\right)\right) \cdot y} + i} \]
            4. lower-fma.f64N/A

              \[\leadsto \frac{t}{\color{blue}{\mathsf{fma}\left(c + y \cdot \left(b + y \cdot \left(a + y\right)\right), y, i\right)}} \]
            5. +-commutativeN/A

              \[\leadsto \frac{t}{\mathsf{fma}\left(\color{blue}{y \cdot \left(b + y \cdot \left(a + y\right)\right) + c}, y, i\right)} \]
            6. *-commutativeN/A

              \[\leadsto \frac{t}{\mathsf{fma}\left(\color{blue}{\left(b + y \cdot \left(a + y\right)\right) \cdot y} + c, y, i\right)} \]
            7. lower-fma.f64N/A

              \[\leadsto \frac{t}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(b + y \cdot \left(a + y\right), y, c\right)}, y, i\right)} \]
            8. +-commutativeN/A

              \[\leadsto \frac{t}{\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{y \cdot \left(a + y\right) + b}, y, c\right), y, i\right)} \]
            9. *-commutativeN/A

              \[\leadsto \frac{t}{\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\left(a + y\right) \cdot y} + b, y, c\right), y, i\right)} \]
            10. lower-fma.f64N/A

              \[\leadsto \frac{t}{\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(a + y, y, b\right)}, y, c\right), y, i\right)} \]
            11. lower-+.f6474.2

              \[\leadsto \frac{t}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{a + y}, y, b\right), y, c\right), y, i\right)} \]
          5. Applied rewrites74.2%

            \[\leadsto \color{blue}{\frac{t}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(a + y, y, b\right), y, c\right), y, i\right)}} \]

          if -3.9999999999999998e-94 < (/.f64 (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 x y) z) y) #s(literal 54929528941/2000000 binary64)) y) #s(literal 28832688827/125000 binary64)) y) t) (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 y a) y) b) y) c) y) i)) < 5.00000000000000018e-11

          1. Initial program 88.7%

            \[\frac{\left(\left(\left(x \cdot y + z\right) \cdot y + 27464.7644705\right) \cdot y + 230661.510616\right) \cdot y + t}{\left(\left(\left(y + a\right) \cdot y + b\right) \cdot y + c\right) \cdot y + i} \]
          2. Add Preprocessing
          3. Taylor expanded in y around 0

            \[\leadsto \frac{\color{blue}{t + y \cdot \left(\frac{28832688827}{125000} + \frac{54929528941}{2000000} \cdot y\right)}}{\left(\left(\left(y + a\right) \cdot y + b\right) \cdot y + c\right) \cdot y + i} \]
          4. Step-by-step derivation
            1. +-commutativeN/A

              \[\leadsto \frac{\color{blue}{y \cdot \left(\frac{28832688827}{125000} + \frac{54929528941}{2000000} \cdot y\right) + t}}{\left(\left(\left(y + a\right) \cdot y + b\right) \cdot y + c\right) \cdot y + i} \]
            2. *-commutativeN/A

              \[\leadsto \frac{\color{blue}{\left(\frac{28832688827}{125000} + \frac{54929528941}{2000000} \cdot y\right) \cdot y} + t}{\left(\left(\left(y + a\right) \cdot y + b\right) \cdot y + c\right) \cdot y + i} \]
            3. lower-fma.f64N/A

              \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{28832688827}{125000} + \frac{54929528941}{2000000} \cdot y, y, t\right)}}{\left(\left(\left(y + a\right) \cdot y + b\right) \cdot y + c\right) \cdot y + i} \]
            4. +-commutativeN/A

              \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\frac{54929528941}{2000000} \cdot y + \frac{28832688827}{125000}}, y, t\right)}{\left(\left(\left(y + a\right) \cdot y + b\right) \cdot y + c\right) \cdot y + i} \]
            5. lower-fma.f6476.1

              \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(27464.7644705, y, 230661.510616\right)}, y, t\right)}{\left(\left(\left(y + a\right) \cdot y + b\right) \cdot y + c\right) \cdot y + i} \]
          5. Applied rewrites76.1%

            \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(27464.7644705, y, 230661.510616\right), y, t\right)}}{\left(\left(\left(y + a\right) \cdot y + b\right) \cdot y + c\right) \cdot y + i} \]
          6. Taylor expanded in y around 0

            \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{54929528941}{2000000}, y, \frac{28832688827}{125000}\right), y, t\right)}{\color{blue}{i + c \cdot y}} \]
          7. Step-by-step derivation
            1. lower-+.f64N/A

              \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{54929528941}{2000000}, y, \frac{28832688827}{125000}\right), y, t\right)}{\color{blue}{i + c \cdot y}} \]
            2. lower-*.f6467.6

              \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(27464.7644705, y, 230661.510616\right), y, t\right)}{i + \color{blue}{c \cdot y}} \]
          8. Applied rewrites67.6%

            \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(27464.7644705, y, 230661.510616\right), y, t\right)}{\color{blue}{i + c \cdot y}} \]

          if 5.0000000000000003e288 < (/.f64 (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 x y) z) y) #s(literal 54929528941/2000000 binary64)) y) #s(literal 28832688827/125000 binary64)) y) t) (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 (*.f64 (+.f64 y a) y) b) y) c) y) i))

          1. Initial program 4.7%

            \[\frac{\left(\left(\left(x \cdot y + z\right) \cdot y + 27464.7644705\right) \cdot y + 230661.510616\right) \cdot y + t}{\left(\left(\left(y + a\right) \cdot y + b\right) \cdot y + c\right) \cdot y + i} \]
          2. Add Preprocessing
          3. Taylor expanded in y around -inf

            \[\leadsto \color{blue}{x + -1 \cdot \frac{-1 \cdot z - -1 \cdot \left(a \cdot x\right)}{y}} \]
          4. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto x + \color{blue}{\left(\mathsf{neg}\left(\frac{-1 \cdot z - -1 \cdot \left(a \cdot x\right)}{y}\right)\right)} \]
            2. unsub-negN/A

              \[\leadsto \color{blue}{x - \frac{-1 \cdot z - -1 \cdot \left(a \cdot x\right)}{y}} \]
            3. lower--.f64N/A

              \[\leadsto \color{blue}{x - \frac{-1 \cdot z - -1 \cdot \left(a \cdot x\right)}{y}} \]
            4. lower-/.f64N/A

              \[\leadsto x - \color{blue}{\frac{-1 \cdot z - -1 \cdot \left(a \cdot x\right)}{y}} \]
            5. distribute-lft-out--N/A

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

              \[\leadsto x - \frac{\color{blue}{\mathsf{neg}\left(\left(z - a \cdot x\right)\right)}}{y} \]
            7. lower-neg.f64N/A

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

              \[\leadsto x - \frac{\mathsf{neg}\left(\color{blue}{\left(z - a \cdot x\right)}\right)}{y} \]
            9. lower-*.f6466.6

              \[\leadsto x - \frac{-\left(z - \color{blue}{a \cdot x}\right)}{y} \]
          5. Applied rewrites66.6%

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{t + \left(230661.510616 + \left(27464.7644705 + \left(z + y \cdot x\right) \cdot y\right) \cdot y\right) \cdot y}{i + \left(c + \left(b + \left(a + y\right) \cdot y\right) \cdot y\right) \cdot y} \leq -4 \cdot 10^{-94}:\\ \;\;\;\;\frac{t}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(a + y, y, b\right), y, c\right), y, i\right)}\\ \mathbf{elif}\;\frac{t + \left(230661.510616 + \left(27464.7644705 + \left(z + y \cdot x\right) \cdot y\right) \cdot y\right) \cdot y}{i + \left(c + \left(b + \left(a + y\right) \cdot y\right) \cdot y\right) \cdot y} \leq 5 \cdot 10^{-11}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(27464.7644705, y, 230661.510616\right), y, t\right)}{c \cdot y + i}\\ \mathbf{elif}\;\frac{t + \left(230661.510616 + \left(27464.7644705 + \left(z + y \cdot x\right) \cdot y\right) \cdot y\right) \cdot y}{i + \left(c + \left(b + \left(a + y\right) \cdot y\right) \cdot y\right) \cdot y} \leq 5 \cdot 10^{+288}:\\ \;\;\;\;\frac{t}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(a + y, y, b\right), y, c\right), y, i\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{z - a \cdot x}{y} + x\\ \end{array} \]
        5. Add Preprocessing

        Reproduce

        ?
        herbie shell --seed 2024230 
        (FPCore (x y z t a b c i)
          :name "Numeric.SpecFunctions:logGamma from math-functions-0.1.5.2"
          :precision binary64
          (/ (+ (* (+ (* (+ (* (+ (* x y) z) y) 27464.7644705) y) 230661.510616) y) t) (+ (* (+ (* (+ (* (+ y a) y) b) y) c) y) i)))