Average Error: 10.0 → 0.3
Time: 1.6m
Precision: 64
\[\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t\]
\[\mathsf{fma}\left(\log y, x, \left(z \cdot \log 1 - \left(\left(0.5 \cdot y + 1\right) \cdot y\right) \cdot z\right) - t\right)\]
\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t
\mathsf{fma}\left(\log y, x, \left(z \cdot \log 1 - \left(\left(0.5 \cdot y + 1\right) \cdot y\right) \cdot z\right) - t\right)
double f(double x, double y, double z, double t) {
        double r18379405 = x;
        double r18379406 = y;
        double r18379407 = log(r18379406);
        double r18379408 = r18379405 * r18379407;
        double r18379409 = z;
        double r18379410 = 1.0;
        double r18379411 = r18379410 - r18379406;
        double r18379412 = log(r18379411);
        double r18379413 = r18379409 * r18379412;
        double r18379414 = r18379408 + r18379413;
        double r18379415 = t;
        double r18379416 = r18379414 - r18379415;
        return r18379416;
}

double f(double x, double y, double z, double t) {
        double r18379417 = y;
        double r18379418 = log(r18379417);
        double r18379419 = x;
        double r18379420 = z;
        double r18379421 = 1.0;
        double r18379422 = log(r18379421);
        double r18379423 = r18379420 * r18379422;
        double r18379424 = 0.5;
        double r18379425 = r18379424 * r18379417;
        double r18379426 = r18379425 + r18379421;
        double r18379427 = r18379426 * r18379417;
        double r18379428 = r18379427 * r18379420;
        double r18379429 = r18379423 - r18379428;
        double r18379430 = t;
        double r18379431 = r18379429 - r18379430;
        double r18379432 = fma(r18379418, r18379419, r18379431);
        return r18379432;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original10.0
Target0.2
Herbie0.3
\[\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 10.0

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

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

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

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

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

Reproduce

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

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

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