Average Error: 9.8 → 0.4
Time: 8.8s
Precision: 64
\[\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t\]
\[\log y \cdot x + \mathsf{fma}\left(z, \log 1 - \left(1 \cdot y + \frac{1}{2} \cdot \frac{{y}^{2}}{{1}^{2}}\right), -t\right)\]
\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t
\log y \cdot x + \mathsf{fma}\left(z, \log 1 - \left(1 \cdot y + \frac{1}{2} \cdot \frac{{y}^{2}}{{1}^{2}}\right), -t\right)
double f(double x, double y, double z, double t) {
        double r459097 = x;
        double r459098 = y;
        double r459099 = log(r459098);
        double r459100 = r459097 * r459099;
        double r459101 = z;
        double r459102 = 1.0;
        double r459103 = r459102 - r459098;
        double r459104 = log(r459103);
        double r459105 = r459101 * r459104;
        double r459106 = r459100 + r459105;
        double r459107 = t;
        double r459108 = r459106 - r459107;
        return r459108;
}

double f(double x, double y, double z, double t) {
        double r459109 = y;
        double r459110 = log(r459109);
        double r459111 = x;
        double r459112 = r459110 * r459111;
        double r459113 = z;
        double r459114 = 1.0;
        double r459115 = log(r459114);
        double r459116 = r459114 * r459109;
        double r459117 = 0.5;
        double r459118 = 2.0;
        double r459119 = pow(r459109, r459118);
        double r459120 = pow(r459114, r459118);
        double r459121 = r459119 / r459120;
        double r459122 = r459117 * r459121;
        double r459123 = r459116 + r459122;
        double r459124 = r459115 - r459123;
        double r459125 = t;
        double r459126 = -r459125;
        double r459127 = fma(r459113, r459124, r459126);
        double r459128 = r459112 + r459127;
        return r459128;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original9.8
Target0.3
Herbie0.4
\[\left(-z\right) \cdot \left(\left(0.5 \cdot \left(y \cdot y\right) + y\right) + \frac{0.3333333333333333148296162562473909929395}{1 \cdot \left(1 \cdot 1\right)} \cdot \left(y \cdot \left(y \cdot y\right)\right)\right) - \left(t - x \cdot \log y\right)\]

Derivation

  1. Initial program 9.8

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

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

    \[\leadsto \mathsf{fma}\left(\log y, x, z \cdot \color{blue}{\left(\log 1 - \left(1 \cdot y + \frac{1}{2} \cdot \frac{{y}^{2}}{{1}^{2}}\right)\right)} - t\right)\]
  4. Using strategy rm
  5. Applied fma-neg0.4

    \[\leadsto \mathsf{fma}\left(\log y, x, \color{blue}{\mathsf{fma}\left(z, \log 1 - \left(1 \cdot y + \frac{1}{2} \cdot \frac{{y}^{2}}{{1}^{2}}\right), -t\right)}\right)\]
  6. Using strategy rm
  7. Applied fma-udef0.4

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

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

Reproduce

herbie shell --seed 2019356 +o rules:numerics
(FPCore (x y z t)
  :name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, B"
  :precision binary64

  :herbie-target
  (- (* (- z) (+ (+ (* 0.5 (* y y)) y) (* (/ 0.3333333333333333 (* 1 (* 1 1))) (* y (* y y))))) (- t (* x (log y))))

  (- (+ (* x (log y)) (* z (log (- 1 y)))) t))