Average Error: 5.9 → 0.1
Time: 10.3s
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 r966942 = x;
        double r966943 = y;
        double r966944 = r966943 * r966943;
        double r966945 = z;
        double r966946 = r966944 / r966945;
        double r966947 = r966942 + r966946;
        return r966947;
}

double f(double x, double y, double z) {
        double r966948 = y;
        double r966949 = z;
        double r966950 = r966948 / r966949;
        double r966951 = x;
        double r966952 = fma(r966950, r966948, r966951);
        return r966952;
}

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