Average Error: 5.9 → 0.1
Time: 19.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 r197770171 = x;
        double r197770172 = y;
        double r197770173 = r197770172 * r197770172;
        double r197770174 = z;
        double r197770175 = r197770173 / r197770174;
        double r197770176 = r197770171 + r197770175;
        return r197770176;
}

double f(double x, double y, double z) {
        double r197770177 = y;
        double r197770178 = z;
        double r197770179 = r197770177 / r197770178;
        double r197770180 = x;
        double r197770181 = fma(r197770179, r197770177, r197770180);
        return r197770181;
}

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