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

    \[\sqrt{2 \cdot {x}^{2}} \]
  2. Applied add-sqr-sqrt_binary6430.8

    \[\leadsto \color{blue}{\sqrt{\sqrt{2 \cdot {x}^{2}}} \cdot \sqrt{\sqrt{2 \cdot {x}^{2}}}} \]
  3. Simplified30.8

    \[\leadsto \color{blue}{\sqrt{\mathsf{hypot}\left(x, x\right)}} \cdot \sqrt{\sqrt{2 \cdot {x}^{2}}} \]
  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 2022077 
(FPCore (x)
  :name "sqrt D"
  :precision binary64
  (sqrt (* 2.0 (pow x 2.0))))