
(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}
Sampling outcomes in binary32 precision:
Herbie found 8 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 57.9%
lift--.f32N/A
lift-log.f32N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
mul-1-negN/A
lower-log1p.f32N/A
lower-neg.f3299.1
Applied rewrites99.1%
(FPCore (alpha u0) :precision binary32 (if (<= u0 0.002850000048056245) (* (fma alpha alpha (* (* (* alpha alpha) 0.5) u0)) u0) (* (* (- (log (- 1.0 u0))) alpha) alpha)))
float code(float alpha, float u0) {
float tmp;
if (u0 <= 0.002850000048056245f) {
tmp = fmaf(alpha, alpha, (((alpha * alpha) * 0.5f) * u0)) * u0;
} else {
tmp = (-logf((1.0f - u0)) * alpha) * alpha;
}
return tmp;
}
function code(alpha, u0) tmp = Float32(0.0) if (u0 <= Float32(0.002850000048056245)) tmp = Float32(fma(alpha, alpha, Float32(Float32(Float32(alpha * alpha) * Float32(0.5)) * u0)) * u0); else tmp = Float32(Float32(Float32(-log(Float32(Float32(1.0) - u0))) * alpha) * alpha); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;u0 \leq 0.002850000048056245:\\
\;\;\;\;\mathsf{fma}\left(\alpha, \alpha, \left(\left(\alpha \cdot \alpha\right) \cdot 0.5\right) \cdot u0\right) \cdot u0\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-\log \left(1 - u0\right)\right) \cdot \alpha\right) \cdot \alpha\\
\end{array}
\end{array}
if u0 < 0.00285000005Initial program 46.2%
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.0
Applied rewrites98.0%
if 0.00285000005 < u0 Initial program 92.4%
lift-*.f32N/A
lift-*.f32N/A
lift-neg.f32N/A
distribute-lft-neg-outN/A
unpow2N/A
lift--.f32N/A
lift-log.f32N/A
distribute-lft-neg-inN/A
lower-neg.f32N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lift-log.f32N/A
lift--.f3292.4
Applied rewrites92.4%
Final simplification96.6%
(FPCore (alpha u0) :precision binary32 (if (<= u0 0.002850000048056245) (* (* (* (- (* -0.5 u0) 1.0) alpha) u0) (- alpha)) (* (* (- (log (- 1.0 u0))) alpha) alpha)))
float code(float alpha, float u0) {
float tmp;
if (u0 <= 0.002850000048056245f) {
tmp = ((((-0.5f * u0) - 1.0f) * alpha) * u0) * -alpha;
} else {
tmp = (-logf((1.0f - u0)) * alpha) * 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) :: tmp
if (u0 <= 0.002850000048056245e0) then
tmp = (((((-0.5e0) * u0) - 1.0e0) * alpha) * u0) * -alpha
else
tmp = (-log((1.0e0 - u0)) * alpha) * alpha
end if
code = tmp
end function
function code(alpha, u0) tmp = Float32(0.0) if (u0 <= Float32(0.002850000048056245)) tmp = Float32(Float32(Float32(Float32(Float32(Float32(-0.5) * u0) - Float32(1.0)) * alpha) * u0) * Float32(-alpha)); else tmp = Float32(Float32(Float32(-log(Float32(Float32(1.0) - u0))) * alpha) * alpha); end return tmp end
function tmp_2 = code(alpha, u0) tmp = single(0.0); if (u0 <= single(0.002850000048056245)) tmp = ((((single(-0.5) * u0) - single(1.0)) * alpha) * u0) * -alpha; else tmp = (-log((single(1.0) - u0)) * alpha) * alpha; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;u0 \leq 0.002850000048056245:\\
\;\;\;\;\left(\left(\left(-0.5 \cdot u0 - 1\right) \cdot \alpha\right) \cdot u0\right) \cdot \left(-\alpha\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-\log \left(1 - u0\right)\right) \cdot \alpha\right) \cdot \alpha\\
\end{array}
\end{array}
if u0 < 0.00285000005Initial program 46.2%
lift-*.f32N/A
lift-*.f32N/A
lift-neg.f32N/A
distribute-lft-neg-outN/A
unpow2N/A
lift--.f32N/A
lift-log.f32N/A
distribute-lft-neg-inN/A
lower-neg.f32N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lift-log.f32N/A
lift--.f3246.2
Applied rewrites46.2%
Taylor expanded in u0 around 0
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
mul-1-negN/A
lift-neg.f3297.6
Applied rewrites97.6%
Taylor expanded in alpha around 0
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
lower-*.f3297.6
Applied rewrites97.6%
if 0.00285000005 < u0 Initial program 92.4%
lift-*.f32N/A
lift-*.f32N/A
lift-neg.f32N/A
distribute-lft-neg-outN/A
unpow2N/A
lift--.f32N/A
lift-log.f32N/A
distribute-lft-neg-inN/A
lower-neg.f32N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lift-log.f32N/A
lift--.f3292.4
Applied rewrites92.4%
Final simplification96.3%
(FPCore (alpha u0) :precision binary32 (* (* (* (- (* -0.5 u0) 1.0) alpha) u0) (- alpha)))
float code(float alpha, float u0) {
return ((((-0.5f * u0) - 1.0f) * 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 = (((((-0.5e0) * u0) - 1.0e0) * alpha) * u0) * -alpha
end function
function code(alpha, u0) return Float32(Float32(Float32(Float32(Float32(Float32(-0.5) * u0) - Float32(1.0)) * alpha) * u0) * Float32(-alpha)) end
function tmp = code(alpha, u0) tmp = ((((single(-0.5) * u0) - single(1.0)) * alpha) * u0) * -alpha; end
\begin{array}{l}
\\
\left(\left(\left(-0.5 \cdot u0 - 1\right) \cdot \alpha\right) \cdot u0\right) \cdot \left(-\alpha\right)
\end{array}
Initial program 57.9%
lift-*.f32N/A
lift-*.f32N/A
lift-neg.f32N/A
distribute-lft-neg-outN/A
unpow2N/A
lift--.f32N/A
lift-log.f32N/A
distribute-lft-neg-inN/A
lower-neg.f32N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lift-log.f32N/A
lift--.f3257.9
Applied rewrites57.9%
Taylor expanded in u0 around 0
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
mul-1-negN/A
lift-neg.f3288.0
Applied rewrites88.0%
Taylor expanded in alpha around 0
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
lower-*.f3288.0
Applied rewrites88.0%
Final simplification88.0%
(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(alpha * Float32(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 57.9%
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.f3292.3
Applied rewrites92.3%
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-*.f3292.3
Applied rewrites92.3%
Taylor expanded in u0 around 0
Applied rewrites88.0%
lift-*.f32N/A
lift-neg.f32N/A
distribute-lft-neg-outN/A
lower-neg.f32N/A
lower-*.f3288.0
lift-*.f32N/A
*-commutativeN/A
lower-*.f3288.0
Applied rewrites88.0%
Final simplification88.0%
(FPCore (alpha u0) :precision binary32 (* (* (fma 0.5 u0 1.0) (* alpha alpha)) u0))
float code(float alpha, float u0) {
return (fmaf(0.5f, u0, 1.0f) * (alpha * alpha)) * u0;
}
function code(alpha, u0) return Float32(Float32(fma(Float32(0.5), u0, Float32(1.0)) * Float32(alpha * alpha)) * u0) end
\begin{array}{l}
\\
\left(\mathsf{fma}\left(0.5, u0, 1\right) \cdot \left(\alpha \cdot \alpha\right)\right) \cdot u0
\end{array}
Initial program 57.9%
Taylor expanded in u0 around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites92.7%
Taylor expanded in alpha around 0
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
+-commutativeN/A
lower-fma.f32N/A
pow2N/A
lift-*.f3292.2
Applied rewrites92.2%
Taylor expanded in u0 around 0
Applied rewrites87.9%
(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 57.9%
Taylor expanded in u0 around 0
lower-*.f32N/A
unpow2N/A
lower-*.f3273.9
Applied rewrites73.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 57.9%
Taylor expanded in u0 around 0
lower-*.f32N/A
unpow2N/A
lower-*.f3273.9
Applied rewrites73.9%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f3273.8
Applied rewrites73.8%
herbie shell --seed 2025064
(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))))