?

Average Error: 12.6 → 0.6
Time: 14.3s
Precision: binary32
Cost: 10016

?

\[\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}} \]
\[\frac{-1}{\mathsf{fma}\left(sin2phi, {alphay}^{-2}, \frac{cos2phi}{alphax \cdot alphax}\right)} \cdot \mathsf{log1p}\left(-u0\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
 (*
  (/ -1.0 (fma sin2phi (pow alphay -2.0) (/ cos2phi (* alphax alphax))))
  (log1p (- u0))))
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 (-1.0f / fmaf(sin2phi, powf(alphay, -2.0f), (cos2phi / (alphax * alphax)))) * log1pf(-u0);
}
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(Float32(-1.0) / fma(sin2phi, (alphay ^ Float32(-2.0)), Float32(cos2phi / Float32(alphax * alphax)))) * log1p(Float32(-u0)))
end
\frac{-\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\frac{-1}{\mathsf{fma}\left(sin2phi, {alphay}^{-2}, \frac{cos2phi}{alphax \cdot alphax}\right)} \cdot \mathsf{log1p}\left(-u0\right)

Error?

Derivation?

  1. Initial program 12.6

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

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

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

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

    [Start]0.6

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

    unpow2 [=>]0.6

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

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

Alternatives

Alternative 1
Error2.4
Cost3684
\[\begin{array}{l} t_0 := \frac{sin2phi}{alphay \cdot alphay}\\ \mathbf{if}\;t_0 \leq 0.014999999664723873:\\ \;\;\;\;\frac{u0 + \left(u0 \cdot u0\right) \cdot 0.5}{\frac{cos2phi}{alphax \cdot alphax} + t_0}\\ \mathbf{else}:\\ \;\;\;\;alphay \cdot \left(\mathsf{log1p}\left(-u0\right) \cdot \frac{alphay}{-sin2phi}\right)\\ \end{array} \]
Alternative 2
Error2.4
Cost3684
\[\begin{array}{l} t_0 := \frac{sin2phi}{alphay \cdot alphay}\\ \mathbf{if}\;t_0 \leq 0.014999999664723873:\\ \;\;\;\;\frac{u0 + \left(u0 \cdot u0\right) \cdot 0.5}{\frac{cos2phi}{alphax \cdot alphax} + t_0}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(-u0\right) \cdot \left(\frac{alphay}{sin2phi} \cdot \left(-alphay\right)\right)\\ \end{array} \]
Alternative 3
Error0.5
Cost3680
\[\frac{-\mathsf{log1p}\left(-u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
Alternative 4
Error5.3
Cost804
\[\begin{array}{l} \mathbf{if}\;\frac{sin2phi}{alphay \cdot alphay} \leq 0.014999999664723873:\\ \;\;\;\;\frac{u0}{\left(alphax \cdot alphax\right) \cdot \frac{sin2phi}{alphay} + alphay \cdot cos2phi} \cdot \left(alphay \cdot \left(alphax \cdot alphax\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{alphay \cdot \left(-alphay\right)}{\left(sin2phi \cdot 0.5 - \frac{sin2phi}{u0}\right) - sin2phi \cdot \left(u0 \cdot -0.08333333333333333\right)}\\ \end{array} \]
Alternative 5
Error5.2
Cost772
\[\begin{array}{l} t_0 := \frac{sin2phi}{alphay \cdot alphay}\\ \mathbf{if}\;t_0 \leq 0.014999999664723873:\\ \;\;\;\;\frac{u0}{t_0 + cos2phi \cdot \frac{-1}{alphax \cdot \left(-alphax\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{alphay \cdot \left(-alphay\right)}{\left(sin2phi \cdot 0.5 - \frac{sin2phi}{u0}\right) - sin2phi \cdot \left(u0 \cdot -0.08333333333333333\right)}\\ \end{array} \]
Alternative 6
Error5.9
Cost708
\[\begin{array}{l} t_0 := \frac{sin2phi}{alphay \cdot alphay}\\ \mathbf{if}\;t_0 \leq 0.014999999664723873:\\ \;\;\;\;\frac{u0}{t_0 + cos2phi \cdot \frac{-1}{alphax \cdot \left(-alphax\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{alphay \cdot \left(-alphay\right)}{sin2phi \cdot 0.5 - \frac{sin2phi}{u0}}\\ \end{array} \]
Alternative 7
Error5.8
Cost612
\[\begin{array}{l} t_0 := \frac{sin2phi}{alphay \cdot alphay}\\ \mathbf{if}\;t_0 \leq 0.014999999664723873:\\ \;\;\;\;\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 8
Error4.1
Cost608
\[\frac{u0 + \left(u0 \cdot u0\right) \cdot 0.5}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
Alternative 9
Error8.1
Cost452
\[\begin{array}{l} \mathbf{if}\;sin2phi \leq 3.199999999423868 \cdot 10^{-22}:\\ \;\;\;\;alphax \cdot \frac{alphax \cdot u0}{cos2phi}\\ \mathbf{else}:\\ \;\;\;\;\frac{alphay \cdot \left(-alphay\right)}{sin2phi \cdot 0.5 - \frac{sin2phi}{u0}}\\ \end{array} \]
Alternative 10
Error10.6
Cost292
\[\begin{array}{l} \mathbf{if}\;sin2phi \leq 3.199999999423868 \cdot 10^{-22}:\\ \;\;\;\;u0 \cdot \left(alphax \cdot \frac{alphax}{cos2phi}\right)\\ \mathbf{else}:\\ \;\;\;\;u0 \cdot \left(alphay \cdot \frac{alphay}{sin2phi}\right)\\ \end{array} \]
Alternative 11
Error10.6
Cost292
\[\begin{array}{l} \mathbf{if}\;sin2phi \leq 3.199999999423868 \cdot 10^{-22}:\\ \;\;\;\;u0 \cdot \left(alphax \cdot \frac{alphax}{cos2phi}\right)\\ \mathbf{else}:\\ \;\;\;\;alphay \cdot \left(u0 \cdot \frac{alphay}{sin2phi}\right)\\ \end{array} \]
Alternative 12
Error10.6
Cost292
\[\begin{array}{l} \mathbf{if}\;sin2phi \leq 3.199999999423868 \cdot 10^{-22}:\\ \;\;\;\;u0 \cdot \frac{alphax}{\frac{cos2phi}{alphax}}\\ \mathbf{else}:\\ \;\;\;\;alphay \cdot \left(u0 \cdot \frac{alphay}{sin2phi}\right)\\ \end{array} \]
Alternative 13
Error10.7
Cost292
\[\begin{array}{l} \mathbf{if}\;sin2phi \leq 3.199999999423868 \cdot 10^{-22}:\\ \;\;\;\;u0 \cdot \frac{alphax \cdot alphax}{cos2phi}\\ \mathbf{else}:\\ \;\;\;\;alphay \cdot \left(u0 \cdot \frac{alphay}{sin2phi}\right)\\ \end{array} \]
Alternative 14
Error10.7
Cost292
\[\begin{array}{l} \mathbf{if}\;sin2phi \leq 3.199999999423868 \cdot 10^{-22}:\\ \;\;\;\;alphax \cdot \frac{alphax \cdot u0}{cos2phi}\\ \mathbf{else}:\\ \;\;\;\;alphay \cdot \left(u0 \cdot \frac{alphay}{sin2phi}\right)\\ \end{array} \]
Alternative 15
Error13.0
Cost224
\[u0 \cdot \left(alphay \cdot \frac{alphay}{sin2phi}\right) \]

Error

Reproduce?

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