Average Error: 5.8 → 0.1
Time: 10.7s
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 r38456088 = x;
        double r38456089 = y;
        double r38456090 = r38456089 * r38456089;
        double r38456091 = z;
        double r38456092 = r38456090 / r38456091;
        double r38456093 = r38456088 + r38456092;
        return r38456093;
}

double f(double x, double y, double z) {
        double r38456094 = y;
        double r38456095 = z;
        double r38456096 = r38456094 / r38456095;
        double r38456097 = x;
        double r38456098 = fma(r38456096, r38456094, r38456097);
        return r38456098;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

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

Derivation

  1. Initial program 5.8

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