Average Error: 2.9 → 1.4
Time: 4.4s
Precision: binary64
\[\left(\left(x - \left(y - 1\right) \cdot z\right) - \left(t - 1\right) \cdot a\right) + \left(\left(y + t\right) - 2\right) \cdot b \]
\[\begin{array}{l} t_1 := \left(y + t\right) - 2\\ \mathbf{if}\;\left(\left(x - \left(y - 1\right) \cdot z\right) - \left(t - 1\right) \cdot a\right) + t_1 \cdot b \leq \infty:\\ \;\;\;\;\mathsf{fma}\left(t_1, b, \mathsf{fma}\left(z, 1 - y, \mathsf{fma}\left(a, 1 - t, x\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;a + \left(\mathsf{fma}\left(y, b - z, x + z\right) + b \cdot -2\right)\\ \end{array} \]
\left(\left(x - \left(y - 1\right) \cdot z\right) - \left(t - 1\right) \cdot a\right) + \left(\left(y + t\right) - 2\right) \cdot b
\begin{array}{l}
t_1 := \left(y + t\right) - 2\\
\mathbf{if}\;\left(\left(x - \left(y - 1\right) \cdot z\right) - \left(t - 1\right) \cdot a\right) + t_1 \cdot b \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(t_1, b, \mathsf{fma}\left(z, 1 - y, \mathsf{fma}\left(a, 1 - t, x\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;a + \left(\mathsf{fma}\left(y, b - z, x + z\right) + b \cdot -2\right)\\


\end{array}
(FPCore (x y z t a b)
 :precision binary64
 (+ (- (- x (* (- y 1.0) z)) (* (- t 1.0) a)) (* (- (+ y t) 2.0) b)))
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (- (+ y t) 2.0)))
   (if (<= (+ (- (- x (* (- y 1.0) z)) (* (- t 1.0) a)) (* t_1 b)) INFINITY)
     (fma t_1 b (fma z (- 1.0 y) (fma a (- 1.0 t) x)))
     (+ a (+ (fma y (- b z) (+ x z)) (* b -2.0))))))
double code(double x, double y, double z, double t, double a, double b) {
	return ((x - ((y - 1.0) * z)) - ((t - 1.0) * a)) + (((y + t) - 2.0) * b);
}
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = (y + t) - 2.0;
	double tmp;
	if ((((x - ((y - 1.0) * z)) - ((t - 1.0) * a)) + (t_1 * b)) <= ((double) INFINITY)) {
		tmp = fma(t_1, b, fma(z, (1.0 - y), fma(a, (1.0 - t), x)));
	} else {
		tmp = a + (fma(y, (b - z), (x + z)) + (b * -2.0));
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Bits error versus b

Derivation

  1. Split input into 2 regimes
  2. if (+.f64 (-.f64 (-.f64 x (*.f64 (-.f64 y 1) z)) (*.f64 (-.f64 t 1) a)) (*.f64 (-.f64 (+.f64 y t) 2) b)) < +inf.0

    1. Initial program 0.0

      \[\left(\left(x - \left(y - 1\right) \cdot z\right) - \left(t - 1\right) \cdot a\right) + \left(\left(y + t\right) - 2\right) \cdot b \]
    2. Simplified0.0

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(y + t\right) - 2, b, \mathsf{fma}\left(z, 1 - y, \mathsf{fma}\left(a, 1 - t, x\right)\right)\right)} \]

    if +inf.0 < (+.f64 (-.f64 (-.f64 x (*.f64 (-.f64 y 1) z)) (*.f64 (-.f64 t 1) a)) (*.f64 (-.f64 (+.f64 y t) 2) b))

    1. Initial program 64.0

      \[\left(\left(x - \left(y - 1\right) \cdot z\right) - \left(t - 1\right) \cdot a\right) + \left(\left(y + t\right) - 2\right) \cdot b \]
    2. Simplified33.2

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(y + t\right) - 2, b, \mathsf{fma}\left(z, 1 - y, \mathsf{fma}\left(a, 1 - t, x\right)\right)\right)} \]
    3. Taylor expanded in t around 0 55.6

      \[\leadsto \color{blue}{\left(y \cdot b + \left(a + \left(z + x\right)\right)\right) - \left(y \cdot z + 2 \cdot b\right)} \]
    4. Simplified29.9

      \[\leadsto \color{blue}{a + \left(\left(z + x\right) + \mathsf{fma}\left(y, b - z, b \cdot -2\right)\right)} \]
    5. Applied fma-udef_binary6429.9

      \[\leadsto a + \left(\left(z + x\right) + \color{blue}{\left(y \cdot \left(b - z\right) + b \cdot -2\right)}\right) \]
    6. Applied associate-+r+_binary6429.9

      \[\leadsto a + \color{blue}{\left(\left(\left(z + x\right) + y \cdot \left(b - z\right)\right) + b \cdot -2\right)} \]
    7. Simplified29.9

      \[\leadsto a + \left(\color{blue}{\mathsf{fma}\left(y, b - z, z + x\right)} + b \cdot -2\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(\left(x - \left(y - 1\right) \cdot z\right) - \left(t - 1\right) \cdot a\right) + \left(\left(y + t\right) - 2\right) \cdot b \leq \infty:\\ \;\;\;\;\mathsf{fma}\left(\left(y + t\right) - 2, b, \mathsf{fma}\left(z, 1 - y, \mathsf{fma}\left(a, 1 - t, x\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;a + \left(\mathsf{fma}\left(y, b - z, x + z\right) + b \cdot -2\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2022068 
(FPCore (x y z t a b)
  :name "Statistics.Distribution.Beta:$centropy from math-functions-0.1.5.2"
  :precision binary64
  (+ (- (- x (* (- y 1.0) z)) (* (- t 1.0) a)) (* (- (+ y t) 2.0) b)))