Average Error: 0.1 → 0.1
Time: 15.8s
Precision: 64
\[x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)\]
\[\mathsf{fma}\left(0.5, x, \left(1 + \log z\right) \cdot y - z \cdot y\right)\]
x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)
\mathsf{fma}\left(0.5, x, \left(1 + \log z\right) \cdot y - z \cdot y\right)
double f(double x, double y, double z) {
        double r11695958 = x;
        double r11695959 = 0.5;
        double r11695960 = r11695958 * r11695959;
        double r11695961 = y;
        double r11695962 = 1.0;
        double r11695963 = z;
        double r11695964 = r11695962 - r11695963;
        double r11695965 = log(r11695963);
        double r11695966 = r11695964 + r11695965;
        double r11695967 = r11695961 * r11695966;
        double r11695968 = r11695960 + r11695967;
        return r11695968;
}

double f(double x, double y, double z) {
        double r11695969 = 0.5;
        double r11695970 = x;
        double r11695971 = 1.0;
        double r11695972 = z;
        double r11695973 = log(r11695972);
        double r11695974 = r11695971 + r11695973;
        double r11695975 = y;
        double r11695976 = r11695974 * r11695975;
        double r11695977 = r11695972 * r11695975;
        double r11695978 = r11695976 - r11695977;
        double r11695979 = fma(r11695969, r11695970, r11695978);
        return r11695979;
}

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(y, \log z + \left(1 - z\right), x \cdot 0.5\right)}\]
  3. Using strategy rm
  4. Applied associate-+r-0.1

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

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

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

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

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

Reproduce

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

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

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