Average Error: 0.1 → 0.1
Time: 8.4s
Precision: 64
\[x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)\]
\[\mathsf{fma}\left(x, 0.5, y \cdot \mathsf{fma}\left(-z, 1, z\right) + y \cdot \left(1 - \left(z - \log z\right)\right)\right)\]
x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)
\mathsf{fma}\left(x, 0.5, y \cdot \mathsf{fma}\left(-z, 1, z\right) + y \cdot \left(1 - \left(z - \log z\right)\right)\right)
double f(double x, double y, double z) {
        double r362648 = x;
        double r362649 = 0.5;
        double r362650 = r362648 * r362649;
        double r362651 = y;
        double r362652 = 1.0;
        double r362653 = z;
        double r362654 = r362652 - r362653;
        double r362655 = log(r362653);
        double r362656 = r362654 + r362655;
        double r362657 = r362651 * r362656;
        double r362658 = r362650 + r362657;
        return r362658;
}

double f(double x, double y, double z) {
        double r362659 = x;
        double r362660 = 0.5;
        double r362661 = y;
        double r362662 = z;
        double r362663 = -r362662;
        double r362664 = 1.0;
        double r362665 = fma(r362663, r362664, r362662);
        double r362666 = r362661 * r362665;
        double r362667 = 1.0;
        double r362668 = log(r362662);
        double r362669 = r362662 - r362668;
        double r362670 = r362667 - r362669;
        double r362671 = r362661 * r362670;
        double r362672 = r362666 + r362671;
        double r362673 = fma(r362659, r362660, r362672);
        return r362673;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original0.1
Target0.1
Herbie0.1
\[\left(y + 0.5 \cdot x\right) - y \cdot \left(z - \log z\right)\]

Derivation

  1. Initial program 0.1

    \[x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)\]
  2. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, 0.5, y \cdot \left(\left(1 - z\right) + \log z\right)\right)}\]
  3. Using strategy rm
  4. Applied distribute-lft-in0.1

    \[\leadsto \mathsf{fma}\left(x, 0.5, \color{blue}{y \cdot \left(1 - z\right) + y \cdot \log z}\right)\]
  5. Using strategy rm
  6. Applied sub-neg0.1

    \[\leadsto \mathsf{fma}\left(x, 0.5, y \cdot \color{blue}{\left(1 + \left(-z\right)\right)} + y \cdot \log z\right)\]
  7. Applied distribute-rgt-in0.1

    \[\leadsto \mathsf{fma}\left(x, 0.5, \color{blue}{\left(1 \cdot y + \left(-z\right) \cdot y\right)} + y \cdot \log z\right)\]
  8. Applied associate-+l+0.1

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

    \[\leadsto \mathsf{fma}\left(x, 0.5, 1 \cdot y + \color{blue}{y \cdot \left(\log z - z\right)}\right)\]
  10. Using strategy rm
  11. Applied *-un-lft-identity0.1

    \[\leadsto \mathsf{fma}\left(x, 0.5, 1 \cdot y + y \cdot \left(\log z - \color{blue}{1 \cdot z}\right)\right)\]
  12. Applied pow10.1

    \[\leadsto \mathsf{fma}\left(x, 0.5, 1 \cdot y + y \cdot \left(\log \color{blue}{\left({z}^{1}\right)} - 1 \cdot z\right)\right)\]
  13. Applied log-pow0.1

    \[\leadsto \mathsf{fma}\left(x, 0.5, 1 \cdot y + y \cdot \left(\color{blue}{1 \cdot \log z} - 1 \cdot z\right)\right)\]
  14. Applied prod-diff0.1

    \[\leadsto \mathsf{fma}\left(x, 0.5, 1 \cdot y + y \cdot \color{blue}{\left(\mathsf{fma}\left(1, \log z, -z \cdot 1\right) + \mathsf{fma}\left(-z, 1, z \cdot 1\right)\right)}\right)\]
  15. Applied distribute-lft-in0.1

    \[\leadsto \mathsf{fma}\left(x, 0.5, 1 \cdot y + \color{blue}{\left(y \cdot \mathsf{fma}\left(1, \log z, -z \cdot 1\right) + y \cdot \mathsf{fma}\left(-z, 1, z \cdot 1\right)\right)}\right)\]
  16. Applied associate-+r+0.1

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

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

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

Reproduce

herbie shell --seed 2020047 +o rules:numerics
(FPCore (x y z)
  :name "System.Random.MWC.Distributions:gamma from mwc-random-0.13.3.2"
  :precision binary64

  :herbie-target
  (- (+ y (* 0.5 x)) (* y (- z (log z))))

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