Average Error: 7.0 → 0.3
Time: 9.7s
Precision: binary64
\[\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t \]
\[\left(\left(y + \left(0.5 \cdot {y}^{2} + \log y \cdot x\right)\right) - \left(0.5 \cdot \left({y}^{2} \cdot z\right) + \left(t + \left(y \cdot z + \log y\right)\right)\right)\right) + \mathsf{fma}\left(-1, t, t\right) \]
\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t
\left(\left(y + \left(0.5 \cdot {y}^{2} + \log y \cdot x\right)\right) - \left(0.5 \cdot \left({y}^{2} \cdot z\right) + \left(t + \left(y \cdot z + \log y\right)\right)\right)\right) + \mathsf{fma}\left(-1, t, t\right)
(FPCore (x y z t)
 :precision binary64
 (- (+ (* (- x 1.0) (log y)) (* (- z 1.0) (log (- 1.0 y)))) t))
(FPCore (x y z t)
 :precision binary64
 (+
  (-
   (+ y (+ (* 0.5 (pow y 2.0)) (* (log y) x)))
   (+ (* 0.5 (* (pow y 2.0) z)) (+ t (+ (* y z) (log y)))))
  (fma -1.0 t t)))
double code(double x, double y, double z, double t) {
	return (((x - 1.0) * log(y)) + ((z - 1.0) * log((1.0 - y)))) - t;
}
double code(double x, double y, double z, double t) {
	return ((y + ((0.5 * pow(y, 2.0)) + (log(y) * x))) - ((0.5 * (pow(y, 2.0) * z)) + (t + ((y * z) + log(y))))) + fma(-1.0, t, t);
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Derivation

  1. Initial program 7.0

    \[\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t \]
  2. Simplified7.0

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

    \[\leadsto \mathsf{fma}\left(x - 1, \log y, \left(z - 1\right) \cdot \color{blue}{\left(-\left(y + 0.5 \cdot {y}^{2}\right)\right)}\right) - t \]
  4. Applied egg-rr0.4

    \[\leadsto \color{blue}{\mathsf{fma}\left(z - 1, \left(-\mathsf{fma}\left(0.5, y \cdot y, y\right)\right) + \frac{\left(x - 1\right) \cdot \log y}{z - 1}, -t\right) + \mathsf{fma}\left(-1, t, t\right)} \]
  5. Applied egg-rr0.4

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

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

    \[\leadsto \left(\left(y + \left(0.5 \cdot {y}^{2} + \log y \cdot x\right)\right) - \left(0.5 \cdot \left({y}^{2} \cdot z\right) + \left(t + \left(y \cdot z + \log y\right)\right)\right)\right) + \mathsf{fma}\left(-1, t, t\right) \]

Reproduce

herbie shell --seed 2022127 
(FPCore (x y z t)
  :name "Statistics.Distribution.Beta:$cdensity from math-functions-0.1.5.2"
  :precision binary64
  (- (+ (* (- x 1.0) (log y)) (* (- z 1.0) (log (- 1.0 y)))) t))