Average Error: 9.8 → 0.3
Time: 1.9s
Precision: binary64
\[\left(\left(x \cdot 3\right) \cdot x\right) \cdot y \]
\[3 \cdot \left(x \cdot \left(y \cdot x\right)\right) \]
\left(\left(x \cdot 3\right) \cdot x\right) \cdot y
3 \cdot \left(x \cdot \left(y \cdot x\right)\right)
(FPCore (x y) :precision binary64 (* (* (* x 3.0) x) y))
(FPCore (x y) :precision binary64 (* 3.0 (* x (* y x))))
double code(double x, double y) {
	return ((x * 3.0) * x) * y;
}
double code(double x, double y) {
	return 3.0 * (x * (y * x));
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original9.8
Target0.2
Herbie0.3
\[\left(x \cdot 3\right) \cdot \left(x \cdot y\right) \]

Derivation

  1. Initial program 9.8

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

    \[\leadsto \color{blue}{\left(x \cdot 3\right) \cdot \left(x \cdot y\right)} \]
  4. Simplified0.2

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

    \[\leadsto \color{blue}{\left(\left(x \cdot 3\right) \cdot y\right) \cdot x} \]
  7. Simplified0.2

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

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

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

Reproduce

herbie shell --seed 2021211 
(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))