Average Error: 30.4 → 15.2
Time: 7.8s
Precision: binary64
\[\sqrt{{x}^{2} + {x}^{2}}\]
\[\begin{array}{l} \mathbf{if}\;x \leq -2.8491681377424 \cdot 10^{-310}:\\ \;\;\;\;\sqrt{{x}^{2} \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{2} \cdot {x}^{1}\\ \end{array}\]
\sqrt{{x}^{2} + {x}^{2}}
\begin{array}{l}
\mathbf{if}\;x \leq -2.8491681377424 \cdot 10^{-310}:\\
\;\;\;\;\sqrt{{x}^{2} \cdot 2}\\

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

\end{array}
(FPCore (x) :precision binary64 (sqrt (+ (pow x 2.0) (pow x 2.0))))
(FPCore (x)
 :precision binary64
 (if (<= x -2.8491681377424e-310)
   (sqrt (* (pow x 2.0) 2.0))
   (* (sqrt 2.0) (pow x 1.0))))
double code(double x) {
	return ((double) sqrt(((double) (((double) pow(x, 2.0)) + ((double) pow(x, 2.0))))));
}
double code(double x) {
	double tmp;
	if ((x <= -2.8491681377424e-310)) {
		tmp = ((double) sqrt(((double) (((double) pow(x, 2.0)) * 2.0))));
	} else {
		tmp = ((double) (((double) sqrt(2.0)) * ((double) pow(x, 1.0))));
	}
	return tmp;
}

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.849168137742421e-310

    1. Initial program Error: 30.5 bits

      \[\sqrt{{x}^{2} + {x}^{2}}\]
    2. SimplifiedError: 30.5 bits

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

    if -2.849168137742421e-310 < x

    1. Initial program Error: 30.2 bits

      \[\sqrt{{x}^{2} + {x}^{2}}\]
    2. SimplifiedError: 30.2 bits

      \[\leadsto \color{blue}{\sqrt{{x}^{2} \cdot 2}}\]
    3. Taylor expanded around 0 Error: 5.7 bits

      \[\leadsto \color{blue}{\sqrt{2} \cdot e^{1 \cdot \left(\log 1 + \log x\right)}}\]
    4. SimplifiedError: 0.4 bits

      \[\leadsto \color{blue}{\sqrt{2} \cdot {x}^{1}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplificationError: 15.2 bits

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.8491681377424 \cdot 10^{-310}:\\ \;\;\;\;\sqrt{{x}^{2} \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{2} \cdot {x}^{1}\\ \end{array}\]

Reproduce

herbie shell --seed 2020204 
(FPCore (x)
  :name "sqrt E"
  :precision binary64
  (sqrt (+ (pow x 2.0) (pow x 2.0))))