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

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

\end{array}
double code(double x) {
	return ((double) sqrt(((double) (((double) (2.0 * x)) * x))));
}
double code(double x) {
	double VAR;
	if ((x <= -1.7415863520255e-310)) {
		VAR = ((double) (-1.0 * ((double) (((double) sqrt(2.0)) * x))));
	} else {
		VAR = ((double) (((double) sqrt(((double) (2.0 * x)))) * ((double) sqrt(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.741586352025499e-310

    1. Initial program 30.6

      \[\sqrt{\left(2 \cdot x\right) \cdot x}\]
    2. Taylor expanded around -inf 0.4

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

    if -1.741586352025499e-310 < x

    1. Initial program 30.4

      \[\sqrt{\left(2 \cdot x\right) \cdot x}\]
    2. Using strategy rm
    3. Applied sqrt-prod0.3

      \[\leadsto \color{blue}{\sqrt{2 \cdot x} \cdot \sqrt{x}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.4

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

Reproduce

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