Average Error: 10.4 → 0.2
Time: 1.6s
Precision: 64
\[\left(\left(x \cdot 3\right) \cdot x\right) \cdot y\]
\[\left(3 \cdot \left(x \cdot y\right)\right) \cdot x\]
\left(\left(x \cdot 3\right) \cdot x\right) \cdot y
\left(3 \cdot \left(x \cdot y\right)\right) \cdot x
double f(double x, double y) {
        double r636828 = x;
        double r636829 = 3.0;
        double r636830 = r636828 * r636829;
        double r636831 = r636830 * r636828;
        double r636832 = y;
        double r636833 = r636831 * r636832;
        return r636833;
}

double f(double x, double y) {
        double r636834 = 3.0;
        double r636835 = x;
        double r636836 = y;
        double r636837 = r636835 * r636836;
        double r636838 = r636834 * r636837;
        double r636839 = r636838 * r636835;
        return r636839;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original10.4
Target0.2
Herbie0.2
\[\left(x \cdot 3\right) \cdot \left(x \cdot y\right)\]

Derivation

  1. Initial program 10.4

    \[\left(\left(x \cdot 3\right) \cdot x\right) \cdot y\]
  2. Using strategy rm
  3. Applied associate-*l*0.2

    \[\leadsto \color{blue}{\left(x \cdot 3\right) \cdot \left(x \cdot y\right)}\]
  4. Using strategy rm
  5. Applied associate-*l*0.2

    \[\leadsto \color{blue}{x \cdot \left(3 \cdot \left(x \cdot y\right)\right)}\]
  6. Using strategy rm
  7. Applied *-commutative0.2

    \[\leadsto \color{blue}{\left(3 \cdot \left(x \cdot y\right)\right) \cdot x}\]
  8. Final simplification0.2

    \[\leadsto \left(3 \cdot \left(x \cdot y\right)\right) \cdot x\]

Reproduce

herbie shell --seed 2020001 +o rules:numerics
(FPCore (x y)
  :name "Diagrams.Segment:$catParam from diagrams-lib-1.3.0.3, A"
  :precision binary64

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

  (* (* (* x 3) x) y))