Average Error: 9.3 → 0.4
Time: 8.2s
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 r435312 = x;
        double r435313 = y;
        double r435314 = log(r435313);
        double r435315 = r435312 * r435314;
        double r435316 = z;
        double r435317 = 1.0;
        double r435318 = r435317 - r435313;
        double r435319 = log(r435318);
        double r435320 = r435316 * r435319;
        double r435321 = r435315 + r435320;
        double r435322 = t;
        double r435323 = r435321 - r435322;
        return r435323;
}

double f(double x, double y, double z, double t) {
        double r435324 = y;
        double r435325 = log(r435324);
        double r435326 = x;
        double r435327 = r435325 * r435326;
        double r435328 = z;
        double r435329 = 1.0;
        double r435330 = log(r435329);
        double r435331 = r435329 * r435324;
        double r435332 = 0.5;
        double r435333 = 2.0;
        double r435334 = pow(r435324, r435333);
        double r435335 = pow(r435329, r435333);
        double r435336 = r435334 / r435335;
        double r435337 = r435332 * r435336;
        double r435338 = r435331 + r435337;
        double r435339 = r435330 - r435338;
        double r435340 = t;
        double r435341 = -r435340;
        double r435342 = fma(r435328, r435339, r435341);
        double r435343 = r435327 + r435342;
        return r435343;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original9.3
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.3

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

    \[\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 2019353 +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))