\[\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
\]
↓
\[\mathsf{fma}\left(y, x, \mathsf{fma}\left(z, z, z \cdot \left(z + z\right)\right)\right)
\]
(FPCore (x y z)
:precision binary64
(+ (+ (+ (* x y) (* z z)) (* z z)) (* z z)))
↓
(FPCore (x y z) :precision binary64 (fma y x (fma z z (* z (+ z z)))))
double code(double x, double y, double z) {
return (((x * y) + (z * z)) + (z * z)) + (z * z);
}
↓
double code(double x, double y, double z) {
return fma(y, x, fma(z, z, (z * (z + z))));
}
function code(x, y, z)
return Float64(Float64(Float64(Float64(x * y) + Float64(z * z)) + Float64(z * z)) + Float64(z * z))
end
↓
function code(x, y, z)
return fma(y, x, fma(z, z, Float64(z * Float64(z + z))))
end
code[x_, y_, z_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision]
↓
code[x_, y_, z_] := N[(y * x + N[(z * z + N[(z * N[(z + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
↓
\mathsf{fma}\left(y, x, \mathsf{fma}\left(z, z, z \cdot \left(z + z\right)\right)\right)
Alternatives
| Alternative 1 |
|---|
| Error | 0.1 |
|---|
| Cost | 7104 |
|---|
\[\mathsf{fma}\left(z, z, z \cdot \left(z + z\right) + y \cdot x\right)
\]
| Alternative 2 |
|---|
| Error | 12.8 |
|---|
| Cost | 976 |
|---|
\[\begin{array}{l}
t_0 := \left(z \cdot z\right) \cdot 3\\
t_1 := z \cdot z + y \cdot x\\
\mathbf{if}\;z \leq -27689.12722169995:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -1.487393591883637 \cdot 10^{-57}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -1.0093204801178489 \cdot 10^{-117}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 9.92149702785056 \cdot 10^{+50}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 13.4 |
|---|
| Cost | 848 |
|---|
\[\begin{array}{l}
t_0 := \left(z \cdot z\right) \cdot 3\\
\mathbf{if}\;z \leq -27689.12722169995:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -1.487393591883637 \cdot 10^{-57}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;z \leq -1.0093204801178489 \cdot 10^{-117}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 6.206492760354703 \cdot 10^{+28}:\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 0.1 |
|---|
| Cost | 832 |
|---|
\[\left(z \cdot \left(z + z\right) + y \cdot x\right) + z \cdot z
\]
| Alternative 5 |
|---|
| Error | 0.1 |
|---|
| Cost | 576 |
|---|
\[z \cdot \left(z \cdot 3\right) + y \cdot x
\]
| Alternative 6 |
|---|
| Error | 23.4 |
|---|
| Cost | 324 |
|---|
\[\begin{array}{l}
\mathbf{if}\;z \leq 9.92149702785056 \cdot 10^{+50}:\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;z \cdot z\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 55.5 |
|---|
| Cost | 192 |
|---|
\[z \cdot z
\]