Average Error: 0.0 → 0.0
Time: 2.3s
Precision: 64
\[2 \cdot \left(x \cdot x + x \cdot y\right)\]
\[{\left(\sqrt{1}\right)}^{3} \cdot \left(\left(2 \cdot x\right) \cdot \left(x + y\right)\right)\]
2 \cdot \left(x \cdot x + x \cdot y\right)
{\left(\sqrt{1}\right)}^{3} \cdot \left(\left(2 \cdot x\right) \cdot \left(x + y\right)\right)
double code(double x, double y) {
	return ((double) (2.0 * ((double) (((double) (x * x)) + ((double) (x * y))))));
}
double code(double x, double y) {
	return ((double) (((double) pow(((double) sqrt(1.0)), 3.0)) * ((double) (((double) (2.0 * x)) * ((double) (x + 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

Original0.0
Target0.0
Herbie0.0
\[\left(x \cdot 2\right) \cdot \left(x + y\right)\]

Derivation

  1. Initial program 0.0

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, x \cdot y\right) \cdot 2}\]
  3. Using strategy rm
  4. Applied add-sqr-sqrt1.1

    \[\leadsto \mathsf{fma}\left(x, x, x \cdot y\right) \cdot \color{blue}{\left(\sqrt{2} \cdot \sqrt{2}\right)}\]
  5. Applied associate-*r*0.8

    \[\leadsto \color{blue}{\left(\mathsf{fma}\left(x, x, x \cdot y\right) \cdot \sqrt{2}\right) \cdot \sqrt{2}}\]
  6. Using strategy rm
  7. Applied add-sqr-sqrt0.8

    \[\leadsto \left(\mathsf{fma}\left(x, x, x \cdot y\right) \cdot \sqrt{2}\right) \cdot \sqrt{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}\]
  8. Applied sqrt-prod0.1

    \[\leadsto \left(\mathsf{fma}\left(x, x, x \cdot y\right) \cdot \sqrt{2}\right) \cdot \color{blue}{\left(\sqrt{\sqrt{2}} \cdot \sqrt{\sqrt{2}}\right)}\]
  9. Applied associate-*r*0.3

    \[\leadsto \color{blue}{\left(\left(\mathsf{fma}\left(x, x, x \cdot y\right) \cdot \sqrt{2}\right) \cdot \sqrt{\sqrt{2}}\right) \cdot \sqrt{\sqrt{2}}}\]
  10. Simplified0.5

    \[\leadsto \color{blue}{\left(\left({\left(\sqrt{\sqrt{2}}\right)}^{3} \cdot x\right) \cdot \left(x + y\right)\right)} \cdot \sqrt{\sqrt{2}}\]
  11. Using strategy rm
  12. Applied *-un-lft-identity0.5

    \[\leadsto \left(\left({\left(\sqrt{\color{blue}{1 \cdot \sqrt{2}}}\right)}^{3} \cdot x\right) \cdot \left(x + y\right)\right) \cdot \sqrt{\sqrt{2}}\]
  13. Applied sqrt-prod0.5

    \[\leadsto \left(\left({\color{blue}{\left(\sqrt{1} \cdot \sqrt{\sqrt{2}}\right)}}^{3} \cdot x\right) \cdot \left(x + y\right)\right) \cdot \sqrt{\sqrt{2}}\]
  14. Applied unpow-prod-down0.5

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

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

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

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

    \[\leadsto {\left(\sqrt{1}\right)}^{3} \cdot \color{blue}{\left(\left(2 \cdot x\right) \cdot \left(x + y\right)\right)}\]
  19. Final simplification0.0

    \[\leadsto {\left(\sqrt{1}\right)}^{3} \cdot \left(\left(2 \cdot x\right) \cdot \left(x + y\right)\right)\]

Reproduce

herbie shell --seed 2020114 +o rules:numerics
(FPCore (x y)
  :name "Linear.Matrix:fromQuaternion from linear-1.19.1.3, B"
  :precision binary64

  :herbie-target
  (* (* x 2) (+ x y))

  (* 2 (+ (* x x) (* x y))))