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

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

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

Error

Derivation

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

    1. Initial program 29.2

      \[\sqrt{x \cdot x + x \cdot x}\]
    2. Simplified29.2

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

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

      \[\leadsto \color{blue}{-x \cdot \sqrt{2}}\]
    5. Simplified0.4

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

    if -1.525212270200155e-310 < x

    1. Initial program 30.2

      \[\sqrt{x \cdot x + x \cdot x}\]
    2. Simplified30.2

      \[\leadsto \color{blue}{\sqrt{x \cdot \left(x + x\right)}}\]
    3. Taylor expanded around 0 0.4

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

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

      \[\leadsto \color{blue}{\left(x \cdot \sqrt{\sqrt{2}}\right) \cdot \sqrt{\sqrt{2}}}\]
    7. Using strategy rm
    8. 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)}\]
    9. 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}}}}\]
    10. Simplified0.3

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

      \[\leadsto \color{blue}{\sqrt{\sqrt{\sqrt{2}}} \cdot \left(x \cdot {\left(\sqrt{\sqrt{2}}\right)}^{1.5}\right)}\]
  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}:\\ \;\;\;\;\sqrt{\sqrt{\sqrt{2}}} \cdot \left(x \cdot {\left(\sqrt{\sqrt{2}}\right)}^{1.5}\right)\\ \end{array}\]

Reproduce

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