Average Error: 0.0 → 0.0
Time: 2.0s
Precision: 64
\[\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) + d1 \cdot 32\]
\[\mathsf{fma}\left(37, d1, \mathsf{fma}\left(d1, d3, d1 \cdot d2\right)\right)\]
\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) + d1 \cdot 32
\mathsf{fma}\left(37, d1, \mathsf{fma}\left(d1, d3, d1 \cdot d2\right)\right)
double f(double d1, double d2, double d3) {
        double r138191 = d1;
        double r138192 = d2;
        double r138193 = r138191 * r138192;
        double r138194 = d3;
        double r138195 = 5.0;
        double r138196 = r138194 + r138195;
        double r138197 = r138196 * r138191;
        double r138198 = r138193 + r138197;
        double r138199 = 32.0;
        double r138200 = r138191 * r138199;
        double r138201 = r138198 + r138200;
        return r138201;
}

double f(double d1, double d2, double d3) {
        double r138202 = 37.0;
        double r138203 = d1;
        double r138204 = d3;
        double r138205 = d2;
        double r138206 = r138203 * r138205;
        double r138207 = fma(r138203, r138204, r138206);
        double r138208 = fma(r138202, r138203, r138207);
        return r138208;
}

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}{\mathsf{fma}\left(32, d1, \mathsf{fma}\left(d1, d2, \left(d3 + 5\right) \cdot d1\right)\right)}\]
  3. Taylor expanded around 0 0.0

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

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

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

Reproduce

herbie shell --seed 2019362 +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)))