Average Error: 9.4 → 0.4
Time: 24.3s
Precision: 64
\[\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t\]
\[\mathsf{fma}\left(x, \log y, z \cdot \left(\log 1 - \mathsf{fma}\left(1, y, \frac{1}{2} \cdot \frac{{y}^{2}}{{1}^{2}}\right)\right)\right) - t\]
\left(x \cdot \log y + z \cdot \log \left(1 - y\right)\right) - t
\mathsf{fma}\left(x, \log y, z \cdot \left(\log 1 - \mathsf{fma}\left(1, y, \frac{1}{2} \cdot \frac{{y}^{2}}{{1}^{2}}\right)\right)\right) - t
double f(double x, double y, double z, double t) {
        double r351648 = x;
        double r351649 = y;
        double r351650 = log(r351649);
        double r351651 = r351648 * r351650;
        double r351652 = z;
        double r351653 = 1.0;
        double r351654 = r351653 - r351649;
        double r351655 = log(r351654);
        double r351656 = r351652 * r351655;
        double r351657 = r351651 + r351656;
        double r351658 = t;
        double r351659 = r351657 - r351658;
        return r351659;
}

double f(double x, double y, double z, double t) {
        double r351660 = x;
        double r351661 = y;
        double r351662 = log(r351661);
        double r351663 = z;
        double r351664 = 1.0;
        double r351665 = log(r351664);
        double r351666 = 0.5;
        double r351667 = 2.0;
        double r351668 = pow(r351661, r351667);
        double r351669 = pow(r351664, r351667);
        double r351670 = r351668 / r351669;
        double r351671 = r351666 * r351670;
        double r351672 = fma(r351664, r351661, r351671);
        double r351673 = r351665 - r351672;
        double r351674 = r351663 * r351673;
        double r351675 = fma(r351660, r351662, r351674);
        double r351676 = t;
        double r351677 = r351675 - r351676;
        return r351677;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original9.4
Target0.3
Herbie0.4
\[\left(-z\right) \cdot \left(\left(0.5 \cdot \left(y \cdot y\right) + y\right) + \frac{0.333333333333333315}{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.4

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

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

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

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

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

Reproduce

herbie shell --seed 2019198 +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))