\[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right)
\]
↓
\[\mathsf{fma}\left({\left(\mathsf{fma}\left(9, a, -3\right)\right)}^{-0.5} \cdot \left(a + -0.3333333333333333\right), rand, a + -0.3333333333333333\right)
\]
(FPCore (a rand)
:precision binary64
(*
(- a (/ 1.0 3.0))
(+ 1.0 (* (/ 1.0 (sqrt (* 9.0 (- a (/ 1.0 3.0))))) rand))))
↓
(FPCore (a rand)
:precision binary64
(fma
(* (pow (fma 9.0 a -3.0) -0.5) (+ a -0.3333333333333333))
rand
(+ a -0.3333333333333333)))
double code(double a, double rand) {
return (a - (1.0 / 3.0)) * (1.0 + ((1.0 / sqrt((9.0 * (a - (1.0 / 3.0))))) * rand));
}
↓
double code(double a, double rand) {
return fma((pow(fma(9.0, a, -3.0), -0.5) * (a + -0.3333333333333333)), rand, (a + -0.3333333333333333));
}
function code(a, rand)
return Float64(Float64(a - Float64(1.0 / 3.0)) * Float64(1.0 + Float64(Float64(1.0 / sqrt(Float64(9.0 * Float64(a - Float64(1.0 / 3.0))))) * rand)))
end
↓
function code(a, rand)
return fma(Float64((fma(9.0, a, -3.0) ^ -0.5) * Float64(a + -0.3333333333333333)), rand, Float64(a + -0.3333333333333333))
end
code[a_, rand_] := N[(N[(a - N[(1.0 / 3.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(1.0 / N[Sqrt[N[(9.0 * N[(a - N[(1.0 / 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * rand), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
↓
code[a_, rand_] := N[(N[(N[Power[N[(9.0 * a + -3.0), $MachinePrecision], -0.5], $MachinePrecision] * N[(a + -0.3333333333333333), $MachinePrecision]), $MachinePrecision] * rand + N[(a + -0.3333333333333333), $MachinePrecision]), $MachinePrecision]
\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right)
↓
\mathsf{fma}\left({\left(\mathsf{fma}\left(9, a, -3\right)\right)}^{-0.5} \cdot \left(a + -0.3333333333333333\right), rand, a + -0.3333333333333333\right)
Alternatives
| Alternative 1 |
|---|
| Error | 0.1 |
|---|
| Cost | 19840 |
|---|
\[\mathsf{fma}\left({\left(\mathsf{fma}\left(9, a, -3\right)\right)}^{-0.5}, rand, 1\right) \cdot \left(a + -0.3333333333333333\right)
\]
| Alternative 2 |
|---|
| Error | 0.1 |
|---|
| Cost | 13504 |
|---|
\[\left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{\mathsf{fma}\left(a, 9, -3\right)}}\right)
\]
| Alternative 3 |
|---|
| Error | 12.0 |
|---|
| Cost | 7112 |
|---|
\[\begin{array}{l}
t_0 := \sqrt{\frac{0.1111111111111111}{a}} \cdot \left(a \cdot rand\right)\\
\mathbf{if}\;rand \leq -3.959536511689741 \cdot 10^{+105}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;rand \leq 2.8722160264104987 \cdot 10^{+47}:\\
\;\;\;\;a + -0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 5.9 |
|---|
| Cost | 7112 |
|---|
\[\begin{array}{l}
t_0 := 0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + -0.3333333333333333}\right)\\
\mathbf{if}\;rand \leq -3.959536511689741 \cdot 10^{+105}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;rand \leq 2.8722160264104987 \cdot 10^{+47}:\\
\;\;\;\;a + -0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 5.9 |
|---|
| Cost | 7112 |
|---|
\[\begin{array}{l}
t_0 := \sqrt{a + -0.3333333333333333}\\
\mathbf{if}\;rand \leq -3.959536511689741 \cdot 10^{+105}:\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot t_0\right)\\
\mathbf{elif}\;rand \leq 2.8722160264104987 \cdot 10^{+47}:\\
\;\;\;\;a + -0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(rand \cdot 0.3333333333333333\right)\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 0.9 |
|---|
| Cost | 7104 |
|---|
\[\left(a + -0.3333333333333333\right) \cdot \left(1 + rand \cdot \frac{0.3333333333333333}{\sqrt{a}}\right)
\]
| Alternative 7 |
|---|
| Error | 0.9 |
|---|
| Cost | 7104 |
|---|
\[\left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand \cdot 0.3333333333333333}{\sqrt{a}}\right)
\]
| Alternative 8 |
|---|
| Error | 0.9 |
|---|
| Cost | 7104 |
|---|
\[\left(a + -0.3333333333333333\right) \cdot \left(1 + rand \cdot \sqrt{\frac{0.1111111111111111}{a}}\right)
\]
| Alternative 9 |
|---|
| Error | 0.2 |
|---|
| Cost | 7104 |
|---|
\[-0.3333333333333333 + \left(a + 0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + -0.3333333333333333}\right)\right)
\]
| Alternative 10 |
|---|
| Error | 18.1 |
|---|
| Cost | 192 |
|---|
\[a + -0.3333333333333333
\]
| Alternative 11 |
|---|
| Error | 19.0 |
|---|
| Cost | 64 |
|---|
\[a
\]