Average Error: 6.5 → 0.1
Time: 12.8s
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 r989259 = x;
        double r989260 = y;
        double r989261 = r989260 * r989260;
        double r989262 = z;
        double r989263 = r989261 / r989262;
        double r989264 = r989259 + r989263;
        return r989264;
}

double f(double x, double y, double z) {
        double r989265 = y;
        double r989266 = z;
        double r989267 = r989265 / r989266;
        double r989268 = x;
        double r989269 = fma(r989267, r989265, r989268);
        return r989269;
}

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 2020042 +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)))