Average Error: 0.1 → 0.1
Time: 11.7s
Precision: 64
\[x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)\]
\[\mathsf{fma}\left(x, 0.5, 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 \left(1 - \left(z - \log z\right)\right)\right)
double f(double x, double y, double z) {
        double r279831 = x;
        double r279832 = 0.5;
        double r279833 = r279831 * r279832;
        double r279834 = y;
        double r279835 = 1.0;
        double r279836 = z;
        double r279837 = r279835 - r279836;
        double r279838 = log(r279836);
        double r279839 = r279837 + r279838;
        double r279840 = r279834 * r279839;
        double r279841 = r279833 + r279840;
        return r279841;
}

double f(double x, double y, double z) {
        double r279842 = x;
        double r279843 = 0.5;
        double r279844 = y;
        double r279845 = 1.0;
        double r279846 = z;
        double r279847 = log(r279846);
        double r279848 = r279846 - r279847;
        double r279849 = r279845 - r279848;
        double r279850 = r279844 * r279849;
        double r279851 = fma(r279842, r279843, r279850);
        return r279851;
}

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-lft-in0.1

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

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

    \[\leadsto \mathsf{fma}\left(x, 0.5, y \cdot 1 + \color{blue}{\left(\log z - z\right) \cdot y}\right)\]
  10. Taylor expanded around 0 0.1

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

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

    \[\leadsto \mathsf{fma}\left(x, 0.5, 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)))))