Numeric.SpecFunctions:logBeta from math-functions-0.1.5.2, B

Percentage Accurate: 99.8% → 99.8%
Time: 13.9s
Alternatives: 13
Speedup: 1.0×

Specification

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

\\
\left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot 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 13 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.8% accurate, 1.0× speedup?

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

\\
\left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i
\end{array}

Alternative 1: 99.8% accurate, 1.0× speedup?

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

\\
i \cdot y + \left(\log c \cdot \left(b - 0.5\right) + \left(a + \left(t + \left(z + \log y \cdot x\right)\right)\right)\right)
\end{array}
Derivation
  1. Initial program 99.5%

    \[\left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i \]
  2. Add Preprocessing
  3. Final simplification99.5%

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

Alternative 2: 47.0% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \log c \cdot b\\ t_2 := \log y \cdot x\\ t_3 := i \cdot y + \left(\log c \cdot \left(b - 0.5\right) + \left(a + \left(t + \left(z + t\_2\right)\right)\right)\right)\\ \mathbf{if}\;t\_3 \leq -1 \cdot 10^{+303}:\\ \;\;\;\;t\_2 + i \cdot y\\ \mathbf{elif}\;t\_3 \leq -2 \cdot 10^{+192}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, t, t\right)\\ \mathbf{elif}\;t\_3 \leq 2 \cdot 10^{+71}:\\ \;\;\;\;\mathsf{fma}\left(y, i, t\_1\right)\\ \mathbf{elif}\;t\_3 \leq 2 \cdot 10^{+303}:\\ \;\;\;\;t\_1 + \left(a + t\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{a} \cdot i, a, a\right)\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (let* ((t_1 (* (log c) b))
        (t_2 (* (log y) x))
        (t_3 (+ (* i y) (+ (* (log c) (- b 0.5)) (+ a (+ t (+ z t_2)))))))
   (if (<= t_3 -1e+303)
     (+ t_2 (* i y))
     (if (<= t_3 -2e+192)
       (fma (/ z t) t t)
       (if (<= t_3 2e+71)
         (fma y i t_1)
         (if (<= t_3 2e+303) (+ t_1 (+ a t)) (fma (* (/ y a) i) a a)))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double t_1 = log(c) * b;
	double t_2 = log(y) * x;
	double t_3 = (i * y) + ((log(c) * (b - 0.5)) + (a + (t + (z + t_2))));
	double tmp;
	if (t_3 <= -1e+303) {
		tmp = t_2 + (i * y);
	} else if (t_3 <= -2e+192) {
		tmp = fma((z / t), t, t);
	} else if (t_3 <= 2e+71) {
		tmp = fma(y, i, t_1);
	} else if (t_3 <= 2e+303) {
		tmp = t_1 + (a + t);
	} else {
		tmp = fma(((y / a) * i), a, a);
	}
	return tmp;
}
function code(x, y, z, t, a, b, c, i)
	t_1 = Float64(log(c) * b)
	t_2 = Float64(log(y) * x)
	t_3 = Float64(Float64(i * y) + Float64(Float64(log(c) * Float64(b - 0.5)) + Float64(a + Float64(t + Float64(z + t_2)))))
	tmp = 0.0
	if (t_3 <= -1e+303)
		tmp = Float64(t_2 + Float64(i * y));
	elseif (t_3 <= -2e+192)
		tmp = fma(Float64(z / t), t, t);
	elseif (t_3 <= 2e+71)
		tmp = fma(y, i, t_1);
	elseif (t_3 <= 2e+303)
		tmp = Float64(t_1 + Float64(a + t));
	else
		tmp = fma(Float64(Float64(y / a) * i), a, a);
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[Log[c], $MachinePrecision] * b), $MachinePrecision]}, Block[{t$95$2 = N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision]}, Block[{t$95$3 = N[(N[(i * y), $MachinePrecision] + N[(N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision]), $MachinePrecision] + N[(a + N[(t + N[(z + t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, -1e+303], N[(t$95$2 + N[(i * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, -2e+192], N[(N[(z / t), $MachinePrecision] * t + t), $MachinePrecision], If[LessEqual[t$95$3, 2e+71], N[(y * i + t$95$1), $MachinePrecision], If[LessEqual[t$95$3, 2e+303], N[(t$95$1 + N[(a + t), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y / a), $MachinePrecision] * i), $MachinePrecision] * a + a), $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \log c \cdot b\\
t_2 := \log y \cdot x\\
t_3 := i \cdot y + \left(\log c \cdot \left(b - 0.5\right) + \left(a + \left(t + \left(z + t\_2\right)\right)\right)\right)\\
\mathbf{if}\;t\_3 \leq -1 \cdot 10^{+303}:\\
\;\;\;\;t\_2 + i \cdot y\\

\mathbf{elif}\;t\_3 \leq -2 \cdot 10^{+192}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, t, t\right)\\

\mathbf{elif}\;t\_3 \leq 2 \cdot 10^{+71}:\\
\;\;\;\;\mathsf{fma}\left(y, i, t\_1\right)\\

\mathbf{elif}\;t\_3 \leq 2 \cdot 10^{+303}:\\
\;\;\;\;t\_1 + \left(a + t\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a} \cdot i, a, a\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) < -1e303

    1. Initial program 99.9%

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

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

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

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

        \[\leadsto \color{blue}{\log y} \cdot x + y \cdot i \]
    5. Applied rewrites79.6%

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

    if -1e303 < (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) < -2.00000000000000008e192

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{-1 \cdot \left(t \cdot \left(-1 \cdot \frac{a + \left(z + \left(i \cdot y + \left(x \cdot \log y + \log c \cdot \left(b - \frac{1}{2}\right)\right)\right)\right)}{t} - 1\right)\right)} \]
    4. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \color{blue}{\left(-1 \cdot t\right) \cdot \left(-1 \cdot \frac{a + \left(z + \left(i \cdot y + \left(x \cdot \log y + \log c \cdot \left(b - \frac{1}{2}\right)\right)\right)\right)}{t} - 1\right)} \]
      2. sub-negN/A

        \[\leadsto \left(-1 \cdot t\right) \cdot \color{blue}{\left(-1 \cdot \frac{a + \left(z + \left(i \cdot y + \left(x \cdot \log y + \log c \cdot \left(b - \frac{1}{2}\right)\right)\right)\right)}{t} + \left(\mathsf{neg}\left(1\right)\right)\right)} \]
      3. metadata-evalN/A

        \[\leadsto \left(-1 \cdot t\right) \cdot \left(-1 \cdot \frac{a + \left(z + \left(i \cdot y + \left(x \cdot \log y + \log c \cdot \left(b - \frac{1}{2}\right)\right)\right)\right)}{t} + \color{blue}{-1}\right) \]
      4. distribute-rgt-inN/A

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

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

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

        \[\leadsto \frac{a + \left(z + \left(i \cdot y + \left(x \cdot \log y + \log c \cdot \left(b - \frac{1}{2}\right)\right)\right)\right)}{t} \cdot \color{blue}{\left(\left(-1 \cdot -1\right) \cdot t\right)} + -1 \cdot \left(-1 \cdot t\right) \]
      8. metadata-evalN/A

        \[\leadsto \frac{a + \left(z + \left(i \cdot y + \left(x \cdot \log y + \log c \cdot \left(b - \frac{1}{2}\right)\right)\right)\right)}{t} \cdot \left(\color{blue}{1} \cdot t\right) + -1 \cdot \left(-1 \cdot t\right) \]
      9. *-lft-identityN/A

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

        \[\leadsto \frac{a + \left(z + \left(i \cdot y + \left(x \cdot \log y + \log c \cdot \left(b - \frac{1}{2}\right)\right)\right)\right)}{t} \cdot t + \color{blue}{\left(-1 \cdot -1\right) \cdot t} \]
    5. Applied rewrites65.5%

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

      \[\leadsto \mathsf{fma}\left(\frac{z}{t}, t, t\right) \]
    7. Step-by-step derivation
      1. Applied rewrites29.5%

        \[\leadsto \mathsf{fma}\left(\frac{z}{t}, t, t\right) \]

      if -2.00000000000000008e192 < (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) < 2.0000000000000001e71

      1. Initial program 99.8%

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

        \[\leadsto \color{blue}{b \cdot \log c} + y \cdot i \]
      4. Step-by-step derivation
        1. lower-*.f64N/A

          \[\leadsto \color{blue}{b \cdot \log c} + y \cdot i \]
        2. lower-log.f6426.3

          \[\leadsto b \cdot \color{blue}{\log c} + y \cdot i \]
      5. Applied rewrites26.3%

        \[\leadsto \color{blue}{b \cdot \log c} + y \cdot i \]
      6. Step-by-step derivation
        1. lift-+.f64N/A

          \[\leadsto \color{blue}{b \cdot \log c + y \cdot i} \]
        2. +-commutativeN/A

          \[\leadsto \color{blue}{y \cdot i + b \cdot \log c} \]
        3. lift-*.f64N/A

          \[\leadsto \color{blue}{y \cdot i} + b \cdot \log c \]
        4. lower-fma.f6426.3

          \[\leadsto \color{blue}{\mathsf{fma}\left(y, i, b \cdot \log c\right)} \]
      7. Applied rewrites26.3%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, i, \log c \cdot b\right)} \]

      if 2.0000000000000001e71 < (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) < 2e303

      1. Initial program 99.8%

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

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

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

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

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

          \[\leadsto \color{blue}{\left(t + a\right)} + \left(z + \left(i \cdot y + \log c \cdot \left(b - \frac{1}{2}\right)\right)\right) \]
        5. associate-+r+N/A

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

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

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

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

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

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

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

          \[\leadsto \left(t + a\right) + \mathsf{fma}\left(b - \frac{1}{2}, \log c, \color{blue}{y \cdot i} + z\right) \]
        13. lower-fma.f6482.1

          \[\leadsto \left(t + a\right) + \mathsf{fma}\left(b - 0.5, \log c, \color{blue}{\mathsf{fma}\left(y, i, z\right)}\right) \]
      5. Applied rewrites82.1%

        \[\leadsto \color{blue}{\left(t + a\right) + \mathsf{fma}\left(b - 0.5, \log c, \mathsf{fma}\left(y, i, z\right)\right)} \]
      6. Taylor expanded in b around inf

        \[\leadsto \left(t + a\right) + b \cdot \color{blue}{\log c} \]
      7. Step-by-step derivation
        1. Applied rewrites54.1%

          \[\leadsto \left(t + a\right) + b \cdot \color{blue}{\log c} \]

        if 2e303 < (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i))

        1. Initial program 99.4%

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

          \[\leadsto \color{blue}{-1 \cdot \left(a \cdot \left(-1 \cdot \frac{t + \left(z + \left(i \cdot y + \left(x \cdot \log y + \log c \cdot \left(b - \frac{1}{2}\right)\right)\right)\right)}{a} - 1\right)\right)} \]
        4. Step-by-step derivation
          1. associate-*r*N/A

            \[\leadsto \color{blue}{\left(-1 \cdot a\right) \cdot \left(-1 \cdot \frac{t + \left(z + \left(i \cdot y + \left(x \cdot \log y + \log c \cdot \left(b - \frac{1}{2}\right)\right)\right)\right)}{a} - 1\right)} \]
          2. sub-negN/A

            \[\leadsto \left(-1 \cdot a\right) \cdot \color{blue}{\left(-1 \cdot \frac{t + \left(z + \left(i \cdot y + \left(x \cdot \log y + \log c \cdot \left(b - \frac{1}{2}\right)\right)\right)\right)}{a} + \left(\mathsf{neg}\left(1\right)\right)\right)} \]
          3. metadata-evalN/A

            \[\leadsto \left(-1 \cdot a\right) \cdot \left(-1 \cdot \frac{t + \left(z + \left(i \cdot y + \left(x \cdot \log y + \log c \cdot \left(b - \frac{1}{2}\right)\right)\right)\right)}{a} + \color{blue}{-1}\right) \]
          4. distribute-rgt-inN/A

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

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

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

            \[\leadsto \frac{t + \left(z + \left(i \cdot y + \left(x \cdot \log y + \log c \cdot \left(b - \frac{1}{2}\right)\right)\right)\right)}{a} \cdot \color{blue}{\left(\left(-1 \cdot -1\right) \cdot a\right)} + -1 \cdot \left(-1 \cdot a\right) \]
          8. metadata-evalN/A

            \[\leadsto \frac{t + \left(z + \left(i \cdot y + \left(x \cdot \log y + \log c \cdot \left(b - \frac{1}{2}\right)\right)\right)\right)}{a} \cdot \left(\color{blue}{1} \cdot a\right) + -1 \cdot \left(-1 \cdot a\right) \]
          9. *-lft-identityN/A

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

            \[\leadsto \frac{t + \left(z + \left(i \cdot y + \left(x \cdot \log y + \log c \cdot \left(b - \frac{1}{2}\right)\right)\right)\right)}{a} \cdot a + \color{blue}{\left(-1 \cdot -1\right) \cdot a} \]
        5. Applied rewrites90.3%

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

          \[\leadsto \mathsf{fma}\left(\frac{i \cdot y}{a}, a, a\right) \]
        7. Step-by-step derivation
          1. Applied rewrites79.5%

            \[\leadsto \mathsf{fma}\left(\frac{y}{a} \cdot i, a, a\right) \]
        8. Recombined 5 regimes into one program.
        9. Final simplification47.0%

          \[\leadsto \begin{array}{l} \mathbf{if}\;i \cdot y + \left(\log c \cdot \left(b - 0.5\right) + \left(a + \left(t + \left(z + \log y \cdot x\right)\right)\right)\right) \leq -1 \cdot 10^{+303}:\\ \;\;\;\;\log y \cdot x + i \cdot y\\ \mathbf{elif}\;i \cdot y + \left(\log c \cdot \left(b - 0.5\right) + \left(a + \left(t + \left(z + \log y \cdot x\right)\right)\right)\right) \leq -2 \cdot 10^{+192}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, t, t\right)\\ \mathbf{elif}\;i \cdot y + \left(\log c \cdot \left(b - 0.5\right) + \left(a + \left(t + \left(z + \log y \cdot x\right)\right)\right)\right) \leq 2 \cdot 10^{+71}:\\ \;\;\;\;\mathsf{fma}\left(y, i, \log c \cdot b\right)\\ \mathbf{elif}\;i \cdot y + \left(\log c \cdot \left(b - 0.5\right) + \left(a + \left(t + \left(z + \log y \cdot x\right)\right)\right)\right) \leq 2 \cdot 10^{+303}:\\ \;\;\;\;\log c \cdot b + \left(a + t\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{a} \cdot i, a, a\right)\\ \end{array} \]
        10. Add Preprocessing

        Reproduce

        ?
        herbie shell --seed 2024230 
        (FPCore (x y z t a b c i)
          :name "Numeric.SpecFunctions:logBeta from math-functions-0.1.5.2, B"
          :precision binary64
          (+ (+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c))) (* y i)))