Average Error: 6.5 → 0.1
Time: 15.9s
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 r34641750 = x;
        double r34641751 = y;
        double r34641752 = r34641751 * r34641751;
        double r34641753 = z;
        double r34641754 = r34641752 / r34641753;
        double r34641755 = r34641750 + r34641754;
        return r34641755;
}

double f(double x, double y, double z) {
        double r34641756 = y;
        double r34641757 = z;
        double r34641758 = r34641756 / r34641757;
        double r34641759 = x;
        double r34641760 = fma(r34641758, r34641756, r34641759);
        return r34641760;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

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

Derivation

  1. Initial program 6.5

    \[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 2019172 +o rules:numerics
(FPCore (x y z)
  :name "Crypto.Random.Test:calculate from crypto-random-0.0.9"

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

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