Average Error: 6.0 → 0.1
Time: 16.5s
Precision: 64
\[x + \frac{y \cdot y}{z}\]
\[\mathsf{fma}\left(\frac{y}{z}, y, x\right)\]
x + \frac{y \cdot y}{z}
\mathsf{fma}\left(\frac{y}{z}, y, x\right)
double f(double x, double y, double z) {
        double r493680 = x;
        double r493681 = y;
        double r493682 = r493681 * r493681;
        double r493683 = z;
        double r493684 = r493682 / r493683;
        double r493685 = r493680 + r493684;
        return r493685;
}

double f(double x, double y, double z) {
        double r493686 = y;
        double r493687 = z;
        double r493688 = r493686 / r493687;
        double r493689 = x;
        double r493690 = fma(r493688, r493686, r493689);
        return r493690;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original6.0
Target0.1
Herbie0.1
\[x + y \cdot \frac{y}{z}\]

Derivation

  1. Initial program 6.0

    \[x + \frac{y \cdot y}{z}\]
  2. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{z}, y, x\right)}\]
  3. Final simplification0.1

    \[\leadsto \mathsf{fma}\left(\frac{y}{z}, y, x\right)\]

Reproduce

herbie shell --seed 2019323 +o rules:numerics
(FPCore (x y z)
  :name "Crypto.Random.Test:calculate from crypto-random-0.0.9"
  :precision binary64

  :herbie-target
  (+ x (* y (/ y z)))

  (+ x (/ (* y y) z)))