Average Error: 6.1 → 0.1
Time: 17.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 r36125278 = x;
        double r36125279 = y;
        double r36125280 = r36125279 * r36125279;
        double r36125281 = z;
        double r36125282 = r36125280 / r36125281;
        double r36125283 = r36125278 + r36125282;
        return r36125283;
}

double f(double x, double y, double z) {
        double r36125284 = y;
        double r36125285 = z;
        double r36125286 = r36125284 / r36125285;
        double r36125287 = x;
        double r36125288 = fma(r36125286, r36125284, r36125287);
        return r36125288;
}

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