Average Error: 30.6 → 0.4
Time: 18.8s
Precision: binary64
Cost: 39233
\[\sqrt{\left(2 \cdot x\right) \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;x \leq -3.1772341154775 \cdot 10^{-311}:\\ \;\;\;\;-\sqrt[3]{\sqrt{2}} \cdot \left(x \cdot \left(\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x} \cdot \sqrt{x \cdot 2}\\ \end{array}\]
\sqrt{\left(2 \cdot x\right) \cdot x}
\begin{array}{l}
\mathbf{if}\;x \leq -3.1772341154775 \cdot 10^{-311}:\\
\;\;\;\;-\sqrt[3]{\sqrt{2}} \cdot \left(x \cdot \left(\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}\right)\right)\\

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

\end{array}
(FPCore (x) :precision binary64 (sqrt (* (* 2.0 x) x)))
(FPCore (x)
 :precision binary64
 (if (<= x -3.1772341154775e-311)
   (- (* (cbrt (sqrt 2.0)) (* x (* (cbrt (sqrt 2.0)) (cbrt (sqrt 2.0))))))
   (* (sqrt x) (sqrt (* x 2.0)))))
double code(double x) {
	return sqrt((2.0 * x) * x);
}
double code(double x) {
	double tmp;
	if (x <= -3.1772341154775e-311) {
		tmp = -(cbrt(sqrt(2.0)) * (x * (cbrt(sqrt(2.0)) * cbrt(sqrt(2.0)))));
	} else {
		tmp = sqrt(x) * sqrt(x * 2.0);
	}
	return tmp;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Alternatives

Alternative 1
Error0.4
Cost26305
\[\begin{array}{l} \mathbf{if}\;x \leq -3.1772341154775 \cdot 10^{-311}:\\ \;\;\;\;-\sqrt{\sqrt{2}} \cdot \left(x \cdot \sqrt{\sqrt{2}}\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x} \cdot \sqrt{x \cdot 2}\\ \end{array}\]
Alternative 2
Error0.4
Cost13441
\[\begin{array}{l} \mathbf{if}\;x \leq -3.1772341154775 \cdot 10^{-311}:\\ \;\;\;\;-x \cdot \sqrt{2}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x} \cdot \sqrt{x \cdot 2}\\ \end{array}\]
Alternative 3
Error0.4
Cost6977
\[\begin{array}{l} \mathbf{if}\;x \leq -3.1772341154775 \cdot 10^{-311}:\\ \;\;\;\;-x \cdot \sqrt{2}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \sqrt{2}\\ \end{array}\]
Alternative 4
Error30.1
Cost6913
\[\begin{array}{l} \mathbf{if}\;x \leq -3.559042902657881 \cdot 10^{-206}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;x \cdot \sqrt{2}\\ \end{array}\]
Alternative 5
Error60.6
Cost64
\[1\]
Alternative 6
Error61.6
Cost64
\[0\]

Error

Derivation

  1. Split input into 2 regimes
  2. if x < -3.17723411547747e-311

    1. Initial program 30.7

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

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

      \[\leadsto \color{blue}{-x \cdot \sqrt{2}}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt_binary64_1130.4

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

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

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

    if -3.17723411547747e-311 < x

    1. Initial program 30.5

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

      \[\leadsto \color{blue}{{\left(\sqrt{\left(2 \cdot x\right) \cdot x}\right)}^{1}}\]
    4. Using strategy rm
    5. Applied add-exp-log_binary64_11632.8

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

      \[\leadsto {\left(e^{\color{blue}{\log \left(\sqrt{x \cdot \left(2 \cdot x\right)}\right)}}\right)}^{1}\]
    7. Using strategy rm
    8. Applied sqrt-prod_binary64_945.7

      \[\leadsto {\left(e^{\log \color{blue}{\left(\sqrt{x} \cdot \sqrt{2 \cdot x}\right)}}\right)}^{1}\]
    9. Applied log-prod_binary64_1646.1

      \[\leadsto {\left(e^{\color{blue}{\log \left(\sqrt{x}\right) + \log \left(\sqrt{2 \cdot x}\right)}}\right)}^{1}\]
    10. Applied exp-sum_binary64_1245.2

      \[\leadsto {\color{blue}{\left(e^{\log \left(\sqrt{x}\right)} \cdot e^{\log \left(\sqrt{2 \cdot x}\right)}\right)}}^{1}\]
    11. Simplified4.7

      \[\leadsto {\left(\color{blue}{\sqrt{x}} \cdot e^{\log \left(\sqrt{2 \cdot x}\right)}\right)}^{1}\]
    12. Simplified0.4

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

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

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

Reproduce

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