
(FPCore (alpha u0) :precision binary32 (* (* (- alpha) alpha) (log (- 1.0 u0))))
float code(float alpha, float u0) {
return (-alpha * alpha) * logf((1.0f - u0));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(alpha, u0)
use fmin_fmax_functions
real(4), intent (in) :: alpha
real(4), intent (in) :: u0
code = (-alpha * alpha) * log((1.0e0 - u0))
end function
function code(alpha, u0) return Float32(Float32(Float32(-alpha) * alpha) * log(Float32(Float32(1.0) - u0))) end
function tmp = code(alpha, u0) tmp = (-alpha * alpha) * log((single(1.0) - u0)); end
\begin{array}{l}
\\
\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right)
\end{array}
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (alpha u0) :precision binary32 (* (* (- alpha) alpha) (log (- 1.0 u0))))
float code(float alpha, float u0) {
return (-alpha * alpha) * logf((1.0f - u0));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(alpha, u0)
use fmin_fmax_functions
real(4), intent (in) :: alpha
real(4), intent (in) :: u0
code = (-alpha * alpha) * log((1.0e0 - u0))
end function
function code(alpha, u0) return Float32(Float32(Float32(-alpha) * alpha) * log(Float32(Float32(1.0) - u0))) end
function tmp = code(alpha, u0) tmp = (-alpha * alpha) * log((single(1.0) - u0)); end
\begin{array}{l}
\\
\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right)
\end{array}
(FPCore (alpha u0) :precision binary32 (* (* (- alpha) alpha) (log1p (- u0))))
float code(float alpha, float u0) {
return (-alpha * alpha) * log1pf(-u0);
}
function code(alpha, u0) return Float32(Float32(Float32(-alpha) * alpha) * log1p(Float32(-u0))) end
\begin{array}{l}
\\
\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \mathsf{log1p}\left(-u0\right)
\end{array}
Initial program 55.5%
lift--.f32N/A
lift-log.f32N/A
*-lft-identityN/A
cancel-sign-sub-invN/A
metadata-evalN/A
mul-1-negN/A
lower-log1p.f32N/A
lower-neg.f3299.0
Applied rewrites99.0%
(FPCore (alpha u0)
:precision binary32
(let* ((t_0 (log (- 1.0 u0))))
(if (<= t_0 -0.0031999999191612005)
(* (* (- alpha) alpha) t_0)
(* (fma alpha alpha (* (* (* alpha alpha) 0.5) u0)) u0))))
float code(float alpha, float u0) {
float t_0 = logf((1.0f - u0));
float tmp;
if (t_0 <= -0.0031999999191612005f) {
tmp = (-alpha * alpha) * t_0;
} else {
tmp = fmaf(alpha, alpha, (((alpha * alpha) * 0.5f) * u0)) * u0;
}
return tmp;
}
function code(alpha, u0) t_0 = log(Float32(Float32(1.0) - u0)) tmp = Float32(0.0) if (t_0 <= Float32(-0.0031999999191612005)) tmp = Float32(Float32(Float32(-alpha) * alpha) * t_0); else tmp = Float32(fma(alpha, alpha, Float32(Float32(Float32(alpha * alpha) * Float32(0.5)) * u0)) * u0); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(1 - u0\right)\\
\mathbf{if}\;t\_0 \leq -0.0031999999191612005:\\
\;\;\;\;\left(\left(-\alpha\right) \cdot \alpha\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\alpha, \alpha, \left(\left(\alpha \cdot \alpha\right) \cdot 0.5\right) \cdot u0\right) \cdot u0\\
\end{array}
\end{array}
if (log.f32 (-.f32 #s(literal 1 binary32) u0)) < -0.00319999992Initial program 93.0%
if -0.00319999992 < (log.f32 (-.f32 #s(literal 1 binary32) u0)) Initial program 42.9%
Taylor expanded in u0 around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites99.2%
Taylor expanded in u0 around 0
*-commutativeN/A
lower-*.f32N/A
pow2N/A
lift-*.f3298.2
Applied rewrites98.2%
(FPCore (alpha u0)
:precision binary32
(let* ((t_0 (log (- 1.0 u0))))
(if (<= t_0 -0.0031999999191612005)
(* (* (- alpha) alpha) t_0)
(- (* (* (- (* (* alpha u0) -0.5) alpha) u0) alpha)))))
float code(float alpha, float u0) {
float t_0 = logf((1.0f - u0));
float tmp;
if (t_0 <= -0.0031999999191612005f) {
tmp = (-alpha * alpha) * t_0;
} else {
tmp = -(((((alpha * u0) * -0.5f) - alpha) * u0) * alpha);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(alpha, u0)
use fmin_fmax_functions
real(4), intent (in) :: alpha
real(4), intent (in) :: u0
real(4) :: t_0
real(4) :: tmp
t_0 = log((1.0e0 - u0))
if (t_0 <= (-0.0031999999191612005e0)) then
tmp = (-alpha * alpha) * t_0
else
tmp = -(((((alpha * u0) * (-0.5e0)) - alpha) * u0) * alpha)
end if
code = tmp
end function
function code(alpha, u0) t_0 = log(Float32(Float32(1.0) - u0)) tmp = Float32(0.0) if (t_0 <= Float32(-0.0031999999191612005)) tmp = Float32(Float32(Float32(-alpha) * alpha) * t_0); else tmp = Float32(-Float32(Float32(Float32(Float32(Float32(alpha * u0) * Float32(-0.5)) - alpha) * u0) * alpha)); end return tmp end
function tmp_2 = code(alpha, u0) t_0 = log((single(1.0) - u0)); tmp = single(0.0); if (t_0 <= single(-0.0031999999191612005)) tmp = (-alpha * alpha) * t_0; else tmp = -(((((alpha * u0) * single(-0.5)) - alpha) * u0) * alpha); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(1 - u0\right)\\
\mathbf{if}\;t\_0 \leq -0.0031999999191612005:\\
\;\;\;\;\left(\left(-\alpha\right) \cdot \alpha\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;-\left(\left(\left(\alpha \cdot u0\right) \cdot -0.5 - \alpha\right) \cdot u0\right) \cdot \alpha\\
\end{array}
\end{array}
if (log.f32 (-.f32 #s(literal 1 binary32) u0)) < -0.00319999992Initial program 93.0%
if -0.00319999992 < (log.f32 (-.f32 #s(literal 1 binary32) u0)) Initial program 42.9%
lift-*.f32N/A
lift-*.f32N/A
lift--.f32N/A
lift-log.f32N/A
lift-neg.f32N/A
distribute-lft-neg-outN/A
unpow2N/A
distribute-lft-neg-outN/A
lower-neg.f32N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lift-log.f32N/A
lift--.f3242.9
Applied rewrites42.9%
Taylor expanded in u0 around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites99.0%
Taylor expanded in u0 around 0
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-*.f3298.0
Applied rewrites98.0%
(FPCore (alpha u0)
:precision binary32
(let* ((t_0 (log (- 1.0 u0))))
(if (<= t_0 -0.0031999999191612005)
(- (* (* t_0 alpha) alpha))
(- (* (* (- (* (* alpha u0) -0.5) alpha) u0) alpha)))))
float code(float alpha, float u0) {
float t_0 = logf((1.0f - u0));
float tmp;
if (t_0 <= -0.0031999999191612005f) {
tmp = -((t_0 * alpha) * alpha);
} else {
tmp = -(((((alpha * u0) * -0.5f) - alpha) * u0) * alpha);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(alpha, u0)
use fmin_fmax_functions
real(4), intent (in) :: alpha
real(4), intent (in) :: u0
real(4) :: t_0
real(4) :: tmp
t_0 = log((1.0e0 - u0))
if (t_0 <= (-0.0031999999191612005e0)) then
tmp = -((t_0 * alpha) * alpha)
else
tmp = -(((((alpha * u0) * (-0.5e0)) - alpha) * u0) * alpha)
end if
code = tmp
end function
function code(alpha, u0) t_0 = log(Float32(Float32(1.0) - u0)) tmp = Float32(0.0) if (t_0 <= Float32(-0.0031999999191612005)) tmp = Float32(-Float32(Float32(t_0 * alpha) * alpha)); else tmp = Float32(-Float32(Float32(Float32(Float32(Float32(alpha * u0) * Float32(-0.5)) - alpha) * u0) * alpha)); end return tmp end
function tmp_2 = code(alpha, u0) t_0 = log((single(1.0) - u0)); tmp = single(0.0); if (t_0 <= single(-0.0031999999191612005)) tmp = -((t_0 * alpha) * alpha); else tmp = -(((((alpha * u0) * single(-0.5)) - alpha) * u0) * alpha); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(1 - u0\right)\\
\mathbf{if}\;t\_0 \leq -0.0031999999191612005:\\
\;\;\;\;-\left(t\_0 \cdot \alpha\right) \cdot \alpha\\
\mathbf{else}:\\
\;\;\;\;-\left(\left(\left(\alpha \cdot u0\right) \cdot -0.5 - \alpha\right) \cdot u0\right) \cdot \alpha\\
\end{array}
\end{array}
if (log.f32 (-.f32 #s(literal 1 binary32) u0)) < -0.00319999992Initial program 93.0%
lift-*.f32N/A
lift-*.f32N/A
lift--.f32N/A
lift-log.f32N/A
lift-neg.f32N/A
distribute-lft-neg-outN/A
unpow2N/A
distribute-lft-neg-outN/A
lower-neg.f32N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lift-log.f32N/A
lift--.f3293.0
Applied rewrites93.0%
if -0.00319999992 < (log.f32 (-.f32 #s(literal 1 binary32) u0)) Initial program 42.9%
lift-*.f32N/A
lift-*.f32N/A
lift--.f32N/A
lift-log.f32N/A
lift-neg.f32N/A
distribute-lft-neg-outN/A
unpow2N/A
distribute-lft-neg-outN/A
lower-neg.f32N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lift-log.f32N/A
lift--.f3242.9
Applied rewrites42.9%
Taylor expanded in u0 around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites99.0%
Taylor expanded in u0 around 0
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-*.f3298.0
Applied rewrites98.0%
(FPCore (alpha u0) :precision binary32 (- (* (* (- (* (* alpha u0) -0.5) alpha) u0) alpha)))
float code(float alpha, float u0) {
return -(((((alpha * u0) * -0.5f) - alpha) * u0) * alpha);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(alpha, u0)
use fmin_fmax_functions
real(4), intent (in) :: alpha
real(4), intent (in) :: u0
code = -(((((alpha * u0) * (-0.5e0)) - alpha) * u0) * alpha)
end function
function code(alpha, u0) return Float32(-Float32(Float32(Float32(Float32(Float32(alpha * u0) * Float32(-0.5)) - alpha) * u0) * alpha)) end
function tmp = code(alpha, u0) tmp = -(((((alpha * u0) * single(-0.5)) - alpha) * u0) * alpha); end
\begin{array}{l}
\\
-\left(\left(\left(\alpha \cdot u0\right) \cdot -0.5 - \alpha\right) \cdot u0\right) \cdot \alpha
\end{array}
Initial program 55.5%
lift-*.f32N/A
lift-*.f32N/A
lift--.f32N/A
lift-log.f32N/A
lift-neg.f32N/A
distribute-lft-neg-outN/A
unpow2N/A
distribute-lft-neg-outN/A
lower-neg.f32N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lift-log.f32N/A
lift--.f3255.5
Applied rewrites55.5%
Taylor expanded in u0 around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites93.7%
Taylor expanded in u0 around 0
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-*.f3287.7
Applied rewrites87.7%
(FPCore (alpha u0) :precision binary32 (- (* alpha (* (* (fma -0.5 u0 -1.0) u0) alpha))))
float code(float alpha, float u0) {
return -(alpha * ((fmaf(-0.5f, u0, -1.0f) * u0) * alpha));
}
function code(alpha, u0) return Float32(-Float32(alpha * Float32(Float32(fma(Float32(-0.5), u0, Float32(-1.0)) * u0) * alpha))) end
\begin{array}{l}
\\
-\alpha \cdot \left(\left(\mathsf{fma}\left(-0.5, u0, -1\right) \cdot u0\right) \cdot \alpha\right)
\end{array}
Initial program 55.5%
Taylor expanded in u0 around 0
*-commutativeN/A
lower-*.f32N/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f32N/A
metadata-evalN/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f3291.5
Applied rewrites91.5%
lift-*.f32N/A
lift-*.f32N/A
lift-neg.f32N/A
mul-1-negN/A
associate-*l*N/A
lower-*.f32N/A
mul-1-negN/A
lift-neg.f32N/A
lower-*.f3291.5
Applied rewrites91.5%
Taylor expanded in u0 around 0
Applied rewrites87.5%
lift-*.f32N/A
lift-neg.f32N/A
distribute-lft-neg-outN/A
lower-neg.f32N/A
lower-*.f3287.5
lift-*.f32N/A
*-commutativeN/A
lower-*.f3287.5
Applied rewrites87.5%
(FPCore (alpha u0) :precision binary32 (* (* (fma 0.5 u0 1.0) u0) (* alpha alpha)))
float code(float alpha, float u0) {
return (fmaf(0.5f, u0, 1.0f) * u0) * (alpha * alpha);
}
function code(alpha, u0) return Float32(Float32(fma(Float32(0.5), u0, Float32(1.0)) * u0) * Float32(alpha * alpha)) end
\begin{array}{l}
\\
\left(\mathsf{fma}\left(0.5, u0, 1\right) \cdot u0\right) \cdot \left(\alpha \cdot \alpha\right)
\end{array}
Initial program 55.5%
Taylor expanded in u0 around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites91.9%
Taylor expanded in alpha around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
+-commutativeN/A
lower-fma.f32N/A
pow2N/A
lift-*.f3291.5
Applied rewrites91.5%
Taylor expanded in u0 around 0
Applied rewrites87.6%
(FPCore (alpha u0) :precision binary32 (* (* alpha alpha) u0))
float code(float alpha, float u0) {
return (alpha * alpha) * u0;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(alpha, u0)
use fmin_fmax_functions
real(4), intent (in) :: alpha
real(4), intent (in) :: u0
code = (alpha * alpha) * u0
end function
function code(alpha, u0) return Float32(Float32(alpha * alpha) * u0) end
function tmp = code(alpha, u0) tmp = (alpha * alpha) * u0; end
\begin{array}{l}
\\
\left(\alpha \cdot \alpha\right) \cdot u0
\end{array}
Initial program 55.5%
Taylor expanded in u0 around 0
lower-*.f32N/A
unpow2N/A
lower-*.f3274.9
Applied rewrites74.9%
(FPCore (alpha u0) :precision binary32 (* alpha (* u0 alpha)))
float code(float alpha, float u0) {
return alpha * (u0 * alpha);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(alpha, u0)
use fmin_fmax_functions
real(4), intent (in) :: alpha
real(4), intent (in) :: u0
code = alpha * (u0 * alpha)
end function
function code(alpha, u0) return Float32(alpha * Float32(u0 * alpha)) end
function tmp = code(alpha, u0) tmp = alpha * (u0 * alpha); end
\begin{array}{l}
\\
\alpha \cdot \left(u0 \cdot \alpha\right)
\end{array}
Initial program 55.5%
Taylor expanded in u0 around 0
lower-*.f32N/A
unpow2N/A
lower-*.f3274.9
Applied rewrites74.9%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f3274.9
Applied rewrites74.9%
herbie shell --seed 2025124
(FPCore (alpha u0)
:name "Beckmann Distribution sample, tan2theta, alphax == alphay"
:precision binary32
:pre (and (and (<= 0.0001 alpha) (<= alpha 1.0)) (and (<= 2.328306437e-10 u0) (<= u0 1.0)))
(* (* (- alpha) alpha) (log (- 1.0 u0))))