| Alternative 1 | |
|---|---|
| Error | 0.6 |
| Cost | 10628 |
(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
(let* ((t_0 (/ sin2phi (* alphay alphay))))
(if (<= (- 1.0 u0) 0.9649999737739563)
(/
(- (log (- 1.0 u0)))
(+
(/
(* 2.0 (/ (* cos2phi (/ 4.0 (* alphax alphax))) alphax))
(/ 8.0 alphax))
t_0))
(/
(-
u0
(+
(* (pow u0 4.0) -0.25)
(- (* (pow u0 2.0) -0.5) (* 0.3333333333333333 (pow u0 3.0)))))
(+ (/ cos2phi (* alphax alphax)) t_0)))))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) {
float t_0 = sin2phi / (alphay * alphay);
float tmp;
if ((1.0f - u0) <= 0.9649999737739563f) {
tmp = -logf((1.0f - u0)) / (((2.0f * ((cos2phi * (4.0f / (alphax * alphax))) / alphax)) / (8.0f / alphax)) + t_0);
} else {
tmp = (u0 - ((powf(u0, 4.0f) * -0.25f) + ((powf(u0, 2.0f) * -0.5f) - (0.3333333333333333f * powf(u0, 3.0f))))) / ((cos2phi / (alphax * alphax)) + t_0);
}
return tmp;
}
real(4) function code(alphax, alphay, u0, cos2phi, sin2phi)
real(4), intent (in) :: alphax
real(4), intent (in) :: alphay
real(4), intent (in) :: u0
real(4), intent (in) :: cos2phi
real(4), intent (in) :: sin2phi
code = -log((1.0e0 - u0)) / ((cos2phi / (alphax * alphax)) + (sin2phi / (alphay * alphay)))
end function
real(4) function code(alphax, alphay, u0, cos2phi, sin2phi)
real(4), intent (in) :: alphax
real(4), intent (in) :: alphay
real(4), intent (in) :: u0
real(4), intent (in) :: cos2phi
real(4), intent (in) :: sin2phi
real(4) :: t_0
real(4) :: tmp
t_0 = sin2phi / (alphay * alphay)
if ((1.0e0 - u0) <= 0.9649999737739563e0) then
tmp = -log((1.0e0 - u0)) / (((2.0e0 * ((cos2phi * (4.0e0 / (alphax * alphax))) / alphax)) / (8.0e0 / alphax)) + t_0)
else
tmp = (u0 - (((u0 ** 4.0e0) * (-0.25e0)) + (((u0 ** 2.0e0) * (-0.5e0)) - (0.3333333333333333e0 * (u0 ** 3.0e0))))) / ((cos2phi / (alphax * alphax)) + t_0)
end if
code = tmp
end function
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) t_0 = Float32(sin2phi / Float32(alphay * alphay)) tmp = Float32(0.0) if (Float32(Float32(1.0) - u0) <= Float32(0.9649999737739563)) tmp = Float32(Float32(-log(Float32(Float32(1.0) - u0))) / Float32(Float32(Float32(Float32(2.0) * Float32(Float32(cos2phi * Float32(Float32(4.0) / Float32(alphax * alphax))) / alphax)) / Float32(Float32(8.0) / alphax)) + t_0)); else tmp = Float32(Float32(u0 - Float32(Float32((u0 ^ Float32(4.0)) * Float32(-0.25)) + Float32(Float32((u0 ^ Float32(2.0)) * Float32(-0.5)) - Float32(Float32(0.3333333333333333) * (u0 ^ Float32(3.0)))))) / Float32(Float32(cos2phi / Float32(alphax * alphax)) + t_0)); end return tmp end
function tmp = code(alphax, alphay, u0, cos2phi, sin2phi) tmp = -log((single(1.0) - u0)) / ((cos2phi / (alphax * alphax)) + (sin2phi / (alphay * alphay))); end
function tmp_2 = code(alphax, alphay, u0, cos2phi, sin2phi) t_0 = sin2phi / (alphay * alphay); tmp = single(0.0); if ((single(1.0) - u0) <= single(0.9649999737739563)) tmp = -log((single(1.0) - u0)) / (((single(2.0) * ((cos2phi * (single(4.0) / (alphax * alphax))) / alphax)) / (single(8.0) / alphax)) + t_0); else tmp = (u0 - (((u0 ^ single(4.0)) * single(-0.25)) + (((u0 ^ single(2.0)) * single(-0.5)) - (single(0.3333333333333333) * (u0 ^ single(3.0)))))) / ((cos2phi / (alphax * alphax)) + t_0); end tmp_2 = tmp; end
\frac{-\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\begin{array}{l}
t_0 := \frac{sin2phi}{alphay \cdot alphay}\\
\mathbf{if}\;1 - u0 \leq 0.9649999737739563:\\
\;\;\;\;\frac{-\log \left(1 - u0\right)}{\frac{2 \cdot \frac{cos2phi \cdot \frac{4}{alphax \cdot alphax}}{alphax}}{\frac{8}{alphax}} + t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{u0 - \left({u0}^{4} \cdot -0.25 + \left({u0}^{2} \cdot -0.5 - 0.3333333333333333 \cdot {u0}^{3}\right)\right)}{\frac{cos2phi}{alphax \cdot alphax} + t_0}\\
\end{array}
Results
if (-.f32 1 u0) < 0.964999974Initial program 1.5
Applied egg-rr1.5
Applied egg-rr1.5
Simplified1.5
[Start]1.5 | \[ \frac{-\log \left(1 - u0\right)}{\frac{2 \cdot \frac{\frac{cos2phi}{alphax} \cdot \frac{4}{alphax}}{alphax}}{\frac{8}{alphax}} + \frac{sin2phi}{alphay \cdot alphay}}
\] |
|---|---|
rational_best-simplify-55 [=>]1.5 | \[ \frac{-\log \left(1 - u0\right)}{\frac{2 \cdot \frac{\color{blue}{4 \cdot \frac{\frac{cos2phi}{alphax}}{alphax}}}{alphax}}{\frac{8}{alphax}} + \frac{sin2phi}{alphay \cdot alphay}}
\] |
rational_best-simplify-53 [=>]1.5 | \[ \frac{-\log \left(1 - u0\right)}{\frac{2 \cdot \frac{4 \cdot \color{blue}{\frac{cos2phi}{alphax \cdot alphax}}}{alphax}}{\frac{8}{alphax}} + \frac{sin2phi}{alphay \cdot alphay}}
\] |
rational_best-simplify-55 [=>]1.5 | \[ \frac{-\log \left(1 - u0\right)}{\frac{2 \cdot \frac{\color{blue}{cos2phi \cdot \frac{4}{alphax \cdot alphax}}}{alphax}}{\frac{8}{alphax}} + \frac{sin2phi}{alphay \cdot alphay}}
\] |
if 0.964999974 < (-.f32 1 u0) Initial program 14.5
Simplified14.5
[Start]14.5 | \[ \frac{-\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\] |
|---|---|
rational_best-simplify-13 [=>]14.5 | \[ \frac{\color{blue}{\frac{\log \left(1 - u0\right)}{-1}}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\] |
rational_best-simplify-53 [=>]14.5 | \[ \color{blue}{\frac{\log \left(1 - u0\right)}{-1 \cdot \left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)}}
\] |
rational_best-simplify-1 [=>]14.5 | \[ \frac{\log \left(1 - u0\right)}{\color{blue}{\left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right) \cdot -1}}
\] |
rational_best-simplify-10 [=>]14.5 | \[ \frac{\log \left(1 - u0\right)}{\color{blue}{-\left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)}}
\] |
rational_best-simplify-54 [=>]14.5 | \[ \frac{\log \left(1 - u0\right)}{-\left(\color{blue}{\frac{\frac{cos2phi}{alphax}}{alphax}} + \frac{sin2phi}{alphay \cdot alphay}\right)}
\] |
Taylor expanded in u0 around 0 0.5
Applied egg-rr0.5
Simplified0.5
[Start]0.5 | \[ \frac{{u0}^{3} \cdot 0.3333333333333333 - -0.5 \cdot {u0}^{2}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} + \frac{u0 - -0.25 \cdot {u0}^{4}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\] |
|---|---|
rational_best-simplify-64 [=>]0.5 | \[ \color{blue}{\frac{\left({u0}^{3} \cdot 0.3333333333333333 - -0.5 \cdot {u0}^{2}\right) + \left(u0 - -0.25 \cdot {u0}^{4}\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}}
\] |
rational_best-simplify-1 [=>]0.5 | \[ \frac{\left(\color{blue}{0.3333333333333333 \cdot {u0}^{3}} - -0.5 \cdot {u0}^{2}\right) + \left(u0 - -0.25 \cdot {u0}^{4}\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\] |
rational_best-simplify-1 [=>]0.5 | \[ \frac{\left(0.3333333333333333 \cdot {u0}^{3} - \color{blue}{{u0}^{2} \cdot -0.5}\right) + \left(u0 - -0.25 \cdot {u0}^{4}\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\] |
rational_best-simplify-1 [=>]0.5 | \[ \frac{\left(0.3333333333333333 \cdot {u0}^{3} - {u0}^{2} \cdot -0.5\right) + \left(u0 - \color{blue}{{u0}^{4} \cdot -0.25}\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\] |
Applied egg-rr0.5
Simplified0.5
[Start]0.5 | \[ \frac{\left(0.3333333333333333 \cdot {u0}^{3} - {u0}^{2} \cdot -0.5\right) + \left(u0 - {u0}^{4} \cdot -0.25\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} + 0
\] |
|---|---|
rational_best-simplify-3 [<=]0.5 | \[ \color{blue}{0 + \frac{\left(0.3333333333333333 \cdot {u0}^{3} - {u0}^{2} \cdot -0.5\right) + \left(u0 - {u0}^{4} \cdot -0.25\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}}
\] |
rational_best-simplify-6 [=>]0.5 | \[ \color{blue}{\frac{\left(0.3333333333333333 \cdot {u0}^{3} - {u0}^{2} \cdot -0.5\right) + \left(u0 - {u0}^{4} \cdot -0.25\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}}
\] |
rational_best-simplify-64 [<=]0.5 | \[ \color{blue}{\frac{0.3333333333333333 \cdot {u0}^{3} - {u0}^{2} \cdot -0.5}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} + \frac{u0 - {u0}^{4} \cdot -0.25}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}}
\] |
rational_best-simplify-67 [=>]0.5 | \[ \color{blue}{\left(\frac{0.3333333333333333 \cdot {u0}^{3}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} - \frac{{u0}^{2} \cdot -0.5}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}\right)} + \frac{u0 - {u0}^{4} \cdot -0.25}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\] |
rational_best-simplify-9 [<=]0.5 | \[ \left(\frac{0.3333333333333333 \cdot {u0}^{3}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} - \frac{{u0}^{2} \cdot -0.5}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}\right) + \color{blue}{\left(\frac{u0 - {u0}^{4} \cdot -0.25}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} - 0\right)}
\] |
metadata-eval [<=]0.5 | \[ \left(\frac{0.3333333333333333 \cdot {u0}^{3}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} - \frac{{u0}^{2} \cdot -0.5}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}\right) + \left(\frac{u0 - {u0}^{4} \cdot -0.25}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} - \color{blue}{\left(0 - 0\right)}\right)
\] |
rational_best-simplify-51 [<=]0.5 | \[ \left(\frac{0.3333333333333333 \cdot {u0}^{3}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} - \frac{{u0}^{2} \cdot -0.5}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}\right) + \color{blue}{\left(0 - \left(0 - \frac{u0 - {u0}^{4} \cdot -0.25}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}\right)\right)}
\] |
rational_best-simplify-14 [<=]0.5 | \[ \left(\frac{0.3333333333333333 \cdot {u0}^{3}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} - \frac{{u0}^{2} \cdot -0.5}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}\right) + \left(0 - \color{blue}{\left(-\frac{u0 - {u0}^{4} \cdot -0.25}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}\right)}\right)
\] |
rational_best-simplify-14 [<=]0.5 | \[ \left(\frac{0.3333333333333333 \cdot {u0}^{3}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} - \frac{{u0}^{2} \cdot -0.5}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}\right) + \color{blue}{\left(-\left(-\frac{u0 - {u0}^{4} \cdot -0.25}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}\right)\right)}
\] |
Final simplification0.6
| Alternative 1 | |
|---|---|
| Error | 0.6 |
| Cost | 10628 |
| Alternative 2 | |
|---|---|
| Error | 0.8 |
| Cost | 7428 |
| Alternative 3 | |
|---|---|
| Error | 1.2 |
| Cost | 7332 |
| Alternative 4 | |
|---|---|
| Error | 0.8 |
| Cost | 7268 |
| Alternative 5 | |
|---|---|
| Error | 1.2 |
| Cost | 7236 |
| Alternative 6 | |
|---|---|
| Error | 1.2 |
| Cost | 7236 |
| Alternative 7 | |
|---|---|
| Error | 1.2 |
| Cost | 4228 |
| Alternative 8 | |
|---|---|
| Error | 1.2 |
| Cost | 4164 |
| Alternative 9 | |
|---|---|
| Error | 3.2 |
| Cost | 3908 |
| Alternative 10 | |
|---|---|
| Error | 3.2 |
| Cost | 3908 |
| Alternative 11 | |
|---|---|
| Error | 1.2 |
| Cost | 3908 |
| Alternative 12 | |
|---|---|
| Error | 3.2 |
| Cost | 3844 |
| Alternative 13 | |
|---|---|
| Error | 3.2 |
| Cost | 3844 |
| Alternative 14 | |
|---|---|
| Error | 3.2 |
| Cost | 3844 |
| Alternative 15 | |
|---|---|
| Error | 7.9 |
| Cost | 672 |
| Alternative 16 | |
|---|---|
| Error | 7.9 |
| Cost | 480 |
| Alternative 17 | |
|---|---|
| Error | 7.9 |
| Cost | 416 |
| Alternative 18 | |
|---|---|
| Error | 7.9 |
| Cost | 416 |
herbie shell --seed 2023100
(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)))))