Average Error: 0.1 → 0.1
Time: 22.7s
Precision: 64
\[x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)\]
\[\mathsf{fma}\left(y, 1 - \left(z - \log z\right), 0.5 \cdot x\right)\]
x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)
\mathsf{fma}\left(y, 1 - \left(z - \log z\right), 0.5 \cdot x\right)
double f(double x, double y, double z) {
        double r216333 = x;
        double r216334 = 0.5;
        double r216335 = r216333 * r216334;
        double r216336 = y;
        double r216337 = 1.0;
        double r216338 = z;
        double r216339 = r216337 - r216338;
        double r216340 = log(r216338);
        double r216341 = r216339 + r216340;
        double r216342 = r216336 * r216341;
        double r216343 = r216335 + r216342;
        return r216343;
}

double f(double x, double y, double z) {
        double r216344 = y;
        double r216345 = 1.0;
        double r216346 = z;
        double r216347 = log(r216346);
        double r216348 = r216346 - r216347;
        double r216349 = r216345 - r216348;
        double r216350 = 0.5;
        double r216351 = x;
        double r216352 = r216350 * r216351;
        double r216353 = fma(r216344, r216349, r216352);
        return r216353;
}

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 add-cube-cbrt0.4

    \[\leadsto \mathsf{fma}\left(y, \color{blue}{\left(\sqrt[3]{\log z} \cdot \sqrt[3]{\log z}\right) \cdot \sqrt[3]{\log z}} + \left(1 - z\right), x \cdot 0.5\right)\]
  5. Applied fma-def0.4

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

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

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

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

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

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

Reproduce

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