\[\left(\left(cosTheta_i > 0.9999 \land cosTheta_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
\[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right)
\]
↓
\[\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \cos \left(\left(u2 + u2\right) \cdot \pi\right)
\]
(FPCore (cosTheta_i u1 u2)
:precision binary64
(* (sqrt (- (log (- 1.0 u1)))) (cos (* (* 2.0 PI) u2))))
↓
(FPCore (cosTheta_i u1 u2)
:precision binary64
(* (sqrt (- (log1p (- u1)))) (cos (* (+ u2 u2) PI))))
double code(double cosTheta_i, double u1, double u2) {
return sqrt(-log((1.0 - u1))) * cos(((2.0 * ((double) M_PI)) * u2));
}
↓
double code(double cosTheta_i, double u1, double u2) {
return sqrt(-log1p(-u1)) * cos(((u2 + u2) * ((double) M_PI)));
}
public static double code(double cosTheta_i, double u1, double u2) {
return Math.sqrt(-Math.log((1.0 - u1))) * Math.cos(((2.0 * Math.PI) * u2));
}
↓
public static double code(double cosTheta_i, double u1, double u2) {
return Math.sqrt(-Math.log1p(-u1)) * Math.cos(((u2 + u2) * Math.PI));
}
def code(cosTheta_i, u1, u2):
return math.sqrt(-math.log((1.0 - u1))) * math.cos(((2.0 * math.pi) * u2))
↓
def code(cosTheta_i, u1, u2):
return math.sqrt(-math.log1p(-u1)) * math.cos(((u2 + u2) * math.pi))
function code(cosTheta_i, u1, u2)
return Float64(sqrt(Float64(-log(Float64(1.0 - u1)))) * cos(Float64(Float64(2.0 * pi) * u2)))
end
↓
function code(cosTheta_i, u1, u2)
return Float64(sqrt(Float64(-log1p(Float64(-u1)))) * cos(Float64(Float64(u2 + u2) * pi)))
end
code[cosTheta$95$i_, u1_, u2_] := N[(N[Sqrt[(-N[Log[N[(1.0 - u1), $MachinePrecision]], $MachinePrecision])], $MachinePrecision] * N[Cos[N[(N[(2.0 * Pi), $MachinePrecision] * u2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
↓
code[cosTheta$95$i_, u1_, u2_] := N[(N[Sqrt[(-N[Log[1 + (-u1)], $MachinePrecision])], $MachinePrecision] * N[Cos[N[(N[(u2 + u2), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right)
↓
\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \cos \left(\left(u2 + u2\right) \cdot \pi\right)
Alternatives
| Alternative 1 |
|---|
| Error | 21.6 |
|---|
| Cost | 32968 |
|---|
\[\begin{array}{l}
t_0 := \cos \left(\left(2 \cdot \pi\right) \cdot u2\right)\\
t_1 := \mathsf{log1p}\left(-u1\right)\\
\mathbf{if}\;t_0 \leq 0.999994:\\
\;\;\;\;\sqrt{-\left(-u1\right)} \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{-\begin{array}{l}
\mathbf{if}\;t_1 \ne 0:\\
\;\;\;\;\frac{-1}{\frac{-1}{t_1}}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}}\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 21.6 |
|---|
| Cost | 32836 |
|---|
\[\begin{array}{l}
t_0 := \cos \left(\left(2 \cdot \pi\right) \cdot u2\right)\\
\mathbf{if}\;t_0 \leq 0.999994:\\
\;\;\;\;\sqrt{-\left(-u1\right)} \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)}\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 26.0 |
|---|
| Cost | 12992 |
|---|
\[\sqrt{-\mathsf{log1p}\left(-u1\right)}
\]
| Alternative 4 |
|---|
| Error | 30.6 |
|---|
| Cost | 7296 |
|---|
\[\sqrt{-\left(u1 \cdot \left(-0.3333333333333333 \cdot \left(u1 \cdot u1\right) + -0.5 \cdot u1\right) - u1\right)}
\]
| Alternative 5 |
|---|
| Error | 30.6 |
|---|
| Cost | 7104 |
|---|
\[\sqrt{u1 - \left(u1 \cdot u1\right) \cdot \left(-0.3333333333333333 \cdot u1 + -0.5\right)}
\]
| Alternative 6 |
|---|
| Error | 33.0 |
|---|
| Cost | 6912 |
|---|
\[\sqrt{-\left(-0.5 \cdot \left(u1 \cdot u1\right) - u1\right)}
\]
| Alternative 7 |
|---|
| Error | 39.5 |
|---|
| Cost | 6592 |
|---|
\[\sqrt{-\left(-u1\right)}
\]