Average Error: 6.2 → 0.1
Time: 57.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 r39786697 = x;
        double r39786698 = y;
        double r39786699 = r39786698 * r39786698;
        double r39786700 = z;
        double r39786701 = r39786699 / r39786700;
        double r39786702 = r39786697 + r39786701;
        return r39786702;
}

double f(double x, double y, double z) {
        double r39786703 = y;
        double r39786704 = z;
        double r39786705 = r39786703 / r39786704;
        double r39786706 = x;
        double r39786707 = fma(r39786705, r39786703, r39786706);
        return r39786707;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

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

Derivation

  1. Initial program 6.2

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