Average Error: 0.0 → 0.0
Time: 3.4s
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 r218162 = d1;
        double r218163 = d2;
        double r218164 = r218162 * r218163;
        double r218165 = d3;
        double r218166 = 5.0;
        double r218167 = r218165 + r218166;
        double r218168 = r218167 * r218162;
        double r218169 = r218164 + r218168;
        double r218170 = 32.0;
        double r218171 = r218162 * r218170;
        double r218172 = r218169 + r218171;
        return r218172;
}

double f(double d1, double d2, double d3) {
        double r218173 = 37.0;
        double r218174 = d1;
        double r218175 = d3;
        double r218176 = d2;
        double r218177 = r218174 * r218176;
        double r218178 = fma(r218174, r218175, r218177);
        double r218179 = fma(r218173, r218174, r218178);
        return r218179;
}

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