| Alternative 1 | |
|---|---|
| Accuracy | 99.0% |
| Cost | 19872 |
\[\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(0.5 + \left(0.5 \cdot \cos \left(\pi \cdot \left(u2 + u2\right)\right) + \frac{\cos \left(u2 \cdot \left(\pi \cdot 2\right)\right) + -1}{2}\right)\right)
\]
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (sqrt (- (log (- 1.0 u1)))) (cos (* (* 2.0 PI) u2))))
(FPCore (cosTheta_i u1 u2)
:precision binary32
(let* ((t_0 (sin (* PI u2))))
(*
(sqrt (- (log1p (- u1))))
(+
0.5
(-
(* 0.5 (cos (* PI (+ u2 u2))))
(* (expm1 (log1p (pow t_0 1.5))) (sqrt t_0)))))))float code(float cosTheta_i, float u1, float u2) {
return sqrtf(-logf((1.0f - u1))) * cosf(((2.0f * ((float) M_PI)) * u2));
}
float code(float cosTheta_i, float u1, float u2) {
float t_0 = sinf((((float) M_PI) * u2));
return sqrtf(-log1pf(-u1)) * (0.5f + ((0.5f * cosf((((float) M_PI) * (u2 + u2)))) - (expm1f(log1pf(powf(t_0, 1.5f))) * sqrtf(t_0))));
}
function code(cosTheta_i, u1, u2) return Float32(sqrt(Float32(-log(Float32(Float32(1.0) - u1)))) * cos(Float32(Float32(Float32(2.0) * Float32(pi)) * u2))) end
function code(cosTheta_i, u1, u2) t_0 = sin(Float32(Float32(pi) * u2)) return Float32(sqrt(Float32(-log1p(Float32(-u1)))) * Float32(Float32(0.5) + Float32(Float32(Float32(0.5) * cos(Float32(Float32(pi) * Float32(u2 + u2)))) - Float32(expm1(log1p((t_0 ^ Float32(1.5)))) * sqrt(t_0))))) end
\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right)
\begin{array}{l}
t_0 := \sin \left(\pi \cdot u2\right)\\
\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(0.5 + \left(0.5 \cdot \cos \left(\pi \cdot \left(u2 + u2\right)\right) - \mathsf{expm1}\left(\mathsf{log1p}\left({t_0}^{1.5}\right)\right) \cdot \sqrt{t_0}\right)\right)
\end{array}
Results
Initial program 57.1%
Simplified99.0%
[Start]57.1 | \[ \sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right)
\] |
|---|---|
sub-neg [=>]57.1 | \[ \sqrt{-\log \color{blue}{\left(1 + \left(-u1\right)\right)}} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right)
\] |
log1p-def [=>]99.0 | \[ \sqrt{-\color{blue}{\mathsf{log1p}\left(-u1\right)}} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right)
\] |
associate-*l* [=>]99.0 | \[ \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \cos \color{blue}{\left(2 \cdot \left(\pi \cdot u2\right)\right)}
\] |
Applied egg-rr99.0%
[Start]99.0 | \[ \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \cos \left(2 \cdot \left(\pi \cdot u2\right)\right)
\] |
|---|---|
cos-2 [=>]98.8 | \[ \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \color{blue}{\left(\cos \left(\pi \cdot u2\right) \cdot \cos \left(\pi \cdot u2\right) - \sin \left(\pi \cdot u2\right) \cdot \sin \left(\pi \cdot u2\right)\right)}
\] |
sqr-cos-a [=>]98.9 | \[ \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(\color{blue}{\left(0.5 + 0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot u2\right)\right)\right)} - \sin \left(\pi \cdot u2\right) \cdot \sin \left(\pi \cdot u2\right)\right)
\] |
associate--l+ [=>]99.0 | \[ \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \color{blue}{\left(0.5 + \left(0.5 \cdot \cos \left(2 \cdot \left(\pi \cdot u2\right)\right) - \sin \left(\pi \cdot u2\right) \cdot \sin \left(\pi \cdot u2\right)\right)\right)}
\] |
count-2 [<=]99.0 | \[ \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(0.5 + \left(0.5 \cdot \cos \color{blue}{\left(\pi \cdot u2 + \pi \cdot u2\right)} - \sin \left(\pi \cdot u2\right) \cdot \sin \left(\pi \cdot u2\right)\right)\right)
\] |
distribute-lft-out [=>]99.0 | \[ \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(0.5 + \left(0.5 \cdot \cos \color{blue}{\left(\pi \cdot \left(u2 + u2\right)\right)} - \sin \left(\pi \cdot u2\right) \cdot \sin \left(\pi \cdot u2\right)\right)\right)
\] |
pow2 [=>]99.0 | \[ \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(0.5 + \left(0.5 \cdot \cos \left(\pi \cdot \left(u2 + u2\right)\right) - \color{blue}{{\sin \left(\pi \cdot u2\right)}^{2}}\right)\right)
\] |
Applied egg-rr99.0%
[Start]99.0 | \[ \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(0.5 + \left(0.5 \cdot \cos \left(\pi \cdot \left(u2 + u2\right)\right) - {\sin \left(\pi \cdot u2\right)}^{2}\right)\right)
\] |
|---|---|
unpow2 [=>]99.0 | \[ \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(0.5 + \left(0.5 \cdot \cos \left(\pi \cdot \left(u2 + u2\right)\right) - \color{blue}{\sin \left(\pi \cdot u2\right) \cdot \sin \left(\pi \cdot u2\right)}\right)\right)
\] |
add-sqr-sqrt [=>]99.0 | \[ \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(0.5 + \left(0.5 \cdot \cos \left(\pi \cdot \left(u2 + u2\right)\right) - \sin \left(\pi \cdot u2\right) \cdot \color{blue}{\left(\sqrt{\sin \left(\pi \cdot u2\right)} \cdot \sqrt{\sin \left(\pi \cdot u2\right)}\right)}\right)\right)
\] |
associate-*r* [=>]99.0 | \[ \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(0.5 + \left(0.5 \cdot \cos \left(\pi \cdot \left(u2 + u2\right)\right) - \color{blue}{\left(\sin \left(\pi \cdot u2\right) \cdot \sqrt{\sin \left(\pi \cdot u2\right)}\right) \cdot \sqrt{\sin \left(\pi \cdot u2\right)}}\right)\right)
\] |
Applied egg-rr99.0%
[Start]99.0 | \[ \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(0.5 + \left(0.5 \cdot \cos \left(\pi \cdot \left(u2 + u2\right)\right) - \left(\sin \left(\pi \cdot u2\right) \cdot \sqrt{\sin \left(\pi \cdot u2\right)}\right) \cdot \sqrt{\sin \left(\pi \cdot u2\right)}\right)\right)
\] |
|---|---|
expm1-log1p-u [=>]99.0 | \[ \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(0.5 + \left(0.5 \cdot \cos \left(\pi \cdot \left(u2 + u2\right)\right) - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sin \left(\pi \cdot u2\right) \cdot \sqrt{\sin \left(\pi \cdot u2\right)}\right)\right)} \cdot \sqrt{\sin \left(\pi \cdot u2\right)}\right)\right)
\] |
*-commutative [=>]99.0 | \[ \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(0.5 + \left(0.5 \cdot \cos \left(\pi \cdot \left(u2 + u2\right)\right) - \mathsf{expm1}\left(\mathsf{log1p}\left(\color{blue}{\sqrt{\sin \left(\pi \cdot u2\right)} \cdot \sin \left(\pi \cdot u2\right)}\right)\right) \cdot \sqrt{\sin \left(\pi \cdot u2\right)}\right)\right)
\] |
pow1/2 [=>]99.0 | \[ \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(0.5 + \left(0.5 \cdot \cos \left(\pi \cdot \left(u2 + u2\right)\right) - \mathsf{expm1}\left(\mathsf{log1p}\left(\color{blue}{{\sin \left(\pi \cdot u2\right)}^{0.5}} \cdot \sin \left(\pi \cdot u2\right)\right)\right) \cdot \sqrt{\sin \left(\pi \cdot u2\right)}\right)\right)
\] |
pow-plus [=>]99.0 | \[ \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(0.5 + \left(0.5 \cdot \cos \left(\pi \cdot \left(u2 + u2\right)\right) - \mathsf{expm1}\left(\mathsf{log1p}\left(\color{blue}{{\sin \left(\pi \cdot u2\right)}^{\left(0.5 + 1\right)}}\right)\right) \cdot \sqrt{\sin \left(\pi \cdot u2\right)}\right)\right)
\] |
metadata-eval [=>]99.0 | \[ \sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(0.5 + \left(0.5 \cdot \cos \left(\pi \cdot \left(u2 + u2\right)\right) - \mathsf{expm1}\left(\mathsf{log1p}\left({\sin \left(\pi \cdot u2\right)}^{\color{blue}{1.5}}\right)\right) \cdot \sqrt{\sin \left(\pi \cdot u2\right)}\right)\right)
\] |
Final simplification99.0%
| Alternative 1 | |
|---|---|
| Accuracy | 99.0% |
| Cost | 19872 |
| Alternative 2 | |
|---|---|
| Accuracy | 96.3% |
| Cost | 13476 |
| Alternative 3 | |
|---|---|
| Accuracy | 94.7% |
| Cost | 13348 |
| Alternative 4 | |
|---|---|
| Accuracy | 90.8% |
| Cost | 13156 |
| Alternative 5 | |
|---|---|
| Accuracy | 99.0% |
| Cost | 13056 |
| Alternative 6 | |
|---|---|
| Accuracy | 79.8% |
| Cost | 6496 |
| Alternative 7 | |
|---|---|
| Accuracy | 76.5% |
| Cost | 3680 |
| Alternative 8 | |
|---|---|
| Accuracy | 75.3% |
| Cost | 3552 |
| Alternative 9 | |
|---|---|
| Accuracy | 72.8% |
| Cost | 3424 |
| Alternative 10 | |
|---|---|
| Accuracy | 64.8% |
| Cost | 3232 |
herbie shell --seed 2023138
(FPCore (cosTheta_i u1 u2)
:name "Beckmann Sample, near normal, slope_x"
:precision binary32
:pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0)) (and (<= 2.328306437e-10 u1) (<= u1 1.0))) (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
(* (sqrt (- (log (- 1.0 u1)))) (cos (* (* 2.0 PI) u2))))