\[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right)
\]
↓
\[\left(1 + \frac{rand}{\sqrt{\mathsf{fma}\left(a, 9, -3\right)}}\right) \cdot \left(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
(* (+ 1.0 (/ rand (sqrt (fma a 9.0 -3.0)))) (+ 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 (1.0 + (rand / sqrt(fma(a, 9.0, -3.0)))) * (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 Float64(Float64(1.0 + Float64(rand / sqrt(fma(a, 9.0, -3.0)))) * 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[(1.0 + N[(rand / N[Sqrt[N[(a * 9.0 + -3.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 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)
↓
\left(1 + \frac{rand}{\sqrt{\mathsf{fma}\left(a, 9, -3\right)}}\right) \cdot \left(a + -0.3333333333333333\right)
Alternatives
| Alternative 1 |
|---|
| Error | 5.5 |
|---|
| Cost | 7112 |
|---|
\[\begin{array}{l}
t_0 := 0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + -0.3333333333333333}\right)\\
\mathbf{if}\;rand \leq -3.874585501730415 \cdot 10^{+76}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;rand \leq 5.583931033628997 \cdot 10^{+78}:\\
\;\;\;\;a + -0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 5.4 |
|---|
| Cost | 7112 |
|---|
\[\begin{array}{l}
t_0 := \sqrt{a + -0.3333333333333333}\\
\mathbf{if}\;rand \leq -3.874585501730415 \cdot 10^{+76}:\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot t_0\right)\\
\mathbf{elif}\;rand \leq 5.583931033628997 \cdot 10^{+78}:\\
\;\;\;\;a + -0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(0.3333333333333333 \cdot rand\right)\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 0.8 |
|---|
| Cost | 7104 |
|---|
\[\left(1 + \frac{rand}{\sqrt{a \cdot 9}}\right) \cdot \left(a + -0.3333333333333333\right)
\]
| Alternative 4 |
|---|
| Error | 0.2 |
|---|
| Cost | 7104 |
|---|
\[\left(a + 0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + -0.3333333333333333}\right)\right) + -0.3333333333333333
\]
| Alternative 5 |
|---|
| Error | 5.9 |
|---|
| Cost | 6984 |
|---|
\[\begin{array}{l}
t_0 := \left(0.3333333333333333 \cdot rand\right) \cdot \sqrt{a}\\
\mathbf{if}\;rand \leq -3.874585501730415 \cdot 10^{+76}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;rand \leq 5.583931033628997 \cdot 10^{+78}:\\
\;\;\;\;a + -0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 5.9 |
|---|
| Cost | 6984 |
|---|
\[\begin{array}{l}
\mathbf{if}\;rand \leq -3.874585501730415 \cdot 10^{+76}:\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)\\
\mathbf{elif}\;rand \leq 5.583931033628997 \cdot 10^{+78}:\\
\;\;\;\;a + -0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\left(0.3333333333333333 \cdot rand\right) \cdot \sqrt{a}\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 18.8 |
|---|
| Cost | 192 |
|---|
\[a + -0.3333333333333333
\]
| Alternative 8 |
|---|
| Error | 19.5 |
|---|
| Cost | 64 |
|---|
\[a
\]