Average Error: 0.1 → 0.0
Time: 13.7s
Precision: 64
\[\left(d1 \cdot 3 + d1 \cdot d2\right) + d1 \cdot d3\]
\[\mathsf{fma}\left(d1, d3 + 3, d2 \cdot d1\right)\]
\left(d1 \cdot 3 + d1 \cdot d2\right) + d1 \cdot d3
\mathsf{fma}\left(d1, d3 + 3, d2 \cdot d1\right)
double f(double d1, double d2, double d3) {
        double r2396726 = d1;
        double r2396727 = 3.0;
        double r2396728 = r2396726 * r2396727;
        double r2396729 = d2;
        double r2396730 = r2396726 * r2396729;
        double r2396731 = r2396728 + r2396730;
        double r2396732 = d3;
        double r2396733 = r2396726 * r2396732;
        double r2396734 = r2396731 + r2396733;
        return r2396734;
}

double f(double d1, double d2, double d3) {
        double r2396735 = d1;
        double r2396736 = d3;
        double r2396737 = 3.0;
        double r2396738 = r2396736 + r2396737;
        double r2396739 = d2;
        double r2396740 = r2396739 * r2396735;
        double r2396741 = fma(r2396735, r2396738, r2396740);
        return r2396741;
}

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. Simplified0.1

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

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

    \[\leadsto \color{blue}{\frac{\left(d2 \cdot d2 - \left(3 + d3\right) \cdot \left(3 + d3\right)\right) \cdot d1}{d2 - \left(3 + d3\right)}}\]
  6. Using strategy rm
  7. Applied add-cube-cbrt24.1

    \[\leadsto \frac{\left(d2 \cdot d2 - \left(3 + d3\right) \cdot \left(3 + d3\right)\right) \cdot d1}{\color{blue}{\left(\sqrt[3]{d2 - \left(3 + d3\right)} \cdot \sqrt[3]{d2 - \left(3 + d3\right)}\right) \cdot \sqrt[3]{d2 - \left(3 + d3\right)}}}\]
  8. Applied times-frac21.8

    \[\leadsto \color{blue}{\frac{d2 \cdot d2 - \left(3 + d3\right) \cdot \left(3 + d3\right)}{\sqrt[3]{d2 - \left(3 + d3\right)} \cdot \sqrt[3]{d2 - \left(3 + d3\right)}} \cdot \frac{d1}{\sqrt[3]{d2 - \left(3 + d3\right)}}}\]
  9. Taylor expanded around -inf 0.1

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

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

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

Reproduce

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

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

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