
(FPCore (x s) :precision binary32 (/ 1.0 (+ 1.0 (exp (/ (- x) s)))))
float code(float x, float s) {
return 1.0f / (1.0f + expf((-x / s)));
}
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(x, s)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (1.0e0 + exp((-x / s)))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(1.0) + exp(Float32(Float32(-x) / s)))) end
function tmp = code(x, s) tmp = single(1.0) / (single(1.0) + exp((-x / s))); end
\begin{array}{l}
\\
\frac{1}{1 + e^{\frac{-x}{s}}}
\end{array}
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x s) :precision binary32 (/ 1.0 (+ 1.0 (exp (/ (- x) s)))))
float code(float x, float s) {
return 1.0f / (1.0f + expf((-x / s)));
}
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(x, s)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (1.0e0 + exp((-x / s)))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(1.0) + exp(Float32(Float32(-x) / s)))) end
function tmp = code(x, s) tmp = single(1.0) / (single(1.0) + exp((-x / s))); end
\begin{array}{l}
\\
\frac{1}{1 + e^{\frac{-x}{s}}}
\end{array}
(FPCore (x s) :precision binary32 (/ 1.0 (+ 1.0 (pow E (/ (- x) s)))))
float code(float x, float s) {
return 1.0f / (1.0f + powf(((float) M_E), (-x / s)));
}
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(1.0) + (Float32(exp(1)) ^ Float32(Float32(-x) / s)))) end
function tmp = code(x, s) tmp = single(1.0) / (single(1.0) + (single(2.71828182845904523536) ^ (-x / s))); end
\begin{array}{l}
\\
\frac{1}{1 + {e}^{\left(\frac{-x}{s}\right)}}
\end{array}
Initial program 99.8%
lift-exp.f32N/A
lift-/.f32N/A
mult-flipN/A
*-commutativeN/A
mult-flipN/A
associate-*l*N/A
*-commutativeN/A
mult-flipN/A
lift-/.f32N/A
exp-prodN/A
lower-pow.f32N/A
lower-exp.f3299.8
Applied rewrites99.8%
lift-exp.f32N/A
exp-1-eN/A
lower-E.f3299.8
Applied rewrites99.8%
(FPCore (x s) :precision binary32 (/ 1.0 (+ 1.0 (/ 1.0 (exp (/ x s))))))
float code(float x, float s) {
return 1.0f / (1.0f + (1.0f / expf((x / s))));
}
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(x, s)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (1.0e0 + (1.0e0 / exp((x / s))))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(Float32(1.0) / exp(Float32(x / s))))) end
function tmp = code(x, s) tmp = single(1.0) / (single(1.0) + (single(1.0) / exp((x / s)))); end
\begin{array}{l}
\\
\frac{1}{1 + \frac{1}{e^{\frac{x}{s}}}}
\end{array}
Initial program 99.8%
lift-exp.f32N/A
lift-/.f32N/A
lift-neg.f32N/A
distribute-frac-negN/A
exp-negN/A
lower-/.f32N/A
lower-exp.f32N/A
lower-/.f3299.8
Applied rewrites99.8%
(FPCore (x s) :precision binary32 (/ 1.0 (- (exp (/ (- x) s)) -1.0)))
float code(float x, float s) {
return 1.0f / (expf((-x / s)) - -1.0f);
}
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(x, s)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (exp((-x / s)) - (-1.0e0))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(exp(Float32(Float32(-x) / s)) - Float32(-1.0))) end
function tmp = code(x, s) tmp = single(1.0) / (exp((-x / s)) - single(-1.0)); end
\begin{array}{l}
\\
\frac{1}{e^{\frac{-x}{s}} - -1}
\end{array}
Initial program 99.8%
lift-+.f32N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f3299.8
Applied rewrites99.8%
(FPCore (x s)
:precision binary32
(let* ((t_0 (- s (- x s))) (t_1 (/ (- x) s)))
(if (<= t_1 30.0)
0.5
(if (<= t_1 5.000000069242139e+23)
(/ 1.0 (* x (* (/ 1.0 (* s x)) t_0)))
(/ 1.0 (/ (/ (* t_0 x) s) x))))))
float code(float x, float s) {
float t_0 = s - (x - s);
float t_1 = -x / s;
float tmp;
if (t_1 <= 30.0f) {
tmp = 0.5f;
} else if (t_1 <= 5.000000069242139e+23f) {
tmp = 1.0f / (x * ((1.0f / (s * x)) * t_0));
} else {
tmp = 1.0f / (((t_0 * x) / s) / x);
}
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(x, s)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: t_0
real(4) :: t_1
real(4) :: tmp
t_0 = s - (x - s)
t_1 = -x / s
if (t_1 <= 30.0e0) then
tmp = 0.5e0
else if (t_1 <= 5.000000069242139e+23) then
tmp = 1.0e0 / (x * ((1.0e0 / (s * x)) * t_0))
else
tmp = 1.0e0 / (((t_0 * x) / s) / x)
end if
code = tmp
end function
function code(x, s) t_0 = Float32(s - Float32(x - s)) t_1 = Float32(Float32(-x) / s) tmp = Float32(0.0) if (t_1 <= Float32(30.0)) tmp = Float32(0.5); elseif (t_1 <= Float32(5.000000069242139e+23)) tmp = Float32(Float32(1.0) / Float32(x * Float32(Float32(Float32(1.0) / Float32(s * x)) * t_0))); else tmp = Float32(Float32(1.0) / Float32(Float32(Float32(t_0 * x) / s) / x)); end return tmp end
function tmp_2 = code(x, s) t_0 = s - (x - s); t_1 = -x / s; tmp = single(0.0); if (t_1 <= single(30.0)) tmp = single(0.5); elseif (t_1 <= single(5.000000069242139e+23)) tmp = single(1.0) / (x * ((single(1.0) / (s * x)) * t_0)); else tmp = single(1.0) / (((t_0 * x) / s) / x); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := s - \left(x - s\right)\\
t_1 := \frac{-x}{s}\\
\mathbf{if}\;t\_1 \leq 30:\\
\;\;\;\;0.5\\
\mathbf{elif}\;t\_1 \leq 5.000000069242139 \cdot 10^{+23}:\\
\;\;\;\;\frac{1}{x \cdot \left(\frac{1}{s \cdot x} \cdot t\_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\frac{t\_0 \cdot x}{s}}{x}}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 30Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites34.8%
if 30 < (/.f32 (neg.f32 x) s) < 5.00000007e23Initial program 99.8%
Taylor expanded in x around 0
lower-+.f32N/A
lower-*.f32N/A
lower-/.f3240.5
Applied rewrites40.5%
Taylor expanded in x around inf
lower-*.f32N/A
lower--.f32N/A
lower-*.f32N/A
lower-/.f32N/A
lower-/.f3240.2
Applied rewrites40.2%
lift--.f32N/A
sub-flipN/A
add-flipN/A
lift-*.f32N/A
count-2-revN/A
lift-/.f32N/A
add-to-fractionN/A
remove-double-negN/A
lift-/.f32N/A
frac-2negN/A
distribute-frac-negN/A
distribute-neg-frac2N/A
frac-subN/A
lift-/.f32N/A
lft-mult-inverseN/A
metadata-evalN/A
*-rgt-identityN/A
remove-double-negN/A
remove-double-negN/A
*-commutativeN/A
lower-/.f32N/A
Applied rewrites35.1%
lift-/.f32N/A
mult-flip-revN/A
lift-/.f32N/A
*-commutativeN/A
lower-*.f3234.4
lift--.f32N/A
lift-+.f32N/A
associate--l+N/A
add-flip-revN/A
sub-negate-revN/A
lift--.f32N/A
lower--.f3234.4
Applied rewrites34.4%
if 5.00000007e23 < (/.f32 (neg.f32 x) s) Initial program 99.8%
Taylor expanded in x around 0
lower-+.f32N/A
lower-*.f32N/A
lower-/.f3240.5
Applied rewrites40.5%
Taylor expanded in x around inf
lower-*.f32N/A
lower--.f32N/A
lower-*.f32N/A
lower-/.f32N/A
lower-/.f3240.2
Applied rewrites40.2%
lift--.f32N/A
sub-flipN/A
add-flipN/A
lift-*.f32N/A
count-2-revN/A
lift-/.f32N/A
add-to-fractionN/A
remove-double-negN/A
lift-/.f32N/A
frac-2negN/A
distribute-frac-negN/A
distribute-neg-frac2N/A
frac-subN/A
lift-/.f32N/A
lft-mult-inverseN/A
metadata-evalN/A
*-rgt-identityN/A
remove-double-negN/A
remove-double-negN/A
*-commutativeN/A
lower-/.f32N/A
Applied rewrites35.1%
lift-*.f32N/A
lift-/.f32N/A
associate-*r/N/A
lift-*.f32N/A
associate-/r*N/A
lower-/.f32N/A
lower-/.f32N/A
*-commutativeN/A
lower-*.f3237.6
lift--.f32N/A
lift-+.f32N/A
associate--l+N/A
add-flip-revN/A
sub-negate-revN/A
lift--.f32N/A
lower--.f3237.6
Applied rewrites37.6%
(FPCore (x s)
:precision binary32
(if (<= (- x) 1.000000031374395e-22)
0.5
(if (<= (- x) 500.0)
(/ 1.0 (/ (fma s s (* (- s x) s)) (* s s)))
(/ 1.0 (* (* (- 2.0 (/ x s)) x) (/ 1.0 x))))))
float code(float x, float s) {
float tmp;
if (-x <= 1.000000031374395e-22f) {
tmp = 0.5f;
} else if (-x <= 500.0f) {
tmp = 1.0f / (fmaf(s, s, ((s - x) * s)) / (s * s));
} else {
tmp = 1.0f / (((2.0f - (x / s)) * x) * (1.0f / x));
}
return tmp;
}
function code(x, s) tmp = Float32(0.0) if (Float32(-x) <= Float32(1.000000031374395e-22)) tmp = Float32(0.5); elseif (Float32(-x) <= Float32(500.0)) tmp = Float32(Float32(1.0) / Float32(fma(s, s, Float32(Float32(s - x) * s)) / Float32(s * s))); else tmp = Float32(Float32(1.0) / Float32(Float32(Float32(Float32(2.0) - Float32(x / s)) * x) * Float32(Float32(1.0) / x))); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-x \leq 1.000000031374395 \cdot 10^{-22}:\\
\;\;\;\;0.5\\
\mathbf{elif}\;-x \leq 500:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(s, s, \left(s - x\right) \cdot s\right)}{s \cdot s}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(2 - \frac{x}{s}\right) \cdot x\right) \cdot \frac{1}{x}}\\
\end{array}
\end{array}
if (neg.f32 x) < 1.00000003e-22Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites34.8%
if 1.00000003e-22 < (neg.f32 x) < 500Initial program 99.8%
Taylor expanded in x around 0
lower-+.f32N/A
lower-*.f32N/A
lower-/.f3240.5
Applied rewrites40.5%
lift-+.f32N/A
lift-*.f32N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f3240.5
Applied rewrites40.5%
lift--.f32N/A
lift-/.f32N/A
frac-2negN/A
lift-neg.f32N/A
sub-to-fractionN/A
mult-flipN/A
metadata-evalN/A
frac-2negN/A
lift-/.f32N/A
lower-*.f32N/A
sub-flip-reverseN/A
lift-neg.f32N/A
remove-double-negN/A
+-commutativeN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
count-2-revN/A
associate--r+N/A
lower--.f32N/A
lower--.f3240.4
Applied rewrites40.4%
lift-*.f32N/A
lift-/.f32N/A
frac-2negN/A
metadata-evalN/A
mult-flip-revN/A
distribute-neg-frac2N/A
distribute-frac-negN/A
lift--.f32N/A
sub-negate-revN/A
sub-flipN/A
lift--.f32N/A
sub-negate-revN/A
div-addN/A
common-denominatorN/A
lower-/.f32N/A
lower-fma.f32N/A
lower-*.f32N/A
lower--.f32N/A
lower-*.f3242.0
Applied rewrites42.0%
if 500 < (neg.f32 x) Initial program 99.8%
Taylor expanded in x around 0
lower-+.f32N/A
lower-*.f32N/A
lower-/.f3240.5
Applied rewrites40.5%
Taylor expanded in x around inf
lower-*.f32N/A
lower--.f32N/A
lower-*.f32N/A
lower-/.f32N/A
lower-/.f3240.2
Applied rewrites40.2%
lift--.f32N/A
sub-flipN/A
add-flipN/A
lift-*.f32N/A
count-2-revN/A
lift-/.f32N/A
add-to-fractionN/A
remove-double-negN/A
lift-/.f32N/A
frac-2negN/A
distribute-frac-negN/A
distribute-neg-frac2N/A
frac-subN/A
lift-/.f32N/A
lft-mult-inverseN/A
metadata-evalN/A
*-rgt-identityN/A
remove-double-negN/A
remove-double-negN/A
*-commutativeN/A
lower-/.f32N/A
Applied rewrites35.1%
lift-*.f32N/A
lift-/.f32N/A
associate-*r/N/A
*-commutativeN/A
associate-*l/N/A
lift-*.f32N/A
associate-/r*N/A
associate-*l/N/A
mult-flipN/A
lower-*.f32N/A
lower-*.f32N/A
lift--.f32N/A
lift-+.f32N/A
count-2N/A
sub-to-fraction-revN/A
lift-/.f32N/A
lower--.f32N/A
lower-/.f3245.9
Applied rewrites45.9%
(FPCore (x s)
:precision binary32
(let* ((t_0 (/ (- x) s)))
(if (<= t_0 30.0)
0.5
(if (<= t_0 4.0000000801635094e+21)
(/ 1.0 (* x (* (* 2.0 s) (/ 1.0 (* s x)))))
(/ 1.0 (/ (/ (* (- s (- x s)) x) s) x))))))
float code(float x, float s) {
float t_0 = -x / s;
float tmp;
if (t_0 <= 30.0f) {
tmp = 0.5f;
} else if (t_0 <= 4.0000000801635094e+21f) {
tmp = 1.0f / (x * ((2.0f * s) * (1.0f / (s * x))));
} else {
tmp = 1.0f / ((((s - (x - s)) * x) / s) / x);
}
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(x, s)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: t_0
real(4) :: tmp
t_0 = -x / s
if (t_0 <= 30.0e0) then
tmp = 0.5e0
else if (t_0 <= 4.0000000801635094e+21) then
tmp = 1.0e0 / (x * ((2.0e0 * s) * (1.0e0 / (s * x))))
else
tmp = 1.0e0 / ((((s - (x - s)) * x) / s) / x)
end if
code = tmp
end function
function code(x, s) t_0 = Float32(Float32(-x) / s) tmp = Float32(0.0) if (t_0 <= Float32(30.0)) tmp = Float32(0.5); elseif (t_0 <= Float32(4.0000000801635094e+21)) tmp = Float32(Float32(1.0) / Float32(x * Float32(Float32(Float32(2.0) * s) * Float32(Float32(1.0) / Float32(s * x))))); else tmp = Float32(Float32(1.0) / Float32(Float32(Float32(Float32(s - Float32(x - s)) * x) / s) / x)); end return tmp end
function tmp_2 = code(x, s) t_0 = -x / s; tmp = single(0.0); if (t_0 <= single(30.0)) tmp = single(0.5); elseif (t_0 <= single(4.0000000801635094e+21)) tmp = single(1.0) / (x * ((single(2.0) * s) * (single(1.0) / (s * x)))); else tmp = single(1.0) / ((((s - (x - s)) * x) / s) / x); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-x}{s}\\
\mathbf{if}\;t\_0 \leq 30:\\
\;\;\;\;0.5\\
\mathbf{elif}\;t\_0 \leq 4.0000000801635094 \cdot 10^{+21}:\\
\;\;\;\;\frac{1}{x \cdot \left(\left(2 \cdot s\right) \cdot \frac{1}{s \cdot x}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\frac{\left(s - \left(x - s\right)\right) \cdot x}{s}}{x}}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 30Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites34.8%
if 30 < (/.f32 (neg.f32 x) s) < 4.00000008e21Initial program 99.8%
Taylor expanded in x around 0
lower-+.f32N/A
lower-*.f32N/A
lower-/.f3240.5
Applied rewrites40.5%
Taylor expanded in x around inf
lower-*.f32N/A
lower--.f32N/A
lower-*.f32N/A
lower-/.f32N/A
lower-/.f3240.2
Applied rewrites40.2%
lift--.f32N/A
lift-*.f32N/A
lift-/.f32N/A
mult-flip-revN/A
lift-/.f32N/A
frac-subN/A
mult-flipN/A
Applied rewrites34.4%
Taylor expanded in x around 0
lower-*.f3228.3
Applied rewrites28.3%
if 4.00000008e21 < (/.f32 (neg.f32 x) s) Initial program 99.8%
Taylor expanded in x around 0
lower-+.f32N/A
lower-*.f32N/A
lower-/.f3240.5
Applied rewrites40.5%
Taylor expanded in x around inf
lower-*.f32N/A
lower--.f32N/A
lower-*.f32N/A
lower-/.f32N/A
lower-/.f3240.2
Applied rewrites40.2%
lift--.f32N/A
sub-flipN/A
add-flipN/A
lift-*.f32N/A
count-2-revN/A
lift-/.f32N/A
add-to-fractionN/A
remove-double-negN/A
lift-/.f32N/A
frac-2negN/A
distribute-frac-negN/A
distribute-neg-frac2N/A
frac-subN/A
lift-/.f32N/A
lft-mult-inverseN/A
metadata-evalN/A
*-rgt-identityN/A
remove-double-negN/A
remove-double-negN/A
*-commutativeN/A
lower-/.f32N/A
Applied rewrites35.1%
lift-*.f32N/A
lift-/.f32N/A
associate-*r/N/A
lift-*.f32N/A
associate-/r*N/A
lower-/.f32N/A
lower-/.f32N/A
*-commutativeN/A
lower-*.f3237.6
lift--.f32N/A
lift-+.f32N/A
associate--l+N/A
add-flip-revN/A
sub-negate-revN/A
lift--.f32N/A
lower--.f3237.6
Applied rewrites37.6%
(FPCore (x s) :precision binary32 (if (<= (/ (- x) s) -10.0) (/ 1.0 (* (* -2.0 s) (/ -1.0 s))) (/ 1.0 (/ (* (- 2.0 (/ x s)) x) x))))
float code(float x, float s) {
float tmp;
if ((-x / s) <= -10.0f) {
tmp = 1.0f / ((-2.0f * s) * (-1.0f / s));
} else {
tmp = 1.0f / (((2.0f - (x / s)) * x) / x);
}
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(x, s)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if ((-x / s) <= (-10.0e0)) then
tmp = 1.0e0 / (((-2.0e0) * s) * ((-1.0e0) / s))
else
tmp = 1.0e0 / (((2.0e0 - (x / s)) * x) / x)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(Float32(-x) / s) <= Float32(-10.0)) tmp = Float32(Float32(1.0) / Float32(Float32(Float32(-2.0) * s) * Float32(Float32(-1.0) / s))); else tmp = Float32(Float32(1.0) / Float32(Float32(Float32(Float32(2.0) - Float32(x / s)) * x) / x)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((-x / s) <= single(-10.0)) tmp = single(1.0) / ((single(-2.0) * s) * (single(-1.0) / s)); else tmp = single(1.0) / (((single(2.0) - (x / s)) * x) / x); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{-x}{s} \leq -10:\\
\;\;\;\;\frac{1}{\left(-2 \cdot s\right) \cdot \frac{-1}{s}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\left(2 - \frac{x}{s}\right) \cdot x}{x}}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -10Initial program 99.8%
Taylor expanded in x around 0
lower-+.f32N/A
lower-*.f32N/A
lower-/.f3240.5
Applied rewrites40.5%
lift-+.f32N/A
lift-*.f32N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f3240.5
Applied rewrites40.5%
lift--.f32N/A
lift-/.f32N/A
frac-2negN/A
lift-neg.f32N/A
sub-to-fractionN/A
mult-flipN/A
metadata-evalN/A
frac-2negN/A
lift-/.f32N/A
lower-*.f32N/A
sub-flip-reverseN/A
lift-neg.f32N/A
remove-double-negN/A
+-commutativeN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
count-2-revN/A
associate--r+N/A
lower--.f32N/A
lower--.f3240.4
Applied rewrites40.4%
Taylor expanded in x around 0
lower-*.f3234.8
Applied rewrites34.8%
if -10 < (/.f32 (neg.f32 x) s) Initial program 99.8%
Taylor expanded in x around 0
lower-+.f32N/A
lower-*.f32N/A
lower-/.f3240.5
Applied rewrites40.5%
Taylor expanded in x around inf
lower-*.f32N/A
lower--.f32N/A
lower-*.f32N/A
lower-/.f32N/A
lower-/.f3240.2
Applied rewrites40.2%
lift--.f32N/A
sub-flipN/A
add-flipN/A
lift-*.f32N/A
count-2-revN/A
lift-/.f32N/A
add-to-fractionN/A
remove-double-negN/A
lift-/.f32N/A
frac-2negN/A
distribute-frac-negN/A
distribute-neg-frac2N/A
frac-subN/A
lift-/.f32N/A
lft-mult-inverseN/A
metadata-evalN/A
*-rgt-identityN/A
remove-double-negN/A
remove-double-negN/A
*-commutativeN/A
lower-/.f32N/A
Applied rewrites35.1%
lift-*.f32N/A
lift-/.f32N/A
associate-*r/N/A
*-commutativeN/A
associate-*l/N/A
lift-*.f32N/A
associate-/r*N/A
associate-*l/N/A
lower-/.f32N/A
lower-*.f32N/A
lift--.f32N/A
lift-+.f32N/A
count-2N/A
sub-to-fraction-revN/A
lift-/.f32N/A
lower--.f3246.1
Applied rewrites46.1%
(FPCore (x s) :precision binary32 (if (<= (+ 1.0 (exp (/ (- x) s))) 20000000000.0) 0.5 (/ 1.0 (* x (/ (* -1.0 x) (* s x))))))
float code(float x, float s) {
float tmp;
if ((1.0f + expf((-x / s))) <= 20000000000.0f) {
tmp = 0.5f;
} else {
tmp = 1.0f / (x * ((-1.0f * x) / (s * x)));
}
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(x, s)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if ((1.0e0 + exp((-x / s))) <= 20000000000.0e0) then
tmp = 0.5e0
else
tmp = 1.0e0 / (x * (((-1.0e0) * x) / (s * x)))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(Float32(1.0) + exp(Float32(Float32(-x) / s))) <= Float32(20000000000.0)) tmp = Float32(0.5); else tmp = Float32(Float32(1.0) / Float32(x * Float32(Float32(Float32(-1.0) * x) / Float32(s * x)))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((single(1.0) + exp((-x / s))) <= single(20000000000.0)) tmp = single(0.5); else tmp = single(1.0) / (x * ((single(-1.0) * x) / (s * x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;1 + e^{\frac{-x}{s}} \leq 20000000000:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \frac{-1 \cdot x}{s \cdot x}}\\
\end{array}
\end{array}
if (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 x) s))) < 2e10Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites34.8%
if 2e10 < (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 x) s))) Initial program 99.8%
Taylor expanded in x around 0
lower-+.f32N/A
lower-*.f32N/A
lower-/.f3240.5
Applied rewrites40.5%
Taylor expanded in x around inf
lower-*.f32N/A
lower--.f32N/A
lower-*.f32N/A
lower-/.f32N/A
lower-/.f3240.2
Applied rewrites40.2%
lift--.f32N/A
sub-flipN/A
add-flipN/A
lift-*.f32N/A
count-2-revN/A
lift-/.f32N/A
add-to-fractionN/A
remove-double-negN/A
lift-/.f32N/A
frac-2negN/A
distribute-frac-negN/A
distribute-neg-frac2N/A
frac-subN/A
lift-/.f32N/A
lft-mult-inverseN/A
metadata-evalN/A
*-rgt-identityN/A
remove-double-negN/A
remove-double-negN/A
*-commutativeN/A
lower-/.f32N/A
Applied rewrites35.1%
Taylor expanded in x around inf
lower-*.f3222.1
Applied rewrites22.1%
(FPCore (x s) :precision binary32 (if (<= (/ (- x) s) -10.0) (/ 1.0 (* (* -2.0 s) (/ -1.0 s))) (/ 3.0 (* (- 2.0 (/ x s)) 3.0))))
float code(float x, float s) {
float tmp;
if ((-x / s) <= -10.0f) {
tmp = 1.0f / ((-2.0f * s) * (-1.0f / s));
} else {
tmp = 3.0f / ((2.0f - (x / s)) * 3.0f);
}
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(x, s)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if ((-x / s) <= (-10.0e0)) then
tmp = 1.0e0 / (((-2.0e0) * s) * ((-1.0e0) / s))
else
tmp = 3.0e0 / ((2.0e0 - (x / s)) * 3.0e0)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(Float32(-x) / s) <= Float32(-10.0)) tmp = Float32(Float32(1.0) / Float32(Float32(Float32(-2.0) * s) * Float32(Float32(-1.0) / s))); else tmp = Float32(Float32(3.0) / Float32(Float32(Float32(2.0) - Float32(x / s)) * Float32(3.0))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((-x / s) <= single(-10.0)) tmp = single(1.0) / ((single(-2.0) * s) * (single(-1.0) / s)); else tmp = single(3.0) / ((single(2.0) - (x / s)) * single(3.0)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{-x}{s} \leq -10:\\
\;\;\;\;\frac{1}{\left(-2 \cdot s\right) \cdot \frac{-1}{s}}\\
\mathbf{else}:\\
\;\;\;\;\frac{3}{\left(2 - \frac{x}{s}\right) \cdot 3}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -10Initial program 99.8%
Taylor expanded in x around 0
lower-+.f32N/A
lower-*.f32N/A
lower-/.f3240.5
Applied rewrites40.5%
lift-+.f32N/A
lift-*.f32N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f3240.5
Applied rewrites40.5%
lift--.f32N/A
lift-/.f32N/A
frac-2negN/A
lift-neg.f32N/A
sub-to-fractionN/A
mult-flipN/A
metadata-evalN/A
frac-2negN/A
lift-/.f32N/A
lower-*.f32N/A
sub-flip-reverseN/A
lift-neg.f32N/A
remove-double-negN/A
+-commutativeN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
count-2-revN/A
associate--r+N/A
lower--.f32N/A
lower--.f3240.4
Applied rewrites40.4%
Taylor expanded in x around 0
lower-*.f3234.8
Applied rewrites34.8%
if -10 < (/.f32 (neg.f32 x) s) Initial program 99.8%
Taylor expanded in x around 0
lower-+.f32N/A
lower-*.f32N/A
lower-/.f3240.5
Applied rewrites40.5%
lift-+.f32N/A
lift-*.f32N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f3240.5
Applied rewrites40.5%
lift--.f32N/A
lift-/.f32N/A
frac-2negN/A
lift-neg.f32N/A
sub-to-fractionN/A
mult-flipN/A
metadata-evalN/A
frac-2negN/A
lift-/.f32N/A
lower-*.f32N/A
sub-flip-reverseN/A
lift-neg.f32N/A
remove-double-negN/A
+-commutativeN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
count-2-revN/A
associate--r+N/A
lower--.f32N/A
lower--.f3240.4
Applied rewrites40.4%
*-lft-identityN/A
*-commutativeN/A
lift-/.f32N/A
metadata-evalN/A
frac-timesN/A
metadata-evalN/A
lower-/.f32N/A
lower-*.f3240.6
Applied rewrites40.6%
(FPCore (x s) :precision binary32 (if (<= (/ (- x) s) -10.0) (/ 1.0 (* x (/ 2.0 x))) (/ 3.0 (* (- 2.0 (/ x s)) 3.0))))
float code(float x, float s) {
float tmp;
if ((-x / s) <= -10.0f) {
tmp = 1.0f / (x * (2.0f / x));
} else {
tmp = 3.0f / ((2.0f - (x / s)) * 3.0f);
}
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(x, s)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if ((-x / s) <= (-10.0e0)) then
tmp = 1.0e0 / (x * (2.0e0 / x))
else
tmp = 3.0e0 / ((2.0e0 - (x / s)) * 3.0e0)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(Float32(-x) / s) <= Float32(-10.0)) tmp = Float32(Float32(1.0) / Float32(x * Float32(Float32(2.0) / x))); else tmp = Float32(Float32(3.0) / Float32(Float32(Float32(2.0) - Float32(x / s)) * Float32(3.0))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((-x / s) <= single(-10.0)) tmp = single(1.0) / (x * (single(2.0) / x)); else tmp = single(3.0) / ((single(2.0) - (x / s)) * single(3.0)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{-x}{s} \leq -10:\\
\;\;\;\;\frac{1}{x \cdot \frac{2}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{3}{\left(2 - \frac{x}{s}\right) \cdot 3}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -10Initial program 99.8%
Taylor expanded in x around 0
lower-+.f32N/A
lower-*.f32N/A
lower-/.f3240.5
Applied rewrites40.5%
Taylor expanded in x around inf
lower-*.f32N/A
lower--.f32N/A
lower-*.f32N/A
lower-/.f32N/A
lower-/.f3240.2
Applied rewrites40.2%
Taylor expanded in x around 0
lower-/.f3234.6
Applied rewrites34.6%
if -10 < (/.f32 (neg.f32 x) s) Initial program 99.8%
Taylor expanded in x around 0
lower-+.f32N/A
lower-*.f32N/A
lower-/.f3240.5
Applied rewrites40.5%
lift-+.f32N/A
lift-*.f32N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f3240.5
Applied rewrites40.5%
lift--.f32N/A
lift-/.f32N/A
frac-2negN/A
lift-neg.f32N/A
sub-to-fractionN/A
mult-flipN/A
metadata-evalN/A
frac-2negN/A
lift-/.f32N/A
lower-*.f32N/A
sub-flip-reverseN/A
lift-neg.f32N/A
remove-double-negN/A
+-commutativeN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
count-2-revN/A
associate--r+N/A
lower--.f32N/A
lower--.f3240.4
Applied rewrites40.4%
*-lft-identityN/A
*-commutativeN/A
lift-/.f32N/A
metadata-evalN/A
frac-timesN/A
metadata-evalN/A
lower-/.f32N/A
lower-*.f3240.6
Applied rewrites40.6%
(FPCore (x s) :precision binary32 (if (<= (/ (- x) s) -10.0) (/ 1.0 (* x (/ 2.0 x))) (/ 1.0 (/ (- s (- x s)) s))))
float code(float x, float s) {
float tmp;
if ((-x / s) <= -10.0f) {
tmp = 1.0f / (x * (2.0f / x));
} else {
tmp = 1.0f / ((s - (x - s)) / s);
}
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(x, s)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if ((-x / s) <= (-10.0e0)) then
tmp = 1.0e0 / (x * (2.0e0 / x))
else
tmp = 1.0e0 / ((s - (x - s)) / s)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(Float32(-x) / s) <= Float32(-10.0)) tmp = Float32(Float32(1.0) / Float32(x * Float32(Float32(2.0) / x))); else tmp = Float32(Float32(1.0) / Float32(Float32(s - Float32(x - s)) / s)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((-x / s) <= single(-10.0)) tmp = single(1.0) / (x * (single(2.0) / x)); else tmp = single(1.0) / ((s - (x - s)) / s); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{-x}{s} \leq -10:\\
\;\;\;\;\frac{1}{x \cdot \frac{2}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{s - \left(x - s\right)}{s}}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -10Initial program 99.8%
Taylor expanded in x around 0
lower-+.f32N/A
lower-*.f32N/A
lower-/.f3240.5
Applied rewrites40.5%
Taylor expanded in x around inf
lower-*.f32N/A
lower--.f32N/A
lower-*.f32N/A
lower-/.f32N/A
lower-/.f3240.2
Applied rewrites40.2%
Taylor expanded in x around 0
lower-/.f3234.6
Applied rewrites34.6%
if -10 < (/.f32 (neg.f32 x) s) Initial program 99.8%
Taylor expanded in x around 0
lower-+.f32N/A
lower-*.f32N/A
lower-/.f3240.5
Applied rewrites40.5%
lift-+.f32N/A
lift-*.f32N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f3240.5
Applied rewrites40.5%
lift--.f32N/A
lift-/.f32N/A
frac-2negN/A
lift-neg.f32N/A
sub-to-fractionN/A
mult-flipN/A
metadata-evalN/A
frac-2negN/A
lift-/.f32N/A
lower-*.f32N/A
sub-flip-reverseN/A
lift-neg.f32N/A
remove-double-negN/A
+-commutativeN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
count-2-revN/A
associate--r+N/A
lower--.f32N/A
lower--.f3240.4
Applied rewrites40.4%
lift-*.f32N/A
lift-/.f32N/A
frac-2negN/A
metadata-evalN/A
mult-flip-revN/A
lift--.f32N/A
lift--.f32N/A
associate--l-N/A
lift-+.f32N/A
sub-negate-revN/A
lift--.f32N/A
frac-2negN/A
lower-/.f3240.5
lift--.f32N/A
lift-+.f32N/A
associate--l+N/A
add-flip-revN/A
sub-negate-revN/A
lift--.f32N/A
lower--.f3240.4
Applied rewrites40.4%
(FPCore (x s) :precision binary32 (if (<= (/ (- x) s) -10.0) (/ 1.0 (* x (/ 2.0 x))) (/ 1.0 (- 2.0 (/ x s)))))
float code(float x, float s) {
float tmp;
if ((-x / s) <= -10.0f) {
tmp = 1.0f / (x * (2.0f / x));
} else {
tmp = 1.0f / (2.0f - (x / s));
}
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(x, s)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if ((-x / s) <= (-10.0e0)) then
tmp = 1.0e0 / (x * (2.0e0 / x))
else
tmp = 1.0e0 / (2.0e0 - (x / s))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(Float32(-x) / s) <= Float32(-10.0)) tmp = Float32(Float32(1.0) / Float32(x * Float32(Float32(2.0) / x))); else tmp = Float32(Float32(1.0) / Float32(Float32(2.0) - Float32(x / s))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((-x / s) <= single(-10.0)) tmp = single(1.0) / (x * (single(2.0) / x)); else tmp = single(1.0) / (single(2.0) - (x / s)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{-x}{s} \leq -10:\\
\;\;\;\;\frac{1}{x \cdot \frac{2}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 - \frac{x}{s}}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -10Initial program 99.8%
Taylor expanded in x around 0
lower-+.f32N/A
lower-*.f32N/A
lower-/.f3240.5
Applied rewrites40.5%
Taylor expanded in x around inf
lower-*.f32N/A
lower--.f32N/A
lower-*.f32N/A
lower-/.f32N/A
lower-/.f3240.2
Applied rewrites40.2%
Taylor expanded in x around 0
lower-/.f3234.6
Applied rewrites34.6%
if -10 < (/.f32 (neg.f32 x) s) Initial program 99.8%
Taylor expanded in x around 0
lower-+.f32N/A
lower-*.f32N/A
lower-/.f3240.5
Applied rewrites40.5%
lift-+.f32N/A
lift-*.f32N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f3240.5
Applied rewrites40.5%
(FPCore (x s) :precision binary32 (if (<= (/ (- x) s) -10.0) 0.5 (/ 1.0 (- 2.0 (/ x s)))))
float code(float x, float s) {
float tmp;
if ((-x / s) <= -10.0f) {
tmp = 0.5f;
} else {
tmp = 1.0f / (2.0f - (x / s));
}
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(x, s)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if ((-x / s) <= (-10.0e0)) then
tmp = 0.5e0
else
tmp = 1.0e0 / (2.0e0 - (x / s))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(Float32(-x) / s) <= Float32(-10.0)) tmp = Float32(0.5); else tmp = Float32(Float32(1.0) / Float32(Float32(2.0) - Float32(x / s))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((-x / s) <= single(-10.0)) tmp = single(0.5); else tmp = single(1.0) / (single(2.0) - (x / s)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{-x}{s} \leq -10:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 - \frac{x}{s}}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -10Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites34.8%
if -10 < (/.f32 (neg.f32 x) s) Initial program 99.8%
Taylor expanded in x around 0
lower-+.f32N/A
lower-*.f32N/A
lower-/.f3240.5
Applied rewrites40.5%
lift-+.f32N/A
lift-*.f32N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f3240.5
Applied rewrites40.5%
(FPCore (x s) :precision binary32 0.5)
float code(float x, float s) {
return 0.5f;
}
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(x, s)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 0.5e0
end function
function code(x, s) return Float32(0.5) end
function tmp = code(x, s) tmp = single(0.5); end
\begin{array}{l}
\\
0.5
\end{array}
Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites34.8%
herbie shell --seed 2025156
(FPCore (x s)
:name "Logistic function"
:precision binary32
:pre (and (<= 0.0 s) (<= s 1.0651631))
(/ 1.0 (+ 1.0 (exp (/ (- x) s)))))