Average Error: 31.2 → 0.1
Time: 3.0s
Precision: binary64
\[\sqrt{2 \cdot \left(x \cdot x\right)} \]
\[\left|\mathsf{hypot}\left(x, x\right)\right| \]
\sqrt{2 \cdot \left(x \cdot x\right)}
\left|\mathsf{hypot}\left(x, x\right)\right|
(FPCore (x) :precision binary64 (sqrt (* 2.0 (* x x))))
(FPCore (x) :precision binary64 (fabs (hypot x x)))
double code(double x) {
	return sqrt(2.0 * (x * x));
}
double code(double x) {
	return fabs(hypot(x, 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.2

    \[\sqrt{2 \cdot \left(x \cdot x\right)} \]
  2. Applied add-sqr-sqrt_binary6431.4

    \[\leadsto \color{blue}{\sqrt{\sqrt{2 \cdot \left(x \cdot x\right)}} \cdot \sqrt{\sqrt{2 \cdot \left(x \cdot x\right)}}} \]
  3. Simplified31.4

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

    \[\leadsto \sqrt{\mathsf{hypot}\left(x, x\right)} \cdot \color{blue}{\sqrt{\mathsf{hypot}\left(x, x\right)}} \]
  5. Applied add-sqr-sqrt_binary640.5

    \[\leadsto \sqrt{\mathsf{hypot}\left(x, x\right)} \cdot \sqrt{\color{blue}{\sqrt{\mathsf{hypot}\left(x, x\right)} \cdot \sqrt{\mathsf{hypot}\left(x, x\right)}}} \]
  6. Applied rem-sqrt-square_binary640.5

    \[\leadsto \sqrt{\mathsf{hypot}\left(x, x\right)} \cdot \color{blue}{\left|\sqrt{\mathsf{hypot}\left(x, x\right)}\right|} \]
  7. Applied add-sqr-sqrt_binary640.5

    \[\leadsto \sqrt{\color{blue}{\sqrt{\mathsf{hypot}\left(x, x\right)} \cdot \sqrt{\mathsf{hypot}\left(x, x\right)}}} \cdot \left|\sqrt{\mathsf{hypot}\left(x, x\right)}\right| \]
  8. Applied rem-sqrt-square_binary640.5

    \[\leadsto \color{blue}{\left|\sqrt{\mathsf{hypot}\left(x, x\right)}\right|} \cdot \left|\sqrt{\mathsf{hypot}\left(x, x\right)}\right| \]
  9. Applied mul-fabs_binary640.5

    \[\leadsto \color{blue}{\left|\sqrt{\mathsf{hypot}\left(x, x\right)} \cdot \sqrt{\mathsf{hypot}\left(x, x\right)}\right|} \]
  10. Simplified0.1

    \[\leadsto \left|\color{blue}{\mathsf{hypot}\left(x, x\right)}\right| \]
  11. Final simplification0.1

    \[\leadsto \left|\mathsf{hypot}\left(x, x\right)\right| \]

Reproduce

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