Average Error: 10.0 → 0.2
Time: 1.8s
Precision: 64
\[\left(\left(x \cdot 3\right) \cdot x\right) \cdot y\]
\[\left(x \cdot y\right) \cdot \left(x \cdot 3\right)\]
\left(\left(x \cdot 3\right) \cdot x\right) \cdot y
\left(x \cdot y\right) \cdot \left(x \cdot 3\right)
double code(double x, double y) {
	return (((x * 3.0) * x) * y);
}
double code(double x, double y) {
	return ((x * y) * (x * 3.0));
}

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.0
Target0.2
Herbie0.2
\[\left(x \cdot 3\right) \cdot \left(x \cdot y\right)\]

Derivation

  1. Initial program 10.0

    \[\left(\left(x \cdot 3\right) \cdot x\right) \cdot y\]
  2. Using strategy rm
  3. Applied *-un-lft-identity10.0

    \[\leadsto \left(\left(x \cdot 3\right) \cdot \color{blue}{\left(1 \cdot x\right)}\right) \cdot y\]
  4. Applied associate-*r*10.0

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

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

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

Reproduce

herbie shell --seed 2020066 +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))