Average Error: 6.4 → 0.1
Time: 12.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 r1021407 = x;
        double r1021408 = y;
        double r1021409 = r1021408 * r1021408;
        double r1021410 = z;
        double r1021411 = r1021409 / r1021410;
        double r1021412 = r1021407 + r1021411;
        return r1021412;
}

double f(double x, double y, double z) {
        double r1021413 = y;
        double r1021414 = z;
        double r1021415 = r1021413 / r1021414;
        double r1021416 = x;
        double r1021417 = fma(r1021415, r1021413, r1021416);
        return r1021417;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

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

Derivation

  1. Initial program 6.4

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