Average Error: 6.4 → 0.1
Time: 16.0s
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 r37898140 = x;
        double r37898141 = y;
        double r37898142 = r37898141 * r37898141;
        double r37898143 = z;
        double r37898144 = r37898142 / r37898143;
        double r37898145 = r37898140 + r37898144;
        return r37898145;
}

double f(double x, double y, double z) {
        double r37898146 = y;
        double r37898147 = z;
        double r37898148 = r37898146 / r37898147;
        double r37898149 = x;
        double r37898150 = fma(r37898148, r37898146, r37898149);
        return r37898150;
}

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