?

Average Accuracy: 60.6% → 98.2%
Time: 16.8s
Precision: binary32
Cost: 7072

?

\[\left(\left(\left(\left(0.0001 \leq alphax \land alphax \leq 1\right) \land \left(0.0001 \leq alphay \land alphay \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u0 \land u0 \leq 1\right)\right) \land \left(0 \leq cos2phi \land cos2phi \leq 1\right)\right) \land 0 \leq sin2phi\]
\[\frac{-\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
\[\left(alphay \cdot \left(\left(alphax \cdot alphax\right) \cdot alphay\right)\right) \cdot \frac{-\mathsf{log1p}\left(-u0\right)}{\mathsf{fma}\left(cos2phi, alphay \cdot alphay, alphax \cdot \left(alphax \cdot sin2phi\right)\right)} \]
(FPCore (alphax alphay u0 cos2phi sin2phi)
 :precision binary32
 (/
  (- (log (- 1.0 u0)))
  (+ (/ cos2phi (* alphax alphax)) (/ sin2phi (* alphay alphay)))))
(FPCore (alphax alphay u0 cos2phi sin2phi)
 :precision binary32
 (*
  (* alphay (* (* alphax alphax) alphay))
  (/
   (- (log1p (- u0)))
   (fma cos2phi (* alphay alphay) (* alphax (* alphax sin2phi))))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
	return -logf((1.0f - u0)) / ((cos2phi / (alphax * alphax)) + (sin2phi / (alphay * alphay)));
}
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
	return (alphay * ((alphax * alphax) * alphay)) * (-log1pf(-u0) / fmaf(cos2phi, (alphay * alphay), (alphax * (alphax * sin2phi))));
}
function code(alphax, alphay, u0, cos2phi, sin2phi)
	return Float32(Float32(-log(Float32(Float32(1.0) - u0))) / Float32(Float32(cos2phi / Float32(alphax * alphax)) + Float32(sin2phi / Float32(alphay * alphay))))
end
function code(alphax, alphay, u0, cos2phi, sin2phi)
	return Float32(Float32(alphay * Float32(Float32(alphax * alphax) * alphay)) * Float32(Float32(-log1p(Float32(-u0))) / fma(cos2phi, Float32(alphay * alphay), Float32(alphax * Float32(alphax * sin2phi)))))
end
\frac{-\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\left(alphay \cdot \left(\left(alphax \cdot alphax\right) \cdot alphay\right)\right) \cdot \frac{-\mathsf{log1p}\left(-u0\right)}{\mathsf{fma}\left(cos2phi, alphay \cdot alphay, alphax \cdot \left(alphax \cdot sin2phi\right)\right)}

Error?

Derivation?

  1. Initial program 60.6%

    \[\frac{-\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
  2. Applied egg-rr97.6%

    \[\leadsto \color{blue}{\frac{-1}{\mathsf{fma}\left(cos2phi, alphay \cdot alphay, alphax \cdot \left(alphax \cdot sin2phi\right)\right)} \cdot \left(\mathsf{log1p}\left(-u0\right) \cdot {\left(alphax \cdot alphay\right)}^{2}\right)} \]
  3. Simplified98.0%

    \[\leadsto \color{blue}{{\left(alphax \cdot alphay\right)}^{2} \cdot \frac{-\mathsf{log1p}\left(-u0\right)}{\mathsf{fma}\left(cos2phi, alphay \cdot alphay, alphax \cdot \left(alphax \cdot sin2phi\right)\right)}} \]
    Proof

    [Start]97.6

    \[ \frac{-1}{\mathsf{fma}\left(cos2phi, alphay \cdot alphay, alphax \cdot \left(alphax \cdot sin2phi\right)\right)} \cdot \left(\mathsf{log1p}\left(-u0\right) \cdot {\left(alphax \cdot alphay\right)}^{2}\right) \]

    associate-*r* [=>]97.6

    \[ \color{blue}{\left(\frac{-1}{\mathsf{fma}\left(cos2phi, alphay \cdot alphay, alphax \cdot \left(alphax \cdot sin2phi\right)\right)} \cdot \mathsf{log1p}\left(-u0\right)\right) \cdot {\left(alphax \cdot alphay\right)}^{2}} \]

    *-commutative [=>]97.6

    \[ \color{blue}{{\left(alphax \cdot alphay\right)}^{2} \cdot \left(\frac{-1}{\mathsf{fma}\left(cos2phi, alphay \cdot alphay, alphax \cdot \left(alphax \cdot sin2phi\right)\right)} \cdot \mathsf{log1p}\left(-u0\right)\right)} \]

    associate-*l/ [=>]98.0

    \[ {\left(alphax \cdot alphay\right)}^{2} \cdot \color{blue}{\frac{-1 \cdot \mathsf{log1p}\left(-u0\right)}{\mathsf{fma}\left(cos2phi, alphay \cdot alphay, alphax \cdot \left(alphax \cdot sin2phi\right)\right)}} \]

    mul-1-neg [=>]98.0

    \[ {\left(alphax \cdot alphay\right)}^{2} \cdot \frac{\color{blue}{-\mathsf{log1p}\left(-u0\right)}}{\mathsf{fma}\left(cos2phi, alphay \cdot alphay, alphax \cdot \left(alphax \cdot sin2phi\right)\right)} \]
  4. Applied egg-rr98.2%

    \[\leadsto \color{blue}{\left(\left(\left(alphax \cdot alphax\right) \cdot alphay\right) \cdot alphay\right)} \cdot \frac{-\mathsf{log1p}\left(-u0\right)}{\mathsf{fma}\left(cos2phi, alphay \cdot alphay, alphax \cdot \left(alphax \cdot sin2phi\right)\right)} \]
  5. Final simplification98.2%

    \[\leadsto \left(alphay \cdot \left(\left(alphax \cdot alphax\right) \cdot alphay\right)\right) \cdot \frac{-\mathsf{log1p}\left(-u0\right)}{\mathsf{fma}\left(cos2phi, alphay \cdot alphay, alphax \cdot \left(alphax \cdot sin2phi\right)\right)} \]

Alternatives

Alternative 1
Accuracy92.8%
Cost3684
\[\begin{array}{l} t_0 := \frac{sin2phi}{alphay \cdot alphay}\\ \mathbf{if}\;t_0 \leq 0.0020000000949949026:\\ \;\;\;\;\frac{u0 + \left(u0 \cdot u0\right) \cdot 0.5}{\frac{cos2phi}{alphax \cdot alphax} + t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(-u0\right) \cdot \left(alphay \cdot \left(-alphay\right)\right)}{sin2phi}\\ \end{array} \]
Alternative 2
Accuracy98.3%
Cost3680
\[\frac{-\mathsf{log1p}\left(-u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
Alternative 3
Accuracy91.8%
Cost3556
\[\begin{array}{l} \mathbf{if}\;u0 \leq 0.00570000009611249:\\ \;\;\;\;\frac{u0 + \left(u0 \cdot u0\right) \cdot 0.5}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(-u0\right) \cdot \left(alphay \cdot \left(-\frac{alphay}{sin2phi}\right)\right)\\ \end{array} \]
Alternative 4
Accuracy91.8%
Cost3556
\[\begin{array}{l} \mathbf{if}\;u0 \leq 0.00570000009611249:\\ \;\;\;\;\frac{u0 + \left(u0 \cdot u0\right) \cdot 0.5}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}\\ \mathbf{else}:\\ \;\;\;\;\frac{alphay}{-sin2phi} \cdot \left(alphay \cdot \mathsf{log1p}\left(-u0\right)\right)\\ \end{array} \]
Alternative 5
Accuracy90.2%
Cost1028
\[\begin{array}{l} \mathbf{if}\;sin2phi \leq 0.0004199999966658652:\\ \;\;\;\;\frac{u0 + \left(u0 \cdot u0\right) \cdot 0.5}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}\\ \mathbf{else}:\\ \;\;\;\;\frac{alphay \cdot \left(-alphay\right)}{\left(\left(sin2phi \cdot 0.5 - \frac{sin2phi}{u0}\right) + sin2phi \cdot \left(u0 \cdot 0.08333333333333333\right)\right) + u0 \cdot \left(u0 \cdot \left(sin2phi \cdot 0.08333333333333333 + sin2phi \cdot -0.041666666666666664\right)\right)}\\ \end{array} \]
Alternative 6
Accuracy84.6%
Cost708
\[\begin{array}{l} t_0 := \frac{sin2phi}{alphay \cdot alphay}\\ \mathbf{if}\;t_0 \leq 0.0020000000949949026:\\ \;\;\;\;\frac{u0}{\frac{cos2phi}{alphax \cdot alphax} + t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\frac{alphay \cdot alphay}{sin2phi}}{0.5 + \left(u0 \cdot 0.08333333333333333 + \frac{-1}{u0}\right)}\\ \end{array} \]
Alternative 7
Accuracy84.1%
Cost676
\[\begin{array}{l} t_0 := \frac{sin2phi}{alphay \cdot alphay}\\ \mathbf{if}\;t_0 \leq 0.0020000000949949026:\\ \;\;\;\;\frac{u0}{\frac{cos2phi}{alphax \cdot alphax} + t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{alphay \cdot alphay}{sin2phi \cdot \left(\frac{1}{u0} - \left(0.5 + u0 \cdot 0.08333333333333333\right)\right)}\\ \end{array} \]
Alternative 8
Accuracy89.9%
Cost676
\[\begin{array}{l} \mathbf{if}\;sin2phi \leq 0.0004199999966658652:\\ \;\;\;\;\frac{u0 + \left(u0 \cdot u0\right) \cdot 0.5}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\frac{alphay \cdot alphay}{sin2phi}}{0.5 + \left(u0 \cdot 0.08333333333333333 + \frac{-1}{u0}\right)}\\ \end{array} \]
Alternative 9
Accuracy82.2%
Cost612
\[\begin{array}{l} t_0 := \frac{sin2phi}{alphay \cdot alphay}\\ \mathbf{if}\;t_0 \leq 0.0020000000949949026:\\ \;\;\;\;\frac{u0}{\frac{cos2phi}{alphax \cdot alphax} + t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{alphay \cdot \left(-alphay\right)}{sin2phi \cdot 0.5 - \frac{sin2phi}{u0}}\\ \end{array} \]
Alternative 10
Accuracy75.1%
Cost452
\[\begin{array}{l} \mathbf{if}\;sin2phi \leq 4.00000018325482 \cdot 10^{-18}:\\ \;\;\;\;\left(alphax \cdot alphax\right) \cdot \frac{u0}{cos2phi}\\ \mathbf{else}:\\ \;\;\;\;\frac{alphay \cdot \left(-alphay\right)}{sin2phi \cdot \left(0.5 + \frac{-1}{u0}\right)}\\ \end{array} \]
Alternative 11
Accuracy75.1%
Cost452
\[\begin{array}{l} \mathbf{if}\;sin2phi \leq 4.00000018325482 \cdot 10^{-18}:\\ \;\;\;\;\left(alphax \cdot alphax\right) \cdot \frac{u0}{cos2phi}\\ \mathbf{else}:\\ \;\;\;\;\frac{alphay \cdot \left(-alphay\right)}{sin2phi \cdot 0.5 - \frac{sin2phi}{u0}}\\ \end{array} \]
Alternative 12
Accuracy67.4%
Cost292
\[\begin{array}{l} \mathbf{if}\;sin2phi \leq 4.00000018325482 \cdot 10^{-18}:\\ \;\;\;\;alphax \cdot \left(u0 \cdot \frac{alphax}{cos2phi}\right)\\ \mathbf{else}:\\ \;\;\;\;alphay \cdot \left(alphay \cdot \frac{u0}{sin2phi}\right)\\ \end{array} \]
Alternative 13
Accuracy67.4%
Cost292
\[\begin{array}{l} \mathbf{if}\;sin2phi \leq 4.00000018325482 \cdot 10^{-18}:\\ \;\;\;\;\left(alphax \cdot u0\right) \cdot \frac{alphax}{cos2phi}\\ \mathbf{else}:\\ \;\;\;\;alphay \cdot \left(alphay \cdot \frac{u0}{sin2phi}\right)\\ \end{array} \]
Alternative 14
Accuracy67.4%
Cost292
\[\begin{array}{l} \mathbf{if}\;sin2phi \leq 4.00000018325482 \cdot 10^{-18}:\\ \;\;\;\;\left(alphax \cdot alphax\right) \cdot \frac{u0}{cos2phi}\\ \mathbf{else}:\\ \;\;\;\;alphay \cdot \left(alphay \cdot \frac{u0}{sin2phi}\right)\\ \end{array} \]
Alternative 15
Accuracy23.3%
Cost224
\[alphax \cdot \left(u0 \cdot \frac{alphax}{cos2phi}\right) \]

Error

Reproduce?

herbie shell --seed 2023129 
(FPCore (alphax alphay u0 cos2phi sin2phi)
  :name "Beckmann Distribution sample, tan2theta, alphax != alphay, u1 <= 0.5"
  :precision binary32
  :pre (and (and (and (and (and (<= 0.0001 alphax) (<= alphax 1.0)) (and (<= 0.0001 alphay) (<= alphay 1.0))) (and (<= 2.328306437e-10 u0) (<= u0 1.0))) (and (<= 0.0 cos2phi) (<= cos2phi 1.0))) (<= 0.0 sin2phi))
  (/ (- (log (- 1.0 u0))) (+ (/ cos2phi (* alphax alphax)) (/ sin2phi (* alphay alphay)))))