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



Bits error versus x
Results
if x < 0.0Initial program 31.0
Taylor expanded in x around -inf 0.4
Simplified0.4
if 0.0 < x Initial program 32.3
Taylor expanded in x around 0 0.4
Final simplification0.4
herbie shell --seed 2022156
(FPCore (x)
:name "sqrt D"
:precision binary64
(sqrt (* 2.0 (pow x 2.0))))