(FPCore (x) :precision binary64 (sqrt (* 2.0 (* x x))))
(FPCore (x) :precision binary64 (if (<= x 1.29087552084645e-310) (* x (- (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 <= 1.29087552084645e-310) {
tmp = x * -sqrt(2.0);
} else {
tmp = sqrt(x) * sqrt((x * 2.0));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
code = sqrt((2.0d0 * (x * x)))
end function
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.29087552084645d-310) then
tmp = x * -sqrt(2.0d0)
else
tmp = sqrt(x) * sqrt((x * 2.0d0))
end if
code = tmp
end function
public static double code(double x) {
return Math.sqrt((2.0 * (x * x)));
}
public static double code(double x) {
double tmp;
if (x <= 1.29087552084645e-310) {
tmp = x * -Math.sqrt(2.0);
} else {
tmp = Math.sqrt(x) * Math.sqrt((x * 2.0));
}
return tmp;
}
def code(x): return math.sqrt((2.0 * (x * x)))
def code(x): tmp = 0 if x <= 1.29087552084645e-310: tmp = x * -math.sqrt(2.0) else: tmp = math.sqrt(x) * math.sqrt((x * 2.0)) return tmp
function code(x) return sqrt(Float64(2.0 * Float64(x * x))) end
function code(x) tmp = 0.0 if (x <= 1.29087552084645e-310) tmp = Float64(x * Float64(-sqrt(2.0))); else tmp = Float64(sqrt(x) * sqrt(Float64(x * 2.0))); end return tmp end
function tmp = code(x) tmp = sqrt((2.0 * (x * x))); end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.29087552084645e-310) tmp = x * -sqrt(2.0); else tmp = sqrt(x) * sqrt((x * 2.0)); end tmp_2 = tmp; end
code[x_] := N[Sqrt[N[(2.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[x_] := If[LessEqual[x, 1.29087552084645e-310], N[(x * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], N[(N[Sqrt[x], $MachinePrecision] * N[Sqrt[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\sqrt{2 \cdot \left(x \cdot x\right)}
\begin{array}{l}
\mathbf{if}\;x \leq 1.29087552084645 \cdot 10^{-310}:\\
\;\;\;\;x \cdot \left(-\sqrt{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{x} \cdot \sqrt{x \cdot 2}\\
\end{array}



Bits error versus x
Results
if x < 1.290875520846451e-310Initial program 31.3
Taylor expanded in x around -inf 0.4
Simplified0.4
if 1.290875520846451e-310 < x Initial program 30.7
Applied egg-rr0.4
Final simplification0.4
herbie shell --seed 2022150
(FPCore (x)
:name "sqrt C"
:precision binary64
(sqrt (* 2.0 (* x x))))