Average Error: 5.9 → 0.1
Time: 16.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 r704444 = x;
        double r704445 = y;
        double r704446 = r704445 * r704445;
        double r704447 = z;
        double r704448 = r704446 / r704447;
        double r704449 = r704444 + r704448;
        return r704449;
}

double f(double x, double y, double z) {
        double r704450 = y;
        double r704451 = z;
        double r704452 = r704450 / r704451;
        double r704453 = x;
        double r704454 = fma(r704452, r704450, r704453);
        return r704454;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

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

Derivation

  1. Initial program 5.9

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