Average Error: 29.7 → 0.3
Time: 2.5s
Precision: binary64
Cost: 39105
\[\sqrt{\left(2 \cdot x\right) \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;x \leq -1.52521227020015 \cdot 10^{-310}:\\ \;\;\;\;-x \cdot \sqrt{2}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot {\left(\sqrt{\sqrt{2}}\right)}^{1.5}\right) \cdot \sqrt{\sqrt{\sqrt{2}}}\\ \end{array}\]
\sqrt{\left(2 \cdot x\right) \cdot x}
\begin{array}{l}
\mathbf{if}\;x \leq -1.52521227020015 \cdot 10^{-310}:\\
\;\;\;\;-x \cdot \sqrt{2}\\

\mathbf{else}:\\
\;\;\;\;\left(x \cdot {\left(\sqrt{\sqrt{2}}\right)}^{1.5}\right) \cdot \sqrt{\sqrt{\sqrt{2}}}\\

\end{array}
(FPCore (x) :precision binary64 (sqrt (* (* 2.0 x) x)))
(FPCore (x)
 :precision binary64
 (if (<= x -1.52521227020015e-310)
   (- (* x (sqrt 2.0)))
   (* (* x (pow (sqrt (sqrt 2.0)) 1.5)) (sqrt (sqrt (sqrt 2.0))))))
double code(double x) {
	return sqrt((2.0 * x) * x);
}
double code(double x) {
	double tmp;
	if (x <= -1.52521227020015e-310) {
		tmp = -(x * sqrt(2.0));
	} else {
		tmp = (x * pow(sqrt(sqrt(2.0)), 1.5)) * sqrt(sqrt(sqrt(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
Error30.5
Cost51648
\[\left(\left(x \cdot \sqrt{\sqrt{2}}\right) \cdot \left|\sqrt[3]{\sqrt{2}}\right|\right) \cdot \sqrt{\sqrt[3]{\sqrt{2}}}\]
Alternative 2
Error30.3
Cost39488
\[\sqrt[3]{\sqrt{x \cdot \left(x \cdot 2\right)}} \cdot \left(\sqrt[3]{\sqrt{x \cdot \left(x \cdot 2\right)}} \cdot \sqrt[3]{\sqrt{x \cdot \left(x \cdot 2\right)}}\right)\]
Alternative 3
Error31.0
Cost39104
\[\sqrt[3]{x \cdot \sqrt{2}} \cdot \left(\sqrt[3]{x \cdot \sqrt{2}} \cdot \sqrt[3]{x \cdot \sqrt{2}}\right)\]
Alternative 4
Error30.5
Cost38848
\[\sqrt[3]{\sqrt{2}} \cdot \left(x \cdot \left(\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}\right)\right)\]
Alternative 5
Error31.4
Cost38848
\[\left(\sqrt{x} \cdot \sqrt{\sqrt{2}}\right) \cdot \left(\sqrt{x} \cdot \sqrt{\sqrt{2}}\right)\]
Alternative 6
Error30.4
Cost38784
\[\left(x \cdot {\left(\sqrt{\sqrt{2}}\right)}^{1.5}\right) \cdot \sqrt{\sqrt{\sqrt{2}}}\]
Alternative 7
Error30.4
Cost32512
\[\sqrt{\sqrt{\sqrt{2}}} \cdot \left(x \cdot {\left(2 \cdot \sqrt{2}\right)}^{0.25}\right)\]
Alternative 8
Error31.3
Cost26048
\[\sqrt{x \cdot \sqrt{2}} \cdot \sqrt{x \cdot \sqrt{2}}\]
Alternative 9
Error30.5
Cost25920
\[\sqrt{\sqrt{2}} \cdot \left(x \cdot \sqrt{\sqrt{2}}\right)\]
Alternative 10
Error40.4
Cost19584
\[\sqrt[3]{{\left(\sqrt{x \cdot \left(x \cdot 2\right)}\right)}^{3}}\]
Alternative 11
Error32.1
Cost19520
\[e^{\log \left(\sqrt{x \cdot \left(x \cdot 2\right)}\right)}\]
Alternative 12
Error31.3
Cost19520
\[\sqrt{x} \cdot \left(\sqrt{2} \cdot \sqrt{x}\right)\]
Alternative 13
Error51.2
Cost19456
\[\sqrt[3]{{\left(x \cdot \sqrt{2}\right)}^{3}}\]
Alternative 14
Error31.2
Cost13120
\[\sqrt{x \cdot 2} \cdot \sqrt{x}\]
Alternative 15
Error29.7
Cost6720
\[\sqrt{x \cdot \left(x \cdot 2\right)}\]
Alternative 16
Error32.5
Cost6656
\[-x \cdot \sqrt{2}\]
Alternative 17
Error30.5
Cost6592
\[x \cdot \sqrt{2}\]
Alternative 18
Error60.5
Cost64
\[1\]
Alternative 19
Error61.6
Cost64
\[0\]
Alternative 20
Error62.9
Cost64
\[-1\]

Error

Derivation

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

    1. Initial program 29.2

      \[\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. Simplified0.4

      \[\leadsto \color{blue}{-x \cdot \sqrt{2}}\]

    if -1.525212270200155e-310 < x

    1. Initial program 30.2

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

      \[\leadsto \color{blue}{x \cdot \sqrt{2}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt_binary64_930.6

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

      \[\leadsto \color{blue}{\left(x \cdot \sqrt{\sqrt{2}}\right) \cdot \sqrt{\sqrt{2}}}\]
    6. Using strategy rm
    7. Applied add-sqr-sqrt_binary64_930.5

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

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

      \[\leadsto \color{blue}{\left(x \cdot {\left(\sqrt{\sqrt{2}}\right)}^{1.5}\right)} \cdot \sqrt{\sqrt{\sqrt{2}}}\]
    10. Simplified0.3

      \[\leadsto \color{blue}{\left(x \cdot {\left(\sqrt{\sqrt{2}}\right)}^{1.5}\right) \cdot \sqrt{\sqrt{\sqrt{2}}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.3

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

Reproduce

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