Average Error: 0.1 → 0.0
Time: 8.9s
Precision: 64
\[\left(d1 \cdot 3 + d1 \cdot d2\right) + d1 \cdot d3\]
\[\mathsf{fma}\left(d1, 3, d1 \cdot d2\right) + d1 \cdot d3\]
\left(d1 \cdot 3 + d1 \cdot d2\right) + d1 \cdot d3
\mathsf{fma}\left(d1, 3, d1 \cdot d2\right) + d1 \cdot d3
double f(double d1, double d2, double d3) {
        double r143291 = d1;
        double r143292 = 3.0;
        double r143293 = r143291 * r143292;
        double r143294 = d2;
        double r143295 = r143291 * r143294;
        double r143296 = r143293 + r143295;
        double r143297 = d3;
        double r143298 = r143291 * r143297;
        double r143299 = r143296 + r143298;
        return r143299;
}

double f(double d1, double d2, double d3) {
        double r143300 = d1;
        double r143301 = 3.0;
        double r143302 = d2;
        double r143303 = r143300 * r143302;
        double r143304 = fma(r143300, r143301, r143303);
        double r143305 = d3;
        double r143306 = r143300 * r143305;
        double r143307 = r143304 + r143306;
        return r143307;
}

Error

Bits error versus d1

Bits error versus d2

Bits error versus d3

Target

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

Derivation

  1. Initial program 0.1

    \[\left(d1 \cdot 3 + d1 \cdot d2\right) + d1 \cdot d3\]
  2. Using strategy rm
  3. Applied fma-def0.0

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

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

Reproduce

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

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

  (+ (+ (* d1 3) (* d1 d2)) (* d1 d3)))