
(FPCore (x eps) :precision binary64 (/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))
double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
}
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(8) function code(x, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0
end function
public static double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-((1.0 + eps) * x)))) / 2.0;
}
def code(x, eps): return (((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-((1.0 + eps) * x)))) / 2.0
function code(x, eps) return Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(-Float64(Float64(1.0 - eps) * x)))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * exp(Float64(-Float64(Float64(1.0 + eps) * x))))) / 2.0) end
function tmp = code(x, eps) tmp = (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0; end
code[x_, eps_] := N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}
\end{array}
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))
double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
}
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(8) function code(x, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0
end function
public static double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-((1.0 + eps) * x)))) / 2.0;
}
def code(x, eps): return (((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-((1.0 + eps) * x)))) / 2.0
function code(x, eps) return Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(-Float64(Float64(1.0 - eps) * x)))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * exp(Float64(-Float64(Float64(1.0 + eps) * x))))) / 2.0) end
function tmp = code(x, eps) tmp = (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0; end
code[x_, eps_] := N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}
\end{array}
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= eps_m 6.5e-6)
(* (+ t_0 t_0) 0.5)
(* (- (exp (* x eps_m)) (- (exp (- (* x eps_m))))) 0.5))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = exp(-x);
double tmp;
if (eps_m <= 6.5e-6) {
tmp = (t_0 + t_0) * 0.5;
} else {
tmp = (exp((x * eps_m)) - -exp(-(x * eps_m))) * 0.5;
}
return tmp;
}
eps_m = private
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(8) function code(x, eps_m)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: t_0
real(8) :: tmp
t_0 = exp(-x)
if (eps_m <= 6.5d-6) then
tmp = (t_0 + t_0) * 0.5d0
else
tmp = (exp((x * eps_m)) - -exp(-(x * eps_m))) * 0.5d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double t_0 = Math.exp(-x);
double tmp;
if (eps_m <= 6.5e-6) {
tmp = (t_0 + t_0) * 0.5;
} else {
tmp = (Math.exp((x * eps_m)) - -Math.exp(-(x * eps_m))) * 0.5;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = math.exp(-x) tmp = 0 if eps_m <= 6.5e-6: tmp = (t_0 + t_0) * 0.5 else: tmp = (math.exp((x * eps_m)) - -math.exp(-(x * eps_m))) * 0.5 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = exp(Float64(-x)) tmp = 0.0 if (eps_m <= 6.5e-6) tmp = Float64(Float64(t_0 + t_0) * 0.5); else tmp = Float64(Float64(exp(Float64(x * eps_m)) - Float64(-exp(Float64(-Float64(x * eps_m))))) * 0.5); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = exp(-x); tmp = 0.0; if (eps_m <= 6.5e-6) tmp = (t_0 + t_0) * 0.5; else tmp = (exp((x * eps_m)) - -exp(-(x * eps_m))) * 0.5; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[eps$95$m, 6.5e-6], N[(N[(t$95$0 + t$95$0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] - (-N[Exp[(-N[(x * eps$95$m), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;eps\_m \leq 6.5 \cdot 10^{-6}:\\
\;\;\;\;\left(t\_0 + t\_0\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(e^{x \cdot eps\_m} - \left(-e^{-x \cdot eps\_m}\right)\right) \cdot 0.5\\
\end{array}
\end{array}
if eps < 6.4999999999999996e-6Initial program 37.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites97.8%
Taylor expanded in eps around 0
mul-1-negN/A
lower-+.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f6497.8
Applied rewrites97.8%
if 6.4999999999999996e-6 < eps Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6499.5
Applied rewrites99.5%
Taylor expanded in eps around inf
*-commutativeN/A
lift-*.f6499.5
Applied rewrites99.5%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (* (- (exp (* (- x) (- 1.0 eps_m))) (- (exp (- (fma x eps_m x))))) 0.5))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return (exp((-x * (1.0 - eps_m))) - -exp(-fma(x, eps_m, x))) * 0.5;
}
eps_m = abs(eps) function code(x, eps_m) return Float64(Float64(exp(Float64(Float64(-x) * Float64(1.0 - eps_m))) - Float64(-exp(Float64(-fma(x, eps_m, x))))) * 0.5) end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(N[(N[Exp[N[((-x) * N[(1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - (-N[Exp[(-N[(x * eps$95$m + x), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\left(e^{\left(-x\right) \cdot \left(1 - eps\_m\right)} - \left(-e^{-\mathsf{fma}\left(x, eps\_m, x\right)}\right)\right) \cdot 0.5
\end{array}
Initial program 73.7%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.0%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= eps_m 6.5e-6)
(* (+ t_0 t_0) 0.5)
(* (- (exp (* x eps_m)) (- (exp (- (fma x eps_m x))))) 0.5))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = exp(-x);
double tmp;
if (eps_m <= 6.5e-6) {
tmp = (t_0 + t_0) * 0.5;
} else {
tmp = (exp((x * eps_m)) - -exp(-fma(x, eps_m, x))) * 0.5;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) t_0 = exp(Float64(-x)) tmp = 0.0 if (eps_m <= 6.5e-6) tmp = Float64(Float64(t_0 + t_0) * 0.5); else tmp = Float64(Float64(exp(Float64(x * eps_m)) - Float64(-exp(Float64(-fma(x, eps_m, x))))) * 0.5); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[eps$95$m, 6.5e-6], N[(N[(t$95$0 + t$95$0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] - (-N[Exp[(-N[(x * eps$95$m + x), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;eps\_m \leq 6.5 \cdot 10^{-6}:\\
\;\;\;\;\left(t\_0 + t\_0\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(e^{x \cdot eps\_m} - \left(-e^{-\mathsf{fma}\left(x, eps\_m, x\right)}\right)\right) \cdot 0.5\\
\end{array}
\end{array}
if eps < 6.4999999999999996e-6Initial program 37.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites97.8%
Taylor expanded in eps around 0
mul-1-negN/A
lower-+.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f6497.8
Applied rewrites97.8%
if 6.4999999999999996e-6 < eps Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6499.5
Applied rewrites99.5%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -4e-249)
(* (- 1.0 (- (exp (- (* x eps_m))))) 0.5)
(if (<= x 7.5e+152)
(* (- (exp (* (- x) (- 1.0 eps_m))) -1.0) 0.5)
(/ (- (+ (/ 1.0 eps_m) 1.0) (/ 1.0 eps_m)) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -4e-249) {
tmp = (1.0 - -exp(-(x * eps_m))) * 0.5;
} else if (x <= 7.5e+152) {
tmp = (exp((-x * (1.0 - eps_m))) - -1.0) * 0.5;
} else {
tmp = (((1.0 / eps_m) + 1.0) - (1.0 / eps_m)) / 2.0;
}
return tmp;
}
eps_m = private
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(8) function code(x, eps_m)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= (-4d-249)) then
tmp = (1.0d0 - -exp(-(x * eps_m))) * 0.5d0
else if (x <= 7.5d+152) then
tmp = (exp((-x * (1.0d0 - eps_m))) - (-1.0d0)) * 0.5d0
else
tmp = (((1.0d0 / eps_m) + 1.0d0) - (1.0d0 / eps_m)) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= -4e-249) {
tmp = (1.0 - -Math.exp(-(x * eps_m))) * 0.5;
} else if (x <= 7.5e+152) {
tmp = (Math.exp((-x * (1.0 - eps_m))) - -1.0) * 0.5;
} else {
tmp = (((1.0 / eps_m) + 1.0) - (1.0 / eps_m)) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -4e-249: tmp = (1.0 - -math.exp(-(x * eps_m))) * 0.5 elif x <= 7.5e+152: tmp = (math.exp((-x * (1.0 - eps_m))) - -1.0) * 0.5 else: tmp = (((1.0 / eps_m) + 1.0) - (1.0 / eps_m)) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -4e-249) tmp = Float64(Float64(1.0 - Float64(-exp(Float64(-Float64(x * eps_m))))) * 0.5); elseif (x <= 7.5e+152) tmp = Float64(Float64(exp(Float64(Float64(-x) * Float64(1.0 - eps_m))) - -1.0) * 0.5); else tmp = Float64(Float64(Float64(Float64(1.0 / eps_m) + 1.0) - Float64(1.0 / eps_m)) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -4e-249) tmp = (1.0 - -exp(-(x * eps_m))) * 0.5; elseif (x <= 7.5e+152) tmp = (exp((-x * (1.0 - eps_m))) - -1.0) * 0.5; else tmp = (((1.0 / eps_m) + 1.0) - (1.0 / eps_m)) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -4e-249], N[(N[(1.0 - (-N[Exp[(-N[(x * eps$95$m), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 7.5e+152], N[(N[(N[Exp[N[((-x) * N[(1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] + 1.0), $MachinePrecision] - N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{-249}:\\
\;\;\;\;\left(1 - \left(-e^{-x \cdot eps\_m}\right)\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{+152}:\\
\;\;\;\;\left(e^{\left(-x\right) \cdot \left(1 - eps\_m\right)} - -1\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{1}{eps\_m} + 1\right) - \frac{1}{eps\_m}}{2}\\
\end{array}
\end{array}
if x < -4.00000000000000022e-249Initial program 70.7%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.5%
Taylor expanded in x around 0
Applied rewrites97.9%
Taylor expanded in eps around inf
*-commutativeN/A
lift-*.f6498.2
Applied rewrites98.2%
if -4.00000000000000022e-249 < x < 7.50000000000000046e152Initial program 68.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.1%
Taylor expanded in x around 0
Applied rewrites83.2%
if 7.50000000000000046e152 < x Initial program 100.0%
Taylor expanded in x around 0
lift-/.f64N/A
lift--.f6451.8
Applied rewrites51.8%
Taylor expanded in eps around 0
lift-/.f6451.8
Applied rewrites51.8%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lift-/.f6447.9
Applied rewrites47.9%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -4e-249)
(* (- 1.0 (- (exp (- (* x eps_m))))) 0.5)
(if (<= x 7.5e+152)
(* (- (exp (* x eps_m)) -1.0) 0.5)
(/ (- (+ (/ 1.0 eps_m) 1.0) (/ 1.0 eps_m)) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -4e-249) {
tmp = (1.0 - -exp(-(x * eps_m))) * 0.5;
} else if (x <= 7.5e+152) {
tmp = (exp((x * eps_m)) - -1.0) * 0.5;
} else {
tmp = (((1.0 / eps_m) + 1.0) - (1.0 / eps_m)) / 2.0;
}
return tmp;
}
eps_m = private
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(8) function code(x, eps_m)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= (-4d-249)) then
tmp = (1.0d0 - -exp(-(x * eps_m))) * 0.5d0
else if (x <= 7.5d+152) then
tmp = (exp((x * eps_m)) - (-1.0d0)) * 0.5d0
else
tmp = (((1.0d0 / eps_m) + 1.0d0) - (1.0d0 / eps_m)) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= -4e-249) {
tmp = (1.0 - -Math.exp(-(x * eps_m))) * 0.5;
} else if (x <= 7.5e+152) {
tmp = (Math.exp((x * eps_m)) - -1.0) * 0.5;
} else {
tmp = (((1.0 / eps_m) + 1.0) - (1.0 / eps_m)) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -4e-249: tmp = (1.0 - -math.exp(-(x * eps_m))) * 0.5 elif x <= 7.5e+152: tmp = (math.exp((x * eps_m)) - -1.0) * 0.5 else: tmp = (((1.0 / eps_m) + 1.0) - (1.0 / eps_m)) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -4e-249) tmp = Float64(Float64(1.0 - Float64(-exp(Float64(-Float64(x * eps_m))))) * 0.5); elseif (x <= 7.5e+152) tmp = Float64(Float64(exp(Float64(x * eps_m)) - -1.0) * 0.5); else tmp = Float64(Float64(Float64(Float64(1.0 / eps_m) + 1.0) - Float64(1.0 / eps_m)) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -4e-249) tmp = (1.0 - -exp(-(x * eps_m))) * 0.5; elseif (x <= 7.5e+152) tmp = (exp((x * eps_m)) - -1.0) * 0.5; else tmp = (((1.0 / eps_m) + 1.0) - (1.0 / eps_m)) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -4e-249], N[(N[(1.0 - (-N[Exp[(-N[(x * eps$95$m), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 7.5e+152], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] + 1.0), $MachinePrecision] - N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{-249}:\\
\;\;\;\;\left(1 - \left(-e^{-x \cdot eps\_m}\right)\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{+152}:\\
\;\;\;\;\left(e^{x \cdot eps\_m} - -1\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{1}{eps\_m} + 1\right) - \frac{1}{eps\_m}}{2}\\
\end{array}
\end{array}
if x < -4.00000000000000022e-249Initial program 70.7%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.5%
Taylor expanded in x around 0
Applied rewrites97.9%
Taylor expanded in eps around inf
*-commutativeN/A
lift-*.f6498.2
Applied rewrites98.2%
if -4.00000000000000022e-249 < x < 7.50000000000000046e152Initial program 68.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.1%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6484.6
Applied rewrites84.6%
Taylor expanded in x around 0
Applied rewrites83.5%
if 7.50000000000000046e152 < x Initial program 100.0%
Taylor expanded in x around 0
lift-/.f64N/A
lift--.f6451.8
Applied rewrites51.8%
Taylor expanded in eps around 0
lift-/.f6451.8
Applied rewrites51.8%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lift-/.f6447.9
Applied rewrites47.9%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -380.0)
(* (- 1.0 (- (exp (- x)))) 0.5)
(if (<= x 7.5e+152)
(* (- (exp (* x eps_m)) -1.0) 0.5)
(/ (- (+ (/ 1.0 eps_m) 1.0) (/ 1.0 eps_m)) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -380.0) {
tmp = (1.0 - -exp(-x)) * 0.5;
} else if (x <= 7.5e+152) {
tmp = (exp((x * eps_m)) - -1.0) * 0.5;
} else {
tmp = (((1.0 / eps_m) + 1.0) - (1.0 / eps_m)) / 2.0;
}
return tmp;
}
eps_m = private
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(8) function code(x, eps_m)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= (-380.0d0)) then
tmp = (1.0d0 - -exp(-x)) * 0.5d0
else if (x <= 7.5d+152) then
tmp = (exp((x * eps_m)) - (-1.0d0)) * 0.5d0
else
tmp = (((1.0d0 / eps_m) + 1.0d0) - (1.0d0 / eps_m)) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= -380.0) {
tmp = (1.0 - -Math.exp(-x)) * 0.5;
} else if (x <= 7.5e+152) {
tmp = (Math.exp((x * eps_m)) - -1.0) * 0.5;
} else {
tmp = (((1.0 / eps_m) + 1.0) - (1.0 / eps_m)) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -380.0: tmp = (1.0 - -math.exp(-x)) * 0.5 elif x <= 7.5e+152: tmp = (math.exp((x * eps_m)) - -1.0) * 0.5 else: tmp = (((1.0 / eps_m) + 1.0) - (1.0 / eps_m)) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -380.0) tmp = Float64(Float64(1.0 - Float64(-exp(Float64(-x)))) * 0.5); elseif (x <= 7.5e+152) tmp = Float64(Float64(exp(Float64(x * eps_m)) - -1.0) * 0.5); else tmp = Float64(Float64(Float64(Float64(1.0 / eps_m) + 1.0) - Float64(1.0 / eps_m)) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -380.0) tmp = (1.0 - -exp(-x)) * 0.5; elseif (x <= 7.5e+152) tmp = (exp((x * eps_m)) - -1.0) * 0.5; else tmp = (((1.0 / eps_m) + 1.0) - (1.0 / eps_m)) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -380.0], N[(N[(1.0 - (-N[Exp[(-x)], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 7.5e+152], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] + 1.0), $MachinePrecision] - N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -380:\\
\;\;\;\;\left(1 - \left(-e^{-x}\right)\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{+152}:\\
\;\;\;\;\left(e^{x \cdot eps\_m} - -1\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{1}{eps\_m} + 1\right) - \frac{1}{eps\_m}}{2}\\
\end{array}
\end{array}
if x < -380Initial program 99.5%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.5%
Taylor expanded in x around 0
Applied rewrites99.5%
Taylor expanded in eps around 0
Applied rewrites99.5%
if -380 < x < 7.50000000000000046e152Initial program 63.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.8%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6489.0
Applied rewrites89.0%
Taylor expanded in x around 0
Applied rewrites78.9%
if 7.50000000000000046e152 < x Initial program 100.0%
Taylor expanded in x around 0
lift-/.f64N/A
lift--.f6451.8
Applied rewrites51.8%
Taylor expanded in eps around 0
lift-/.f6451.8
Applied rewrites51.8%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lift-/.f6447.9
Applied rewrites47.9%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 2400.0)
(* (- 1.0 (- (exp (- x)))) 0.5)
(if (<= x 5.8e+109)
(/ (- (/ 1.0 eps_m) (/ 1.0 eps_m)) 2.0)
(if (<= x 7.5e+152)
(fma (* (- (* 0.3333333333333333 x) 0.5) x) x 1.0)
(/ (- (+ (/ 1.0 eps_m) 1.0) (/ 1.0 eps_m)) 2.0)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 2400.0) {
tmp = (1.0 - -exp(-x)) * 0.5;
} else if (x <= 5.8e+109) {
tmp = ((1.0 / eps_m) - (1.0 / eps_m)) / 2.0;
} else if (x <= 7.5e+152) {
tmp = fma((((0.3333333333333333 * x) - 0.5) * x), x, 1.0);
} else {
tmp = (((1.0 / eps_m) + 1.0) - (1.0 / eps_m)) / 2.0;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 2400.0) tmp = Float64(Float64(1.0 - Float64(-exp(Float64(-x)))) * 0.5); elseif (x <= 5.8e+109) tmp = Float64(Float64(Float64(1.0 / eps_m) - Float64(1.0 / eps_m)) / 2.0); elseif (x <= 7.5e+152) tmp = fma(Float64(Float64(Float64(0.3333333333333333 * x) - 0.5) * x), x, 1.0); else tmp = Float64(Float64(Float64(Float64(1.0 / eps_m) + 1.0) - Float64(1.0 / eps_m)) / 2.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 2400.0], N[(N[(1.0 - (-N[Exp[(-x)], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 5.8e+109], N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] - N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 7.5e+152], N[(N[(N[(N[(0.3333333333333333 * x), $MachinePrecision] - 0.5), $MachinePrecision] * x), $MachinePrecision] * x + 1.0), $MachinePrecision], N[(N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] + 1.0), $MachinePrecision] - N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2400:\\
\;\;\;\;\left(1 - \left(-e^{-x}\right)\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{+109}:\\
\;\;\;\;\frac{\frac{1}{eps\_m} - \frac{1}{eps\_m}}{2}\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{+152}:\\
\;\;\;\;\mathsf{fma}\left(\left(0.3333333333333333 \cdot x - 0.5\right) \cdot x, x, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{1}{eps\_m} + 1\right) - \frac{1}{eps\_m}}{2}\\
\end{array}
\end{array}
if x < 2400Initial program 63.5%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.7%
Taylor expanded in x around 0
Applied rewrites88.0%
Taylor expanded in eps around 0
Applied rewrites78.7%
if 2400 < x < 5.8e109Initial program 100.0%
Taylor expanded in x around 0
lift-/.f64N/A
lift--.f6451.4
Applied rewrites51.4%
Taylor expanded in eps around 0
lift-/.f6451.4
Applied rewrites51.4%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lift-/.f6448.2
Applied rewrites48.2%
Taylor expanded in eps around 0
lift-/.f6450.5
Applied rewrites50.5%
if 5.8e109 < x < 7.50000000000000046e152Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites53.2%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f640.8
Applied rewrites0.8%
lift-*.f64N/A
lift-fma.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift--.f640.8
Applied rewrites0.8%
Taylor expanded in x around 0
Applied rewrites48.4%
if 7.50000000000000046e152 < x Initial program 100.0%
Taylor expanded in x around 0
lift-/.f64N/A
lift--.f6451.8
Applied rewrites51.8%
Taylor expanded in eps around 0
lift-/.f6451.8
Applied rewrites51.8%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lift-/.f6447.9
Applied rewrites47.9%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 2.25e-17)
(* (- 1.0 (- (fma x eps_m x) 1.0)) 0.5)
(if (<= x 5.8e+109)
(/ (- (/ 1.0 eps_m) (/ 1.0 eps_m)) 2.0)
(if (<= x 7.5e+152)
(fma (* (- (* 0.3333333333333333 x) 0.5) x) x 1.0)
(/ (- (+ (/ 1.0 eps_m) 1.0) (/ 1.0 eps_m)) 2.0)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 2.25e-17) {
tmp = (1.0 - (fma(x, eps_m, x) - 1.0)) * 0.5;
} else if (x <= 5.8e+109) {
tmp = ((1.0 / eps_m) - (1.0 / eps_m)) / 2.0;
} else if (x <= 7.5e+152) {
tmp = fma((((0.3333333333333333 * x) - 0.5) * x), x, 1.0);
} else {
tmp = (((1.0 / eps_m) + 1.0) - (1.0 / eps_m)) / 2.0;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 2.25e-17) tmp = Float64(Float64(1.0 - Float64(fma(x, eps_m, x) - 1.0)) * 0.5); elseif (x <= 5.8e+109) tmp = Float64(Float64(Float64(1.0 / eps_m) - Float64(1.0 / eps_m)) / 2.0); elseif (x <= 7.5e+152) tmp = fma(Float64(Float64(Float64(0.3333333333333333 * x) - 0.5) * x), x, 1.0); else tmp = Float64(Float64(Float64(Float64(1.0 / eps_m) + 1.0) - Float64(1.0 / eps_m)) / 2.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 2.25e-17], N[(N[(1.0 - N[(N[(x * eps$95$m + x), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 5.8e+109], N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] - N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 7.5e+152], N[(N[(N[(N[(0.3333333333333333 * x), $MachinePrecision] - 0.5), $MachinePrecision] * x), $MachinePrecision] * x + 1.0), $MachinePrecision], N[(N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] + 1.0), $MachinePrecision] - N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.25 \cdot 10^{-17}:\\
\;\;\;\;\left(1 - \left(\mathsf{fma}\left(x, eps\_m, x\right) - 1\right)\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{+109}:\\
\;\;\;\;\frac{\frac{1}{eps\_m} - \frac{1}{eps\_m}}{2}\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{+152}:\\
\;\;\;\;\mathsf{fma}\left(\left(0.3333333333333333 \cdot x - 0.5\right) \cdot x, x, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{1}{eps\_m} + 1\right) - \frac{1}{eps\_m}}{2}\\
\end{array}
\end{array}
if x < 2.24999999999999989e-17Initial program 63.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.2%
Taylor expanded in x around 0
Applied rewrites89.5%
Taylor expanded in x around 0
lower--.f64N/A
*-commutativeN/A
+-commutativeN/A
distribute-rgt1-inN/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f6470.4
Applied rewrites70.4%
if 2.24999999999999989e-17 < x < 5.8e109Initial program 93.6%
Taylor expanded in x around 0
lift-/.f64N/A
lift--.f6451.6
Applied rewrites51.6%
Taylor expanded in eps around 0
lift-/.f6451.4
Applied rewrites51.4%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lift-/.f6441.8
Applied rewrites41.8%
Taylor expanded in eps around 0
lift-/.f6443.6
Applied rewrites43.6%
if 5.8e109 < x < 7.50000000000000046e152Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites53.2%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f640.8
Applied rewrites0.8%
lift-*.f64N/A
lift-fma.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift--.f640.8
Applied rewrites0.8%
Taylor expanded in x around 0
Applied rewrites48.4%
if 7.50000000000000046e152 < x Initial program 100.0%
Taylor expanded in x around 0
lift-/.f64N/A
lift--.f6451.8
Applied rewrites51.8%
Taylor expanded in eps around 0
lift-/.f6451.8
Applied rewrites51.8%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lift-/.f6447.9
Applied rewrites47.9%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 2.25e-17) (* (- 1.0 (- (fma x eps_m x) 1.0)) 0.5) (/ (- (/ 1.0 eps_m) (/ 1.0 eps_m)) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 2.25e-17) {
tmp = (1.0 - (fma(x, eps_m, x) - 1.0)) * 0.5;
} else {
tmp = ((1.0 / eps_m) - (1.0 / eps_m)) / 2.0;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 2.25e-17) tmp = Float64(Float64(1.0 - Float64(fma(x, eps_m, x) - 1.0)) * 0.5); else tmp = Float64(Float64(Float64(1.0 / eps_m) - Float64(1.0 / eps_m)) / 2.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 2.25e-17], N[(N[(1.0 - N[(N[(x * eps$95$m + x), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] - N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.25 \cdot 10^{-17}:\\
\;\;\;\;\left(1 - \left(\mathsf{fma}\left(x, eps\_m, x\right) - 1\right)\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{eps\_m} - \frac{1}{eps\_m}}{2}\\
\end{array}
\end{array}
if x < 2.24999999999999989e-17Initial program 63.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.2%
Taylor expanded in x around 0
Applied rewrites89.5%
Taylor expanded in x around 0
lower--.f64N/A
*-commutativeN/A
+-commutativeN/A
distribute-rgt1-inN/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f6470.4
Applied rewrites70.4%
if 2.24999999999999989e-17 < x Initial program 97.4%
Taylor expanded in x around 0
lift-/.f64N/A
lift--.f6451.3
Applied rewrites51.3%
Taylor expanded in eps around 0
lift-/.f6451.2
Applied rewrites51.2%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lift-/.f6445.9
Applied rewrites45.9%
Taylor expanded in eps around 0
lift-/.f6447.9
Applied rewrites47.9%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 2400.0) 1.0 (/ (- (/ 1.0 eps_m) (/ 1.0 eps_m)) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 2400.0) {
tmp = 1.0;
} else {
tmp = ((1.0 / eps_m) - (1.0 / eps_m)) / 2.0;
}
return tmp;
}
eps_m = private
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(8) function code(x, eps_m)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= 2400.0d0) then
tmp = 1.0d0
else
tmp = ((1.0d0 / eps_m) - (1.0d0 / eps_m)) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= 2400.0) {
tmp = 1.0;
} else {
tmp = ((1.0 / eps_m) - (1.0 / eps_m)) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 2400.0: tmp = 1.0 else: tmp = ((1.0 / eps_m) - (1.0 / eps_m)) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 2400.0) tmp = 1.0; else tmp = Float64(Float64(Float64(1.0 / eps_m) - Float64(1.0 / eps_m)) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 2400.0) tmp = 1.0; else tmp = ((1.0 / eps_m) - (1.0 / eps_m)) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 2400.0], 1.0, N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] - N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2400:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{eps\_m} - \frac{1}{eps\_m}}{2}\\
\end{array}
\end{array}
if x < 2400Initial program 63.5%
Taylor expanded in x around 0
Applied rewrites60.1%
if 2400 < x Initial program 100.0%
Taylor expanded in x around 0
lift-/.f64N/A
lift--.f6451.2
Applied rewrites51.2%
Taylor expanded in eps around 0
lift-/.f6451.2
Applied rewrites51.2%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lift-/.f6448.5
Applied rewrites48.5%
Taylor expanded in eps around 0
lift-/.f6450.7
Applied rewrites50.7%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 1.0)
eps_m = fabs(eps);
double code(double x, double eps_m) {
return 1.0;
}
eps_m = private
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(8) function code(x, eps_m)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
code = 1.0d0
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
return 1.0;
}
eps_m = math.fabs(eps) def code(x, eps_m): return 1.0
eps_m = abs(eps) function code(x, eps_m) return 1.0 end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = 1.0; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := 1.0
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
1
\end{array}
Initial program 73.7%
Taylor expanded in x around 0
Applied rewrites44.1%
herbie shell --seed 2025114
(FPCore (x eps)
:name "NMSE Section 6.1 mentioned, A"
:precision binary64
(/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))