Average Error: 31.0 → 0.4
Time: 1.5s
Precision: binary64
\[\sqrt{2 \cdot \left(x \cdot x\right)}\]
\[\sqrt{2 \cdot \left|x\right|} \cdot \sqrt{\left|x\right|}\]
\sqrt{2 \cdot \left(x \cdot x\right)}
\sqrt{2 \cdot \left|x\right|} \cdot \sqrt{\left|x\right|}
(FPCore (x) :precision binary64 (sqrt (* 2.0 (* x x))))
(FPCore (x) :precision binary64 (* (sqrt (* 2.0 (fabs x))) (sqrt (fabs x))))
double code(double x) {
	return sqrt(2.0 * (x * x));
}
double code(double x) {
	return sqrt(2.0 * fabs(x)) * sqrt(fabs(x));
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 31.0

    \[\sqrt{2 \cdot \left(x \cdot x\right)}\]
  2. Using strategy rm
  3. Applied sqrt-prod_binary64_9231.1

    \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{x \cdot x}}\]
  4. Simplified0.4

    \[\leadsto \sqrt{2} \cdot \color{blue}{\left|x\right|}\]
  5. Using strategy rm
  6. Applied add-sqr-sqrt_binary64_980.7

    \[\leadsto \sqrt{2} \cdot \color{blue}{\left(\sqrt{\left|x\right|} \cdot \sqrt{\left|x\right|}\right)}\]
  7. Applied associate-*r*_binary64_190.6

    \[\leadsto \color{blue}{\left(\sqrt{2} \cdot \sqrt{\left|x\right|}\right) \cdot \sqrt{\left|x\right|}}\]
  8. Using strategy rm
  9. Applied sqrt-unprod_binary64_960.4

    \[\leadsto \color{blue}{\sqrt{2 \cdot \left|x\right|}} \cdot \sqrt{\left|x\right|}\]
  10. Final simplification0.4

    \[\leadsto \sqrt{2 \cdot \left|x\right|} \cdot \sqrt{\left|x\right|}\]

Reproduce

herbie shell --seed 2020280 
(FPCore (x)
  :name "sqrt C"
  :precision binary64
  (sqrt (* 2.0 (* x x))))