Average Error: 6.5 → 0.1
Time: 10.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 r515474 = x;
        double r515475 = y;
        double r515476 = r515475 * r515475;
        double r515477 = z;
        double r515478 = r515476 / r515477;
        double r515479 = r515474 + r515478;
        return r515479;
}

double f(double x, double y, double z) {
        double r515480 = y;
        double r515481 = z;
        double r515482 = r515480 / r515481;
        double r515483 = x;
        double r515484 = fma(r515482, r515480, r515483);
        return r515484;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

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

Derivation

  1. Initial program 6.5

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