Average Error: 31.0 → 0.4
Time: 2.1s
Precision: binary64
\[\sqrt{2 \cdot {x}^{2}}\]
\[\sqrt{2 \cdot \left|x\right|} \cdot \sqrt{\left|x\right|}\]
\sqrt{2 \cdot {x}^{2}}
\sqrt{2 \cdot \left|x\right|} \cdot \sqrt{\left|x\right|}
(FPCore (x) :precision binary64 (sqrt (* 2.0 (pow x 2.0))))
(FPCore (x) :precision binary64 (* (sqrt (* 2.0 (fabs x))) (sqrt (fabs x))))
double code(double x) {
	return sqrt(2.0 * pow(x, 2.0));
}
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 {x}^{2}}\]
  2. Using strategy rm
  3. Applied sqrt-prod_binary6431.1

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

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

    \[\leadsto \sqrt{2} \cdot \color{blue}{\left(\sqrt{\left|x\right|} \cdot \sqrt{\left|x\right|}\right)}\]
  7. Applied associate-*r*_binary640.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_binary640.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 D"
  :precision binary64
  (sqrt (* 2.0 (pow x 2.0))))