Average Error: 30.6 → 0.7
Time: 2.4s
Precision: binary64
\[\sqrt{x \cdot x + x \cdot x}\]
\[\sqrt{\left|x \cdot \sqrt{2}\right|} \cdot \sqrt{\left|x \cdot \sqrt{2}\right|}\]
\sqrt{x \cdot x + x \cdot x}
\sqrt{\left|x \cdot \sqrt{2}\right|} \cdot \sqrt{\left|x \cdot \sqrt{2}\right|}
(FPCore (x) :precision binary64 (sqrt (+ (* x x) (* x x))))
(FPCore (x)
 :precision binary64
 (* (sqrt (fabs (* x (sqrt 2.0)))) (sqrt (fabs (* x (sqrt 2.0))))))
double code(double x) {
	return sqrt((x * x) + (x * x));
}
double code(double x) {
	return sqrt(fabs(x * sqrt(2.0))) * sqrt(fabs(x * sqrt(2.0)));
}

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{x \cdot x + x \cdot x}\]
  2. Simplified30.6

    \[\leadsto \color{blue}{\sqrt{x \cdot \left(x + x\right)}}\]
  3. Using strategy rm
  4. Applied add-sqr-sqrt_binary6430.8

    \[\leadsto \color{blue}{\sqrt{\sqrt{x \cdot \left(x + x\right)}} \cdot \sqrt{\sqrt{x \cdot \left(x + x\right)}}}\]
  5. Using strategy rm
  6. Applied add-exp-log_binary6432.5

    \[\leadsto \sqrt{\sqrt{x \cdot \left(x + x\right)}} \cdot \sqrt{\color{blue}{e^{\log \left(\sqrt{x \cdot \left(x + x\right)}\right)}}}\]
  7. Using strategy rm
  8. Applied add-sqr-sqrt_binary6432.5

    \[\leadsto \color{blue}{\sqrt{\sqrt{\sqrt{x \cdot \left(x + x\right)}} \cdot \sqrt{e^{\log \left(\sqrt{x \cdot \left(x + x\right)}\right)}}} \cdot \sqrt{\sqrt{\sqrt{x \cdot \left(x + x\right)}} \cdot \sqrt{e^{\log \left(\sqrt{x \cdot \left(x + x\right)}\right)}}}}\]
  9. Simplified32.1

    \[\leadsto \color{blue}{\sqrt{\left|x \cdot \sqrt{2}\right|}} \cdot \sqrt{\sqrt{\sqrt{x \cdot \left(x + x\right)}} \cdot \sqrt{e^{\log \left(\sqrt{x \cdot \left(x + x\right)}\right)}}}\]
  10. Simplified0.7

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

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

Reproduce

herbie shell --seed 2020260 
(FPCore (x)
  :name "sqrt A"
  :precision binary64
  (sqrt (+ (* x x) (* x x))))