
(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 14 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)) (* alphay (- alphax))) (+ (/ sin2phi (/ alphay alphax)) (/ cos2phi (/ alphax alphay)))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
return (log1pf(-u0) * (alphay * -alphax)) / ((sin2phi / (alphay / alphax)) + (cos2phi / (alphax / alphay)));
}
function code(alphax, alphay, u0, cos2phi, sin2phi) return Float32(Float32(log1p(Float32(-u0)) * Float32(alphay * Float32(-alphax))) / Float32(Float32(sin2phi / Float32(alphay / alphax)) + Float32(cos2phi / Float32(alphax / alphay)))) end
\begin{array}{l}
\\
\frac{\mathsf{log1p}\left(-u0\right) \cdot \left(alphay \cdot \left(-alphax\right)\right)}{\frac{sin2phi}{\frac{alphay}{alphax}} + \frac{cos2phi}{\frac{alphax}{alphay}}}
\end{array}
Initial program 57.7%
neg-sub057.7%
div-sub57.7%
--rgt-identity57.7%
div-sub57.7%
--rgt-identity57.7%
neg-sub057.7%
sub-neg57.7%
log1p-def97.6%
Simplified97.6%
+-commutative97.6%
associate-/r*97.5%
associate-/r*97.6%
frac-add97.3%
Applied egg-rr97.3%
expm1-log1p-u95.7%
expm1-udef52.3%
associate-/r/52.3%
*-commutative52.3%
fma-def52.3%
*-commutative52.3%
Applied egg-rr52.3%
expm1-def96.9%
expm1-log1p98.4%
Simplified98.4%
Taylor expanded in alphax around 0 98.6%
associate-*l/98.4%
associate-/l*98.6%
associate-/l*98.7%
Applied egg-rr98.7%
Final simplification98.7%
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (* (* alphax alphay) (/ (- (log1p (- u0))) (+ (/ (* alphax sin2phi) alphay) (/ (* alphay cos2phi) alphax)))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
return (alphax * alphay) * (-log1pf(-u0) / (((alphax * sin2phi) / alphay) + ((alphay * cos2phi) / alphax)));
}
function code(alphax, alphay, u0, cos2phi, sin2phi) return Float32(Float32(alphax * alphay) * Float32(Float32(-log1p(Float32(-u0))) / Float32(Float32(Float32(alphax * sin2phi) / alphay) + Float32(Float32(alphay * cos2phi) / alphax)))) end
\begin{array}{l}
\\
\left(alphax \cdot alphay\right) \cdot \frac{-\mathsf{log1p}\left(-u0\right)}{\frac{alphax \cdot sin2phi}{alphay} + \frac{alphay \cdot cos2phi}{alphax}}
\end{array}
Initial program 57.7%
neg-sub057.7%
div-sub57.7%
--rgt-identity57.7%
div-sub57.7%
--rgt-identity57.7%
neg-sub057.7%
sub-neg57.7%
log1p-def97.6%
Simplified97.6%
+-commutative97.6%
associate-/r*97.5%
associate-/r*97.6%
frac-add97.3%
Applied egg-rr97.3%
expm1-log1p-u95.7%
expm1-udef52.3%
associate-/r/52.3%
*-commutative52.3%
fma-def52.3%
*-commutative52.3%
Applied egg-rr52.3%
expm1-def96.9%
expm1-log1p98.4%
Simplified98.4%
Taylor expanded in alphax around 0 98.6%
Final simplification98.6%
(FPCore (alphax alphay u0 cos2phi sin2phi)
:precision binary32
(if (<= (/ sin2phi (* alphay alphay)) 0.0012000000569969416)
(*
(* alphax alphay)
(/
(- u0 (* (* u0 u0) -0.5))
(+ (/ (* alphax sin2phi) alphay) (/ (* alphay cos2phi) alphax))))
(* (/ (log1p (- u0)) sin2phi) (* alphay (- alphay)))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
float tmp;
if ((sin2phi / (alphay * alphay)) <= 0.0012000000569969416f) {
tmp = (alphax * alphay) * ((u0 - ((u0 * u0) * -0.5f)) / (((alphax * sin2phi) / alphay) + ((alphay * cos2phi) / alphax)));
} else {
tmp = (log1pf(-u0) / sin2phi) * (alphay * -alphay);
}
return tmp;
}
function code(alphax, alphay, u0, cos2phi, sin2phi) tmp = Float32(0.0) if (Float32(sin2phi / Float32(alphay * alphay)) <= Float32(0.0012000000569969416)) tmp = Float32(Float32(alphax * alphay) * Float32(Float32(u0 - Float32(Float32(u0 * u0) * Float32(-0.5))) / Float32(Float32(Float32(alphax * sin2phi) / alphay) + Float32(Float32(alphay * cos2phi) / alphax)))); else tmp = Float32(Float32(log1p(Float32(-u0)) / sin2phi) * Float32(alphay * Float32(-alphay))); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{sin2phi}{alphay \cdot alphay} \leq 0.0012000000569969416:\\
\;\;\;\;\left(alphax \cdot alphay\right) \cdot \frac{u0 - \left(u0 \cdot u0\right) \cdot -0.5}{\frac{alphax \cdot sin2phi}{alphay} + \frac{alphay \cdot cos2phi}{alphax}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(-u0\right)}{sin2phi} \cdot \left(alphay \cdot \left(-alphay\right)\right)\\
\end{array}
\end{array}
if (/.f32 sin2phi (*.f32 alphay alphay)) < 0.00120000006Initial program 54.9%
neg-sub054.9%
div-sub54.9%
--rgt-identity54.9%
div-sub54.9%
--rgt-identity54.9%
neg-sub054.9%
sub-neg54.9%
log1p-def98.6%
Simplified98.6%
+-commutative98.6%
associate-/r*98.6%
associate-/r*98.8%
frac-add98.2%
Applied egg-rr98.2%
expm1-log1p-u94.7%
expm1-udef84.4%
associate-/r/84.4%
*-commutative84.4%
fma-def84.4%
*-commutative84.4%
Applied egg-rr84.4%
expm1-def94.9%
expm1-log1p98.4%
Simplified98.4%
Taylor expanded in alphax around 0 98.3%
Taylor expanded in u0 around 0 86.2%
neg-mul-137.8%
+-commutative37.8%
unsub-neg37.8%
*-commutative37.8%
unpow237.8%
Simplified86.2%
if 0.00120000006 < (/.f32 sin2phi (*.f32 alphay alphay)) Initial program 59.8%
associate-/r*59.8%
Simplified59.8%
Taylor expanded in cos2phi around 0 62.1%
mul-1-neg62.1%
unpow262.1%
*-commutative62.1%
Simplified62.1%
Taylor expanded in alphay around 0 62.1%
associate-/l*61.8%
sub-neg61.8%
log1p-def98.1%
associate-/l*98.7%
*-commutative98.7%
associate-*l/98.6%
*-commutative98.6%
unpow298.6%
Simplified98.6%
Final simplification93.1%
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (/ (- (log1p (- u0))) (+ (/ sin2phi (* alphay alphay)) (/ cos2phi (* alphax alphax)))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
return -log1pf(-u0) / ((sin2phi / (alphay * alphay)) + (cos2phi / (alphax * alphax)));
}
function code(alphax, alphay, u0, cos2phi, sin2phi) return Float32(Float32(-log1p(Float32(-u0))) / Float32(Float32(sin2phi / Float32(alphay * alphay)) + Float32(cos2phi / Float32(alphax * alphax)))) end
\begin{array}{l}
\\
\frac{-\mathsf{log1p}\left(-u0\right)}{\frac{sin2phi}{alphay \cdot alphay} + \frac{cos2phi}{alphax \cdot alphax}}
\end{array}
Initial program 57.7%
neg-sub057.7%
div-sub57.7%
--rgt-identity57.7%
div-sub57.7%
--rgt-identity57.7%
neg-sub057.7%
sub-neg57.7%
log1p-def97.6%
Simplified97.6%
Final simplification97.6%
(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(Float32(cos2phi / alphax) / 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 57.7%
neg-sub057.7%
div-sub57.7%
--rgt-identity57.7%
div-sub57.7%
--rgt-identity57.7%
sub-neg57.7%
+-commutative57.7%
neg-sub057.7%
associate-+l-57.7%
sub0-neg57.7%
neg-mul-157.7%
log-prod-0.0%
associate--r+-0.0%
Simplified97.6%
Final simplification97.6%
(FPCore (alphax alphay u0 cos2phi sin2phi)
:precision binary32
(let* ((t_0 (/ sin2phi (* alphay alphay))))
(if (<= t_0 0.00015999999595806003)
(* u0 (/ 1.0 (+ t_0 (/ cos2phi (* alphax alphax)))))
(-
(* (* alphay alphay) (/ u0 sin2phi))
(/ (* alphay (* alphay (* u0 u0))) (/ sin2phi -0.5))))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
float t_0 = sin2phi / (alphay * alphay);
float tmp;
if (t_0 <= 0.00015999999595806003f) {
tmp = u0 * (1.0f / (t_0 + (cos2phi / (alphax * alphax))));
} else {
tmp = ((alphay * alphay) * (u0 / sin2phi)) - ((alphay * (alphay * (u0 * u0))) / (sin2phi / -0.5f));
}
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 <= 0.00015999999595806003e0) then
tmp = u0 * (1.0e0 / (t_0 + (cos2phi / (alphax * alphax))))
else
tmp = ((alphay * alphay) * (u0 / sin2phi)) - ((alphay * (alphay * (u0 * u0))) / (sin2phi / (-0.5e0)))
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(0.00015999999595806003)) tmp = Float32(u0 * Float32(Float32(1.0) / Float32(t_0 + Float32(cos2phi / Float32(alphax * alphax))))); else tmp = Float32(Float32(Float32(alphay * alphay) * Float32(u0 / sin2phi)) - Float32(Float32(alphay * Float32(alphay * Float32(u0 * u0))) / Float32(sin2phi / Float32(-0.5)))); 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(0.00015999999595806003)) tmp = u0 * (single(1.0) / (t_0 + (cos2phi / (alphax * alphax)))); else tmp = ((alphay * alphay) * (u0 / sin2phi)) - ((alphay * (alphay * (u0 * u0))) / (sin2phi / single(-0.5))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{sin2phi}{alphay \cdot alphay}\\
\mathbf{if}\;t_0 \leq 0.00015999999595806003:\\
\;\;\;\;u0 \cdot \frac{1}{t_0 + \frac{cos2phi}{alphax \cdot alphax}}\\
\mathbf{else}:\\
\;\;\;\;\left(alphay \cdot alphay\right) \cdot \frac{u0}{sin2phi} - \frac{alphay \cdot \left(alphay \cdot \left(u0 \cdot u0\right)\right)}{\frac{sin2phi}{-0.5}}\\
\end{array}
\end{array}
if (/.f32 sin2phi (*.f32 alphay alphay)) < 1.59999996e-4Initial program 54.9%
associate-/r*54.9%
Simplified54.9%
Taylor expanded in u0 around 0 74.1%
unpow274.1%
unpow274.1%
Simplified74.1%
div-inv74.2%
+-commutative74.2%
Applied egg-rr74.2%
if 1.59999996e-4 < (/.f32 sin2phi (*.f32 alphay alphay)) Initial program 59.6%
associate-/r*59.6%
Simplified59.6%
Taylor expanded in cos2phi around 0 61.3%
mul-1-neg61.3%
unpow261.3%
*-commutative61.3%
Simplified61.3%
Taylor expanded in u0 around 0 88.0%
mul-1-neg88.0%
unsub-neg88.0%
associate-*r/88.0%
*-commutative88.0%
associate-/l*88.0%
*-commutative88.0%
unpow288.0%
associate-*l*88.0%
unpow288.0%
associate-/l*86.7%
associate-/r/88.1%
unpow288.1%
Simplified88.1%
Final simplification82.3%
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (* (* alphax alphay) (/ (- u0 (* (* u0 u0) -0.5)) (+ (/ (* alphax sin2phi) alphay) (/ (* alphay cos2phi) alphax)))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
return (alphax * alphay) * ((u0 - ((u0 * u0) * -0.5f)) / (((alphax * sin2phi) / alphay) + ((alphay * 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 * alphay) * ((u0 - ((u0 * u0) * (-0.5e0))) / (((alphax * sin2phi) / alphay) + ((alphay * cos2phi) / alphax)))
end function
function code(alphax, alphay, u0, cos2phi, sin2phi) return Float32(Float32(alphax * alphay) * Float32(Float32(u0 - Float32(Float32(u0 * u0) * Float32(-0.5))) / Float32(Float32(Float32(alphax * sin2phi) / alphay) + Float32(Float32(alphay * cos2phi) / alphax)))) end
function tmp = code(alphax, alphay, u0, cos2phi, sin2phi) tmp = (alphax * alphay) * ((u0 - ((u0 * u0) * single(-0.5))) / (((alphax * sin2phi) / alphay) + ((alphay * cos2phi) / alphax))); end
\begin{array}{l}
\\
\left(alphax \cdot alphay\right) \cdot \frac{u0 - \left(u0 \cdot u0\right) \cdot -0.5}{\frac{alphax \cdot sin2phi}{alphay} + \frac{alphay \cdot cos2phi}{alphax}}
\end{array}
Initial program 57.7%
neg-sub057.7%
div-sub57.7%
--rgt-identity57.7%
div-sub57.7%
--rgt-identity57.7%
neg-sub057.7%
sub-neg57.7%
log1p-def97.6%
Simplified97.6%
+-commutative97.6%
associate-/r*97.5%
associate-/r*97.6%
frac-add97.3%
Applied egg-rr97.3%
expm1-log1p-u95.7%
expm1-udef52.3%
associate-/r/52.3%
*-commutative52.3%
fma-def52.3%
*-commutative52.3%
Applied egg-rr52.3%
expm1-def96.9%
expm1-log1p98.4%
Simplified98.4%
Taylor expanded in alphax around 0 98.6%
Taylor expanded in u0 around 0 87.6%
neg-mul-166.0%
+-commutative66.0%
unsub-neg66.0%
*-commutative66.0%
unpow266.0%
Simplified87.6%
Final simplification87.6%
(FPCore (alphax alphay u0 cos2phi sin2phi)
:precision binary32
(let* ((t_0 (/ sin2phi (* alphay alphay))))
(if (<= t_0 0.00015999999595806003)
(* u0 (/ 1.0 (+ t_0 (/ cos2phi (* alphax alphax)))))
(/ (* (* 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 <= 0.00015999999595806003f) {
tmp = u0 * (1.0f / (t_0 + (cos2phi / (alphax * alphax))));
} 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 <= 0.00015999999595806003e0) then
tmp = u0 * (1.0e0 / (t_0 + (cos2phi / (alphax * alphax))))
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(0.00015999999595806003)) tmp = Float32(u0 * Float32(Float32(1.0) / Float32(t_0 + Float32(cos2phi / Float32(alphax * alphax))))); else tmp = Float32(Float32(Float32(alphay * alphay) * Float32(u0 - Float32(u0 * Float32(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(0.00015999999595806003)) tmp = u0 * (single(1.0) / (t_0 + (cos2phi / (alphax * alphax)))); 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 0.00015999999595806003:\\
\;\;\;\;u0 \cdot \frac{1}{t_0 + \frac{cos2phi}{alphax \cdot alphax}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(alphay \cdot alphay\right) \cdot \left(u0 - u0 \cdot \left(u0 \cdot -0.5\right)\right)}{sin2phi}\\
\end{array}
\end{array}
if (/.f32 sin2phi (*.f32 alphay alphay)) < 1.59999996e-4Initial program 54.9%
associate-/r*54.9%
Simplified54.9%
Taylor expanded in u0 around 0 74.1%
unpow274.1%
unpow274.1%
Simplified74.1%
div-inv74.2%
+-commutative74.2%
Applied egg-rr74.2%
if 1.59999996e-4 < (/.f32 sin2phi (*.f32 alphay alphay)) Initial program 59.6%
associate-/r*59.6%
Simplified59.6%
Taylor expanded in cos2phi around 0 61.3%
mul-1-neg61.3%
unpow261.3%
*-commutative61.3%
Simplified61.3%
div-inv61.3%
sub-neg61.3%
log1p-udef97.6%
Applied egg-rr97.6%
Taylor expanded in u0 around 0 87.9%
neg-mul-187.9%
+-commutative87.9%
unsub-neg87.9%
*-commutative87.9%
unpow287.9%
Simplified87.9%
un-div-inv88.1%
*-commutative88.1%
associate-*l*88.1%
Applied egg-rr88.1%
Final simplification82.3%
(FPCore (alphax alphay u0 cos2phi sin2phi)
:precision binary32
(let* ((t_0 (/ sin2phi (* alphay alphay))))
(if (<= t_0 0.00015999999595806003)
(/ u0 (+ (/ (/ cos2phi alphax) alphax) t_0))
(* (/ (* alphay alphay) sin2phi) (- u0 (* u0 (* u0 -0.5)))))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
float t_0 = sin2phi / (alphay * alphay);
float tmp;
if (t_0 <= 0.00015999999595806003f) {
tmp = u0 / (((cos2phi / alphax) / alphax) + t_0);
} else {
tmp = ((alphay * alphay) / sin2phi) * (u0 - (u0 * (u0 * -0.5f)));
}
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 <= 0.00015999999595806003e0) then
tmp = u0 / (((cos2phi / alphax) / alphax) + t_0)
else
tmp = ((alphay * alphay) / sin2phi) * (u0 - (u0 * (u0 * (-0.5e0))))
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(0.00015999999595806003)) tmp = Float32(u0 / Float32(Float32(Float32(cos2phi / alphax) / alphax) + t_0)); else tmp = Float32(Float32(Float32(alphay * alphay) / sin2phi) * Float32(u0 - Float32(u0 * Float32(u0 * Float32(-0.5))))); 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(0.00015999999595806003)) tmp = u0 / (((cos2phi / alphax) / alphax) + t_0); else tmp = ((alphay * alphay) / sin2phi) * (u0 - (u0 * (u0 * single(-0.5)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{sin2phi}{alphay \cdot alphay}\\
\mathbf{if}\;t_0 \leq 0.00015999999595806003:\\
\;\;\;\;\frac{u0}{\frac{\frac{cos2phi}{alphax}}{alphax} + t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{alphay \cdot alphay}{sin2phi} \cdot \left(u0 - u0 \cdot \left(u0 \cdot -0.5\right)\right)\\
\end{array}
\end{array}
if (/.f32 sin2phi (*.f32 alphay alphay)) < 1.59999996e-4Initial program 54.9%
associate-/r*54.9%
Simplified54.9%
Taylor expanded in u0 around 0 74.1%
unpow274.1%
unpow274.1%
Simplified74.1%
+-commutative74.1%
clear-num74.2%
frac-add74.0%
associate-/l*74.0%
div-inv74.0%
clear-num73.9%
*-commutative73.9%
*-un-lft-identity73.9%
associate-/l*73.8%
div-inv73.8%
clear-num74.0%
Applied egg-rr74.0%
Taylor expanded in sin2phi around 0 74.1%
unpow274.1%
associate-/r*74.1%
unpow274.1%
Simplified74.1%
if 1.59999996e-4 < (/.f32 sin2phi (*.f32 alphay alphay)) Initial program 59.6%
associate-/r*59.6%
Simplified59.6%
Taylor expanded in cos2phi around 0 61.3%
mul-1-neg61.3%
unpow261.3%
*-commutative61.3%
Simplified61.3%
div-inv61.3%
sub-neg61.3%
log1p-udef97.6%
Applied egg-rr97.6%
Taylor expanded in u0 around 0 87.9%
neg-mul-187.9%
+-commutative87.9%
unsub-neg87.9%
*-commutative87.9%
unpow287.9%
Simplified87.9%
Taylor expanded in alphay around 0 88.1%
associate-/l*87.6%
*-commutative87.6%
unpow287.6%
associate-*r*87.6%
associate-/r/88.0%
unpow288.0%
Simplified88.0%
Final simplification82.3%
(FPCore (alphax alphay u0 cos2phi sin2phi)
:precision binary32
(let* ((t_0 (/ sin2phi (* alphay alphay))))
(if (<= t_0 0.00015999999595806003)
(/ 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 <= 0.00015999999595806003f) {
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 <= 0.00015999999595806003e0) 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(0.00015999999595806003)) tmp = Float32(u0 / Float32(Float32(Float32(cos2phi / alphax) / alphax) + t_0)); else tmp = Float32(Float32(Float32(alphay * alphay) * Float32(u0 - Float32(u0 * Float32(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(0.00015999999595806003)) 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 0.00015999999595806003:\\
\;\;\;\;\frac{u0}{\frac{\frac{cos2phi}{alphax}}{alphax} + t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(alphay \cdot alphay\right) \cdot \left(u0 - u0 \cdot \left(u0 \cdot -0.5\right)\right)}{sin2phi}\\
\end{array}
\end{array}
if (/.f32 sin2phi (*.f32 alphay alphay)) < 1.59999996e-4Initial program 54.9%
associate-/r*54.9%
Simplified54.9%
Taylor expanded in u0 around 0 74.1%
unpow274.1%
unpow274.1%
Simplified74.1%
+-commutative74.1%
clear-num74.2%
frac-add74.0%
associate-/l*74.0%
div-inv74.0%
clear-num73.9%
*-commutative73.9%
*-un-lft-identity73.9%
associate-/l*73.8%
div-inv73.8%
clear-num74.0%
Applied egg-rr74.0%
Taylor expanded in sin2phi around 0 74.1%
unpow274.1%
associate-/r*74.1%
unpow274.1%
Simplified74.1%
if 1.59999996e-4 < (/.f32 sin2phi (*.f32 alphay alphay)) Initial program 59.6%
associate-/r*59.6%
Simplified59.6%
Taylor expanded in cos2phi around 0 61.3%
mul-1-neg61.3%
unpow261.3%
*-commutative61.3%
Simplified61.3%
div-inv61.3%
sub-neg61.3%
log1p-udef97.6%
Applied egg-rr97.6%
Taylor expanded in u0 around 0 87.9%
neg-mul-187.9%
+-commutative87.9%
unsub-neg87.9%
*-commutative87.9%
unpow287.9%
Simplified87.9%
un-div-inv88.1%
*-commutative88.1%
associate-*l*88.1%
Applied egg-rr88.1%
Final simplification82.3%
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (/ u0 (+ (/ sin2phi (* alphay alphay)) (/ cos2phi (* alphax alphax)))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
return u0 / ((sin2phi / (alphay * alphay)) + (cos2phi / (alphax * 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 = u0 / ((sin2phi / (alphay * alphay)) + (cos2phi / (alphax * alphax)))
end function
function code(alphax, alphay, u0, cos2phi, sin2phi) return Float32(u0 / Float32(Float32(sin2phi / Float32(alphay * alphay)) + Float32(cos2phi / Float32(alphax * alphax)))) end
function tmp = code(alphax, alphay, u0, cos2phi, sin2phi) tmp = u0 / ((sin2phi / (alphay * alphay)) + (cos2phi / (alphax * alphax))); end
\begin{array}{l}
\\
\frac{u0}{\frac{sin2phi}{alphay \cdot alphay} + \frac{cos2phi}{alphax \cdot alphax}}
\end{array}
Initial program 57.7%
associate-/r*57.7%
Simplified57.7%
Taylor expanded in u0 around 0 75.2%
unpow275.2%
unpow275.2%
Simplified75.2%
Final simplification75.2%
(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(Float32(cos2phi / 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{\frac{cos2phi}{alphax}}{alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\end{array}
Initial program 57.7%
associate-/r*57.7%
Simplified57.7%
Taylor expanded in u0 around 0 75.2%
unpow275.2%
unpow275.2%
Simplified75.2%
+-commutative75.2%
clear-num75.2%
frac-add68.1%
associate-/l*68.0%
div-inv68.0%
clear-num67.9%
*-commutative67.9%
*-un-lft-identity67.9%
associate-/l*67.9%
div-inv67.9%
clear-num68.1%
Applied egg-rr68.1%
Taylor expanded in sin2phi around 0 75.2%
unpow275.2%
associate-/r*75.2%
unpow275.2%
Simplified75.2%
Final simplification75.2%
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (if (<= sin2phi 9.999999998199587e-24) (* (* alphax alphax) (/ u0 cos2phi)) (* (* alphay alphay) (/ u0 sin2phi))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
float tmp;
if (sin2phi <= 9.999999998199587e-24f) {
tmp = (alphax * alphax) * (u0 / cos2phi);
} 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 <= 9.999999998199587e-24) then
tmp = (alphax * alphax) * (u0 / cos2phi)
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(9.999999998199587e-24)) tmp = Float32(Float32(alphax * alphax) * Float32(u0 / cos2phi)); 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(9.999999998199587e-24)) tmp = (alphax * alphax) * (u0 / cos2phi); else tmp = (alphay * alphay) * (u0 / sin2phi); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;sin2phi \leq 9.999999998199587 \cdot 10^{-24}:\\
\;\;\;\;\left(alphax \cdot alphax\right) \cdot \frac{u0}{cos2phi}\\
\mathbf{else}:\\
\;\;\;\;\left(alphay \cdot alphay\right) \cdot \frac{u0}{sin2phi}\\
\end{array}
\end{array}
if sin2phi < 1e-23Initial program 54.1%
associate-/r*54.0%
Simplified54.0%
Taylor expanded in u0 around 0 74.8%
unpow274.8%
unpow274.8%
Simplified74.8%
Taylor expanded in cos2phi around inf 62.3%
associate-/l*62.3%
associate-/r/62.3%
unpow262.3%
Simplified62.3%
if 1e-23 < sin2phi Initial program 58.8%
associate-/r*58.8%
Simplified58.8%
Taylor expanded in u0 around 0 75.3%
unpow275.3%
unpow275.3%
Simplified75.3%
Taylor expanded in cos2phi around 0 69.4%
associate-/l*68.7%
associate-/r/69.5%
unpow269.5%
Simplified69.5%
Final simplification67.8%
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (* (* alphax alphax) (/ u0 cos2phi)))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
return (alphax * alphax) * (u0 / cos2phi);
}
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 * alphax) * (u0 / cos2phi)
end function
function code(alphax, alphay, u0, cos2phi, sin2phi) return Float32(Float32(alphax * alphax) * Float32(u0 / cos2phi)) end
function tmp = code(alphax, alphay, u0, cos2phi, sin2phi) tmp = (alphax * alphax) * (u0 / cos2phi); end
\begin{array}{l}
\\
\left(alphax \cdot alphax\right) \cdot \frac{u0}{cos2phi}
\end{array}
Initial program 57.7%
associate-/r*57.7%
Simplified57.7%
Taylor expanded in u0 around 0 75.2%
unpow275.2%
unpow275.2%
Simplified75.2%
Taylor expanded in cos2phi around inf 24.6%
associate-/l*24.6%
associate-/r/24.7%
unpow224.7%
Simplified24.7%
Final simplification24.7%
herbie shell --seed 2023258
(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)))))