?

Average Accuracy: 57.7% → 98.3%
Time: 15.6s
Precision: binary32
Cost: 16352

?

\[\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 \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
\[\sin \left(\pi \cdot \left(2 \cdot u2\right)\right) \cdot \sqrt{\mathsf{log1p}\left(u1\right) - \mathsf{log1p}\left(u1 \cdot \left(-u1\right)\right)} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (* (sqrt (- (log (- 1.0 u1)))) (sin (* (* 2.0 PI) u2))))
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (* (sin (* PI (* 2.0 u2))) (sqrt (- (log1p u1) (log1p (* u1 (- u1)))))))
float code(float cosTheta_i, float u1, float u2) {
	return sqrtf(-logf((1.0f - u1))) * sinf(((2.0f * ((float) M_PI)) * u2));
}
float code(float cosTheta_i, float u1, float u2) {
	return sinf((((float) M_PI) * (2.0f * u2))) * sqrtf((log1pf(u1) - log1pf((u1 * -u1))));
}
function code(cosTheta_i, u1, u2)
	return Float32(sqrt(Float32(-log(Float32(Float32(1.0) - u1)))) * sin(Float32(Float32(Float32(2.0) * Float32(pi)) * u2)))
end
function code(cosTheta_i, u1, u2)
	return Float32(sin(Float32(Float32(pi) * Float32(Float32(2.0) * u2))) * sqrt(Float32(log1p(u1) - log1p(Float32(u1 * Float32(-u1))))))
end
\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right)
\sin \left(\pi \cdot \left(2 \cdot u2\right)\right) \cdot \sqrt{\mathsf{log1p}\left(u1\right) - \mathsf{log1p}\left(u1 \cdot \left(-u1\right)\right)}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 57.7%

    \[\sqrt{-\log \left(1 - u1\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  2. Applied egg-rr90.4%

    \[\leadsto \sqrt{-\color{blue}{\left(\log \left(1 - u1 \cdot u1\right) + -1 \cdot \mathsf{log1p}\left(u1\right)\right)}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  3. Simplified98.3%

    \[\leadsto \sqrt{-\color{blue}{\left(\mathsf{log1p}\left(u1 \cdot \left(-u1\right)\right) - \mathsf{log1p}\left(u1\right)\right)}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    Proof

    [Start]90.4

    \[ \sqrt{-\left(\log \left(1 - u1 \cdot u1\right) + -1 \cdot \mathsf{log1p}\left(u1\right)\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]

    mul-1-neg [=>]90.4

    \[ \sqrt{-\left(\log \left(1 - u1 \cdot u1\right) + \color{blue}{\left(-\mathsf{log1p}\left(u1\right)\right)}\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]

    sub-neg [<=]90.4

    \[ \sqrt{-\color{blue}{\left(\log \left(1 - u1 \cdot u1\right) - \mathsf{log1p}\left(u1\right)\right)}} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]

    sub-neg [=>]90.4

    \[ \sqrt{-\left(\log \color{blue}{\left(1 + \left(-u1 \cdot u1\right)\right)} - \mathsf{log1p}\left(u1\right)\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]

    log1p-def [=>]98.3

    \[ \sqrt{-\left(\color{blue}{\mathsf{log1p}\left(-u1 \cdot u1\right)} - \mathsf{log1p}\left(u1\right)\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]

    distribute-rgt-neg-in [=>]98.3

    \[ \sqrt{-\left(\mathsf{log1p}\left(\color{blue}{u1 \cdot \left(-u1\right)}\right) - \mathsf{log1p}\left(u1\right)\right)} \cdot \sin \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  4. Taylor expanded in u2 around inf 54.7%

    \[\leadsto \color{blue}{\sin \left(2 \cdot \left(u2 \cdot \pi\right)\right) \cdot \sqrt{\log \left(1 + u1\right) - \log \left(1 + -1 \cdot {u1}^{2}\right)}} \]
  5. Simplified98.3%

    \[\leadsto \color{blue}{\sin \left(\pi \cdot \left(2 \cdot u2\right)\right) \cdot \sqrt{\mathsf{log1p}\left(u1\right) - \mathsf{log1p}\left(u1 \cdot \left(-u1\right)\right)}} \]
    Proof

    [Start]54.7

    \[ \sin \left(2 \cdot \left(u2 \cdot \pi\right)\right) \cdot \sqrt{\log \left(1 + u1\right) - \log \left(1 + -1 \cdot {u1}^{2}\right)} \]

    associate-*r* [=>]54.7

    \[ \sin \color{blue}{\left(\left(2 \cdot u2\right) \cdot \pi\right)} \cdot \sqrt{\log \left(1 + u1\right) - \log \left(1 + -1 \cdot {u1}^{2}\right)} \]

    *-commutative [=>]54.7

    \[ \sin \color{blue}{\left(\pi \cdot \left(2 \cdot u2\right)\right)} \cdot \sqrt{\log \left(1 + u1\right) - \log \left(1 + -1 \cdot {u1}^{2}\right)} \]

    log1p-def [=>]90.4

    \[ \sin \left(\pi \cdot \left(2 \cdot u2\right)\right) \cdot \sqrt{\color{blue}{\mathsf{log1p}\left(u1\right)} - \log \left(1 + -1 \cdot {u1}^{2}\right)} \]

    log1p-def [=>]98.3

    \[ \sin \left(\pi \cdot \left(2 \cdot u2\right)\right) \cdot \sqrt{\mathsf{log1p}\left(u1\right) - \color{blue}{\mathsf{log1p}\left(-1 \cdot {u1}^{2}\right)}} \]

    *-commutative [=>]98.3

    \[ \sin \left(\pi \cdot \left(2 \cdot u2\right)\right) \cdot \sqrt{\mathsf{log1p}\left(u1\right) - \mathsf{log1p}\left(\color{blue}{{u1}^{2} \cdot -1}\right)} \]

    unpow2 [=>]98.3

    \[ \sin \left(\pi \cdot \left(2 \cdot u2\right)\right) \cdot \sqrt{\mathsf{log1p}\left(u1\right) - \mathsf{log1p}\left(\color{blue}{\left(u1 \cdot u1\right)} \cdot -1\right)} \]

    associate-*l* [=>]98.3

    \[ \sin \left(\pi \cdot \left(2 \cdot u2\right)\right) \cdot \sqrt{\mathsf{log1p}\left(u1\right) - \mathsf{log1p}\left(\color{blue}{u1 \cdot \left(u1 \cdot -1\right)}\right)} \]

    *-commutative [<=]98.3

    \[ \sin \left(\pi \cdot \left(2 \cdot u2\right)\right) \cdot \sqrt{\mathsf{log1p}\left(u1\right) - \mathsf{log1p}\left(u1 \cdot \color{blue}{\left(-1 \cdot u1\right)}\right)} \]

    mul-1-neg [=>]98.3

    \[ \sin \left(\pi \cdot \left(2 \cdot u2\right)\right) \cdot \sqrt{\mathsf{log1p}\left(u1\right) - \mathsf{log1p}\left(u1 \cdot \color{blue}{\left(-u1\right)}\right)} \]
  6. Final simplification98.3%

    \[\leadsto \sin \left(\pi \cdot \left(2 \cdot u2\right)\right) \cdot \sqrt{\mathsf{log1p}\left(u1\right) - \mathsf{log1p}\left(u1 \cdot \left(-u1\right)\right)} \]

Alternatives

Alternative 1
Accuracy94.1%
Cost13412
\[\begin{array}{l} t_0 := u2 \cdot \left(\pi \cdot 2\right)\\ \mathbf{if}\;t_0 \leq 0.0035000001080334187:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(\pi \cdot \left(2 \cdot u2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin t_0 \cdot \sqrt{2 \cdot \left(u1 \cdot \left(0.5 + u1 \cdot 0.25\right)\right)}\\ \end{array} \]
Alternative 2
Accuracy94.1%
Cost13348
\[\begin{array}{l} t_0 := u2 \cdot \left(\pi \cdot 2\right)\\ \mathbf{if}\;t_0 \leq 0.0035000001080334187:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(\pi \cdot \left(2 \cdot u2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin t_0 \cdot \sqrt{u1 + u1 \cdot \left(u1 \cdot 0.5\right)}\\ \end{array} \]
Alternative 3
Accuracy90.4%
Cost13220
\[\begin{array}{l} \mathbf{if}\;u2 \cdot \left(\pi \cdot 2\right) \leq 0.01119999960064888:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \left(\pi \cdot \left(2 \cdot u2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sin \left(2 \cdot \left(\pi \cdot u2\right)\right) \cdot \sqrt{u1}\\ \end{array} \]
Alternative 4
Accuracy83.7%
Cost13156
\[\begin{array}{l} \mathbf{if}\;u2 \cdot \left(\pi \cdot 2\right) \leq 0.01119999960064888:\\ \;\;\;\;\left(\pi \cdot \left(2 \cdot u2\right)\right) \cdot \sqrt{u1 - \left(u1 \cdot u1\right) \cdot -0.5}\\ \mathbf{else}:\\ \;\;\;\;\sin \left(2 \cdot \left(\pi \cdot u2\right)\right) \cdot \sqrt{u1}\\ \end{array} \]
Alternative 5
Accuracy98.3%
Cost13056
\[\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \sin \left(2 \cdot \left(\pi \cdot u2\right)\right) \]
Alternative 6
Accuracy91.7%
Cost10112
\[\sqrt{u1 - \left(u1 \cdot u1\right) \cdot \left(-0.5 + u1 \cdot -0.3333333333333333\right)} \cdot \sin \left(u2 \cdot \left(\pi \cdot 2\right)\right) \]
Alternative 7
Accuracy74.2%
Cost6784
\[\left(\pi \cdot \left(2 \cdot u2\right)\right) \cdot \sqrt{u1 - \left(u1 \cdot u1\right) \cdot -0.5} \]
Alternative 8
Accuracy66.3%
Cost6592
\[2 \cdot \left(u2 \cdot \left(\pi \cdot \sqrt{u1}\right)\right) \]

Error

Reproduce?

herbie shell --seed 2023129 
(FPCore (cosTheta_i u1 u2)
  :name "Beckmann Sample, near normal, slope_y"
  :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)))) (sin (* (* 2.0 PI) u2))))