(FPCore (x y) :precision binary64 (sqrt (+ (* x x) y)))
(FPCore (x y)
:precision binary64
(let* ((t_0 (fma 0.5 (/ y x) x)))
(if (<= x -5.298076076378501e+152)
(- t_0)
(if (<= x 5.945564708482161e+108) (sqrt (fma x x y)) t_0))))double code(double x, double y) {
return sqrt(((x * x) + y));
}
double code(double x, double y) {
double t_0 = fma(0.5, (y / x), x);
double tmp;
if (x <= -5.298076076378501e+152) {
tmp = -t_0;
} else if (x <= 5.945564708482161e+108) {
tmp = sqrt(fma(x, x, y));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y) return sqrt(Float64(Float64(x * x) + y)) end
function code(x, y) t_0 = fma(0.5, Float64(y / x), x) tmp = 0.0 if (x <= -5.298076076378501e+152) tmp = Float64(-t_0); elseif (x <= 5.945564708482161e+108) tmp = sqrt(fma(x, x, y)); else tmp = t_0; end return tmp end
code[x_, y_] := N[Sqrt[N[(N[(x * x), $MachinePrecision] + y), $MachinePrecision]], $MachinePrecision]
code[x_, y_] := Block[{t$95$0 = N[(0.5 * N[(y / x), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[x, -5.298076076378501e+152], (-t$95$0), If[LessEqual[x, 5.945564708482161e+108], N[Sqrt[N[(x * x + y), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\sqrt{x \cdot x + y}
\begin{array}{l}
t_0 := \mathsf{fma}\left(0.5, \frac{y}{x}, x\right)\\
\mathbf{if}\;x \leq -5.298076076378501 \cdot 10^{+152}:\\
\;\;\;\;-t_0\\
\mathbf{elif}\;x \leq 5.945564708482161 \cdot 10^{+108}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(x, x, y\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}




Bits error versus x




Bits error versus y
| Original | 21.7 |
|---|---|
| Target | 0.5 |
| Herbie | 0.1 |
if x < -5.29807607637850107e152Initial program 63.5
Simplified63.5
Taylor expanded in x around -inf 0
Simplified0
if -5.29807607637850107e152 < x < 5.94556470848216066e108Initial program 0.0
Simplified0.0
if 5.94556470848216066e108 < x Initial program 50.0
Simplified50.0
Taylor expanded in x around inf 0.5
Simplified0.5
Final simplification0.1
herbie shell --seed 2022131
(FPCore (x y)
:name "Linear.Quaternion:$clog from linear-1.19.1.3"
:precision binary64
:herbie-target
(if (< x -1.5097698010472593e+153) (- (+ (* 0.5 (/ y x)) x)) (if (< x 5.582399551122541e+57) (sqrt (+ (* x x) y)) (+ (* 0.5 (/ y x)) x)))
(sqrt (+ (* x x) y)))