Average Error: 6.0 → 0.1
Time: 3.7s
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 r839282 = x;
        double r839283 = y;
        double r839284 = r839283 * r839283;
        double r839285 = z;
        double r839286 = r839284 / r839285;
        double r839287 = r839282 + r839286;
        return r839287;
}

double f(double x, double y, double z) {
        double r839288 = y;
        double r839289 = z;
        double r839290 = r839288 / r839289;
        double r839291 = x;
        double r839292 = fma(r839290, r839288, r839291);
        return r839292;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

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

Derivation

  1. Initial program 6.0

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