Average Error: 6.1 → 0.1
Time: 3.0s
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 r722205 = x;
        double r722206 = y;
        double r722207 = r722206 * r722206;
        double r722208 = z;
        double r722209 = r722207 / r722208;
        double r722210 = r722205 + r722209;
        return r722210;
}

double f(double x, double y, double z) {
        double r722211 = y;
        double r722212 = z;
        double r722213 = r722211 / r722212;
        double r722214 = x;
        double r722215 = fma(r722213, r722211, r722214);
        return r722215;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

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

Derivation

  1. Initial program 6.1

    \[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 2020001 +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)))