?

Average Error: 39.34% → 1.76%
Time: 16.9s
Precision: binary32
Cost: 3744

?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 39.34

    \[\frac{-\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
  2. Simplified1.64

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

    [Start]39.34

    \[ \frac{-\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]

    sub-neg [=>]39.34

    \[ \frac{-\log \color{blue}{\left(1 + \left(-u0\right)\right)}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]

    log1p-def [=>]1.64

    \[ \frac{-\color{blue}{\mathsf{log1p}\left(-u0\right)}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
  3. Applied egg-rr1.76

    \[\leadsto \frac{-\mathsf{log1p}\left(-u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \color{blue}{\frac{1}{alphay \cdot \left(-alphay\right)} \cdot \left(-sin2phi\right)}} \]
  4. Taylor expanded in alphay around 0 1.76

    \[\leadsto \frac{-\mathsf{log1p}\left(-u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \color{blue}{\frac{-1}{{alphay}^{2}}} \cdot \left(-sin2phi\right)} \]
  5. Simplified1.76

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

    [Start]1.76

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

    unpow2 [=>]1.76

    \[ \frac{-\mathsf{log1p}\left(-u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{-1}{\color{blue}{alphay \cdot alphay}} \cdot \left(-sin2phi\right)} \]
  6. Applied egg-rr1.78

    \[\leadsto \frac{-\mathsf{log1p}\left(-u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \color{blue}{\frac{1}{\frac{alphay \cdot alphay}{sin2phi}}}} \]
  7. Simplified1.76

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

    [Start]1.78

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

    associate-/r/ [=>]1.76

    \[ \frac{-\mathsf{log1p}\left(-u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \color{blue}{\frac{1}{alphay \cdot alphay} \cdot sin2phi}} \]
  8. Final simplification1.76

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

Alternatives

Alternative 1
Error7.29%
Cost3684
\[\begin{array}{l} t_0 := \frac{sin2phi}{alphay \cdot alphay}\\ \mathbf{if}\;t_0 \leq 300000:\\ \;\;\;\;\frac{u0 + \left(u0 \cdot u0\right) \cdot 0.5}{\frac{cos2phi}{alphax \cdot alphax} + t_0}\\ \mathbf{else}:\\ \;\;\;\;alphay \cdot \left(\frac{\mathsf{log1p}\left(-u0\right)}{sin2phi} \cdot \left(-alphay\right)\right)\\ \end{array} \]
Alternative 2
Error7.28%
Cost3684
\[\begin{array}{l} t_0 := \frac{sin2phi}{alphay \cdot alphay}\\ \mathbf{if}\;t_0 \leq 300000:\\ \;\;\;\;\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
Error7.28%
Cost3684
\[\begin{array}{l} t_0 := \frac{sin2phi}{alphay \cdot alphay}\\ \mathbf{if}\;t_0 \leq 400000:\\ \;\;\;\;\frac{u0 + \left(u0 \cdot u0\right) \cdot 0.5}{\frac{cos2phi}{alphax \cdot alphax} + t_0}\\ \mathbf{else}:\\ \;\;\;\;\left(alphay \cdot alphay\right) \cdot \frac{\mathsf{log1p}\left(-u0\right)}{-sin2phi}\\ \end{array} \]
Alternative 4
Error1.64%
Cost3680
\[\frac{-\mathsf{log1p}\left(-u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
Alternative 5
Error16.49%
Cost804
\[\begin{array}{l} \mathbf{if}\;\frac{sin2phi}{alphay \cdot alphay} \leq 50:\\ \;\;\;\;\frac{u0}{\frac{\left(alphay \cdot alphay\right) \cdot \frac{cos2phi}{alphax} + alphax \cdot sin2phi}{alphax \cdot \left(alphay \cdot alphay\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
Error16.44%
Cost772
\[\begin{array}{l} \mathbf{if}\;\frac{sin2phi}{alphay \cdot alphay} \leq 50:\\ \;\;\;\;\frac{u0}{\frac{\frac{cos2phi}{alphax}}{alphax} + \frac{\frac{sin2phi}{alphay}}{alphay}}\\ \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 7
Error16.45%
Cost708
\[\begin{array}{l} \mathbf{if}\;\frac{sin2phi}{alphay \cdot alphay} \leq 50:\\ \;\;\;\;\frac{u0}{\frac{\frac{cos2phi}{alphax}}{alphax} + \frac{\frac{sin2phi}{alphay}}{alphay}}\\ \mathbf{else}:\\ \;\;\;\;\frac{alphay \cdot \left(-alphay\right)}{sin2phi \cdot \left(0.5 + \left(u0 \cdot 0.08333333333333333 + \frac{-1}{u0}\right)\right)}\\ \end{array} \]
Alternative 8
Error16.42%
Cost676
\[\begin{array}{l} \mathbf{if}\;sin2phi \leq 4.999999873689376 \cdot 10^{-5}:\\ \;\;\;\;\frac{u0}{\frac{cos2phi \cdot \frac{alphay}{\frac{alphax}{alphay}} + alphax \cdot sin2phi}{alphax \cdot \left(alphay \cdot alphay\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 9
Error18.22%
Cost612
\[\begin{array}{l} t_0 := \frac{sin2phi}{alphay \cdot alphay}\\ \mathbf{if}\;t_0 \leq 50:\\ \;\;\;\;\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
Error18.22%
Cost612
\[\begin{array}{l} \mathbf{if}\;\frac{sin2phi}{alphay \cdot alphay} \leq 50:\\ \;\;\;\;\frac{u0}{\frac{\frac{cos2phi}{alphax}}{alphax} + \frac{\frac{sin2phi}{alphay}}{alphay}}\\ \mathbf{else}:\\ \;\;\;\;\frac{alphay \cdot \left(-alphay\right)}{sin2phi \cdot 0.5 - \frac{sin2phi}{u0}}\\ \end{array} \]
Alternative 11
Error12.63%
Cost608
\[\frac{u0 + \left(u0 \cdot u0\right) \cdot 0.5}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
Alternative 12
Error25.09%
Cost580
\[\begin{array}{l} \mathbf{if}\;\frac{sin2phi}{alphay \cdot alphay} \leq 9.9999998245167 \cdot 10^{-15}:\\ \;\;\;\;\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 13
Error25.06%
Cost580
\[\begin{array}{l} \mathbf{if}\;\frac{sin2phi}{alphay \cdot alphay} \leq 9.9999998245167 \cdot 10^{-15}:\\ \;\;\;\;\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 14
Error32.71%
Cost420
\[\begin{array}{l} \mathbf{if}\;\frac{sin2phi}{alphay \cdot alphay} \leq 9.9999998245167 \cdot 10^{-15}:\\ \;\;\;\;\left(alphax \cdot alphax\right) \cdot \frac{u0}{cos2phi}\\ \mathbf{else}:\\ \;\;\;\;\left(alphay \cdot alphay\right) \cdot \frac{u0}{sin2phi}\\ \end{array} \]
Alternative 15
Error32.79%
Cost420
\[\begin{array}{l} \mathbf{if}\;\frac{sin2phi}{alphay \cdot alphay} \leq 9.9999998245167 \cdot 10^{-15}:\\ \;\;\;\;\left(alphax \cdot alphax\right) \cdot \frac{u0}{cos2phi}\\ \mathbf{else}:\\ \;\;\;\;\frac{u0 \cdot alphay}{\frac{sin2phi}{alphay}}\\ \end{array} \]
Alternative 16
Error32.81%
Cost292
\[\begin{array}{l} \mathbf{if}\;sin2phi \leq 4.999999918875795 \cdot 10^{-18}:\\ \;\;\;\;u0 \cdot \left(alphax \cdot \frac{alphax}{cos2phi}\right)\\ \mathbf{else}:\\ \;\;\;\;alphay \cdot \left(u0 \cdot \frac{alphay}{sin2phi}\right)\\ \end{array} \]
Alternative 17
Error32.81%
Cost292
\[\begin{array}{l} \mathbf{if}\;sin2phi \leq 4.999999918875795 \cdot 10^{-18}:\\ \;\;\;\;u0 \cdot \left(alphax \cdot \frac{alphax}{cos2phi}\right)\\ \mathbf{else}:\\ \;\;\;\;u0 \cdot \left(alphay \cdot \frac{alphay}{sin2phi}\right)\\ \end{array} \]
Alternative 18
Error32.82%
Cost292
\[\begin{array}{l} \mathbf{if}\;sin2phi \leq 4.999999918875795 \cdot 10^{-18}:\\ \;\;\;\;\left(alphax \cdot alphax\right) \cdot \frac{u0}{cos2phi}\\ \mathbf{else}:\\ \;\;\;\;u0 \cdot \left(alphay \cdot \frac{alphay}{sin2phi}\right)\\ \end{array} \]
Alternative 19
Error41.18%
Cost224
\[alphay \cdot \left(u0 \cdot \frac{alphay}{sin2phi}\right) \]

Error

Reproduce?

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