
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (/ (- (log (- 1.0 u0))) (+ (/ cos2phi (* 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)));
}
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
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 tmp = code(alphax, alphay, u0, cos2phi, sin2phi) tmp = -log((single(1.0) - u0)) / ((cos2phi / (alphax * alphax)) + (sin2phi / (alphay * alphay))); end
\begin{array}{l}
\\
\frac{-\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (/ (- (log (- 1.0 u0))) (+ (/ cos2phi (* 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)));
}
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
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 tmp = code(alphax, alphay, u0, cos2phi, sin2phi) tmp = -log((single(1.0) - u0)) / ((cos2phi / (alphax * alphax)) + (sin2phi / (alphay * alphay))); end
\begin{array}{l}
\\
\frac{-\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\end{array}
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (/ (log1p (- u0)) (- (* (pow alphax -2.0) (- cos2phi)) (/ sin2phi (* alphay alphay)))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
return log1pf(-u0) / ((powf(alphax, -2.0f) * -cos2phi) - (sin2phi / (alphay * alphay)));
}
function code(alphax, alphay, u0, cos2phi, sin2phi) return Float32(log1p(Float32(-u0)) / Float32(Float32((alphax ^ Float32(-2.0)) * Float32(-cos2phi)) - Float32(sin2phi / Float32(alphay * alphay)))) end
\begin{array}{l}
\\
\frac{\mathsf{log1p}\left(-u0\right)}{{alphax}^{-2} \cdot \left(-cos2phi\right) - \frac{sin2phi}{alphay \cdot alphay}}
\end{array}
Initial program 60.5%
distribute-frac-neg60.5%
distribute-neg-frac260.5%
sub-neg60.5%
log1p-define98.1%
neg-sub098.1%
associate--r+98.1%
neg-sub098.1%
associate-/r*98.2%
distribute-neg-frac298.2%
Simplified98.2%
distribute-frac-neg298.2%
associate-/r*98.1%
neg-sub098.1%
div-inv98.2%
pow298.2%
pow-flip98.3%
metadata-eval98.3%
Applied egg-rr98.3%
neg-sub098.3%
distribute-lft-neg-in98.3%
*-commutative98.3%
Simplified98.3%
Final simplification98.3%
(FPCore (alphax alphay u0 cos2phi sin2phi)
:precision binary32
(let* ((t_0 (/ sin2phi (* alphay alphay))))
(if (<= t_0 2.0000000072549875e-15)
(* (pow alphax 2.0) (* u0 (+ (* 0.5 (/ u0 cos2phi)) (/ 1.0 cos2phi))))
(/ (log1p (- u0)) (- (/ (/ cos2phi alphax) alphax) t_0)))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
float t_0 = sin2phi / (alphay * alphay);
float tmp;
if (t_0 <= 2.0000000072549875e-15f) {
tmp = powf(alphax, 2.0f) * (u0 * ((0.5f * (u0 / cos2phi)) + (1.0f / cos2phi)));
} else {
tmp = log1pf(-u0) / (((cos2phi / alphax) / alphax) - t_0);
}
return tmp;
}
function code(alphax, alphay, u0, cos2phi, sin2phi) t_0 = Float32(sin2phi / Float32(alphay * alphay)) tmp = Float32(0.0) if (t_0 <= Float32(2.0000000072549875e-15)) tmp = Float32((alphax ^ Float32(2.0)) * Float32(u0 * Float32(Float32(Float32(0.5) * Float32(u0 / cos2phi)) + Float32(Float32(1.0) / cos2phi)))); else tmp = Float32(log1p(Float32(-u0)) / Float32(Float32(Float32(cos2phi / alphax) / alphax) - t_0)); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{sin2phi}{alphay \cdot alphay}\\
\mathbf{if}\;t\_0 \leq 2.0000000072549875 \cdot 10^{-15}:\\
\;\;\;\;{alphax}^{2} \cdot \left(u0 \cdot \left(0.5 \cdot \frac{u0}{cos2phi} + \frac{1}{cos2phi}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(-u0\right)}{\frac{\frac{cos2phi}{alphax}}{alphax} - t\_0}\\
\end{array}
\end{array}
if (/.f32 sin2phi (*.f32 alphay alphay)) < 2.00000001e-15Initial program 50.3%
distribute-frac-neg50.3%
distribute-neg-frac250.3%
sub-neg50.3%
log1p-define98.6%
neg-sub098.6%
associate--r+98.6%
neg-sub098.6%
associate-/r*98.8%
distribute-neg-frac298.8%
Simplified98.8%
Taylor expanded in cos2phi around inf 41.7%
mul-1-neg41.7%
associate-/l*41.7%
distribute-rgt-neg-in41.7%
distribute-neg-frac241.7%
sub-neg41.7%
log1p-define78.2%
Simplified78.2%
Taylor expanded in u0 around 0 71.9%
if 2.00000001e-15 < (/.f32 sin2phi (*.f32 alphay alphay)) Initial program 63.2%
distribute-frac-neg63.2%
distribute-neg-frac263.2%
sub-neg63.2%
log1p-define98.0%
neg-sub098.0%
associate--r+98.0%
neg-sub098.0%
associate-/r*98.0%
distribute-neg-frac298.0%
Simplified98.0%
add-sqr-sqrt-0.0%
sqrt-unprod88.5%
sqr-neg88.5%
sqrt-prod88.5%
add-sqr-sqrt88.5%
div-inv88.5%
Applied egg-rr88.5%
associate-*r/88.5%
*-rgt-identity88.5%
Simplified88.5%
Final simplification85.0%
(FPCore (alphax alphay u0 cos2phi sin2phi)
:precision binary32
(let* ((t_0 (/ (* alphax sin2phi) alphay))
(t_1 (/ (* cos2phi alphay) alphax))
(t_2 (- t_1 t_0))
(t_3 (/ (* alphax alphay) t_2)))
(if (<= sin2phi 2.00000006274879e-22)
(* (pow alphax 2.0) (* u0 (+ (* 0.5 (/ u0 cos2phi)) (/ 1.0 cos2phi))))
(*
u0
(+
(/ (* alphax alphay) (- t_0 t_1))
(*
u0
(+
(* t_3 -0.5)
(*
u0
(+
(* t_3 -0.3333333333333333)
(* -0.25 (/ (* alphax (* u0 alphay)) t_2)))))))))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
float t_0 = (alphax * sin2phi) / alphay;
float t_1 = (cos2phi * alphay) / alphax;
float t_2 = t_1 - t_0;
float t_3 = (alphax * alphay) / t_2;
float tmp;
if (sin2phi <= 2.00000006274879e-22f) {
tmp = powf(alphax, 2.0f) * (u0 * ((0.5f * (u0 / cos2phi)) + (1.0f / cos2phi)));
} else {
tmp = u0 * (((alphax * alphay) / (t_0 - t_1)) + (u0 * ((t_3 * -0.5f) + (u0 * ((t_3 * -0.3333333333333333f) + (-0.25f * ((alphax * (u0 * alphay)) / t_2)))))));
}
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
real(4) :: t_0
real(4) :: t_1
real(4) :: t_2
real(4) :: t_3
real(4) :: tmp
t_0 = (alphax * sin2phi) / alphay
t_1 = (cos2phi * alphay) / alphax
t_2 = t_1 - t_0
t_3 = (alphax * alphay) / t_2
if (sin2phi <= 2.00000006274879e-22) then
tmp = (alphax ** 2.0e0) * (u0 * ((0.5e0 * (u0 / cos2phi)) + (1.0e0 / cos2phi)))
else
tmp = u0 * (((alphax * alphay) / (t_0 - t_1)) + (u0 * ((t_3 * (-0.5e0)) + (u0 * ((t_3 * (-0.3333333333333333e0)) + ((-0.25e0) * ((alphax * (u0 * alphay)) / t_2)))))))
end if
code = tmp
end function
function code(alphax, alphay, u0, cos2phi, sin2phi) t_0 = Float32(Float32(alphax * sin2phi) / alphay) t_1 = Float32(Float32(cos2phi * alphay) / alphax) t_2 = Float32(t_1 - t_0) t_3 = Float32(Float32(alphax * alphay) / t_2) tmp = Float32(0.0) if (sin2phi <= Float32(2.00000006274879e-22)) tmp = Float32((alphax ^ Float32(2.0)) * Float32(u0 * Float32(Float32(Float32(0.5) * Float32(u0 / cos2phi)) + Float32(Float32(1.0) / cos2phi)))); else tmp = Float32(u0 * Float32(Float32(Float32(alphax * alphay) / Float32(t_0 - t_1)) + Float32(u0 * Float32(Float32(t_3 * Float32(-0.5)) + Float32(u0 * Float32(Float32(t_3 * Float32(-0.3333333333333333)) + Float32(Float32(-0.25) * Float32(Float32(alphax * Float32(u0 * alphay)) / t_2)))))))); end return tmp end
function tmp_2 = code(alphax, alphay, u0, cos2phi, sin2phi) t_0 = (alphax * sin2phi) / alphay; t_1 = (cos2phi * alphay) / alphax; t_2 = t_1 - t_0; t_3 = (alphax * alphay) / t_2; tmp = single(0.0); if (sin2phi <= single(2.00000006274879e-22)) tmp = (alphax ^ single(2.0)) * (u0 * ((single(0.5) * (u0 / cos2phi)) + (single(1.0) / cos2phi))); else tmp = u0 * (((alphax * alphay) / (t_0 - t_1)) + (u0 * ((t_3 * single(-0.5)) + (u0 * ((t_3 * single(-0.3333333333333333)) + (single(-0.25) * ((alphax * (u0 * alphay)) / t_2))))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{alphax \cdot sin2phi}{alphay}\\
t_1 := \frac{cos2phi \cdot alphay}{alphax}\\
t_2 := t\_1 - t\_0\\
t_3 := \frac{alphax \cdot alphay}{t\_2}\\
\mathbf{if}\;sin2phi \leq 2.00000006274879 \cdot 10^{-22}:\\
\;\;\;\;{alphax}^{2} \cdot \left(u0 \cdot \left(0.5 \cdot \frac{u0}{cos2phi} + \frac{1}{cos2phi}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;u0 \cdot \left(\frac{alphax \cdot alphay}{t\_0 - t\_1} + u0 \cdot \left(t\_3 \cdot -0.5 + u0 \cdot \left(t\_3 \cdot -0.3333333333333333 + -0.25 \cdot \frac{alphax \cdot \left(u0 \cdot alphay\right)}{t\_2}\right)\right)\right)\\
\end{array}
\end{array}
if sin2phi < 2.00000006e-22Initial program 51.5%
distribute-frac-neg51.5%
distribute-neg-frac251.5%
sub-neg51.5%
log1p-define98.7%
neg-sub098.7%
associate--r+98.7%
neg-sub098.7%
associate-/r*98.8%
distribute-neg-frac298.8%
Simplified98.8%
Taylor expanded in cos2phi around inf 42.3%
mul-1-neg42.3%
associate-/l*42.2%
distribute-rgt-neg-in42.2%
distribute-neg-frac242.2%
sub-neg42.2%
log1p-define79.7%
Simplified79.7%
Taylor expanded in u0 around 0 73.3%
if 2.00000006e-22 < sin2phi Initial program 62.7%
distribute-frac-neg62.7%
distribute-neg-frac262.7%
sub-neg62.7%
log1p-define98.0%
neg-sub098.0%
associate--r+98.0%
neg-sub098.0%
associate-/r*98.0%
distribute-neg-frac298.0%
Simplified98.0%
frac-2neg98.0%
frac-2neg98.0%
add-sqr-sqrt-0.0%
sqrt-unprod87.3%
sqr-neg87.3%
sqrt-prod87.3%
add-sqr-sqrt87.3%
associate-/r*87.3%
frac-sub87.1%
Applied egg-rr87.1%
associate-*l/87.1%
Simplified87.1%
Taylor expanded in u0 around 0 82.9%
Final simplification81.0%
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (/ (log1p (- 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) - (sin2phi / (alphay * alphay)));
}
function code(alphax, alphay, u0, cos2phi, sin2phi) return Float32(log1p(Float32(-u0)) / Float32(Float32(Float32(cos2phi / alphax) / Float32(-alphax)) - Float32(sin2phi / Float32(alphay * alphay)))) end
\begin{array}{l}
\\
\frac{\mathsf{log1p}\left(-u0\right)}{\frac{\frac{cos2phi}{alphax}}{-alphax} - \frac{sin2phi}{alphay \cdot alphay}}
\end{array}
Initial program 60.5%
distribute-frac-neg60.5%
distribute-neg-frac260.5%
sub-neg60.5%
log1p-define98.1%
neg-sub098.1%
associate--r+98.1%
neg-sub098.1%
associate-/r*98.2%
distribute-neg-frac298.2%
Simplified98.2%
Final simplification98.2%
(FPCore (alphax alphay u0 cos2phi sin2phi)
:precision binary32
(let* ((t_0 (/ (* alphax sin2phi) alphay))
(t_1 (/ (* cos2phi alphay) alphax))
(t_2 (- t_1 t_0))
(t_3 (/ (* alphax alphay) t_2)))
(if (<= sin2phi 2.00000006274879e-22)
(* (pow alphax 2.0) (/ u0 cos2phi))
(*
u0
(+
(/ (* alphax alphay) (- t_0 t_1))
(*
u0
(+
(* t_3 -0.5)
(*
u0
(+
(* t_3 -0.3333333333333333)
(* -0.25 (/ (* alphax (* u0 alphay)) t_2)))))))))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
float t_0 = (alphax * sin2phi) / alphay;
float t_1 = (cos2phi * alphay) / alphax;
float t_2 = t_1 - t_0;
float t_3 = (alphax * alphay) / t_2;
float tmp;
if (sin2phi <= 2.00000006274879e-22f) {
tmp = powf(alphax, 2.0f) * (u0 / cos2phi);
} else {
tmp = u0 * (((alphax * alphay) / (t_0 - t_1)) + (u0 * ((t_3 * -0.5f) + (u0 * ((t_3 * -0.3333333333333333f) + (-0.25f * ((alphax * (u0 * alphay)) / t_2)))))));
}
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
real(4) :: t_0
real(4) :: t_1
real(4) :: t_2
real(4) :: t_3
real(4) :: tmp
t_0 = (alphax * sin2phi) / alphay
t_1 = (cos2phi * alphay) / alphax
t_2 = t_1 - t_0
t_3 = (alphax * alphay) / t_2
if (sin2phi <= 2.00000006274879e-22) then
tmp = (alphax ** 2.0e0) * (u0 / cos2phi)
else
tmp = u0 * (((alphax * alphay) / (t_0 - t_1)) + (u0 * ((t_3 * (-0.5e0)) + (u0 * ((t_3 * (-0.3333333333333333e0)) + ((-0.25e0) * ((alphax * (u0 * alphay)) / t_2)))))))
end if
code = tmp
end function
function code(alphax, alphay, u0, cos2phi, sin2phi) t_0 = Float32(Float32(alphax * sin2phi) / alphay) t_1 = Float32(Float32(cos2phi * alphay) / alphax) t_2 = Float32(t_1 - t_0) t_3 = Float32(Float32(alphax * alphay) / t_2) tmp = Float32(0.0) if (sin2phi <= Float32(2.00000006274879e-22)) tmp = Float32((alphax ^ Float32(2.0)) * Float32(u0 / cos2phi)); else tmp = Float32(u0 * Float32(Float32(Float32(alphax * alphay) / Float32(t_0 - t_1)) + Float32(u0 * Float32(Float32(t_3 * Float32(-0.5)) + Float32(u0 * Float32(Float32(t_3 * Float32(-0.3333333333333333)) + Float32(Float32(-0.25) * Float32(Float32(alphax * Float32(u0 * alphay)) / t_2)))))))); end return tmp end
function tmp_2 = code(alphax, alphay, u0, cos2phi, sin2phi) t_0 = (alphax * sin2phi) / alphay; t_1 = (cos2phi * alphay) / alphax; t_2 = t_1 - t_0; t_3 = (alphax * alphay) / t_2; tmp = single(0.0); if (sin2phi <= single(2.00000006274879e-22)) tmp = (alphax ^ single(2.0)) * (u0 / cos2phi); else tmp = u0 * (((alphax * alphay) / (t_0 - t_1)) + (u0 * ((t_3 * single(-0.5)) + (u0 * ((t_3 * single(-0.3333333333333333)) + (single(-0.25) * ((alphax * (u0 * alphay)) / t_2))))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{alphax \cdot sin2phi}{alphay}\\
t_1 := \frac{cos2phi \cdot alphay}{alphax}\\
t_2 := t\_1 - t\_0\\
t_3 := \frac{alphax \cdot alphay}{t\_2}\\
\mathbf{if}\;sin2phi \leq 2.00000006274879 \cdot 10^{-22}:\\
\;\;\;\;{alphax}^{2} \cdot \frac{u0}{cos2phi}\\
\mathbf{else}:\\
\;\;\;\;u0 \cdot \left(\frac{alphax \cdot alphay}{t\_0 - t\_1} + u0 \cdot \left(t\_3 \cdot -0.5 + u0 \cdot \left(t\_3 \cdot -0.3333333333333333 + -0.25 \cdot \frac{alphax \cdot \left(u0 \cdot alphay\right)}{t\_2}\right)\right)\right)\\
\end{array}
\end{array}
if sin2phi < 2.00000006e-22Initial program 51.5%
distribute-frac-neg51.5%
distribute-neg-frac251.5%
sub-neg51.5%
log1p-define98.7%
neg-sub098.7%
associate--r+98.7%
neg-sub098.7%
associate-/r*98.8%
distribute-neg-frac298.8%
Simplified98.8%
Taylor expanded in cos2phi around inf 42.3%
mul-1-neg42.3%
associate-/l*42.2%
distribute-rgt-neg-in42.2%
distribute-neg-frac242.2%
sub-neg42.2%
log1p-define79.7%
Simplified79.7%
Taylor expanded in u0 around 0 65.2%
associate-/l*65.2%
Simplified65.2%
if 2.00000006e-22 < sin2phi Initial program 62.7%
distribute-frac-neg62.7%
distribute-neg-frac262.7%
sub-neg62.7%
log1p-define98.0%
neg-sub098.0%
associate--r+98.0%
neg-sub098.0%
associate-/r*98.0%
distribute-neg-frac298.0%
Simplified98.0%
frac-2neg98.0%
frac-2neg98.0%
add-sqr-sqrt-0.0%
sqrt-unprod87.3%
sqr-neg87.3%
sqrt-prod87.3%
add-sqr-sqrt87.3%
associate-/r*87.3%
frac-sub87.1%
Applied egg-rr87.1%
associate-*l/87.1%
Simplified87.1%
Taylor expanded in u0 around 0 82.9%
Final simplification79.5%
(FPCore (alphax alphay u0 cos2phi sin2phi)
:precision binary32
(let* ((t_0 (/ (* cos2phi alphay) alphax))
(t_1 (/ (* alphax sin2phi) alphay))
(t_2 (- t_0 t_1))
(t_3 (/ (* alphax alphay) t_2)))
(*
u0
(+
(/ (* alphax alphay) (- t_1 t_0))
(*
u0
(+
(* t_3 -0.5)
(*
u0
(+
(* t_3 -0.3333333333333333)
(* -0.25 (/ (* alphax (* u0 alphay)) t_2))))))))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
float t_0 = (cos2phi * alphay) / alphax;
float t_1 = (alphax * sin2phi) / alphay;
float t_2 = t_0 - t_1;
float t_3 = (alphax * alphay) / t_2;
return u0 * (((alphax * alphay) / (t_1 - t_0)) + (u0 * ((t_3 * -0.5f) + (u0 * ((t_3 * -0.3333333333333333f) + (-0.25f * ((alphax * (u0 * alphay)) / t_2)))))));
}
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) :: t_1
real(4) :: t_2
real(4) :: t_3
t_0 = (cos2phi * alphay) / alphax
t_1 = (alphax * sin2phi) / alphay
t_2 = t_0 - t_1
t_3 = (alphax * alphay) / t_2
code = u0 * (((alphax * alphay) / (t_1 - t_0)) + (u0 * ((t_3 * (-0.5e0)) + (u0 * ((t_3 * (-0.3333333333333333e0)) + ((-0.25e0) * ((alphax * (u0 * alphay)) / t_2)))))))
end function
function code(alphax, alphay, u0, cos2phi, sin2phi) t_0 = Float32(Float32(cos2phi * alphay) / alphax) t_1 = Float32(Float32(alphax * sin2phi) / alphay) t_2 = Float32(t_0 - t_1) t_3 = Float32(Float32(alphax * alphay) / t_2) return Float32(u0 * Float32(Float32(Float32(alphax * alphay) / Float32(t_1 - t_0)) + Float32(u0 * Float32(Float32(t_3 * Float32(-0.5)) + Float32(u0 * Float32(Float32(t_3 * Float32(-0.3333333333333333)) + Float32(Float32(-0.25) * Float32(Float32(alphax * Float32(u0 * alphay)) / t_2)))))))) end
function tmp = code(alphax, alphay, u0, cos2phi, sin2phi) t_0 = (cos2phi * alphay) / alphax; t_1 = (alphax * sin2phi) / alphay; t_2 = t_0 - t_1; t_3 = (alphax * alphay) / t_2; tmp = u0 * (((alphax * alphay) / (t_1 - t_0)) + (u0 * ((t_3 * single(-0.5)) + (u0 * ((t_3 * single(-0.3333333333333333)) + (single(-0.25) * ((alphax * (u0 * alphay)) / t_2))))))); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{cos2phi \cdot alphay}{alphax}\\
t_1 := \frac{alphax \cdot sin2phi}{alphay}\\
t_2 := t\_0 - t\_1\\
t_3 := \frac{alphax \cdot alphay}{t\_2}\\
u0 \cdot \left(\frac{alphax \cdot alphay}{t\_1 - t\_0} + u0 \cdot \left(t\_3 \cdot -0.5 + u0 \cdot \left(t\_3 \cdot -0.3333333333333333 + -0.25 \cdot \frac{alphax \cdot \left(u0 \cdot alphay\right)}{t\_2}\right)\right)\right)
\end{array}
\end{array}
Initial program 60.5%
distribute-frac-neg60.5%
distribute-neg-frac260.5%
sub-neg60.5%
log1p-define98.1%
neg-sub098.1%
associate--r+98.1%
neg-sub098.1%
associate-/r*98.2%
distribute-neg-frac298.2%
Simplified98.2%
frac-2neg98.2%
frac-2neg98.2%
add-sqr-sqrt-0.0%
sqrt-unprod73.0%
sqr-neg73.0%
sqrt-prod73.0%
add-sqr-sqrt73.0%
associate-/r*72.9%
frac-sub72.7%
Applied egg-rr72.7%
associate-*l/72.7%
Simplified72.7%
Taylor expanded in u0 around 0 69.2%
Final simplification69.2%
(FPCore (alphax alphay u0 cos2phi sin2phi)
:precision binary32
(let* ((t_0 (/ (* cos2phi alphay) alphax))
(t_1 (/ (* alphax sin2phi) alphay))
(t_2 (- t_0 t_1)))
(*
u0
(+
(/ (* alphax alphay) (- t_1 t_0))
(*
u0
(+
(* (/ (* alphax alphay) t_2) -0.5)
(* -0.3333333333333333 (/ (* alphax (* u0 alphay)) t_2))))))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
float t_0 = (cos2phi * alphay) / alphax;
float t_1 = (alphax * sin2phi) / alphay;
float t_2 = t_0 - t_1;
return u0 * (((alphax * alphay) / (t_1 - t_0)) + (u0 * ((((alphax * alphay) / t_2) * -0.5f) + (-0.3333333333333333f * ((alphax * (u0 * alphay)) / t_2)))));
}
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) :: t_1
real(4) :: t_2
t_0 = (cos2phi * alphay) / alphax
t_1 = (alphax * sin2phi) / alphay
t_2 = t_0 - t_1
code = u0 * (((alphax * alphay) / (t_1 - t_0)) + (u0 * ((((alphax * alphay) / t_2) * (-0.5e0)) + ((-0.3333333333333333e0) * ((alphax * (u0 * alphay)) / t_2)))))
end function
function code(alphax, alphay, u0, cos2phi, sin2phi) t_0 = Float32(Float32(cos2phi * alphay) / alphax) t_1 = Float32(Float32(alphax * sin2phi) / alphay) t_2 = Float32(t_0 - t_1) return Float32(u0 * Float32(Float32(Float32(alphax * alphay) / Float32(t_1 - t_0)) + Float32(u0 * Float32(Float32(Float32(Float32(alphax * alphay) / t_2) * Float32(-0.5)) + Float32(Float32(-0.3333333333333333) * Float32(Float32(alphax * Float32(u0 * alphay)) / t_2)))))) end
function tmp = code(alphax, alphay, u0, cos2phi, sin2phi) t_0 = (cos2phi * alphay) / alphax; t_1 = (alphax * sin2phi) / alphay; t_2 = t_0 - t_1; tmp = u0 * (((alphax * alphay) / (t_1 - t_0)) + (u0 * ((((alphax * alphay) / t_2) * single(-0.5)) + (single(-0.3333333333333333) * ((alphax * (u0 * alphay)) / t_2))))); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{cos2phi \cdot alphay}{alphax}\\
t_1 := \frac{alphax \cdot sin2phi}{alphay}\\
t_2 := t\_0 - t\_1\\
u0 \cdot \left(\frac{alphax \cdot alphay}{t\_1 - t\_0} + u0 \cdot \left(\frac{alphax \cdot alphay}{t\_2} \cdot -0.5 + -0.3333333333333333 \cdot \frac{alphax \cdot \left(u0 \cdot alphay\right)}{t\_2}\right)\right)
\end{array}
\end{array}
Initial program 60.5%
distribute-frac-neg60.5%
distribute-neg-frac260.5%
sub-neg60.5%
log1p-define98.1%
neg-sub098.1%
associate--r+98.1%
neg-sub098.1%
associate-/r*98.2%
distribute-neg-frac298.2%
Simplified98.2%
frac-2neg98.2%
frac-2neg98.2%
add-sqr-sqrt-0.0%
sqrt-unprod73.0%
sqr-neg73.0%
sqrt-prod73.0%
add-sqr-sqrt73.0%
associate-/r*72.9%
frac-sub72.7%
Applied egg-rr72.7%
associate-*l/72.7%
Simplified72.7%
Taylor expanded in u0 around 0 67.7%
Final simplification67.7%
(FPCore (alphax alphay u0 cos2phi sin2phi)
:precision binary32
(let* ((t_0 (* cos2phi (/ alphay alphax)))
(t_1 (/ (* alphax sin2phi) alphay)))
(*
u0
(+
(* -0.5 (* alphax (/ (* u0 alphay) (- t_0 t_1))))
(* alphax (/ alphay (- t_1 t_0)))))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
float t_0 = cos2phi * (alphay / alphax);
float t_1 = (alphax * sin2phi) / alphay;
return u0 * ((-0.5f * (alphax * ((u0 * alphay) / (t_0 - t_1)))) + (alphax * (alphay / (t_1 - t_0))));
}
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) :: t_1
t_0 = cos2phi * (alphay / alphax)
t_1 = (alphax * sin2phi) / alphay
code = u0 * (((-0.5e0) * (alphax * ((u0 * alphay) / (t_0 - t_1)))) + (alphax * (alphay / (t_1 - t_0))))
end function
function code(alphax, alphay, u0, cos2phi, sin2phi) t_0 = Float32(cos2phi * Float32(alphay / alphax)) t_1 = Float32(Float32(alphax * sin2phi) / alphay) return Float32(u0 * Float32(Float32(Float32(-0.5) * Float32(alphax * Float32(Float32(u0 * alphay) / Float32(t_0 - t_1)))) + Float32(alphax * Float32(alphay / Float32(t_1 - t_0))))) end
function tmp = code(alphax, alphay, u0, cos2phi, sin2phi) t_0 = cos2phi * (alphay / alphax); t_1 = (alphax * sin2phi) / alphay; tmp = u0 * ((single(-0.5) * (alphax * ((u0 * alphay) / (t_0 - t_1)))) + (alphax * (alphay / (t_1 - t_0)))); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := cos2phi \cdot \frac{alphay}{alphax}\\
t_1 := \frac{alphax \cdot sin2phi}{alphay}\\
u0 \cdot \left(-0.5 \cdot \left(alphax \cdot \frac{u0 \cdot alphay}{t\_0 - t\_1}\right) + alphax \cdot \frac{alphay}{t\_1 - t\_0}\right)
\end{array}
\end{array}
Initial program 60.5%
distribute-frac-neg60.5%
distribute-neg-frac260.5%
sub-neg60.5%
log1p-define98.1%
neg-sub098.1%
associate--r+98.1%
neg-sub098.1%
associate-/r*98.2%
distribute-neg-frac298.2%
Simplified98.2%
frac-2neg98.2%
frac-2neg98.2%
add-sqr-sqrt-0.0%
sqrt-unprod73.0%
sqr-neg73.0%
sqrt-prod73.0%
add-sqr-sqrt73.0%
associate-/r*72.9%
frac-sub72.7%
Applied egg-rr72.7%
associate-*l/72.7%
Simplified72.7%
Taylor expanded in u0 around 0 65.1%
+-commutative65.1%
mul-1-neg65.1%
unsub-neg65.1%
associate-/l*65.1%
*-commutative65.1%
*-commutative65.1%
associate-*r/65.1%
associate-/l*65.1%
Simplified65.1%
Final simplification65.1%
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (/ (* alphax (* u0 alphay)) (- (* alphax (/ sin2phi alphay)) (/ (* cos2phi alphay) alphax))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
return (alphax * (u0 * alphay)) / ((alphax * (sin2phi / alphay)) - ((cos2phi * alphay) / alphax));
}
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 = (alphax * (u0 * alphay)) / ((alphax * (sin2phi / alphay)) - ((cos2phi * alphay) / alphax))
end function
function code(alphax, alphay, u0, cos2phi, sin2phi) return Float32(Float32(alphax * Float32(u0 * alphay)) / Float32(Float32(alphax * Float32(sin2phi / alphay)) - Float32(Float32(cos2phi * alphay) / alphax))) end
function tmp = code(alphax, alphay, u0, cos2phi, sin2phi) tmp = (alphax * (u0 * alphay)) / ((alphax * (sin2phi / alphay)) - ((cos2phi * alphay) / alphax)); end
\begin{array}{l}
\\
\frac{alphax \cdot \left(u0 \cdot alphay\right)}{alphax \cdot \frac{sin2phi}{alphay} - \frac{cos2phi \cdot alphay}{alphax}}
\end{array}
Initial program 60.5%
distribute-frac-neg60.5%
distribute-neg-frac260.5%
sub-neg60.5%
log1p-define98.1%
neg-sub098.1%
associate--r+98.1%
neg-sub098.1%
associate-/r*98.2%
distribute-neg-frac298.2%
Simplified98.2%
frac-2neg98.2%
frac-2neg98.2%
add-sqr-sqrt-0.0%
sqrt-unprod73.0%
sqr-neg73.0%
sqrt-prod73.0%
add-sqr-sqrt73.0%
associate-/r*72.9%
frac-sub72.7%
Applied egg-rr72.7%
associate-*l/72.7%
Simplified72.7%
Taylor expanded in u0 around 0 56.9%
mul-1-neg56.9%
*-commutative56.9%
*-commutative56.9%
associate-*r/56.9%
Simplified56.9%
Final simplification56.9%
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (/ (* alphax (* u0 alphay)) (- (/ (* alphax sin2phi) alphay) (* cos2phi (/ alphay alphax)))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
return (alphax * (u0 * alphay)) / (((alphax * sin2phi) / alphay) - (cos2phi * (alphay / alphax)));
}
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 = (alphax * (u0 * alphay)) / (((alphax * sin2phi) / alphay) - (cos2phi * (alphay / alphax)))
end function
function code(alphax, alphay, u0, cos2phi, sin2phi) return Float32(Float32(alphax * Float32(u0 * alphay)) / Float32(Float32(Float32(alphax * sin2phi) / alphay) - Float32(cos2phi * Float32(alphay / alphax)))) end
function tmp = code(alphax, alphay, u0, cos2phi, sin2phi) tmp = (alphax * (u0 * alphay)) / (((alphax * sin2phi) / alphay) - (cos2phi * (alphay / alphax))); end
\begin{array}{l}
\\
\frac{alphax \cdot \left(u0 \cdot alphay\right)}{\frac{alphax \cdot sin2phi}{alphay} - cos2phi \cdot \frac{alphay}{alphax}}
\end{array}
Initial program 60.5%
distribute-frac-neg60.5%
distribute-neg-frac260.5%
sub-neg60.5%
log1p-define98.1%
neg-sub098.1%
associate--r+98.1%
neg-sub098.1%
associate-/r*98.2%
distribute-neg-frac298.2%
Simplified98.2%
frac-2neg98.2%
frac-2neg98.2%
add-sqr-sqrt-0.0%
sqrt-unprod73.0%
sqr-neg73.0%
sqrt-prod73.0%
add-sqr-sqrt73.0%
associate-/r*72.9%
frac-sub72.7%
Applied egg-rr72.7%
associate-*l/72.7%
Simplified72.7%
Taylor expanded in u0 around 0 56.9%
associate-*r/56.9%
mul-1-neg56.9%
*-commutative56.9%
*-commutative56.9%
associate-*r/56.9%
Simplified56.9%
Final simplification56.9%
herbie shell --seed 2024096
(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)))))