Average Error: 6.3 → 0.1
Time: 4.2s
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 r884644 = x;
        double r884645 = y;
        double r884646 = r884645 * r884645;
        double r884647 = z;
        double r884648 = r884646 / r884647;
        double r884649 = r884644 + r884648;
        return r884649;
}

double f(double x, double y, double z) {
        double r884650 = y;
        double r884651 = z;
        double r884652 = r884650 / r884651;
        double r884653 = x;
        double r884654 = fma(r884652, r884650, r884653);
        return r884654;
}

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