Average Error: 10.1 → 0.3
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 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

Original10.1
Target0.2
Herbie0.3
\[\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. 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.3

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

    \[\leadsto x \cdot \left(\color{blue}{\left(\sqrt{3} \cdot \sqrt{3}\right)} \cdot \left(x \cdot y\right)\right)\]
  8. Applied associate-*l*0.5

    \[\leadsto x \cdot \color{blue}{\left(\sqrt{3} \cdot \left(\sqrt{3} \cdot \left(x \cdot y\right)\right)\right)}\]
  9. Taylor expanded around 0 10.4

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

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

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

Reproduce

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