
(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 19 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
(*
(* alphax alphax)
(*
(* alphay alphay)
(/
(log1p (- u0))
(- (fma (* alphax alphax) sin2phi (* cos2phi (* alphay alphay))))))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
return (alphax * alphax) * ((alphay * alphay) * (log1pf(-u0) / -fmaf((alphax * alphax), sin2phi, (cos2phi * (alphay * alphay)))));
}
function code(alphax, alphay, u0, cos2phi, sin2phi) return Float32(Float32(alphax * alphax) * Float32(Float32(alphay * alphay) * Float32(log1p(Float32(-u0)) / Float32(-fma(Float32(alphax * alphax), sin2phi, Float32(cos2phi * Float32(alphay * alphay))))))) end
\begin{array}{l}
\\
\left(alphax \cdot alphax\right) \cdot \left(\left(alphay \cdot alphay\right) \cdot \frac{\mathsf{log1p}\left(-u0\right)}{-\mathsf{fma}\left(alphax \cdot alphax, sin2phi, cos2phi \cdot \left(alphay \cdot alphay\right)\right)}\right)
\end{array}
Initial program 60.6%
lift-/.f32N/A
lift-+.f32N/A
lift-/.f32N/A
lift-/.f32N/A
frac-addN/A
associate-/r/N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
Applied rewrites98.5%
Final simplification98.5%
(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 60.6%
lift-log.f32N/A
lift--.f32N/A
sub-negN/A
lower-log1p.f32N/A
lower-neg.f3298.3
Applied rewrites98.3%
Final simplification98.3%
(FPCore (alphax alphay u0 cos2phi sin2phi)
:precision binary32
(let* ((t_0 (/ sin2phi (* alphay alphay))))
(if (<= t_0 5.00000006675716e-11)
(/ u0 (fma (/ cos2phi alphax) (/ 1.0 alphax) t_0))
(/
(fma (* u0 u0) (fma u0 (fma u0 0.25 0.3333333333333333) 0.5) u0)
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 <= 5.00000006675716e-11f) {
tmp = u0 / fmaf((cos2phi / alphax), (1.0f / alphax), t_0);
} else {
tmp = fmaf((u0 * u0), fmaf(u0, fmaf(u0, 0.25f, 0.3333333333333333f), 0.5f), u0) / 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(5.00000006675716e-11)) tmp = Float32(u0 / fma(Float32(cos2phi / alphax), Float32(Float32(1.0) / alphax), t_0)); else tmp = Float32(fma(Float32(u0 * u0), fma(u0, fma(u0, Float32(0.25), Float32(0.3333333333333333)), Float32(0.5)), u0) / t_0); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{sin2phi}{alphay \cdot alphay}\\
\mathbf{if}\;t\_0 \leq 5.00000006675716 \cdot 10^{-11}:\\
\;\;\;\;\frac{u0}{\mathsf{fma}\left(\frac{cos2phi}{alphax}, \frac{1}{alphax}, t\_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(u0 \cdot u0, \mathsf{fma}\left(u0, \mathsf{fma}\left(u0, 0.25, 0.3333333333333333\right), 0.5\right), u0\right)}{t\_0}\\
\end{array}
\end{array}
if (/.f32 sin2phi (*.f32 alphay alphay)) < 5.00000007e-11Initial program 57.7%
Taylor expanded in u0 around 0
lower-/.f32N/A
lower-+.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f3273.3
Applied rewrites73.3%
Applied rewrites73.3%
if 5.00000007e-11 < (/.f32 sin2phi (*.f32 alphay alphay)) Initial program 62.1%
Taylor expanded in u0 around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
unpow2N/A
*-rgt-identityN/A
lower-fma.f32N/A
unpow2N/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f3293.2
Applied rewrites93.2%
Taylor expanded in cos2phi around 0
lower-/.f32N/A
unpow2N/A
lower-*.f3289.0
Applied rewrites89.0%
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (/ (fma (* u0 u0) (fma u0 (fma u0 0.25 0.3333333333333333) 0.5) u0) (+ (/ cos2phi (* alphax alphax)) (/ (/ sin2phi alphay) alphay))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
return fmaf((u0 * u0), fmaf(u0, fmaf(u0, 0.25f, 0.3333333333333333f), 0.5f), u0) / ((cos2phi / (alphax * alphax)) + ((sin2phi / alphay) / alphay));
}
function code(alphax, alphay, u0, cos2phi, sin2phi) return Float32(fma(Float32(u0 * u0), fma(u0, fma(u0, Float32(0.25), Float32(0.3333333333333333)), Float32(0.5)), u0) / Float32(Float32(cos2phi / Float32(alphax * alphax)) + Float32(Float32(sin2phi / alphay) / alphay))) end
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(u0 \cdot u0, \mathsf{fma}\left(u0, \mathsf{fma}\left(u0, 0.25, 0.3333333333333333\right), 0.5\right), u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{\frac{sin2phi}{alphay}}{alphay}}
\end{array}
Initial program 60.6%
Taylor expanded in u0 around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
unpow2N/A
*-rgt-identityN/A
lower-fma.f32N/A
unpow2N/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f3293.2
Applied rewrites93.2%
lift-/.f32N/A
lift-*.f32N/A
associate-/r*N/A
lower-/.f32N/A
lower-/.f3293.2
Applied rewrites93.2%
(FPCore (alphax alphay u0 cos2phi sin2phi)
:precision binary32
(*
(*
alphax
(/
(fma u0 (* u0 (fma u0 (fma u0 0.25 0.3333333333333333) 0.5)) u0)
(fma cos2phi (* alphay alphay) (* alphax (* alphax sin2phi)))))
(* alphax (* alphay alphay))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
return (alphax * (fmaf(u0, (u0 * fmaf(u0, fmaf(u0, 0.25f, 0.3333333333333333f), 0.5f)), u0) / fmaf(cos2phi, (alphay * alphay), (alphax * (alphax * sin2phi))))) * (alphax * (alphay * alphay));
}
function code(alphax, alphay, u0, cos2phi, sin2phi) return Float32(Float32(alphax * Float32(fma(u0, Float32(u0 * fma(u0, fma(u0, Float32(0.25), Float32(0.3333333333333333)), Float32(0.5))), u0) / fma(cos2phi, Float32(alphay * alphay), Float32(alphax * Float32(alphax * sin2phi))))) * Float32(alphax * Float32(alphay * alphay))) end
\begin{array}{l}
\\
\left(alphax \cdot \frac{\mathsf{fma}\left(u0, u0 \cdot \mathsf{fma}\left(u0, \mathsf{fma}\left(u0, 0.25, 0.3333333333333333\right), 0.5\right), u0\right)}{\mathsf{fma}\left(cos2phi, alphay \cdot alphay, alphax \cdot \left(alphax \cdot sin2phi\right)\right)}\right) \cdot \left(alphax \cdot \left(alphay \cdot alphay\right)\right)
\end{array}
Initial program 60.6%
Taylor expanded in u0 around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
unpow2N/A
*-rgt-identityN/A
lower-fma.f32N/A
unpow2N/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f3293.2
Applied rewrites93.2%
lift-/.f32N/A
lift-+.f32N/A
lift-/.f32N/A
lift-/.f32N/A
frac-addN/A
lift-*.f32N/A
+-commutativeN/A
lift-fma.f32N/A
lift-*.f32N/A
associate-*r*N/A
lift-*.f32N/A
lift-*.f32N/A
associate-/r/N/A
lower-*.f32N/A
Applied rewrites93.0%
lift-*.f32N/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lift-*.f32N/A
associate-*r*N/A
lift-*.f32N/A
associate-*r*N/A
lower-*.f32N/A
Applied rewrites93.2%
Final simplification93.2%
(FPCore (alphax alphay u0 cos2phi sin2phi)
:precision binary32
(let* ((t_0 (/ sin2phi (* alphay alphay))))
(if (<= t_0 5.00000006675716e-11)
(/ u0 (+ (/ cos2phi (* alphax alphax)) (/ (/ sin2phi alphay) alphay)))
(/
(fma (* u0 u0) (fma u0 (fma u0 0.25 0.3333333333333333) 0.5) u0)
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 <= 5.00000006675716e-11f) {
tmp = u0 / ((cos2phi / (alphax * alphax)) + ((sin2phi / alphay) / alphay));
} else {
tmp = fmaf((u0 * u0), fmaf(u0, fmaf(u0, 0.25f, 0.3333333333333333f), 0.5f), u0) / 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(5.00000006675716e-11)) tmp = Float32(u0 / Float32(Float32(cos2phi / Float32(alphax * alphax)) + Float32(Float32(sin2phi / alphay) / alphay))); else tmp = Float32(fma(Float32(u0 * u0), fma(u0, fma(u0, Float32(0.25), Float32(0.3333333333333333)), Float32(0.5)), u0) / t_0); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{sin2phi}{alphay \cdot alphay}\\
\mathbf{if}\;t\_0 \leq 5.00000006675716 \cdot 10^{-11}:\\
\;\;\;\;\frac{u0}{\frac{cos2phi}{alphax \cdot alphax} + \frac{\frac{sin2phi}{alphay}}{alphay}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(u0 \cdot u0, \mathsf{fma}\left(u0, \mathsf{fma}\left(u0, 0.25, 0.3333333333333333\right), 0.5\right), u0\right)}{t\_0}\\
\end{array}
\end{array}
if (/.f32 sin2phi (*.f32 alphay alphay)) < 5.00000007e-11Initial program 57.7%
Taylor expanded in u0 around 0
lower-/.f32N/A
lower-+.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f3273.3
Applied rewrites73.3%
Applied rewrites73.3%
if 5.00000007e-11 < (/.f32 sin2phi (*.f32 alphay alphay)) Initial program 62.1%
Taylor expanded in u0 around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
unpow2N/A
*-rgt-identityN/A
lower-fma.f32N/A
unpow2N/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f3293.2
Applied rewrites93.2%
Taylor expanded in cos2phi around 0
lower-/.f32N/A
unpow2N/A
lower-*.f3289.0
Applied rewrites89.0%
(FPCore (alphax alphay u0 cos2phi sin2phi)
:precision binary32
(let* ((t_0 (/ sin2phi (* alphay alphay))))
(if (<= t_0 5.00000006675716e-11)
(/ u0 (+ (/ cos2phi (* alphax alphax)) t_0))
(/
(fma (* u0 u0) (fma u0 (fma u0 0.25 0.3333333333333333) 0.5) u0)
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 <= 5.00000006675716e-11f) {
tmp = u0 / ((cos2phi / (alphax * alphax)) + t_0);
} else {
tmp = fmaf((u0 * u0), fmaf(u0, fmaf(u0, 0.25f, 0.3333333333333333f), 0.5f), u0) / 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(5.00000006675716e-11)) tmp = Float32(u0 / Float32(Float32(cos2phi / Float32(alphax * alphax)) + t_0)); else tmp = Float32(fma(Float32(u0 * u0), fma(u0, fma(u0, Float32(0.25), Float32(0.3333333333333333)), Float32(0.5)), u0) / t_0); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{sin2phi}{alphay \cdot alphay}\\
\mathbf{if}\;t\_0 \leq 5.00000006675716 \cdot 10^{-11}:\\
\;\;\;\;\frac{u0}{\frac{cos2phi}{alphax \cdot alphax} + t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(u0 \cdot u0, \mathsf{fma}\left(u0, \mathsf{fma}\left(u0, 0.25, 0.3333333333333333\right), 0.5\right), u0\right)}{t\_0}\\
\end{array}
\end{array}
if (/.f32 sin2phi (*.f32 alphay alphay)) < 5.00000007e-11Initial program 57.7%
Taylor expanded in u0 around 0
lower-/.f32N/A
lower-+.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f3273.3
Applied rewrites73.3%
if 5.00000007e-11 < (/.f32 sin2phi (*.f32 alphay alphay)) Initial program 62.1%
Taylor expanded in u0 around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
unpow2N/A
*-rgt-identityN/A
lower-fma.f32N/A
unpow2N/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f3293.2
Applied rewrites93.2%
Taylor expanded in cos2phi around 0
lower-/.f32N/A
unpow2N/A
lower-*.f3289.0
Applied rewrites89.0%
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (/ (fma (* u0 u0) (fma u0 (fma u0 0.25 0.3333333333333333) 0.5) u0) (+ (/ cos2phi (* alphax alphax)) (/ sin2phi (* alphay alphay)))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
return fmaf((u0 * u0), fmaf(u0, fmaf(u0, 0.25f, 0.3333333333333333f), 0.5f), u0) / ((cos2phi / (alphax * alphax)) + (sin2phi / (alphay * alphay)));
}
function code(alphax, alphay, u0, cos2phi, sin2phi) return Float32(fma(Float32(u0 * u0), fma(u0, fma(u0, Float32(0.25), Float32(0.3333333333333333)), Float32(0.5)), u0) / Float32(Float32(cos2phi / Float32(alphax * alphax)) + Float32(sin2phi / Float32(alphay * alphay)))) end
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(u0 \cdot u0, \mathsf{fma}\left(u0, \mathsf{fma}\left(u0, 0.25, 0.3333333333333333\right), 0.5\right), u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\end{array}
Initial program 60.6%
Taylor expanded in u0 around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
unpow2N/A
*-rgt-identityN/A
lower-fma.f32N/A
unpow2N/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f3293.2
Applied rewrites93.2%
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (/ (fma (* u0 u0) (fma u0 0.3333333333333333 0.5) u0) (+ (/ sin2phi (* alphay alphay)) (/ (/ cos2phi alphax) alphax))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
return fmaf((u0 * u0), fmaf(u0, 0.3333333333333333f, 0.5f), u0) / ((sin2phi / (alphay * alphay)) + ((cos2phi / alphax) / alphax));
}
function code(alphax, alphay, u0, cos2phi, sin2phi) return Float32(fma(Float32(u0 * u0), fma(u0, Float32(0.3333333333333333), Float32(0.5)), u0) / Float32(Float32(sin2phi / Float32(alphay * alphay)) + Float32(Float32(cos2phi / alphax) / alphax))) end
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(u0 \cdot u0, \mathsf{fma}\left(u0, 0.3333333333333333, 0.5\right), u0\right)}{\frac{sin2phi}{alphay \cdot alphay} + \frac{\frac{cos2phi}{alphax}}{alphax}}
\end{array}
Initial program 60.6%
lift-log.f32N/A
lift--.f32N/A
sub-negN/A
lower-log1p.f32N/A
lower-neg.f3298.3
Applied rewrites98.3%
lift-/.f32N/A
lift-*.f32N/A
associate-/r*N/A
lower-/.f32N/A
lower-/.f3298.3
Applied rewrites98.3%
Taylor expanded in u0 around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
unpow2N/A
*-rgt-identityN/A
lower-fma.f32N/A
unpow2N/A
lower-*.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f3291.0
Applied rewrites91.0%
Final simplification91.0%
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (/ (fma (* u0 u0) (fma u0 0.3333333333333333 0.5) u0) (+ (/ cos2phi (* alphax alphax)) (/ sin2phi (* alphay alphay)))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
return fmaf((u0 * u0), fmaf(u0, 0.3333333333333333f, 0.5f), u0) / ((cos2phi / (alphax * alphax)) + (sin2phi / (alphay * alphay)));
}
function code(alphax, alphay, u0, cos2phi, sin2phi) return Float32(fma(Float32(u0 * u0), fma(u0, Float32(0.3333333333333333), Float32(0.5)), u0) / Float32(Float32(cos2phi / Float32(alphax * alphax)) + Float32(sin2phi / Float32(alphay * alphay)))) end
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(u0 \cdot u0, \mathsf{fma}\left(u0, 0.3333333333333333, 0.5\right), u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\end{array}
Initial program 60.6%
Taylor expanded in u0 around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
unpow2N/A
*-rgt-identityN/A
lower-fma.f32N/A
unpow2N/A
lower-*.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f3291.0
Applied rewrites91.0%
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (/ (fma u0 (* u0 0.5) u0) (+ (/ cos2phi (* alphax alphax)) (/ sin2phi (* alphay alphay)))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
return fmaf(u0, (u0 * 0.5f), u0) / ((cos2phi / (alphax * alphax)) + (sin2phi / (alphay * alphay)));
}
function code(alphax, alphay, u0, cos2phi, sin2phi) return Float32(fma(u0, Float32(u0 * Float32(0.5)), u0) / Float32(Float32(cos2phi / Float32(alphax * alphax)) + Float32(sin2phi / Float32(alphay * alphay)))) end
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(u0, u0 \cdot 0.5, u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\end{array}
Initial program 60.6%
Taylor expanded in u0 around 0
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f3287.0
Applied rewrites87.0%
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (* (fma u0 0.5 1.0) (/ u0 (+ (/ cos2phi (* alphax alphax)) (/ sin2phi (* alphay alphay))))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
return fmaf(u0, 0.5f, 1.0f) * (u0 / ((cos2phi / (alphax * alphax)) + (sin2phi / (alphay * alphay))));
}
function code(alphax, alphay, u0, cos2phi, sin2phi) return Float32(fma(u0, Float32(0.5), Float32(1.0)) * Float32(u0 / Float32(Float32(cos2phi / Float32(alphax * alphax)) + Float32(sin2phi / Float32(alphay * alphay))))) end
\begin{array}{l}
\\
\mathsf{fma}\left(u0, 0.5, 1\right) \cdot \frac{u0}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\end{array}
Initial program 60.6%
Taylor expanded in u0 around 0
distribute-lft-inN/A
associate-*r*N/A
*-commutativeN/A
associate-*r/N/A
*-rgt-identityN/A
distribute-lft1-inN/A
+-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
lower-/.f32N/A
lower-+.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f32N/A
lower-/.f32N/A
Applied rewrites86.9%
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (if (<= (/ sin2phi (* alphay alphay)) 1.600000073301928e-17) (* (/ 1.0 cos2phi) (* u0 (* alphax alphax))) (/ (* u0 (* alphay alphay)) sin2phi)))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
float tmp;
if ((sin2phi / (alphay * alphay)) <= 1.600000073301928e-17f) {
tmp = (1.0f / cos2phi) * (u0 * (alphax * alphax));
} else {
tmp = (u0 * (alphay * 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 / (alphay * alphay)) <= 1.600000073301928e-17) then
tmp = (1.0e0 / cos2phi) * (u0 * (alphax * alphax))
else
tmp = (u0 * (alphay * alphay)) / 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.600000073301928e-17)) tmp = Float32(Float32(Float32(1.0) / cos2phi) * Float32(u0 * Float32(alphax * alphax))); else tmp = Float32(Float32(u0 * Float32(alphay * alphay)) / sin2phi); end return tmp end
function tmp_2 = code(alphax, alphay, u0, cos2phi, sin2phi) tmp = single(0.0); if ((sin2phi / (alphay * alphay)) <= single(1.600000073301928e-17)) tmp = (single(1.0) / cos2phi) * (u0 * (alphax * alphax)); else tmp = (u0 * (alphay * alphay)) / sin2phi; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{sin2phi}{alphay \cdot alphay} \leq 1.600000073301928 \cdot 10^{-17}:\\
\;\;\;\;\frac{1}{cos2phi} \cdot \left(u0 \cdot \left(alphax \cdot alphax\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{u0 \cdot \left(alphay \cdot alphay\right)}{sin2phi}\\
\end{array}
\end{array}
if (/.f32 sin2phi (*.f32 alphay alphay)) < 1.60000007e-17Initial program 60.9%
Taylor expanded in u0 around 0
lower-/.f32N/A
lower-+.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f3271.8
Applied rewrites71.8%
Taylor expanded in cos2phi around inf
Applied rewrites57.2%
Applied rewrites57.3%
if 1.60000007e-17 < (/.f32 sin2phi (*.f32 alphay alphay)) Initial program 60.5%
Taylor expanded in u0 around 0
lower-/.f32N/A
lower-+.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f3274.9
Applied rewrites74.9%
Taylor expanded in cos2phi around 0
Applied rewrites71.3%
Final simplification67.7%
(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 60.6%
Taylor expanded in u0 around 0
lower-/.f32N/A
lower-+.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f3274.1
Applied rewrites74.1%
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (if (<= (/ sin2phi (* alphay alphay)) 1.600000073301928e-17) (/ (* u0 (* alphax alphax)) cos2phi) (/ (* u0 (* alphay alphay)) sin2phi)))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
float tmp;
if ((sin2phi / (alphay * alphay)) <= 1.600000073301928e-17f) {
tmp = (u0 * (alphax * alphax)) / cos2phi;
} else {
tmp = (u0 * (alphay * 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 / (alphay * alphay)) <= 1.600000073301928e-17) then
tmp = (u0 * (alphax * alphax)) / cos2phi
else
tmp = (u0 * (alphay * alphay)) / 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.600000073301928e-17)) tmp = Float32(Float32(u0 * Float32(alphax * alphax)) / cos2phi); else tmp = Float32(Float32(u0 * Float32(alphay * alphay)) / sin2phi); end return tmp end
function tmp_2 = code(alphax, alphay, u0, cos2phi, sin2phi) tmp = single(0.0); if ((sin2phi / (alphay * alphay)) <= single(1.600000073301928e-17)) tmp = (u0 * (alphax * alphax)) / cos2phi; else tmp = (u0 * (alphay * alphay)) / sin2phi; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{sin2phi}{alphay \cdot alphay} \leq 1.600000073301928 \cdot 10^{-17}:\\
\;\;\;\;\frac{u0 \cdot \left(alphax \cdot alphax\right)}{cos2phi}\\
\mathbf{else}:\\
\;\;\;\;\frac{u0 \cdot \left(alphay \cdot alphay\right)}{sin2phi}\\
\end{array}
\end{array}
if (/.f32 sin2phi (*.f32 alphay alphay)) < 1.60000007e-17Initial program 60.9%
Taylor expanded in u0 around 0
lower-/.f32N/A
lower-+.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f3271.8
Applied rewrites71.8%
Taylor expanded in cos2phi around inf
Applied rewrites57.2%
if 1.60000007e-17 < (/.f32 sin2phi (*.f32 alphay alphay)) Initial program 60.5%
Taylor expanded in u0 around 0
lower-/.f32N/A
lower-+.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f3274.9
Applied rewrites74.9%
Taylor expanded in cos2phi around 0
Applied rewrites71.3%
Final simplification67.7%
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (/ (* u0 (* alphax alphax)) cos2phi))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
return (u0 * (alphax * alphax)) / 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 = (u0 * (alphax * alphax)) / cos2phi
end function
function code(alphax, alphay, u0, cos2phi, sin2phi) return Float32(Float32(u0 * Float32(alphax * alphax)) / cos2phi) end
function tmp = code(alphax, alphay, u0, cos2phi, sin2phi) tmp = (u0 * (alphax * alphax)) / cos2phi; end
\begin{array}{l}
\\
\frac{u0 \cdot \left(alphax \cdot alphax\right)}{cos2phi}
\end{array}
Initial program 60.6%
Taylor expanded in u0 around 0
lower-/.f32N/A
lower-+.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f3274.1
Applied rewrites74.1%
Taylor expanded in cos2phi around inf
Applied rewrites23.1%
Final simplification23.1%
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (* u0 (/ (* alphax alphax) cos2phi)))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
return u0 * ((alphax * alphax) / 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 = u0 * ((alphax * alphax) / cos2phi)
end function
function code(alphax, alphay, u0, cos2phi, sin2phi) return Float32(u0 * Float32(Float32(alphax * alphax) / cos2phi)) end
function tmp = code(alphax, alphay, u0, cos2phi, sin2phi) tmp = u0 * ((alphax * alphax) / cos2phi); end
\begin{array}{l}
\\
u0 \cdot \frac{alphax \cdot alphax}{cos2phi}
\end{array}
Initial program 60.6%
Taylor expanded in u0 around 0
lower-/.f32N/A
lower-+.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f3274.1
Applied rewrites74.1%
Taylor expanded in cos2phi around inf
Applied rewrites23.1%
Applied rewrites23.1%
(FPCore (alphax alphay u0 cos2phi sin2phi) :precision binary32 (* alphax (/ (* u0 alphax) cos2phi)))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
return alphax * ((u0 * alphax) / 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 * ((u0 * alphax) / cos2phi)
end function
function code(alphax, alphay, u0, cos2phi, sin2phi) return Float32(alphax * Float32(Float32(u0 * alphax) / cos2phi)) end
function tmp = code(alphax, alphay, u0, cos2phi, sin2phi) tmp = alphax * ((u0 * alphax) / cos2phi); end
\begin{array}{l}
\\
alphax \cdot \frac{u0 \cdot alphax}{cos2phi}
\end{array}
Initial program 60.6%
Taylor expanded in u0 around 0
lower-/.f32N/A
lower-+.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f3274.1
Applied rewrites74.1%
Taylor expanded in cos2phi around inf
Applied rewrites23.1%
Applied rewrites23.1%
Final simplification23.1%
(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(alphax * Float32(alphax * Float32(u0 / cos2phi))) end
function tmp = code(alphax, alphay, u0, cos2phi, sin2phi) tmp = alphax * (alphax * (u0 / cos2phi)); end
\begin{array}{l}
\\
alphax \cdot \left(alphax \cdot \frac{u0}{cos2phi}\right)
\end{array}
Initial program 60.6%
Taylor expanded in u0 around 0
lower-/.f32N/A
lower-+.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f3274.1
Applied rewrites74.1%
Taylor expanded in cos2phi around inf
Applied rewrites23.1%
Applied rewrites23.1%
herbie shell --seed 2024234
(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)))))