Average Error: 6.3 → 0.1
Time: 3.8s
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 r891086 = x;
        double r891087 = y;
        double r891088 = r891087 * r891087;
        double r891089 = z;
        double r891090 = r891088 / r891089;
        double r891091 = r891086 + r891090;
        return r891091;
}

double f(double x, double y, double z) {
        double r891092 = y;
        double r891093 = z;
        double r891094 = r891092 / r891093;
        double r891095 = x;
        double r891096 = fma(r891094, r891092, r891095);
        return r891096;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

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

Derivation

  1. Initial program 6.3

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