
(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 0.00021)
(* (+ t_0 t_0) 0.5)
(* (+ (exp (* x eps_m)) (exp (* (- 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 <= 0.00021) {
tmp = (t_0 + t_0) * 0.5;
} else {
tmp = (exp((x * eps_m)) + exp((-eps_m * x))) * 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 <= 0.00021d0) then
tmp = (t_0 + t_0) * 0.5d0
else
tmp = (exp((x * eps_m)) + exp((-eps_m * x))) * 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 <= 0.00021) {
tmp = (t_0 + t_0) * 0.5;
} else {
tmp = (Math.exp((x * eps_m)) + Math.exp((-eps_m * x))) * 0.5;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = math.exp(-x) tmp = 0 if eps_m <= 0.00021: tmp = (t_0 + t_0) * 0.5 else: tmp = (math.exp((x * eps_m)) + math.exp((-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 <= 0.00021) tmp = Float64(Float64(t_0 + t_0) * 0.5); else tmp = Float64(Float64(exp(Float64(x * eps_m)) + exp(Float64(Float64(-eps_m) * x))) * 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 <= 0.00021) tmp = (t_0 + t_0) * 0.5; else tmp = (exp((x * eps_m)) + exp((-eps_m * x))) * 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, 0.00021], 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[((-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 0.00021:\\
\;\;\;\;\left(t\_0 + t\_0\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(e^{x \cdot eps\_m} + e^{\left(-eps\_m\right) \cdot x}\right) \cdot 0.5\\
\end{array}
\end{array}
if eps < 2.1000000000000001e-4Initial program 73.0%
Taylor expanded in eps around inf
Applied rewrites99.2%
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.f6471.6
Applied rewrites71.6%
if 2.1000000000000001e-4 < eps Initial program 73.0%
Taylor expanded in eps around inf
Applied rewrites99.2%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6485.1
Applied rewrites85.1%
Taylor expanded in eps around inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f6485.3
Applied rewrites85.3%
lift--.f64N/A
lift-neg.f64N/A
add-flip-revN/A
lower-+.f6485.3
Applied rewrites85.3%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (* (- (exp (* (- eps_m 1.0) x)) (- (exp (- (fma x eps_m x))))) 0.5))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return (exp(((eps_m - 1.0) * x)) - -exp(-fma(x, eps_m, x))) * 0.5;
}
eps_m = abs(eps) function code(x, eps_m) return Float64(Float64(exp(Float64(Float64(eps_m - 1.0) * x)) - 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[(N[(eps$95$m - 1.0), $MachinePrecision] * x), $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(eps\_m - 1\right) \cdot x} - \left(-e^{-\mathsf{fma}\left(x, eps\_m, x\right)}\right)\right) \cdot 0.5
\end{array}
Initial program 73.0%
Taylor expanded in eps around inf
Applied rewrites99.2%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= x -7.5e-225)
(* (- (+ (- x) 1.0) (- (exp (- (fma x eps_m x))))) 0.5)
(if (<= x 9.5e+108)
(* (- (exp (* x eps_m)) -1.0) 0.5)
(* (+ t_0 t_0) 0.5)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = exp(-x);
double tmp;
if (x <= -7.5e-225) {
tmp = ((-x + 1.0) - -exp(-fma(x, eps_m, x))) * 0.5;
} else if (x <= 9.5e+108) {
tmp = (exp((x * eps_m)) - -1.0) * 0.5;
} else {
tmp = (t_0 + t_0) * 0.5;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) t_0 = exp(Float64(-x)) tmp = 0.0 if (x <= -7.5e-225) tmp = Float64(Float64(Float64(Float64(-x) + 1.0) - Float64(-exp(Float64(-fma(x, eps_m, x))))) * 0.5); elseif (x <= 9.5e+108) tmp = Float64(Float64(exp(Float64(x * eps_m)) - -1.0) * 0.5); else tmp = Float64(Float64(t_0 + t_0) * 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[x, -7.5e-225], N[(N[(N[((-x) + 1.0), $MachinePrecision] - (-N[Exp[(-N[(x * eps$95$m + x), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 9.5e+108], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(t$95$0 + t$95$0), $MachinePrecision] * 0.5), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;x \leq -7.5 \cdot 10^{-225}:\\
\;\;\;\;\left(\left(\left(-x\right) + 1\right) - \left(-e^{-\mathsf{fma}\left(x, eps\_m, x\right)}\right)\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{+108}:\\
\;\;\;\;\left(e^{x \cdot eps\_m} - -1\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(t\_0 + t\_0\right) \cdot 0.5\\
\end{array}
\end{array}
if x < -7.49999999999999954e-225Initial program 73.0%
Taylor expanded in eps around inf
Applied rewrites99.2%
Taylor expanded in x around 0
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f6464.5
Applied rewrites64.5%
Taylor expanded in eps around 0
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f6464.0
Applied rewrites64.0%
if -7.49999999999999954e-225 < x < 9.50000000000000097e108Initial program 73.0%
Taylor expanded in eps around inf
Applied rewrites99.2%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6485.1
Applied rewrites85.1%
Taylor expanded in x around 0
Applied rewrites64.0%
if 9.50000000000000097e108 < x Initial program 73.0%
Taylor expanded in eps around inf
Applied rewrites99.2%
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.f6471.6
Applied rewrites71.6%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= x -7.5e-225)
(* (- (+ (- x) 1.0) (- (exp (- (fma x eps_m x))))) 0.5)
(if (<= x 9.5e+108)
(* (- (exp (* x eps_m)) -1.0) 0.5)
(* (* (+ t_0 t_0) x) 0.5)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = exp(-x);
double tmp;
if (x <= -7.5e-225) {
tmp = ((-x + 1.0) - -exp(-fma(x, eps_m, x))) * 0.5;
} else if (x <= 9.5e+108) {
tmp = (exp((x * eps_m)) - -1.0) * 0.5;
} else {
tmp = ((t_0 + t_0) * x) * 0.5;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) t_0 = exp(Float64(-x)) tmp = 0.0 if (x <= -7.5e-225) tmp = Float64(Float64(Float64(Float64(-x) + 1.0) - Float64(-exp(Float64(-fma(x, eps_m, x))))) * 0.5); elseif (x <= 9.5e+108) tmp = Float64(Float64(exp(Float64(x * eps_m)) - -1.0) * 0.5); else tmp = Float64(Float64(Float64(t_0 + t_0) * 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[x, -7.5e-225], N[(N[(N[((-x) + 1.0), $MachinePrecision] - (-N[Exp[(-N[(x * eps$95$m + x), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 9.5e+108], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(t$95$0 + t$95$0), $MachinePrecision] * x), $MachinePrecision] * 0.5), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;x \leq -7.5 \cdot 10^{-225}:\\
\;\;\;\;\left(\left(\left(-x\right) + 1\right) - \left(-e^{-\mathsf{fma}\left(x, eps\_m, x\right)}\right)\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{+108}:\\
\;\;\;\;\left(e^{x \cdot eps\_m} - -1\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(\left(t\_0 + t\_0\right) \cdot x\right) \cdot 0.5\\
\end{array}
\end{array}
if x < -7.49999999999999954e-225Initial program 73.0%
Taylor expanded in eps around inf
Applied rewrites99.2%
Taylor expanded in x around 0
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f6464.5
Applied rewrites64.5%
Taylor expanded in eps around 0
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f6464.0
Applied rewrites64.0%
if -7.49999999999999954e-225 < x < 9.50000000000000097e108Initial program 73.0%
Taylor expanded in eps around inf
Applied rewrites99.2%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6485.1
Applied rewrites85.1%
Taylor expanded in x around 0
Applied rewrites64.0%
if 9.50000000000000097e108 < x Initial program 73.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites58.2%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
mul-1-negN/A
add-flipN/A
mul-1-negN/A
lower-+.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f6416.6
Applied rewrites16.6%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -7.5e-225)
(* (- (+ (- x) 1.0) (- (exp (- (fma x eps_m x))))) 0.5)
(if (<= x 2.2e+104)
(* (- (exp (* x eps_m)) -1.0) 0.5)
(/ (- (/ 1.0 eps_m) (/ (- 1.0 eps_m) eps_m)) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -7.5e-225) {
tmp = ((-x + 1.0) - -exp(-fma(x, eps_m, x))) * 0.5;
} else if (x <= 2.2e+104) {
tmp = (exp((x * eps_m)) - -1.0) * 0.5;
} else {
tmp = ((1.0 / eps_m) - ((1.0 - eps_m) / eps_m)) / 2.0;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -7.5e-225) tmp = Float64(Float64(Float64(Float64(-x) + 1.0) - Float64(-exp(Float64(-fma(x, eps_m, x))))) * 0.5); elseif (x <= 2.2e+104) tmp = Float64(Float64(exp(Float64(x * eps_m)) - -1.0) * 0.5); else tmp = Float64(Float64(Float64(1.0 / eps_m) - Float64(Float64(1.0 - eps_m) / eps_m)) / 2.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -7.5e-225], N[(N[(N[((-x) + 1.0), $MachinePrecision] - (-N[Exp[(-N[(x * eps$95$m + x), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 2.2e+104], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] - N[(N[(1.0 - eps$95$m), $MachinePrecision] / eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.5 \cdot 10^{-225}:\\
\;\;\;\;\left(\left(\left(-x\right) + 1\right) - \left(-e^{-\mathsf{fma}\left(x, eps\_m, x\right)}\right)\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{+104}:\\
\;\;\;\;\left(e^{x \cdot eps\_m} - -1\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{eps\_m} - \frac{1 - eps\_m}{eps\_m}}{2}\\
\end{array}
\end{array}
if x < -7.49999999999999954e-225Initial program 73.0%
Taylor expanded in eps around inf
Applied rewrites99.2%
Taylor expanded in x around 0
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lift--.f6464.5
Applied rewrites64.5%
Taylor expanded in eps around 0
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f6464.0
Applied rewrites64.0%
if -7.49999999999999954e-225 < x < 2.2e104Initial program 73.0%
Taylor expanded in eps around inf
Applied rewrites99.2%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6485.1
Applied rewrites85.1%
Taylor expanded in x around 0
Applied rewrites64.0%
if 2.2e104 < x Initial program 73.0%
Taylor expanded in x around 0
sub-to-multN/A
inv-powN/A
pow-negN/A
metadata-evalN/A
unpow1N/A
sub-flipN/A
mul-1-negN/A
mult-flipN/A
mul-1-negN/A
sub-flipN/A
lower-/.f64N/A
lift--.f6437.5
Applied rewrites37.5%
Taylor expanded in eps around 0
lower-/.f64N/A
lift-neg.f64N/A
lift-exp.f6419.2
Applied rewrites19.2%
Taylor expanded in x around 0
lower-/.f6418.9
Applied rewrites18.9%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -1850.0)
(/ (- (/ (exp (- x)) eps_m) (/ (- eps_m) eps_m)) 2.0)
(if (<= x -4.5e-150)
(*
(fma (- (- eps_m (/ (fma eps_m eps_m -1.0) (- eps_m 1.0))) 1.0) x 2.0)
0.5)
(if (<= x 2.2e+104)
(* (- (exp (* x eps_m)) -1.0) 0.5)
(/ (- (/ 1.0 eps_m) (/ (- 1.0 eps_m) eps_m)) 2.0)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -1850.0) {
tmp = ((exp(-x) / eps_m) - (-eps_m / eps_m)) / 2.0;
} else if (x <= -4.5e-150) {
tmp = fma(((eps_m - (fma(eps_m, eps_m, -1.0) / (eps_m - 1.0))) - 1.0), x, 2.0) * 0.5;
} else if (x <= 2.2e+104) {
tmp = (exp((x * eps_m)) - -1.0) * 0.5;
} else {
tmp = ((1.0 / eps_m) - ((1.0 - eps_m) / eps_m)) / 2.0;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -1850.0) tmp = Float64(Float64(Float64(exp(Float64(-x)) / eps_m) - Float64(Float64(-eps_m) / eps_m)) / 2.0); elseif (x <= -4.5e-150) tmp = Float64(fma(Float64(Float64(eps_m - Float64(fma(eps_m, eps_m, -1.0) / Float64(eps_m - 1.0))) - 1.0), x, 2.0) * 0.5); elseif (x <= 2.2e+104) tmp = Float64(Float64(exp(Float64(x * eps_m)) - -1.0) * 0.5); else tmp = Float64(Float64(Float64(1.0 / eps_m) - Float64(Float64(1.0 - eps_m) / eps_m)) / 2.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -1850.0], N[(N[(N[(N[Exp[(-x)], $MachinePrecision] / eps$95$m), $MachinePrecision] - N[((-eps$95$m) / eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, -4.5e-150], N[(N[(N[(N[(eps$95$m - N[(N[(eps$95$m * eps$95$m + -1.0), $MachinePrecision] / N[(eps$95$m - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 2.2e+104], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] - N[(N[(1.0 - eps$95$m), $MachinePrecision] / eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1850:\\
\;\;\;\;\frac{\frac{e^{-x}}{eps\_m} - \frac{-eps\_m}{eps\_m}}{2}\\
\mathbf{elif}\;x \leq -4.5 \cdot 10^{-150}:\\
\;\;\;\;\mathsf{fma}\left(\left(eps\_m - \frac{\mathsf{fma}\left(eps\_m, eps\_m, -1\right)}{eps\_m - 1}\right) - 1, x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{+104}:\\
\;\;\;\;\left(e^{x \cdot eps\_m} - -1\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{eps\_m} - \frac{1 - eps\_m}{eps\_m}}{2}\\
\end{array}
\end{array}
if x < -1850Initial program 73.0%
Taylor expanded in x around 0
sub-to-multN/A
inv-powN/A
pow-negN/A
metadata-evalN/A
unpow1N/A
sub-flipN/A
mul-1-negN/A
mult-flipN/A
mul-1-negN/A
sub-flipN/A
lower-/.f64N/A
lift--.f6437.5
Applied rewrites37.5%
Taylor expanded in eps around 0
lower-/.f64N/A
lift-neg.f64N/A
lift-exp.f6419.2
Applied rewrites19.2%
Taylor expanded in eps around inf
mul-1-negN/A
lower-neg.f6419.7
Applied rewrites19.7%
if -1850 < x < -4.5000000000000002e-150Initial program 73.0%
Taylor expanded in eps around inf
Applied rewrites99.2%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
add-flipN/A
mul-1-negN/A
add-flipN/A
mul-1-negN/A
sub-negate-revN/A
sub-negate-revN/A
mul-1-negN/A
add-flipN/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6443.9
Applied rewrites43.9%
lift-+.f64N/A
flip-+N/A
lower-/.f64N/A
unpow2N/A
metadata-evalN/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
lift--.f6452.0
Applied rewrites52.0%
lift-*.f64N/A
pow2N/A
lower--.f64N/A
sub-flipN/A
metadata-evalN/A
pow2N/A
lower-fma.f6452.0
Applied rewrites52.0%
if -4.5000000000000002e-150 < x < 2.2e104Initial program 73.0%
Taylor expanded in eps around inf
Applied rewrites99.2%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6485.1
Applied rewrites85.1%
Taylor expanded in x around 0
Applied rewrites64.0%
if 2.2e104 < x Initial program 73.0%
Taylor expanded in x around 0
sub-to-multN/A
inv-powN/A
pow-negN/A
metadata-evalN/A
unpow1N/A
sub-flipN/A
mul-1-negN/A
mult-flipN/A
mul-1-negN/A
sub-flipN/A
lower-/.f64N/A
lift--.f6437.5
Applied rewrites37.5%
Taylor expanded in eps around 0
lower-/.f64N/A
lift-neg.f64N/A
lift-exp.f6419.2
Applied rewrites19.2%
Taylor expanded in x around 0
lower-/.f6418.9
Applied rewrites18.9%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -4.5e-150)
(*
(fma (- (- eps_m (/ (fma eps_m eps_m -1.0) (- eps_m 1.0))) 1.0) x 2.0)
0.5)
(if (<= x 2.2e+104)
(* (- (exp (* x eps_m)) -1.0) 0.5)
(/ (- (/ 1.0 eps_m) (/ (- 1.0 eps_m) eps_m)) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -4.5e-150) {
tmp = fma(((eps_m - (fma(eps_m, eps_m, -1.0) / (eps_m - 1.0))) - 1.0), x, 2.0) * 0.5;
} else if (x <= 2.2e+104) {
tmp = (exp((x * eps_m)) - -1.0) * 0.5;
} else {
tmp = ((1.0 / eps_m) - ((1.0 - eps_m) / eps_m)) / 2.0;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -4.5e-150) tmp = Float64(fma(Float64(Float64(eps_m - Float64(fma(eps_m, eps_m, -1.0) / Float64(eps_m - 1.0))) - 1.0), x, 2.0) * 0.5); elseif (x <= 2.2e+104) tmp = Float64(Float64(exp(Float64(x * eps_m)) - -1.0) * 0.5); else tmp = Float64(Float64(Float64(1.0 / eps_m) - Float64(Float64(1.0 - eps_m) / eps_m)) / 2.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -4.5e-150], N[(N[(N[(N[(eps$95$m - N[(N[(eps$95$m * eps$95$m + -1.0), $MachinePrecision] / N[(eps$95$m - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 2.2e+104], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] - N[(N[(1.0 - eps$95$m), $MachinePrecision] / eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.5 \cdot 10^{-150}:\\
\;\;\;\;\mathsf{fma}\left(\left(eps\_m - \frac{\mathsf{fma}\left(eps\_m, eps\_m, -1\right)}{eps\_m - 1}\right) - 1, x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{+104}:\\
\;\;\;\;\left(e^{x \cdot eps\_m} - -1\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{eps\_m} - \frac{1 - eps\_m}{eps\_m}}{2}\\
\end{array}
\end{array}
if x < -4.5000000000000002e-150Initial program 73.0%
Taylor expanded in eps around inf
Applied rewrites99.2%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
add-flipN/A
mul-1-negN/A
add-flipN/A
mul-1-negN/A
sub-negate-revN/A
sub-negate-revN/A
mul-1-negN/A
add-flipN/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6443.9
Applied rewrites43.9%
lift-+.f64N/A
flip-+N/A
lower-/.f64N/A
unpow2N/A
metadata-evalN/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
lift--.f6452.0
Applied rewrites52.0%
lift-*.f64N/A
pow2N/A
lower--.f64N/A
sub-flipN/A
metadata-evalN/A
pow2N/A
lower-fma.f6452.0
Applied rewrites52.0%
if -4.5000000000000002e-150 < x < 2.2e104Initial program 73.0%
Taylor expanded in eps around inf
Applied rewrites99.2%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6485.1
Applied rewrites85.1%
Taylor expanded in x around 0
Applied rewrites64.0%
if 2.2e104 < x Initial program 73.0%
Taylor expanded in x around 0
sub-to-multN/A
inv-powN/A
pow-negN/A
metadata-evalN/A
unpow1N/A
sub-flipN/A
mul-1-negN/A
mult-flipN/A
mul-1-negN/A
sub-flipN/A
lower-/.f64N/A
lift--.f6437.5
Applied rewrites37.5%
Taylor expanded in eps around 0
lower-/.f64N/A
lift-neg.f64N/A
lift-exp.f6419.2
Applied rewrites19.2%
Taylor expanded in x around 0
lower-/.f6418.9
Applied rewrites18.9%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 2.2e+104) (* (- (exp (* x eps_m)) -1.0) 0.5) (/ (- (/ 1.0 eps_m) (/ (- 1.0 eps_m) eps_m)) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 2.2e+104) {
tmp = (exp((x * eps_m)) - -1.0) * 0.5;
} else {
tmp = ((1.0 / eps_m) - ((1.0 - eps_m) / 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 <= 2.2d+104) then
tmp = (exp((x * eps_m)) - (-1.0d0)) * 0.5d0
else
tmp = ((1.0d0 / eps_m) - ((1.0d0 - eps_m) / 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 <= 2.2e+104) {
tmp = (Math.exp((x * eps_m)) - -1.0) * 0.5;
} else {
tmp = ((1.0 / eps_m) - ((1.0 - eps_m) / eps_m)) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 2.2e+104: tmp = (math.exp((x * eps_m)) - -1.0) * 0.5 else: tmp = ((1.0 / eps_m) - ((1.0 - eps_m) / eps_m)) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 2.2e+104) tmp = Float64(Float64(exp(Float64(x * eps_m)) - -1.0) * 0.5); else tmp = Float64(Float64(Float64(1.0 / eps_m) - Float64(Float64(1.0 - eps_m) / eps_m)) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 2.2e+104) tmp = (exp((x * eps_m)) - -1.0) * 0.5; else tmp = ((1.0 / eps_m) - ((1.0 - eps_m) / eps_m)) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 2.2e+104], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] - N[(N[(1.0 - eps$95$m), $MachinePrecision] / eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.2 \cdot 10^{+104}:\\
\;\;\;\;\left(e^{x \cdot eps\_m} - -1\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{eps\_m} - \frac{1 - eps\_m}{eps\_m}}{2}\\
\end{array}
\end{array}
if x < 2.2e104Initial program 73.0%
Taylor expanded in eps around inf
Applied rewrites99.2%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6485.1
Applied rewrites85.1%
Taylor expanded in x around 0
Applied rewrites64.0%
if 2.2e104 < x Initial program 73.0%
Taylor expanded in x around 0
sub-to-multN/A
inv-powN/A
pow-negN/A
metadata-evalN/A
unpow1N/A
sub-flipN/A
mul-1-negN/A
mult-flipN/A
mul-1-negN/A
sub-flipN/A
lower-/.f64N/A
lift--.f6437.5
Applied rewrites37.5%
Taylor expanded in eps around 0
lower-/.f64N/A
lift-neg.f64N/A
lift-exp.f6419.2
Applied rewrites19.2%
Taylor expanded in x around 0
lower-/.f6418.9
Applied rewrites18.9%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 4.3e-196)
(* (fma -2.0 x 2.0) 0.5)
(if (<= x 1.45)
(* (* (- (/ 1.0 (* x x)) 0.5) x) x)
(/ (- (/ 1.0 eps_m) (/ (- 1.0 eps_m) eps_m)) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 4.3e-196) {
tmp = fma(-2.0, x, 2.0) * 0.5;
} else if (x <= 1.45) {
tmp = (((1.0 / (x * x)) - 0.5) * x) * x;
} else {
tmp = ((1.0 / eps_m) - ((1.0 - eps_m) / eps_m)) / 2.0;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 4.3e-196) tmp = Float64(fma(-2.0, x, 2.0) * 0.5); elseif (x <= 1.45) tmp = Float64(Float64(Float64(Float64(1.0 / Float64(x * x)) - 0.5) * x) * x); else tmp = Float64(Float64(Float64(1.0 / eps_m) - Float64(Float64(1.0 - eps_m) / eps_m)) / 2.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 4.3e-196], N[(N[(-2.0 * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 1.45], N[(N[(N[(N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision], N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] - N[(N[(1.0 - eps$95$m), $MachinePrecision] / eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.3 \cdot 10^{-196}:\\
\;\;\;\;\mathsf{fma}\left(-2, x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 1.45:\\
\;\;\;\;\left(\left(\frac{1}{x \cdot x} - 0.5\right) \cdot x\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{eps\_m} - \frac{1 - eps\_m}{eps\_m}}{2}\\
\end{array}
\end{array}
if x < 4.29999999999999979e-196Initial program 73.0%
Taylor expanded in eps around inf
Applied rewrites99.2%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
add-flipN/A
mul-1-negN/A
add-flipN/A
mul-1-negN/A
sub-negate-revN/A
sub-negate-revN/A
mul-1-negN/A
add-flipN/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6443.9
Applied rewrites43.9%
Taylor expanded in eps around 0
Applied rewrites43.9%
if 4.29999999999999979e-196 < x < 1.44999999999999996Initial program 73.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites58.2%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6443.4
Applied rewrites43.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6418.5
Applied rewrites18.5%
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift--.f6422.5
Applied rewrites22.5%
if 1.44999999999999996 < x Initial program 73.0%
Taylor expanded in x around 0
sub-to-multN/A
inv-powN/A
pow-negN/A
metadata-evalN/A
unpow1N/A
sub-flipN/A
mul-1-negN/A
mult-flipN/A
mul-1-negN/A
sub-flipN/A
lower-/.f64N/A
lift--.f6437.5
Applied rewrites37.5%
Taylor expanded in eps around 0
lower-/.f64N/A
lift-neg.f64N/A
lift-exp.f6419.2
Applied rewrites19.2%
Taylor expanded in x around 0
lower-/.f6418.9
Applied rewrites18.9%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
}
eps_m = abs(eps) function code(x, eps_m) return fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0) end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)
\end{array}
Initial program 73.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites58.2%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-flipN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6452.6
Applied rewrites52.6%
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.0%
Taylor expanded in x around 0
Applied rewrites44.3%
herbie shell --seed 2025140
(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))