
(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))) (+ (/ 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(Float32(-log1p(Float32(-u0))) / Float32(Float32(cos2phi / Float32(alphax * alphax)) + Float32(sin2phi / Float32(alphay * alphay)))) end
\begin{array}{l}
\\
\frac{-\mathsf{log1p}\left(-u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\end{array}
Initial program 64.1%
neg-sub064.1%
div-sub64.1%
--rgt-identity64.1%
div-sub64.1%
--rgt-identity64.1%
neg-sub064.1%
sub-neg64.1%
log1p-def98.6%
Simplified98.6%
Final simplification98.6%
(FPCore (alphax alphay u0 cos2phi sin2phi)
:precision binary32
(if (<= (/ sin2phi (* alphay alphay)) 1.5)
(/
(- u0 (* (* u0 u0) -0.5))
(+ (/ (/ cos2phi alphax) alphax) (/ (/ sin2phi alphay) alphay)))
(* alphay (/ (- (log1p (- u0))) (/ sin2phi alphay)))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
float tmp;
if ((sin2phi / (alphay * alphay)) <= 1.5f) {
tmp = (u0 - ((u0 * u0) * -0.5f)) / (((cos2phi / alphax) / alphax) + ((sin2phi / alphay) / alphay));
} else {
tmp = alphay * (-log1pf(-u0) / (sin2phi / alphay));
}
return tmp;
}
function code(alphax, alphay, u0, cos2phi, sin2phi) tmp = Float32(0.0) if (Float32(sin2phi / Float32(alphay * alphay)) <= Float32(1.5)) tmp = Float32(Float32(u0 - Float32(Float32(u0 * u0) * Float32(-0.5))) / Float32(Float32(Float32(cos2phi / alphax) / alphax) + Float32(Float32(sin2phi / alphay) / alphay))); else tmp = Float32(alphay * Float32(Float32(-log1p(Float32(-u0))) / Float32(sin2phi / alphay))); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{sin2phi}{alphay \cdot alphay} \leq 1.5:\\
\;\;\;\;\frac{u0 - \left(u0 \cdot u0\right) \cdot -0.5}{\frac{\frac{cos2phi}{alphax}}{alphax} + \frac{\frac{sin2phi}{alphay}}{alphay}}\\
\mathbf{else}:\\
\;\;\;\;alphay \cdot \frac{-\mathsf{log1p}\left(-u0\right)}{\frac{sin2phi}{alphay}}\\
\end{array}
\end{array}
if (/.f32 sin2phi (*.f32 alphay alphay)) < 1.5Initial program 60.0%
neg-sub060.0%
div-sub60.0%
--rgt-identity60.0%
div-sub60.0%
--rgt-identity60.0%
sub-neg60.0%
+-commutative60.0%
neg-sub060.0%
associate-+l-60.0%
sub0-neg60.0%
neg-mul-160.0%
log-prod-0.0%
associate--r+-0.0%
Simplified98.3%
associate-/r*98.4%
div-inv98.3%
Applied egg-rr98.3%
un-div-inv98.4%
Applied egg-rr98.4%
Taylor expanded in u0 around 0 85.5%
+-commutative85.5%
neg-mul-185.5%
unsub-neg85.5%
*-commutative85.5%
unpow285.5%
Simplified85.5%
if 1.5 < (/.f32 sin2phi (*.f32 alphay alphay)) Initial program 68.2%
neg-sub068.2%
div-sub68.2%
--rgt-identity68.2%
div-sub68.2%
--rgt-identity68.2%
sub-neg68.2%
+-commutative68.2%
neg-sub068.2%
associate-+l-68.2%
sub0-neg68.2%
neg-mul-168.2%
log-prod-0.0%
associate--r+-0.0%
Simplified98.8%
associate-/r*98.7%
div-inv98.6%
Applied egg-rr98.6%
un-div-inv98.7%
Applied egg-rr98.7%
Taylor expanded in cos2phi around 0 68.5%
mul-1-neg68.5%
*-commutative68.5%
associate-/l*68.2%
sub-neg68.2%
log1p-def98.7%
unpow298.7%
associate-/l/98.7%
distribute-frac-neg98.7%
associate-/r/98.7%
*-commutative98.7%
Simplified98.7%
Final simplification92.1%
(FPCore (alphax alphay u0 cos2phi sin2phi)
:precision binary32
(if (<= (/ sin2phi (* alphay alphay)) 1.5)
(/
(- u0 (* (* u0 u0) -0.5))
(+ (/ (/ cos2phi alphax) alphax) (/ (/ sin2phi alphay) alphay)))
(* (log1p (- u0)) (* alphay (- (/ alphay sin2phi))))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
float tmp;
if ((sin2phi / (alphay * alphay)) <= 1.5f) {
tmp = (u0 - ((u0 * u0) * -0.5f)) / (((cos2phi / alphax) / alphax) + ((sin2phi / alphay) / alphay));
} else {
tmp = log1pf(-u0) * (alphay * -(alphay / sin2phi));
}
return tmp;
}
function code(alphax, alphay, u0, cos2phi, sin2phi) tmp = Float32(0.0) if (Float32(sin2phi / Float32(alphay * alphay)) <= Float32(1.5)) tmp = Float32(Float32(u0 - Float32(Float32(u0 * u0) * Float32(-0.5))) / Float32(Float32(Float32(cos2phi / alphax) / alphax) + Float32(Float32(sin2phi / alphay) / alphay))); else tmp = Float32(log1p(Float32(-u0)) * Float32(alphay * Float32(-Float32(alphay / sin2phi)))); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{sin2phi}{alphay \cdot alphay} \leq 1.5:\\
\;\;\;\;\frac{u0 - \left(u0 \cdot u0\right) \cdot -0.5}{\frac{\frac{cos2phi}{alphax}}{alphax} + \frac{\frac{sin2phi}{alphay}}{alphay}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(-u0\right) \cdot \left(alphay \cdot \left(-\frac{alphay}{sin2phi}\right)\right)\\
\end{array}
\end{array}
if (/.f32 sin2phi (*.f32 alphay alphay)) < 1.5Initial program 60.0%
neg-sub060.0%
div-sub60.0%
--rgt-identity60.0%
div-sub60.0%
--rgt-identity60.0%
sub-neg60.0%
+-commutative60.0%
neg-sub060.0%
associate-+l-60.0%
sub0-neg60.0%
neg-mul-160.0%
log-prod-0.0%
associate--r+-0.0%
Simplified98.3%
associate-/r*98.4%
div-inv98.3%
Applied egg-rr98.3%
un-div-inv98.4%
Applied egg-rr98.4%
Taylor expanded in u0 around 0 85.5%
+-commutative85.5%
neg-mul-185.5%
unsub-neg85.5%
*-commutative85.5%
unpow285.5%
Simplified85.5%
if 1.5 < (/.f32 sin2phi (*.f32 alphay alphay)) Initial program 68.2%
neg-sub068.2%
div-sub68.2%
--rgt-identity68.2%
div-sub68.2%
--rgt-identity68.2%
sub-neg68.2%
+-commutative68.2%
neg-sub068.2%
associate-+l-68.2%
sub0-neg68.2%
neg-mul-168.2%
log-prod-0.0%
associate--r+-0.0%
Simplified98.8%
div-inv98.8%
Applied egg-rr98.8%
div-inv98.7%
div-inv98.7%
+-commutative98.7%
associate-/r*98.7%
Applied egg-rr98.7%
Taylor expanded in sin2phi around inf 99.1%
unpow299.1%
associate-*r/99.1%
Simplified99.1%
Final simplification92.3%
(FPCore (alphax alphay u0 cos2phi sin2phi)
:precision binary32
(if (<= (/ sin2phi (* alphay alphay)) 1.5)
(/
u0
(+
(/ cos2phi (* alphax alphax))
(* sin2phi (/ -1.0 (* alphay (- alphay))))))
(/ (* (* alphay alphay) (+ u0 (* (* u0 u0) 0.5))) sin2phi)))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
float tmp;
if ((sin2phi / (alphay * alphay)) <= 1.5f) {
tmp = u0 / ((cos2phi / (alphax * alphax)) + (sin2phi * (-1.0f / (alphay * -alphay))));
} else {
tmp = ((alphay * alphay) * (u0 + ((u0 * u0) * 0.5f))) / sin2phi;
}
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) :: tmp
if ((sin2phi / (alphay * alphay)) <= 1.5e0) then
tmp = u0 / ((cos2phi / (alphax * alphax)) + (sin2phi * ((-1.0e0) / (alphay * -alphay))))
else
tmp = ((alphay * alphay) * (u0 + ((u0 * u0) * 0.5e0))) / sin2phi
end if
code = tmp
end function
function code(alphax, alphay, u0, cos2phi, sin2phi) tmp = Float32(0.0) if (Float32(sin2phi / Float32(alphay * alphay)) <= Float32(1.5)) tmp = Float32(u0 / Float32(Float32(cos2phi / Float32(alphax * alphax)) + Float32(sin2phi * Float32(Float32(-1.0) / Float32(alphay * Float32(-alphay)))))); else tmp = Float32(Float32(Float32(alphay * alphay) * Float32(u0 + Float32(Float32(u0 * u0) * Float32(0.5)))) / sin2phi); end return tmp end
function tmp_2 = code(alphax, alphay, u0, cos2phi, sin2phi) tmp = single(0.0); if ((sin2phi / (alphay * alphay)) <= single(1.5)) tmp = u0 / ((cos2phi / (alphax * alphax)) + (sin2phi * (single(-1.0) / (alphay * -alphay)))); else tmp = ((alphay * alphay) * (u0 + ((u0 * u0) * single(0.5)))) / sin2phi; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{sin2phi}{alphay \cdot alphay} \leq 1.5:\\
\;\;\;\;\frac{u0}{\frac{cos2phi}{alphax \cdot alphax} + sin2phi \cdot \frac{-1}{alphay \cdot \left(-alphay\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(alphay \cdot alphay\right) \cdot \left(u0 + \left(u0 \cdot u0\right) \cdot 0.5\right)}{sin2phi}\\
\end{array}
\end{array}
if (/.f32 sin2phi (*.f32 alphay alphay)) < 1.5Initial program 60.0%
associate-/r*60.0%
Simplified60.0%
Taylor expanded in u0 around 0 71.1%
unpow271.1%
unpow271.1%
Simplified71.1%
frac-2neg71.1%
div-inv71.1%
Applied egg-rr71.1%
if 1.5 < (/.f32 sin2phi (*.f32 alphay alphay)) Initial program 68.2%
neg-sub068.2%
div-sub68.2%
--rgt-identity68.2%
div-sub68.2%
--rgt-identity68.2%
sub-neg68.2%
+-commutative68.2%
neg-sub068.2%
associate-+l-68.2%
sub0-neg68.2%
neg-mul-168.2%
log-prod-0.0%
associate--r+-0.0%
Simplified98.8%
div-inv98.8%
Applied egg-rr98.8%
div-inv98.7%
div-inv98.7%
+-commutative98.7%
associate-/r*98.7%
Applied egg-rr98.7%
Taylor expanded in sin2phi around inf 68.5%
associate-*r/68.5%
*-commutative68.5%
associate-*r*68.5%
neg-mul-168.5%
sub-neg68.5%
log1p-def99.1%
unpow299.1%
Simplified99.1%
Taylor expanded in u0 around 0 89.4%
associate-*r*89.4%
distribute-rgt-out89.4%
unpow289.4%
unpow289.4%
Simplified89.4%
Final simplification80.3%
(FPCore (alphax alphay u0 cos2phi sin2phi)
:precision binary32
(let* ((t_0 (/ sin2phi (* alphay alphay))))
(if (<= t_0 1.5)
(/ u0 (+ (/ cos2phi (* alphax alphax)) t_0))
(/ (* (* alphay alphay) (+ u0 (* (* u0 u0) 0.5))) sin2phi))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
float t_0 = sin2phi / (alphay * alphay);
float tmp;
if (t_0 <= 1.5f) {
tmp = u0 / ((cos2phi / (alphax * alphax)) + t_0);
} else {
tmp = ((alphay * alphay) * (u0 + ((u0 * u0) * 0.5f))) / sin2phi;
}
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) :: tmp
t_0 = sin2phi / (alphay * alphay)
if (t_0 <= 1.5e0) then
tmp = u0 / ((cos2phi / (alphax * alphax)) + t_0)
else
tmp = ((alphay * alphay) * (u0 + ((u0 * u0) * 0.5e0))) / sin2phi
end if
code = tmp
end function
function code(alphax, alphay, u0, cos2phi, sin2phi) t_0 = Float32(sin2phi / Float32(alphay * alphay)) tmp = Float32(0.0) if (t_0 <= Float32(1.5)) tmp = Float32(u0 / Float32(Float32(cos2phi / Float32(alphax * alphax)) + t_0)); else tmp = Float32(Float32(Float32(alphay * alphay) * Float32(u0 + Float32(Float32(u0 * u0) * Float32(0.5)))) / sin2phi); end return tmp end
function tmp_2 = code(alphax, alphay, u0, cos2phi, sin2phi) t_0 = sin2phi / (alphay * alphay); tmp = single(0.0); if (t_0 <= single(1.5)) tmp = u0 / ((cos2phi / (alphax * alphax)) + t_0); else tmp = ((alphay * alphay) * (u0 + ((u0 * u0) * single(0.5)))) / sin2phi; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{sin2phi}{alphay \cdot alphay}\\
\mathbf{if}\;t_0 \leq 1.5:\\
\;\;\;\;\frac{u0}{\frac{cos2phi}{alphax \cdot alphax} + t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(alphay \cdot alphay\right) \cdot \left(u0 + \left(u0 \cdot u0\right) \cdot 0.5\right)}{sin2phi}\\
\end{array}
\end{array}
if (/.f32 sin2phi (*.f32 alphay alphay)) < 1.5Initial program 60.0%
associate-/r*60.0%
Simplified60.0%
Taylor expanded in u0 around 0 71.1%
unpow271.1%
unpow271.1%
Simplified71.1%
if 1.5 < (/.f32 sin2phi (*.f32 alphay alphay)) Initial program 68.2%
neg-sub068.2%
div-sub68.2%
--rgt-identity68.2%
div-sub68.2%
--rgt-identity68.2%
sub-neg68.2%
+-commutative68.2%
neg-sub068.2%
associate-+l-68.2%
sub0-neg68.2%
neg-mul-168.2%
log-prod-0.0%
associate--r+-0.0%
Simplified98.8%
div-inv98.8%
Applied egg-rr98.8%
div-inv98.7%
div-inv98.7%
+-commutative98.7%
associate-/r*98.7%
Applied egg-rr98.7%
Taylor expanded in sin2phi around inf 68.5%
associate-*r/68.5%
*-commutative68.5%
associate-*r*68.5%
neg-mul-168.5%
sub-neg68.5%
log1p-def99.1%
unpow299.1%
Simplified99.1%
Taylor expanded in u0 around 0 89.4%
associate-*r*89.4%
distribute-rgt-out89.4%
unpow289.4%
unpow289.4%
Simplified89.4%
Final simplification80.3%
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (/ (- u0 (* (* u0 u0) -0.5)) (+ (/ (/ cos2phi alphax) alphax) (/ (/ sin2phi alphay) alphay))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
return (u0 - ((u0 * u0) * -0.5f)) / (((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 = (u0 - ((u0 * u0) * (-0.5e0))) / (((cos2phi / alphax) / alphax) + ((sin2phi / alphay) / alphay))
end function
function code(alphax, alphay, u0, cos2phi, sin2phi) return Float32(Float32(u0 - Float32(Float32(u0 * u0) * Float32(-0.5))) / Float32(Float32(Float32(cos2phi / alphax) / alphax) + Float32(Float32(sin2phi / alphay) / alphay))) end
function tmp = code(alphax, alphay, u0, cos2phi, sin2phi) tmp = (u0 - ((u0 * u0) * single(-0.5))) / (((cos2phi / alphax) / alphax) + ((sin2phi / alphay) / alphay)); end
\begin{array}{l}
\\
\frac{u0 - \left(u0 \cdot u0\right) \cdot -0.5}{\frac{\frac{cos2phi}{alphax}}{alphax} + \frac{\frac{sin2phi}{alphay}}{alphay}}
\end{array}
Initial program 64.1%
neg-sub064.1%
div-sub64.1%
--rgt-identity64.1%
div-sub64.1%
--rgt-identity64.1%
sub-neg64.1%
+-commutative64.1%
neg-sub064.1%
associate-+l-64.1%
sub0-neg64.1%
neg-mul-164.1%
log-prod-0.0%
associate--r+-0.0%
Simplified98.6%
associate-/r*98.6%
div-inv98.4%
Applied egg-rr98.4%
un-div-inv98.6%
Applied egg-rr98.6%
Taylor expanded in u0 around 0 87.3%
+-commutative87.3%
neg-mul-187.3%
unsub-neg87.3%
*-commutative87.3%
unpow287.3%
Simplified87.3%
Final simplification87.3%
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (/ u0 (+ (/ cos2phi (* alphax alphax)) (/ sin2phi (* alphay alphay)))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
return 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 = u0 / ((cos2phi / (alphax * alphax)) + (sin2phi / (alphay * alphay)))
end function
function code(alphax, alphay, u0, cos2phi, sin2phi) return Float32(u0 / Float32(Float32(cos2phi / Float32(alphax * alphax)) + Float32(sin2phi / Float32(alphay * alphay)))) end
function tmp = code(alphax, alphay, u0, cos2phi, sin2phi) tmp = u0 / ((cos2phi / (alphax * alphax)) + (sin2phi / (alphay * alphay))); end
\begin{array}{l}
\\
\frac{u0}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\end{array}
Initial program 64.1%
associate-/r*64.1%
Simplified64.1%
Taylor expanded in u0 around 0 74.6%
unpow274.6%
unpow274.6%
Simplified74.6%
Final simplification74.6%
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (if (<= sin2phi 1.0000000168623835e-16) (* alphax (/ u0 (/ cos2phi alphax))) (* (* alphay alphay) (/ u0 sin2phi))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
float tmp;
if (sin2phi <= 1.0000000168623835e-16f) {
tmp = alphax * (u0 / (cos2phi / alphax));
} else {
tmp = (alphay * alphay) * (u0 / sin2phi);
}
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) :: tmp
if (sin2phi <= 1.0000000168623835e-16) then
tmp = alphax * (u0 / (cos2phi / alphax))
else
tmp = (alphay * alphay) * (u0 / sin2phi)
end if
code = tmp
end function
function code(alphax, alphay, u0, cos2phi, sin2phi) tmp = Float32(0.0) if (sin2phi <= Float32(1.0000000168623835e-16)) tmp = Float32(alphax * Float32(u0 / Float32(cos2phi / alphax))); else tmp = Float32(Float32(alphay * alphay) * Float32(u0 / sin2phi)); end return tmp end
function tmp_2 = code(alphax, alphay, u0, cos2phi, sin2phi) tmp = single(0.0); if (sin2phi <= single(1.0000000168623835e-16)) tmp = alphax * (u0 / (cos2phi / alphax)); else tmp = (alphay * alphay) * (u0 / sin2phi); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;sin2phi \leq 1.0000000168623835 \cdot 10^{-16}:\\
\;\;\;\;alphax \cdot \frac{u0}{\frac{cos2phi}{alphax}}\\
\mathbf{else}:\\
\;\;\;\;\left(alphay \cdot alphay\right) \cdot \frac{u0}{sin2phi}\\
\end{array}
\end{array}
if sin2phi < 1.00000002e-16Initial program 60.3%
associate-/r*60.3%
Simplified60.3%
Taylor expanded in u0 around 0 70.5%
unpow270.5%
unpow270.5%
Simplified70.5%
Taylor expanded in cos2phi around inf 55.0%
unpow255.0%
associate-/l*55.0%
associate-/r/55.0%
Simplified55.0%
Taylor expanded in u0 around 0 55.0%
*-commutative55.0%
associate-*r/55.0%
unpow255.0%
associate-*l*55.0%
associate-*r/55.1%
Simplified55.1%
Taylor expanded in alphax around 0 55.1%
associate-/l*55.1%
Simplified55.1%
if 1.00000002e-16 < sin2phi Initial program 66.2%
associate-/r*66.2%
Simplified66.2%
Taylor expanded in u0 around 0 76.9%
unpow276.9%
unpow276.9%
Simplified76.9%
+-commutative76.9%
associate-/r*76.8%
associate-/r*76.8%
frac-add76.7%
Applied egg-rr76.7%
Taylor expanded in sin2phi around inf 73.9%
associate-/l*73.8%
associate-/r/73.8%
unpow273.8%
Simplified73.8%
Final simplification67.2%
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (if (<= sin2phi 1.0000000168623835e-16) (* alphax (/ u0 (/ cos2phi alphax))) (/ (* alphay (* u0 alphay)) sin2phi)))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
float tmp;
if (sin2phi <= 1.0000000168623835e-16f) {
tmp = alphax * (u0 / (cos2phi / alphax));
} else {
tmp = (alphay * (u0 * alphay)) / sin2phi;
}
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) :: tmp
if (sin2phi <= 1.0000000168623835e-16) then
tmp = alphax * (u0 / (cos2phi / alphax))
else
tmp = (alphay * (u0 * alphay)) / sin2phi
end if
code = tmp
end function
function code(alphax, alphay, u0, cos2phi, sin2phi) tmp = Float32(0.0) if (sin2phi <= Float32(1.0000000168623835e-16)) tmp = Float32(alphax * Float32(u0 / Float32(cos2phi / alphax))); else tmp = Float32(Float32(alphay * Float32(u0 * alphay)) / sin2phi); end return tmp end
function tmp_2 = code(alphax, alphay, u0, cos2phi, sin2phi) tmp = single(0.0); if (sin2phi <= single(1.0000000168623835e-16)) tmp = alphax * (u0 / (cos2phi / alphax)); else tmp = (alphay * (u0 * alphay)) / sin2phi; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;sin2phi \leq 1.0000000168623835 \cdot 10^{-16}:\\
\;\;\;\;alphax \cdot \frac{u0}{\frac{cos2phi}{alphax}}\\
\mathbf{else}:\\
\;\;\;\;\frac{alphay \cdot \left(u0 \cdot alphay\right)}{sin2phi}\\
\end{array}
\end{array}
if sin2phi < 1.00000002e-16Initial program 60.3%
associate-/r*60.3%
Simplified60.3%
Taylor expanded in u0 around 0 70.5%
unpow270.5%
unpow270.5%
Simplified70.5%
Taylor expanded in cos2phi around inf 55.0%
unpow255.0%
associate-/l*55.0%
associate-/r/55.0%
Simplified55.0%
Taylor expanded in u0 around 0 55.0%
*-commutative55.0%
associate-*r/55.0%
unpow255.0%
associate-*l*55.0%
associate-*r/55.1%
Simplified55.1%
Taylor expanded in alphax around 0 55.1%
associate-/l*55.1%
Simplified55.1%
if 1.00000002e-16 < sin2phi Initial program 66.2%
neg-sub066.2%
div-sub66.2%
--rgt-identity66.2%
div-sub66.2%
--rgt-identity66.2%
sub-neg66.2%
+-commutative66.2%
neg-sub066.2%
associate-+l-66.2%
sub0-neg66.2%
neg-mul-166.2%
log-prod-0.0%
associate--r+-0.0%
Simplified98.7%
div-inv98.7%
Applied egg-rr98.7%
div-inv98.6%
div-inv98.5%
+-commutative98.5%
associate-/r*98.6%
Applied egg-rr98.6%
Taylor expanded in sin2phi around inf 63.3%
associate-*r/63.3%
*-commutative63.3%
associate-*r*63.3%
neg-mul-163.3%
sub-neg63.3%
log1p-def93.7%
unpow293.7%
Simplified93.7%
Taylor expanded in u0 around 0 73.9%
*-commutative73.9%
unpow273.9%
associate-*l*73.9%
*-commutative73.9%
Simplified73.9%
Final simplification67.3%
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (* alphax (/ u0 (/ cos2phi alphax))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
return alphax * (u0 / (cos2phi / 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 / (cos2phi / alphax))
end function
function code(alphax, alphay, u0, cos2phi, sin2phi) return Float32(alphax * Float32(u0 / Float32(cos2phi / alphax))) end
function tmp = code(alphax, alphay, u0, cos2phi, sin2phi) tmp = alphax * (u0 / (cos2phi / alphax)); end
\begin{array}{l}
\\
alphax \cdot \frac{u0}{\frac{cos2phi}{alphax}}
\end{array}
Initial program 64.1%
associate-/r*64.1%
Simplified64.1%
Taylor expanded in u0 around 0 74.6%
unpow274.6%
unpow274.6%
Simplified74.6%
Taylor expanded in cos2phi around inf 25.8%
unpow225.8%
associate-/l*25.8%
associate-/r/25.8%
Simplified25.8%
Taylor expanded in u0 around 0 25.8%
*-commutative25.8%
associate-*r/25.8%
unpow225.8%
associate-*l*25.8%
associate-*r/25.8%
Simplified25.8%
Taylor expanded in alphax around 0 25.8%
associate-/l*25.8%
Simplified25.8%
Final simplification25.8%
herbie shell --seed 2023195
(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)))))