Average Error: 6.4 → 0.1
Time: 14.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 r549228 = x;
        double r549229 = y;
        double r549230 = r549229 * r549229;
        double r549231 = z;
        double r549232 = r549230 / r549231;
        double r549233 = r549228 + r549232;
        return r549233;
}

double f(double x, double y, double z) {
        double r549234 = y;
        double r549235 = z;
        double r549236 = r549234 / r549235;
        double r549237 = x;
        double r549238 = fma(r549236, r549234, r549237);
        return r549238;
}

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