?

Average Error: 13.8 → 0.3
Time: 12.9s
Precision: binary32
Cost: 19520

?

\[\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[3]{{\cos \left(u2 \cdot \left(2 \cdot \pi\right)\right)}^{3} \cdot {\left(-\mathsf{log1p}\left(-u1\right)\right)}^{1.5}} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (* (sqrt (- (log (- 1.0 u1)))) (cos (* (* 2.0 PI) u2))))
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (cbrt (* (pow (cos (* u2 (* 2.0 PI))) 3.0) (pow (- (log1p (- u1))) 1.5))))
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) {
	return cbrtf((powf(cosf((u2 * (2.0f * ((float) M_PI)))), 3.0f) * powf(-log1pf(-u1), 1.5f)));
}
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)
	return cbrt(Float32((cos(Float32(u2 * Float32(Float32(2.0) * Float32(pi)))) ^ Float32(3.0)) * (Float32(-log1p(Float32(-u1))) ^ Float32(1.5))))
end
\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right)
\sqrt[3]{{\cos \left(u2 \cdot \left(2 \cdot \pi\right)\right)}^{3} \cdot {\left(-\mathsf{log1p}\left(-u1\right)\right)}^{1.5}}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 13.8

    \[\sqrt{-\log \left(1 - u1\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  2. Applied egg-rr14.7

    \[\leadsto \sqrt{-\color{blue}{\left(\log \left(1 - {u1}^{3}\right) - \log \left(1 + \mathsf{fma}\left(u1, u1, u1\right)\right)\right)}} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  3. Simplified0.9

    \[\leadsto \sqrt{-\color{blue}{\left(\log \left(1 - {u1}^{3}\right) - \mathsf{log1p}\left(\mathsf{fma}\left(u1, u1, u1\right)\right)\right)}} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
    Proof

    [Start]14.7

    \[ \sqrt{-\left(\log \left(1 - {u1}^{3}\right) - \log \left(1 + \mathsf{fma}\left(u1, u1, u1\right)\right)\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]

    log1p-def [=>]0.9

    \[ \sqrt{-\left(\log \left(1 - {u1}^{3}\right) - \color{blue}{\mathsf{log1p}\left(\mathsf{fma}\left(u1, u1, u1\right)\right)}\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) \]
  4. Taylor expanded in u2 around inf 14.8

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

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

    [Start]14.8

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

    *-commutative [=>]14.8

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

    associate-*r* [=>]14.8

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

    unpow2 [=>]14.8

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

    +-commutative [=>]14.8

    \[ \cos \left(\left(2 \cdot u2\right) \cdot \pi\right) \cdot \sqrt{\log \left(u1 \cdot u1 + \color{blue}{\left(u1 + 1\right)}\right) - \log \left(1 - {u1}^{3}\right)} \]
  6. Applied egg-rr14.5

    \[\leadsto \color{blue}{\sqrt[3]{{\cos \left(2 \cdot \left(u2 \cdot \pi\right)\right)}^{3} \cdot {\log \left(\frac{1}{1 - u1}\right)}^{1.5}}} \]
  7. Simplified0.3

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

    [Start]14.5

    \[ \sqrt[3]{{\cos \left(2 \cdot \left(u2 \cdot \pi\right)\right)}^{3} \cdot {\log \left(\frac{1}{1 - u1}\right)}^{1.5}} \]

    associate-*r* [=>]14.5

    \[ \sqrt[3]{{\cos \color{blue}{\left(\left(2 \cdot u2\right) \cdot \pi\right)}}^{3} \cdot {\log \left(\frac{1}{1 - u1}\right)}^{1.5}} \]

    *-commutative [=>]14.5

    \[ \sqrt[3]{{\cos \left(\color{blue}{\left(u2 \cdot 2\right)} \cdot \pi\right)}^{3} \cdot {\log \left(\frac{1}{1 - u1}\right)}^{1.5}} \]

    associate-*l* [=>]14.5

    \[ \sqrt[3]{{\cos \color{blue}{\left(u2 \cdot \left(2 \cdot \pi\right)\right)}}^{3} \cdot {\log \left(\frac{1}{1 - u1}\right)}^{1.5}} \]

    log-rec [=>]13.8

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

    sub-neg [=>]13.8

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

    log1p-def [=>]0.3

    \[ \sqrt[3]{{\cos \left(u2 \cdot \left(2 \cdot \pi\right)\right)}^{3} \cdot {\left(-\color{blue}{\mathsf{log1p}\left(-u1\right)}\right)}^{1.5}} \]
  8. Final simplification0.3

    \[\leadsto \sqrt[3]{{\cos \left(u2 \cdot \left(2 \cdot \pi\right)\right)}^{3} \cdot {\left(-\mathsf{log1p}\left(-u1\right)\right)}^{1.5}} \]

Alternatives

Alternative 1
Error1.3
Cost13476
\[\begin{array}{l} t_0 := u2 \cdot \left(2 \cdot \pi\right)\\ \mathbf{if}\;t_0 \leq 0.0002800000074785203:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{u1 + \left(u1 \cdot u1\right) \cdot \left(0.5 + u1 \cdot 0.3333333333333333\right)} \cdot \cos t_0\\ \end{array} \]
Alternative 2
Error1.7
Cost13348
\[\begin{array}{l} t_0 := u2 \cdot \left(2 \cdot \pi\right)\\ \mathbf{if}\;t_0 \leq 0.000699999975040555:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)}\\ \mathbf{else}:\\ \;\;\;\;\cos t_0 \cdot \sqrt{u1 + u1 \cdot \left(u1 \cdot 0.5\right)}\\ \end{array} \]
Alternative 3
Error2.9
Cost13156
\[\begin{array}{l} \mathbf{if}\;u2 \cdot \left(2 \cdot \pi\right) \leq 0.008999999612569809:\\ \;\;\;\;\sqrt{-\mathsf{log1p}\left(-u1\right)}\\ \mathbf{else}:\\ \;\;\;\;\cos \left(2 \cdot \left(u2 \cdot \pi\right)\right) \cdot \sqrt{u1}\\ \end{array} \]
Alternative 4
Error0.3
Cost13056
\[\sqrt{-\mathsf{log1p}\left(-u1\right)} \cdot \cos \left(2 \cdot \left(u2 \cdot \pi\right)\right) \]
Alternative 5
Error6.2
Cost6496
\[\sqrt{-\mathsf{log1p}\left(-u1\right)} \]
Alternative 6
Error11.0
Cost3232
\[\sqrt{u1} \]

Error

Reproduce?

herbie shell --seed 2023045 
(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))))