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

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

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

    \[\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 rem-square-sqrt_binary640.1

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

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

Reproduce

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