\[\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)
\]
↓
\[\cos th \cdot \frac{\mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}{\sqrt{2}}
\]
(FPCore (a1 a2 th)
:precision binary64
(+
(* (/ (cos th) (sqrt 2.0)) (* a1 a1))
(* (/ (cos th) (sqrt 2.0)) (* a2 a2))))
↓
(FPCore (a1 a2 th)
:precision binary64
(* (cos th) (/ (fma a1 a1 (* a2 a2)) (sqrt 2.0))))
double code(double a1, double a2, double th) {
return ((cos(th) / sqrt(2.0)) * (a1 * a1)) + ((cos(th) / sqrt(2.0)) * (a2 * a2));
}
↓
double code(double a1, double a2, double th) {
return cos(th) * (fma(a1, a1, (a2 * a2)) / sqrt(2.0));
}
function code(a1, a2, th)
return Float64(Float64(Float64(cos(th) / sqrt(2.0)) * Float64(a1 * a1)) + Float64(Float64(cos(th) / sqrt(2.0)) * Float64(a2 * a2)))
end
↓
function code(a1, a2, th)
return Float64(cos(th) * Float64(fma(a1, a1, Float64(a2 * a2)) / sqrt(2.0)))
end
code[a1_, a2_, th_] := N[(N[(N[(N[Cos[th], $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * N[(a1 * a1), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[th], $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * N[(a2 * a2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
↓
code[a1_, a2_, th_] := N[(N[Cos[th], $MachinePrecision] * N[(N[(a1 * a1 + N[(a2 * a2), $MachinePrecision]), $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)
↓
\cos th \cdot \frac{\mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}{\sqrt{2}}
Alternatives
| Alternative 1 |
|---|
| Accuracy | 67.2% |
|---|
| Cost | 13645 |
|---|
\[\begin{array}{l}
\mathbf{if}\;a1 \leq -3 \cdot 10^{-82} \lor \neg \left(a1 \leq -1.2 \cdot 10^{-96}\right) \land a1 \leq -5.2 \cdot 10^{-155}:\\
\;\;\;\;a1 \cdot \left(\sqrt{0.5} \cdot \left(\cos th \cdot a1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\cos th \cdot \left(\left(a2 \cdot a2\right) \cdot \sqrt{0.5}\right)\\
\end{array}
\]
| Alternative 2 |
|---|
| Accuracy | 67.1% |
|---|
| Cost | 13645 |
|---|
\[\begin{array}{l}
\mathbf{if}\;a1 \leq -2.2 \cdot 10^{-81} \lor \neg \left(a1 \leq -1.3 \cdot 10^{-95}\right) \land a1 \leq -3 \cdot 10^{-155}:\\
\;\;\;\;a1 \cdot \left(\sqrt{0.5} \cdot \left(\cos th \cdot a1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\cos th \cdot \frac{a2}{\frac{\sqrt{2}}{a2}}\\
\end{array}
\]
| Alternative 3 |
|---|
| Accuracy | 67.1% |
|---|
| Cost | 13645 |
|---|
\[\begin{array}{l}
t_1 := \cos th \cdot a1\\
\mathbf{if}\;a1 \leq -1.7 \cdot 10^{-81}:\\
\;\;\;\;a1 \cdot \left(\sqrt{0.5} \cdot t_1\right)\\
\mathbf{elif}\;a1 \leq -1.45 \cdot 10^{-96} \lor \neg \left(a1 \leq -5.2 \cdot 10^{-155}\right):\\
\;\;\;\;\cos th \cdot \frac{a2}{\frac{\sqrt{2}}{a2}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5} \cdot \left(a1 \cdot t_1\right)\\
\end{array}
\]
| Alternative 4 |
|---|
| Accuracy | 67.2% |
|---|
| Cost | 13644 |
|---|
\[\begin{array}{l}
t_1 := \cos th \cdot a1\\
\mathbf{if}\;a1 \leq -3.2 \cdot 10^{-82}:\\
\;\;\;\;a1 \cdot \left(\sqrt{0.5} \cdot t_1\right)\\
\mathbf{elif}\;a1 \leq -1.3 \cdot 10^{-95}:\\
\;\;\;\;\cos th \cdot \frac{a2}{\frac{\sqrt{2}}{a2}}\\
\mathbf{elif}\;a1 \leq -5.2 \cdot 10^{-155}:\\
\;\;\;\;\sqrt{0.5} \cdot \left(a1 \cdot t_1\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5} \cdot \left(a2 \cdot \left(\cos th \cdot a2\right)\right)\\
\end{array}
\]
| Alternative 5 |
|---|
| Accuracy | 67.1% |
|---|
| Cost | 13644 |
|---|
\[\begin{array}{l}
\mathbf{if}\;a1 \leq -1.4 \cdot 10^{-81}:\\
\;\;\;\;\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right)\\
\mathbf{elif}\;a1 \leq -8.6 \cdot 10^{-97}:\\
\;\;\;\;\cos th \cdot \frac{a2}{\frac{\sqrt{2}}{a2}}\\
\mathbf{elif}\;a1 \leq -5.2 \cdot 10^{-155}:\\
\;\;\;\;\sqrt{0.5} \cdot \left(a1 \cdot \left(\cos th \cdot a1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5} \cdot \left(a2 \cdot \left(\cos th \cdot a2\right)\right)\\
\end{array}
\]
| Alternative 6 |
|---|
| Accuracy | 67.0% |
|---|
| Cost | 13644 |
|---|
\[\begin{array}{l}
\mathbf{if}\;a1 \leq -2.15 \cdot 10^{-81}:\\
\;\;\;\;\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right)\\
\mathbf{elif}\;a1 \leq -1.65 \cdot 10^{-95}:\\
\;\;\;\;\frac{\cos th}{\frac{\sqrt{2}}{a2 \cdot a2}}\\
\mathbf{elif}\;a1 \leq -5.2 \cdot 10^{-155}:\\
\;\;\;\;\sqrt{0.5} \cdot \left(a1 \cdot \left(\cos th \cdot a1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{0.5} \cdot \left(a2 \cdot \left(\cos th \cdot a2\right)\right)\\
\end{array}
\]
| Alternative 7 |
|---|
| Accuracy | 67.0% |
|---|
| Cost | 13644 |
|---|
\[\begin{array}{l}
\mathbf{if}\;a1 \leq -1.85 \cdot 10^{-81}:\\
\;\;\;\;\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right)\\
\mathbf{elif}\;a1 \leq -1.15 \cdot 10^{-96}:\\
\;\;\;\;\frac{\cos th}{\frac{\sqrt{2}}{a2 \cdot a2}}\\
\mathbf{elif}\;a1 \leq -3 \cdot 10^{-155}:\\
\;\;\;\;\sqrt{0.5} \cdot \left(a1 \cdot \left(\cos th \cdot a1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{a2 \cdot \left(\cos th \cdot a2\right)}{\sqrt{2}}\\
\end{array}
\]
| Alternative 8 |
|---|
| Accuracy | 67.1% |
|---|
| Cost | 13644 |
|---|
\[\begin{array}{l}
\mathbf{if}\;a1 \leq -7.8 \cdot 10^{-82}:\\
\;\;\;\;\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right)\\
\mathbf{elif}\;a1 \leq -1.65 \cdot 10^{-96}:\\
\;\;\;\;\frac{\cos th}{\frac{\sqrt{2}}{a2 \cdot a2}}\\
\mathbf{elif}\;a1 \leq -5.2 \cdot 10^{-155}:\\
\;\;\;\;\sqrt{0.5} \cdot \left(a1 \cdot \left(\cos th \cdot a1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos th \cdot \left(a2 \cdot a2\right)}{\sqrt{2}}\\
\end{array}
\]
| Alternative 9 |
|---|
| Accuracy | 76.8% |
|---|
| Cost | 13513 |
|---|
\[\begin{array}{l}
\mathbf{if}\;th \leq -7.8 \cdot 10^{+15} \lor \neg \left(th \leq 800000\right):\\
\;\;\;\;a1 \cdot \left(\sqrt{0.5} \cdot \left(\cos th \cdot a1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{a2 \cdot a2 + a1 \cdot a1}{\sqrt{2}}\\
\end{array}
\]
| Alternative 10 |
|---|
| Accuracy | 99.2% |
|---|
| Cost | 13504 |
|---|
\[\frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2 + a1 \cdot a1\right)
\]
| Alternative 11 |
|---|
| Accuracy | 59.7% |
|---|
| Cost | 6976 |
|---|
\[\frac{a2 \cdot a2 + a1 \cdot a1}{\sqrt{2}}
\]
| Alternative 12 |
|---|
| Accuracy | 41.4% |
|---|
| Cost | 6852 |
|---|
\[\begin{array}{l}
\mathbf{if}\;a2 \leq 1.8 \cdot 10^{-189}:\\
\;\;\;\;\left(a1 \cdot a1\right) \cdot \sqrt{0.5}\\
\mathbf{else}:\\
\;\;\;\;\left(a2 \cdot a2\right) \cdot \sqrt{0.5}\\
\end{array}
\]
| Alternative 13 |
|---|
| Accuracy | 41.5% |
|---|
| Cost | 6852 |
|---|
\[\begin{array}{l}
\mathbf{if}\;a2 \leq 1.8 \cdot 10^{-189}:\\
\;\;\;\;a1 \cdot \frac{a1}{\sqrt{2}}\\
\mathbf{else}:\\
\;\;\;\;\left(a2 \cdot a2\right) \cdot \sqrt{0.5}\\
\end{array}
\]
| Alternative 14 |
|---|
| Accuracy | 41.5% |
|---|
| Cost | 6852 |
|---|
\[\begin{array}{l}
\mathbf{if}\;a2 \leq 1.8 \cdot 10^{-189}:\\
\;\;\;\;\frac{a1}{\frac{\sqrt{2}}{a1}}\\
\mathbf{else}:\\
\;\;\;\;\left(a2 \cdot a2\right) \cdot \sqrt{0.5}\\
\end{array}
\]
| Alternative 15 |
|---|
| Accuracy | 41.5% |
|---|
| Cost | 6852 |
|---|
\[\begin{array}{l}
\mathbf{if}\;a2 \leq 1.8 \cdot 10^{-189}:\\
\;\;\;\;\frac{a1}{\frac{\sqrt{2}}{a1}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a2}{\frac{\sqrt{2}}{a2}}\\
\end{array}
\]
| Alternative 16 |
|---|
| Accuracy | 41.4% |
|---|
| Cost | 6852 |
|---|
\[\begin{array}{l}
\mathbf{if}\;a2 \leq 1.8 \cdot 10^{-189}:\\
\;\;\;\;\frac{a1 \cdot a1}{\sqrt{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a2}{\frac{\sqrt{2}}{a2}}\\
\end{array}
\]
| Alternative 17 |
|---|
| Accuracy | 36.8% |
|---|
| Cost | 6720 |
|---|
\[\left(a1 \cdot a1\right) \cdot \sqrt{0.5}
\]