Average Error: 31.0 → 0.3
Time: 2.5s
Precision: binary64
\[\sqrt{\left(2 \cdot x\right) \cdot x} \]
\[\begin{array}{l} t_0 := \sqrt[3]{\sqrt[3]{\sqrt{2}}}\\ \mathbf{if}\;x \leq 2.1786358791023 \cdot 10^{-310}:\\ \;\;\;\;-{t_0}^{8} \cdot \left(x \cdot t_0\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x \cdot 2} \cdot \sqrt{x}\\ \end{array} \]
(FPCore (x) :precision binary64 (sqrt (* (* 2.0 x) x)))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (cbrt (cbrt (sqrt 2.0)))))
   (if (<= x 2.1786358791023e-310)
     (- (* (pow t_0 8.0) (* x t_0)))
     (* (sqrt (* x 2.0)) (sqrt x)))))
double code(double x) {
	return sqrt(((2.0 * x) * x));
}
double code(double x) {
	double t_0 = cbrt(cbrt(sqrt(2.0)));
	double tmp;
	if (x <= 2.1786358791023e-310) {
		tmp = -(pow(t_0, 8.0) * (x * t_0));
	} else {
		tmp = sqrt((x * 2.0)) * sqrt(x);
	}
	return tmp;
}
public static double code(double x) {
	return Math.sqrt(((2.0 * x) * x));
}
public static double code(double x) {
	double t_0 = Math.cbrt(Math.cbrt(Math.sqrt(2.0)));
	double tmp;
	if (x <= 2.1786358791023e-310) {
		tmp = -(Math.pow(t_0, 8.0) * (x * t_0));
	} else {
		tmp = Math.sqrt((x * 2.0)) * Math.sqrt(x);
	}
	return tmp;
}
function code(x)
	return sqrt(Float64(Float64(2.0 * x) * x))
end
function code(x)
	t_0 = cbrt(cbrt(sqrt(2.0)))
	tmp = 0.0
	if (x <= 2.1786358791023e-310)
		tmp = Float64(-Float64((t_0 ^ 8.0) * Float64(x * t_0)));
	else
		tmp = Float64(sqrt(Float64(x * 2.0)) * sqrt(x));
	end
	return tmp
end
code[x_] := N[Sqrt[N[(N[(2.0 * x), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]
code[x_] := Block[{t$95$0 = N[Power[N[Power[N[Sqrt[2.0], $MachinePrecision], 1/3], $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[x, 2.1786358791023e-310], (-N[(N[Power[t$95$0, 8.0], $MachinePrecision] * N[(x * t$95$0), $MachinePrecision]), $MachinePrecision]), N[(N[Sqrt[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]]]
\sqrt{\left(2 \cdot x\right) \cdot x}
\begin{array}{l}
t_0 := \sqrt[3]{\sqrt[3]{\sqrt{2}}}\\
\mathbf{if}\;x \leq 2.1786358791023 \cdot 10^{-310}:\\
\;\;\;\;-{t_0}^{8} \cdot \left(x \cdot t_0\right)\\

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


\end{array}

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 < 2.178635879102305e-310

    1. Initial program 31.3

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

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

      \[\leadsto \color{blue}{-\sqrt{2} \cdot x} \]
    4. Applied add-cube-cbrt_binary640.4

      \[\leadsto -\color{blue}{\left(\left(\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}\right) \cdot \sqrt[3]{\sqrt{2}}\right)} \cdot x \]
    5. Applied associate-*l*_binary640.4

      \[\leadsto -\color{blue}{\left(\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}\right) \cdot \left(\sqrt[3]{\sqrt{2}} \cdot x\right)} \]
    6. Applied add-cube-cbrt_binary640.4

      \[\leadsto -\left(\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}\right) \cdot \left(\color{blue}{\left(\left(\sqrt[3]{\sqrt[3]{\sqrt{2}}} \cdot \sqrt[3]{\sqrt[3]{\sqrt{2}}}\right) \cdot \sqrt[3]{\sqrt[3]{\sqrt{2}}}\right)} \cdot x\right) \]
    7. Applied associate-*l*_binary640.4

      \[\leadsto -\left(\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}\right) \cdot \color{blue}{\left(\left(\sqrt[3]{\sqrt[3]{\sqrt{2}}} \cdot \sqrt[3]{\sqrt[3]{\sqrt{2}}}\right) \cdot \left(\sqrt[3]{\sqrt[3]{\sqrt{2}}} \cdot x\right)\right)} \]
    8. Applied associate-*r*_binary640.3

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

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

    if 2.178635879102305e-310 < x

    1. Initial program 30.7

      \[\sqrt{\left(2 \cdot x\right) \cdot x} \]
    2. Applied sqrt-prod_binary640.4

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

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

Reproduce

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