Average Error: 6.4 → 0.1
Time: 17.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 r631340 = x;
        double r631341 = y;
        double r631342 = r631341 * r631341;
        double r631343 = z;
        double r631344 = r631342 / r631343;
        double r631345 = r631340 + r631344;
        return r631345;
}

double f(double x, double y, double z) {
        double r631346 = y;
        double r631347 = z;
        double r631348 = r631346 / r631347;
        double r631349 = x;
        double r631350 = fma(r631348, r631346, r631349);
        return r631350;
}

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