Average Error: 6.4 → 0.1
Time: 12.6s
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 r33980099 = x;
        double r33980100 = y;
        double r33980101 = r33980100 * r33980100;
        double r33980102 = z;
        double r33980103 = r33980101 / r33980102;
        double r33980104 = r33980099 + r33980103;
        return r33980104;
}

double f(double x, double y, double z) {
        double r33980105 = y;
        double r33980106 = z;
        double r33980107 = r33980105 / r33980106;
        double r33980108 = x;
        double r33980109 = fma(r33980107, r33980105, r33980108);
        return r33980109;
}

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