Average Error: 30.5 → 0.4
Time: 1.8s
Precision: binary64
\[\sqrt{x \cdot x + x \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;x \leq 1.18320777133784 \cdot 10^{-310}:\\ \;\;\;\;x \cdot \left(-\sqrt{2}\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x} \cdot \sqrt{x + x}\\ \end{array}\]
\sqrt{x \cdot x + x \cdot x}
\begin{array}{l}
\mathbf{if}\;x \leq 1.18320777133784 \cdot 10^{-310}:\\
\;\;\;\;x \cdot \left(-\sqrt{2}\right)\\

\mathbf{else}:\\
\;\;\;\;\sqrt{x} \cdot \sqrt{x + x}\\

\end{array}
double code(double x) {
	return ((double) sqrt(((double) (((double) (x * x)) + ((double) (x * x))))));
}
double code(double x) {
	double VAR;
	if ((x <= 1.18320777133784e-310)) {
		VAR = ((double) (x * ((double) -(((double) sqrt(2.0))))));
	} else {
		VAR = ((double) (((double) sqrt(x)) * ((double) sqrt(((double) (x + x))))));
	}
	return VAR;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if x < 1.18320777133784e-310

    1. Initial program Error: 30.7 bits

      \[\sqrt{x \cdot x + x \cdot x}\]
    2. SimplifiedError: 30.7 bits

      \[\leadsto \color{blue}{\sqrt{x \cdot \left(x + x\right)}}\]
    3. Taylor expanded around -inf Error: 0.4 bits

      \[\leadsto \color{blue}{-1 \cdot \left(x \cdot \sqrt{2}\right)}\]
    4. SimplifiedError: 0.4 bits

      \[\leadsto \color{blue}{x \cdot \left(-\sqrt{2}\right)}\]

    if 1.18320777133784e-310 < x

    1. Initial program Error: 30.3 bits

      \[\sqrt{x \cdot x + x \cdot x}\]
    2. SimplifiedError: 30.3 bits

      \[\leadsto \color{blue}{\sqrt{x \cdot \left(x + x\right)}}\]
    3. Using strategy rm
    4. Applied sqrt-prodError: 0.4 bits

      \[\leadsto \color{blue}{\sqrt{x} \cdot \sqrt{x + x}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplificationError: 0.4 bits

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.18320777133784 \cdot 10^{-310}:\\ \;\;\;\;x \cdot \left(-\sqrt{2}\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x} \cdot \sqrt{x + x}\\ \end{array}\]

Reproduce

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