\[\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 | 7360 |
|---|
\[a + \left(-0.3333333333333333 - \frac{rand}{3 \cdot \sqrt{a + -0.3333333333333333}} \cdot \left(0.3333333333333333 - a\right)\right)
\]
| Alternative 2 |
|---|
| Error | 0.1 |
|---|
| Cost | 7232 |
|---|
\[\left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{\frac{rand}{3}}{\sqrt{a + -0.3333333333333333}}\right)
\]
| Alternative 3 |
|---|
| Error | 5.2 |
|---|
| Cost | 7112 |
|---|
\[\begin{array}{l}
t_0 := rand \cdot \left(0.3333333333333333 \cdot \sqrt{a + -0.3333333333333333}\right)\\
\mathbf{if}\;rand \leq -1.0077323823976105 \cdot 10^{+90}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;rand \leq 1.535103304380144 \cdot 10^{+75}:\\
\;\;\;\;a + -0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 5.2 |
|---|
| Cost | 7112 |
|---|
\[\begin{array}{l}
t_0 := rand \cdot \sqrt{\left(a + -0.3333333333333333\right) \cdot 0.1111111111111111}\\
\mathbf{if}\;rand \leq -1.0077323823976105 \cdot 10^{+90}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;rand \leq 1.535103304380144 \cdot 10^{+75}:\\
\;\;\;\;a + -0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 0.8 |
|---|
| Cost | 7104 |
|---|
\[\left(a + -0.3333333333333333\right) \cdot \left(1 - -0.3333333333333333 \cdot \frac{rand}{\sqrt{a}}\right)
\]
| Alternative 6 |
|---|
| Error | 0.8 |
|---|
| Cost | 7104 |
|---|
\[\left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{a \cdot 9}}\right)
\]
| Alternative 7 |
|---|
| Error | 0.2 |
|---|
| Cost | 7104 |
|---|
\[-0.3333333333333333 + \left(a + 0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + -0.3333333333333333}\right)\right)
\]
| Alternative 8 |
|---|
| Error | 5.7 |
|---|
| Cost | 6984 |
|---|
\[\begin{array}{l}
t_0 := rand \cdot \sqrt{a \cdot 0.1111111111111111}\\
\mathbf{if}\;rand \leq -1.0077323823976105 \cdot 10^{+90}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;rand \leq 1.535103304380144 \cdot 10^{+75}:\\
\;\;\;\;a + -0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 18.8 |
|---|
| Cost | 192 |
|---|
\[a + -0.3333333333333333
\]
| Alternative 10 |
|---|
| Error | 19.5 |
|---|
| Cost | 64 |
|---|
\[a
\]