Math FPCore C Julia Wolfram TeX \[\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y
\]
↓
\[\begin{array}{l}
\mathbf{if}\;\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y \leq 5 \cdot 10^{+252}:\\
\;\;\;\;\mathsf{fma}\left(x, x, y \cdot \left(x \cdot 2 + y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x + y \cdot y\\
\end{array}
\]
(FPCore (x y) :precision binary64 (+ (+ (* x x) (* (* x 2.0) y)) (* y y))) ↓
(FPCore (x y)
:precision binary64
(if (<= (+ (+ (* x x) (* (* x 2.0) y)) (* y y)) 5e+252)
(fma x x (* y (+ (* x 2.0) y)))
(+ (* x x) (* y y)))) double code(double x, double y) {
return ((x * x) + ((x * 2.0) * y)) + (y * y);
}
↓
double code(double x, double y) {
double tmp;
if ((((x * x) + ((x * 2.0) * y)) + (y * y)) <= 5e+252) {
tmp = fma(x, x, (y * ((x * 2.0) + y)));
} else {
tmp = (x * x) + (y * y);
}
return tmp;
}
function code(x, y)
return Float64(Float64(Float64(x * x) + Float64(Float64(x * 2.0) * y)) + Float64(y * y))
end
↓
function code(x, y)
tmp = 0.0
if (Float64(Float64(Float64(x * x) + Float64(Float64(x * 2.0) * y)) + Float64(y * y)) <= 5e+252)
tmp = fma(x, x, Float64(y * Float64(Float64(x * 2.0) + y)));
else
tmp = Float64(Float64(x * x) + Float64(y * y));
end
return tmp
end
code[x_, y_] := N[(N[(N[(x * x), $MachinePrecision] + N[(N[(x * 2.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]
↓
code[x_, y_] := If[LessEqual[N[(N[(N[(x * x), $MachinePrecision] + N[(N[(x * 2.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision], 5e+252], N[(x * x + N[(y * N[(N[(x * 2.0), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]]
\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y
↓
\begin{array}{l}
\mathbf{if}\;\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y \leq 5 \cdot 10^{+252}:\\
\;\;\;\;\mathsf{fma}\left(x, x, y \cdot \left(x \cdot 2 + y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x + y \cdot y\\
\end{array}
Alternatives Alternative 1 Accuracy 99.9% Cost 7876
\[\begin{array}{l}
\mathbf{if}\;\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y \leq 5 \cdot 10^{+252}:\\
\;\;\;\;\mathsf{fma}\left(x, x, y \cdot \left(x \cdot 2 + y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x + y \cdot y\\
\end{array}
\]
Alternative 2 Accuracy 99.9% Cost 1604
\[\begin{array}{l}
\mathbf{if}\;\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y \leq 5 \cdot 10^{+252}:\\
\;\;\;\;y \cdot y + x \cdot \left(x + 2 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x + y \cdot y\\
\end{array}
\]
Alternative 3 Accuracy 67.4% Cost 580
\[\begin{array}{l}
\mathbf{if}\;y \leq 3 \cdot 10^{-133}:\\
\;\;\;\;x \cdot \left(x + \left(y + y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot y\\
\end{array}
\]
Alternative 4 Accuracy 98.9% Cost 448
\[x \cdot x + y \cdot y
\]
Alternative 5 Accuracy 67.6% Cost 324
\[\begin{array}{l}
\mathbf{if}\;y \leq 2.3 \cdot 10^{-133}:\\
\;\;\;\;x \cdot x\\
\mathbf{else}:\\
\;\;\;\;y \cdot y\\
\end{array}
\]
Alternative 6 Accuracy 57.8% Cost 192
\[x \cdot x
\]