Average Error: 0.0 → 0.0
Time: 14.4s
Precision: 64
\[\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) + d1 \cdot 32\]
\[\mathsf{fma}\left(37, d1, 1 \cdot \left(d1 \cdot \left(d3 + d2\right)\right)\right)\]
\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) + d1 \cdot 32
\mathsf{fma}\left(37, d1, 1 \cdot \left(d1 \cdot \left(d3 + d2\right)\right)\right)
double f(double d1, double d2, double d3) {
        double r207659 = d1;
        double r207660 = d2;
        double r207661 = r207659 * r207660;
        double r207662 = d3;
        double r207663 = 5.0;
        double r207664 = r207662 + r207663;
        double r207665 = r207664 * r207659;
        double r207666 = r207661 + r207665;
        double r207667 = 32.0;
        double r207668 = r207659 * r207667;
        double r207669 = r207666 + r207668;
        return r207669;
}

double f(double d1, double d2, double d3) {
        double r207670 = 37.0;
        double r207671 = d1;
        double r207672 = 1.0;
        double r207673 = d3;
        double r207674 = d2;
        double r207675 = r207673 + r207674;
        double r207676 = r207671 * r207675;
        double r207677 = r207672 * r207676;
        double r207678 = fma(r207670, r207671, r207677);
        return r207678;
}

Error

Bits error versus d1

Bits error versus d2

Bits error versus d3

Target

Original0.0
Target0.0
Herbie0.0
\[d1 \cdot \left(\left(37 + d3\right) + d2\right)\]

Derivation

  1. Initial program 0.0

    \[\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) + d1 \cdot 32\]
  2. Simplified0.0

    \[\leadsto \color{blue}{d1 \cdot \left(\left(\left(d3 + 5\right) + 32\right) + d2\right)}\]
  3. Using strategy rm
  4. Applied flip-+21.6

    \[\leadsto d1 \cdot \color{blue}{\frac{\left(\left(d3 + 5\right) + 32\right) \cdot \left(\left(d3 + 5\right) + 32\right) - d2 \cdot d2}{\left(\left(d3 + 5\right) + 32\right) - d2}}\]
  5. Applied associate-*r/25.4

    \[\leadsto \color{blue}{\frac{d1 \cdot \left(\left(\left(d3 + 5\right) + 32\right) \cdot \left(\left(d3 + 5\right) + 32\right) - d2 \cdot d2\right)}{\left(\left(d3 + 5\right) + 32\right) - d2}}\]
  6. Taylor expanded around 0 0.0

    \[\leadsto \color{blue}{37 \cdot d1 + \left(1 \cdot \left(d1 \cdot d3\right) + 1 \cdot \left(d1 \cdot d2\right)\right)}\]
  7. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(37, d1, 1 \cdot \left(d1 \cdot \left(d3 + d2\right)\right)\right)}\]
  8. Final simplification0.0

    \[\leadsto \mathsf{fma}\left(37, d1, 1 \cdot \left(d1 \cdot \left(d3 + d2\right)\right)\right)\]

Reproduce

herbie shell --seed 2019212 +o rules:numerics
(FPCore (d1 d2 d3)
  :name "FastMath dist3"
  :precision binary64

  :herbie-target
  (* d1 (+ (+ 37 d3) d2))

  (+ (+ (* d1 d2) (* (+ d3 5) d1)) (* d1 32)))