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

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

Derivation

  1. Initial program 10.1

    \[\left(\left(x \cdot 3\right) \cdot x\right) \cdot y\]
  2. Simplified0.3

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

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

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

Reproduce

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

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

  (* (* (* x 3.0) x) y))