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

    \[\leadsto \color{blue}{\sqrt{2 \cdot \left(x \cdot x\right)}}\]
  3. Using strategy rm
  4. Applied sqrt-prod_binary6431.1

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

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

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

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

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

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

Reproduce

herbie shell --seed 2020280 
(FPCore (x)
  :name "sqrt E"
  :precision binary64
  (sqrt (+ (pow x 2.0) (pow x 2.0))))