Math FPCore C Julia Wolfram TeX \[\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y
\]
↓
\[\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, x, y \cdot \left(y + y\right)\right)\right)
\]
(FPCore (x y) :precision binary64 (+ (+ (+ (* x x) (* y y)) (* y y)) (* y y))) ↓
(FPCore (x y) :precision binary64 (fma y y (fma x x (* y (+ y y))))) double code(double x, double y) {
return (((x * x) + (y * y)) + (y * y)) + (y * y);
}
↓
double code(double x, double y) {
return fma(y, y, fma(x, x, (y * (y + y))));
}
function code(x, y)
return Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) + Float64(y * y)) + Float64(y * y))
end
↓
function code(x, y)
return fma(y, y, fma(x, x, Float64(y * Float64(y + y))))
end
code[x_, y_] := N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]
↓
code[x_, y_] := N[(y * y + N[(x * x + N[(y * N[(y + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y
↓
\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, x, y \cdot \left(y + y\right)\right)\right)
Alternatives Alternative 1 Accuracy 81.5% Cost 713
\[\begin{array}{l}
\mathbf{if}\;x \leq -2.95 \cdot 10^{-24} \lor \neg \left(x \leq 1.7 \cdot 10^{-61}\right):\\
\;\;\;\;x \cdot x + y \cdot y\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(y \cdot 3\right)\\
\end{array}
\]
Alternative 2 Accuracy 80.5% Cost 585
\[\begin{array}{l}
\mathbf{if}\;y \leq -5.8 \cdot 10^{-58} \lor \neg \left(y \leq 1.55 \cdot 10^{-106}\right):\\
\;\;\;\;3 \cdot \left(y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\]
Alternative 3 Accuracy 80.6% Cost 585
\[\begin{array}{l}
\mathbf{if}\;y \leq -4.3 \cdot 10^{-54} \lor \neg \left(y \leq 1.55 \cdot 10^{-106}\right):\\
\;\;\;\;y \cdot \left(y \cdot 3\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\]
Alternative 4 Accuracy 99.8% Cost 576
\[x \cdot x + 3 \cdot \left(y \cdot y\right)
\]
Alternative 5 Accuracy 99.8% Cost 576
\[x \cdot x + y \cdot \left(y \cdot 3\right)
\]
Alternative 6 Accuracy 59.5% Cost 456
\[\begin{array}{l}
\mathbf{if}\;x \leq -2.5 \cdot 10^{-151}:\\
\;\;\;\;x \cdot x\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{-158}:\\
\;\;\;\;y \cdot y\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\]
Alternative 7 Accuracy 56.6% Cost 192
\[x \cdot x
\]