Average Error: 0.1 → 0.1
Time: 12.8s
Precision: 64
\[\left(x \cdot 3\right) \cdot y - z\]
\[\mathsf{fma}\left(x, 3 \cdot y, -z\right)\]
\left(x \cdot 3\right) \cdot y - z
\mathsf{fma}\left(x, 3 \cdot y, -z\right)
double f(double x, double y, double z) {
        double r474789 = x;
        double r474790 = 3.0;
        double r474791 = r474789 * r474790;
        double r474792 = y;
        double r474793 = r474791 * r474792;
        double r474794 = z;
        double r474795 = r474793 - r474794;
        return r474795;
}

double f(double x, double y, double z) {
        double r474796 = x;
        double r474797 = 3.0;
        double r474798 = y;
        double r474799 = r474797 * r474798;
        double r474800 = z;
        double r474801 = -r474800;
        double r474802 = fma(r474796, r474799, r474801);
        return r474802;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original0.1
Target0.1
Herbie0.1
\[x \cdot \left(3 \cdot y\right) - z\]

Derivation

  1. Initial program 0.1

    \[\left(x \cdot 3\right) \cdot y - z\]
  2. Using strategy rm
  3. Applied pow10.1

    \[\leadsto \left(x \cdot 3\right) \cdot \color{blue}{{y}^{1}} - z\]
  4. Applied pow10.1

    \[\leadsto \left(x \cdot \color{blue}{{3}^{1}}\right) \cdot {y}^{1} - z\]
  5. Applied pow10.1

    \[\leadsto \left(\color{blue}{{x}^{1}} \cdot {3}^{1}\right) \cdot {y}^{1} - z\]
  6. Applied pow-prod-down0.1

    \[\leadsto \color{blue}{{\left(x \cdot 3\right)}^{1}} \cdot {y}^{1} - z\]
  7. Applied pow-prod-down0.1

    \[\leadsto \color{blue}{{\left(\left(x \cdot 3\right) \cdot y\right)}^{1}} - z\]
  8. Simplified0.1

    \[\leadsto {\color{blue}{\left(x \cdot \left(3 \cdot y\right)\right)}}^{1} - z\]
  9. Using strategy rm
  10. Applied unpow-prod-down0.1

    \[\leadsto \color{blue}{{x}^{1} \cdot {\left(3 \cdot y\right)}^{1}} - z\]
  11. Applied fma-neg0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left({x}^{1}, {\left(3 \cdot y\right)}^{1}, -z\right)}\]
  12. Final simplification0.1

    \[\leadsto \mathsf{fma}\left(x, 3 \cdot y, -z\right)\]

Reproduce

herbie shell --seed 2019305 +o rules:numerics
(FPCore (x y z)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, B"
  :precision binary64

  :herbie-target
  (- (* x (* 3 y)) z)

  (- (* (* x 3) y) z))