Average Error: 5.4 → 0.1
Time: 12.9s
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 r29584912 = x;
        double r29584913 = y;
        double r29584914 = r29584913 * r29584913;
        double r29584915 = z;
        double r29584916 = r29584914 / r29584915;
        double r29584917 = r29584912 + r29584916;
        return r29584917;
}

double f(double x, double y, double z) {
        double r29584918 = y;
        double r29584919 = z;
        double r29584920 = r29584918 / r29584919;
        double r29584921 = x;
        double r29584922 = fma(r29584920, r29584918, r29584921);
        return r29584922;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original5.4
Target0.1
Herbie0.1
\[x + y \cdot \frac{y}{z}\]

Derivation

  1. Initial program 5.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 2019158 +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)))