?

Average Error: 12.6 → 0.5
Time: 18.1s
Precision: binary32
Cost: 3776

?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 12.6

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

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

    [Start]12.6

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

    sub-neg [=>]12.6

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

    log1p-def [=>]0.5

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

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

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

    [Start]0.5

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

    associate-/r* [=>]0.5

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

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

Alternatives

Alternative 1
Error0.5
Cost3744
\[\frac{-\mathsf{log1p}\left(-u0\right)}{\frac{sin2phi}{alphay \cdot alphay} + \frac{1}{alphax} \cdot \frac{cos2phi}{alphax}} \]
Alternative 2
Error4.1
Cost3684
\[\begin{array}{l} t_0 := \frac{sin2phi}{alphay \cdot alphay}\\ \mathbf{if}\;t_0 \leq 4.999999873689376 \cdot 10^{-5}:\\ \;\;\;\;\frac{u0}{cos2phi \cdot \frac{\frac{-1}{alphax}}{-alphax} + t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\mathsf{log1p}\left(-u0\right)}{t_0}\\ \end{array} \]
Alternative 3
Error4.0
Cost3684
\[\begin{array}{l} t_0 := \frac{sin2phi}{alphay \cdot alphay}\\ \mathbf{if}\;t_0 \leq 4.999999873689376 \cdot 10^{-5}:\\ \;\;\;\;\frac{u0}{t_0 - cos2phi \cdot \frac{\frac{1}{alphax}}{-alphax}}\\ \mathbf{else}:\\ \;\;\;\;\frac{alphay \cdot \left(\mathsf{log1p}\left(-u0\right) \cdot \left(-alphay\right)\right)}{sin2phi}\\ \end{array} \]
Alternative 4
Error0.5
Cost3680
\[\frac{-\mathsf{log1p}\left(-u0\right)}{\frac{sin2phi}{alphay \cdot alphay} + \frac{cos2phi}{alphax \cdot alphax}} \]
Alternative 5
Error0.5
Cost3680
\[\frac{-\mathsf{log1p}\left(-u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{\frac{sin2phi}{alphay}}{alphay}} \]
Alternative 6
Error0.5
Cost3680
\[\frac{-\mathsf{log1p}\left(-u0\right)}{\frac{sin2phi}{alphay \cdot alphay} + \frac{\frac{cos2phi}{alphax}}{alphax}} \]
Alternative 7
Error7.7
Cost736
\[\frac{u0}{sin2phi \cdot \left(-alphax \cdot alphax\right) - cos2phi \cdot \left(alphay \cdot alphay\right)} \cdot \left(\left(alphax \cdot alphax\right) \cdot \left(alphay \cdot \left(-alphay\right)\right)\right) \]
Alternative 8
Error7.6
Cost608
\[\frac{u0}{alphax \cdot sin2phi + \left(alphay \cdot alphay\right) \cdot \frac{cos2phi}{alphax}} \cdot \left(alphax \cdot \left(alphay \cdot alphay\right)\right) \]
Alternative 9
Error10.8
Cost548
\[\begin{array}{l} \mathbf{if}\;\frac{sin2phi}{alphay \cdot alphay} \leq 5.999999802552836 \cdot 10^{-11}:\\ \;\;\;\;\left(alphax \cdot alphay\right) \cdot \frac{u0 \cdot alphax}{cos2phi \cdot alphay}\\ \mathbf{else}:\\ \;\;\;\;\frac{u0 \cdot \left(alphay \cdot alphay\right)}{sin2phi}\\ \end{array} \]
Alternative 10
Error7.6
Cost544
\[\left(alphax \cdot alphay\right) \cdot \frac{u0}{sin2phi \cdot \frac{alphax}{alphay} + alphay \cdot \frac{cos2phi}{alphax}} \]
Alternative 11
Error7.6
Cost544
\[\frac{u0}{\frac{alphax \cdot sin2phi}{alphay} + \frac{cos2phi \cdot alphay}{alphax}} \cdot \left(alphax \cdot alphay\right) \]
Alternative 12
Error7.7
Cost480
\[\frac{u0}{\frac{sin2phi}{alphay \cdot alphay} + \frac{1}{alphax} \cdot \frac{cos2phi}{alphax}} \]
Alternative 13
Error10.8
Cost420
\[\begin{array}{l} \mathbf{if}\;\frac{sin2phi}{alphay \cdot alphay} \leq 5.999999802552836 \cdot 10^{-11}:\\ \;\;\;\;\frac{alphax}{\frac{\frac{cos2phi}{alphax}}{u0}}\\ \mathbf{else}:\\ \;\;\;\;\left(alphay \cdot alphay\right) \cdot \frac{u0}{sin2phi}\\ \end{array} \]
Alternative 14
Error10.8
Cost420
\[\begin{array}{l} \mathbf{if}\;\frac{sin2phi}{alphay \cdot alphay} \leq 5.999999802552836 \cdot 10^{-11}:\\ \;\;\;\;\frac{alphax}{\frac{\frac{cos2phi}{alphax}}{u0}}\\ \mathbf{else}:\\ \;\;\;\;\frac{u0 \cdot \left(alphay \cdot alphay\right)}{sin2phi}\\ \end{array} \]
Alternative 15
Error7.7
Cost416
\[\frac{u0}{\frac{sin2phi}{alphay \cdot alphay} + \frac{cos2phi}{alphax \cdot alphax}} \]
Alternative 16
Error10.6
Cost292
\[\begin{array}{l} \mathbf{if}\;sin2phi \leq 9.999999682655225 \cdot 10^{-20}:\\ \;\;\;\;\left(alphax \cdot alphax\right) \cdot \frac{u0}{cos2phi}\\ \mathbf{else}:\\ \;\;\;\;\left(alphay \cdot alphay\right) \cdot \frac{u0}{sin2phi}\\ \end{array} \]
Alternative 17
Error24.3
Cost224
\[alphax \cdot \frac{alphax}{\frac{cos2phi}{u0}} \]
Alternative 18
Error24.3
Cost224
\[u0 \cdot \left(alphax \cdot \frac{alphax}{cos2phi}\right) \]
Alternative 19
Error24.3
Cost224
\[u0 \cdot \frac{alphax}{\frac{cos2phi}{alphax}} \]
Alternative 20
Error24.3
Cost224
\[\left(alphax \cdot alphax\right) \cdot \frac{u0}{cos2phi} \]

Error

Reproduce?

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