
(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}
Sampling outcomes in binary64 precision:
Herbie found 15 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 (* (- x -1.0) (exp (- x)))))
(if (<= eps_m 0.00068)
(* (+ 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 = (x - -1.0) * exp(-x);
double tmp;
if (eps_m <= 0.00068) {
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 = (x - (-1.0d0)) * exp(-x)
if (eps_m <= 0.00068d0) 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 = (x - -1.0) * Math.exp(-x);
double tmp;
if (eps_m <= 0.00068) {
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 = (x - -1.0) * math.exp(-x) tmp = 0 if eps_m <= 0.00068: 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 = Float64(Float64(x - -1.0) * exp(Float64(-x))) tmp = 0.0 if (eps_m <= 0.00068) tmp = Float64(Float64(t_0 + t_0) * 0.5); else tmp = Float64(Float64(exp(Float64(x * eps_m)) + 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 = (x - -1.0) * exp(-x); tmp = 0.0; if (eps_m <= 0.00068) 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[(N[(x - -1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps$95$m, 0.00068], 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 := \left(x - -1\right) \cdot e^{-x}\\
\mathbf{if}\;eps\_m \leq 0.00068:\\
\;\;\;\;\left(t\_0 + t\_0\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(e^{x \cdot eps\_m} + e^{-x \cdot eps\_m}\right) \cdot 0.5\\
\end{array}
\end{array}
if eps < 6.8e-4Initial program 63.7%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.8%
if 6.8e-4 < 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
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lift-*.f64100.0
Applied rewrites100.0%
Final simplification78.6%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<=
(/
(-
(* (+ 1.0 (/ 1.0 eps_m)) (exp (* (+ -1.0 eps_m) x)))
(* (- (/ 1.0 eps_m) 1.0) (exp (* (- -1.0 eps_m) x))))
2.0)
0.0)
(exp (- x))
(* (+ (exp (* x eps_m)) (exp (- (* x eps_m)))) 0.5)))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (((((1.0 + (1.0 / eps_m)) * exp(((-1.0 + eps_m) * x))) - (((1.0 / eps_m) - 1.0) * exp(((-1.0 - eps_m) * x)))) / 2.0) <= 0.0) {
tmp = exp(-x);
} 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) :: tmp
if (((((1.0d0 + (1.0d0 / eps_m)) * exp((((-1.0d0) + eps_m) * x))) - (((1.0d0 / eps_m) - 1.0d0) * exp((((-1.0d0) - eps_m) * x)))) / 2.0d0) <= 0.0d0) then
tmp = exp(-x)
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 tmp;
if (((((1.0 + (1.0 / eps_m)) * Math.exp(((-1.0 + eps_m) * x))) - (((1.0 / eps_m) - 1.0) * Math.exp(((-1.0 - eps_m) * x)))) / 2.0) <= 0.0) {
tmp = Math.exp(-x);
} 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): tmp = 0 if ((((1.0 + (1.0 / eps_m)) * math.exp(((-1.0 + eps_m) * x))) - (((1.0 / eps_m) - 1.0) * math.exp(((-1.0 - eps_m) * x)))) / 2.0) <= 0.0: tmp = math.exp(-x) 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) tmp = 0.0 if (Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) * exp(Float64(Float64(-1.0 + eps_m) * x))) - Float64(Float64(Float64(1.0 / eps_m) - 1.0) * exp(Float64(Float64(-1.0 - eps_m) * x)))) / 2.0) <= 0.0) tmp = exp(Float64(-x)); else tmp = Float64(Float64(exp(Float64(x * eps_m)) + exp(Float64(-Float64(x * eps_m)))) * 0.5); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (((((1.0 + (1.0 / eps_m)) * exp(((-1.0 + eps_m) * x))) - (((1.0 / eps_m) - 1.0) * exp(((-1.0 - eps_m) * x)))) / 2.0) <= 0.0) tmp = exp(-x); 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_] := If[LessEqual[N[(N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(N[(-1.0 + eps$95$m), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[N[(N[(-1.0 - eps$95$m), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0], N[Exp[(-x)], $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}
\mathbf{if}\;\frac{\left(1 + \frac{1}{eps\_m}\right) \cdot e^{\left(-1 + eps\_m\right) \cdot x} - \left(\frac{1}{eps\_m} - 1\right) \cdot e^{\left(-1 - eps\_m\right) \cdot x}}{2} \leq 0:\\
\;\;\;\;e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\left(e^{x \cdot eps\_m} + e^{-x \cdot eps\_m}\right) \cdot 0.5\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) #s(literal 2 binary64)) < 0.0Initial program 37.2%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites95.7%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6469.7
Applied rewrites69.7%
Taylor expanded in eps around 0
lower-exp.f64N/A
lift-neg.f6495.7
Applied rewrites95.7%
if 0.0 < (/.f64 (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) #s(literal 2 binary64)) 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
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lift-*.f64100.0
Applied rewrites100.0%
Final simplification98.2%
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(x * Float64(-1.0 + eps_m))) + 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^{x \cdot \left(-1 + eps\_m\right)} + e^{-\mathsf{fma}\left(x, eps\_m, x\right)}\right) \cdot 0.5
\end{array}
Initial program 73.5%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.2%
Final simplification98.2%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -8.2e-241)
(* (+ 1.0 (exp (- (* x eps_m)))) 0.5)
(if (<= x 850000.0)
(* (- (exp (* x eps_m)) (- (fma x eps_m x) 1.0)) 0.5)
(if (or (<= x 8.5e+71) (not (or (<= x 4.5e+123) (not (<= x 2.05e+167)))))
(/ (- (* (+ 1.0 (/ 1.0 eps_m)) 1.0) (/ (fma -1.0 eps_m 1.0) eps_m)) 2.0)
(* (- (exp (* x (+ -1.0 eps_m))) -1.0) 0.5)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -8.2e-241) {
tmp = (1.0 + exp(-(x * eps_m))) * 0.5;
} else if (x <= 850000.0) {
tmp = (exp((x * eps_m)) - (fma(x, eps_m, x) - 1.0)) * 0.5;
} else if ((x <= 8.5e+71) || !((x <= 4.5e+123) || !(x <= 2.05e+167))) {
tmp = (((1.0 + (1.0 / eps_m)) * 1.0) - (fma(-1.0, eps_m, 1.0) / eps_m)) / 2.0;
} else {
tmp = (exp((x * (-1.0 + eps_m))) - -1.0) * 0.5;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -8.2e-241) tmp = Float64(Float64(1.0 + exp(Float64(-Float64(x * eps_m)))) * 0.5); elseif (x <= 850000.0) tmp = Float64(Float64(exp(Float64(x * eps_m)) - Float64(fma(x, eps_m, x) - 1.0)) * 0.5); elseif ((x <= 8.5e+71) || !((x <= 4.5e+123) || !(x <= 2.05e+167))) tmp = Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) * 1.0) - Float64(fma(-1.0, eps_m, 1.0) / eps_m)) / 2.0); else tmp = Float64(Float64(exp(Float64(x * Float64(-1.0 + eps_m))) - -1.0) * 0.5); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -8.2e-241], N[(N[(1.0 + N[Exp[(-N[(x * eps$95$m), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 850000.0], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] - N[(N[(x * eps$95$m + x), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[Or[LessEqual[x, 8.5e+71], N[Not[Or[LessEqual[x, 4.5e+123], N[Not[LessEqual[x, 2.05e+167]], $MachinePrecision]]], $MachinePrecision]], N[(N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] - N[(N[(-1.0 * eps$95$m + 1.0), $MachinePrecision] / eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(x * N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.2 \cdot 10^{-241}:\\
\;\;\;\;\left(1 + e^{-x \cdot eps\_m}\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 850000:\\
\;\;\;\;\left(e^{x \cdot eps\_m} - \left(\mathsf{fma}\left(x, eps\_m, x\right) - 1\right)\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{+71} \lor \neg \left(x \leq 4.5 \cdot 10^{+123} \lor \neg \left(x \leq 2.05 \cdot 10^{+167}\right)\right):\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) \cdot 1 - \frac{\mathsf{fma}\left(-1, eps\_m, 1\right)}{eps\_m}}{2}\\
\mathbf{else}:\\
\;\;\;\;\left(e^{x \cdot \left(-1 + eps\_m\right)} - -1\right) \cdot 0.5\\
\end{array}
\end{array}
if x < -8.1999999999999997e-241Initial program 69.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites97.6%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6497.6
Applied rewrites97.6%
Taylor expanded in eps around inf
*-commutativeN/A
lift-*.f6498.0
Applied rewrites98.0%
Taylor expanded in x around 0
Applied rewrites68.3%
if -8.1999999999999997e-241 < x < 8.5e5Initial program 56.2%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites97.4%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6497.4
Applied rewrites97.4%
Taylor expanded in eps around inf
*-commutativeN/A
lift-*.f6497.8
Applied rewrites97.8%
Taylor expanded in x around 0
*-commutativeN/A
+-commutativeN/A
distribute-rgt1-inN/A
+-commutativeN/A
*-commutativeN/A
lower--.f64N/A
lift-fma.f6486.1
Applied rewrites86.1%
if 8.5e5 < x < 8.4999999999999996e71 or 4.49999999999999983e123 < x < 2.05e167Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites19.1%
Taylor expanded in x around 0
lower--.f64N/A
inv-powN/A
lower-pow.f6483.3
Applied rewrites83.3%
Taylor expanded in eps around 0
lower-/.f64N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
lower-fma.f6483.3
Applied rewrites83.3%
if 8.4999999999999996e71 < x < 4.49999999999999983e123 or 2.05e167 < x Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites40.9%
Final simplification71.4%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -8.2e-241)
(* (+ 1.0 (exp (- (* x eps_m)))) 0.5)
(if (<= x 850000.0)
(* (- (exp (* x eps_m)) -1.0) 0.5)
(if (or (<= x 8.5e+71) (not (or (<= x 4.5e+123) (not (<= x 2.05e+167)))))
(/ (- (* (+ 1.0 (/ 1.0 eps_m)) 1.0) (/ (fma -1.0 eps_m 1.0) eps_m)) 2.0)
(* (- (exp (* x (+ -1.0 eps_m))) -1.0) 0.5)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -8.2e-241) {
tmp = (1.0 + exp(-(x * eps_m))) * 0.5;
} else if (x <= 850000.0) {
tmp = (exp((x * eps_m)) - -1.0) * 0.5;
} else if ((x <= 8.5e+71) || !((x <= 4.5e+123) || !(x <= 2.05e+167))) {
tmp = (((1.0 + (1.0 / eps_m)) * 1.0) - (fma(-1.0, eps_m, 1.0) / eps_m)) / 2.0;
} else {
tmp = (exp((x * (-1.0 + eps_m))) - -1.0) * 0.5;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -8.2e-241) tmp = Float64(Float64(1.0 + exp(Float64(-Float64(x * eps_m)))) * 0.5); elseif (x <= 850000.0) tmp = Float64(Float64(exp(Float64(x * eps_m)) - -1.0) * 0.5); elseif ((x <= 8.5e+71) || !((x <= 4.5e+123) || !(x <= 2.05e+167))) tmp = Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) * 1.0) - Float64(fma(-1.0, eps_m, 1.0) / eps_m)) / 2.0); else tmp = Float64(Float64(exp(Float64(x * Float64(-1.0 + eps_m))) - -1.0) * 0.5); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -8.2e-241], N[(N[(1.0 + N[Exp[(-N[(x * eps$95$m), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 850000.0], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], If[Or[LessEqual[x, 8.5e+71], N[Not[Or[LessEqual[x, 4.5e+123], N[Not[LessEqual[x, 2.05e+167]], $MachinePrecision]]], $MachinePrecision]], N[(N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] - N[(N[(-1.0 * eps$95$m + 1.0), $MachinePrecision] / eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(x * N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.2 \cdot 10^{-241}:\\
\;\;\;\;\left(1 + e^{-x \cdot eps\_m}\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 850000:\\
\;\;\;\;\left(e^{x \cdot eps\_m} - -1\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{+71} \lor \neg \left(x \leq 4.5 \cdot 10^{+123} \lor \neg \left(x \leq 2.05 \cdot 10^{+167}\right)\right):\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) \cdot 1 - \frac{\mathsf{fma}\left(-1, eps\_m, 1\right)}{eps\_m}}{2}\\
\mathbf{else}:\\
\;\;\;\;\left(e^{x \cdot \left(-1 + eps\_m\right)} - -1\right) \cdot 0.5\\
\end{array}
\end{array}
if x < -8.1999999999999997e-241Initial program 69.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites97.6%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6497.6
Applied rewrites97.6%
Taylor expanded in eps around inf
*-commutativeN/A
lift-*.f6498.0
Applied rewrites98.0%
Taylor expanded in x around 0
Applied rewrites68.3%
if -8.1999999999999997e-241 < x < 8.5e5Initial program 56.2%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites97.4%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6497.4
Applied rewrites97.4%
Taylor expanded in x around 0
Applied rewrites85.7%
if 8.5e5 < x < 8.4999999999999996e71 or 4.49999999999999983e123 < x < 2.05e167Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites19.1%
Taylor expanded in x around 0
lower--.f64N/A
inv-powN/A
lower-pow.f6483.3
Applied rewrites83.3%
Taylor expanded in eps around 0
lower-/.f64N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
lower-fma.f6483.3
Applied rewrites83.3%
if 8.4999999999999996e71 < x < 4.49999999999999983e123 or 2.05e167 < x Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites40.9%
Final simplification71.3%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -8.2e-241)
(* (+ 1.0 (exp (- (* x eps_m)))) 0.5)
(if (or (<= x 850000.0)
(not
(or (<= x 8.5e+71)
(not (or (<= x 4.4e+123) (not (<= x 2.05e+167)))))))
(* (- (exp (* x eps_m)) -1.0) 0.5)
(/
(- (* (+ 1.0 (/ 1.0 eps_m)) 1.0) (/ (fma -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 <= -8.2e-241) {
tmp = (1.0 + exp(-(x * eps_m))) * 0.5;
} else if ((x <= 850000.0) || !((x <= 8.5e+71) || !((x <= 4.4e+123) || !(x <= 2.05e+167)))) {
tmp = (exp((x * eps_m)) - -1.0) * 0.5;
} else {
tmp = (((1.0 + (1.0 / eps_m)) * 1.0) - (fma(-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 <= -8.2e-241) tmp = Float64(Float64(1.0 + exp(Float64(-Float64(x * eps_m)))) * 0.5); elseif ((x <= 850000.0) || !((x <= 8.5e+71) || !((x <= 4.4e+123) || !(x <= 2.05e+167)))) tmp = Float64(Float64(exp(Float64(x * eps_m)) - -1.0) * 0.5); else tmp = Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) * 1.0) - Float64(fma(-1.0, eps_m, 1.0) / eps_m)) / 2.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -8.2e-241], N[(N[(1.0 + N[Exp[(-N[(x * eps$95$m), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[Or[LessEqual[x, 850000.0], N[Not[Or[LessEqual[x, 8.5e+71], N[Not[Or[LessEqual[x, 4.4e+123], N[Not[LessEqual[x, 2.05e+167]], $MachinePrecision]]], $MachinePrecision]]], $MachinePrecision]], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] - N[(N[(-1.0 * eps$95$m + 1.0), $MachinePrecision] / eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.2 \cdot 10^{-241}:\\
\;\;\;\;\left(1 + e^{-x \cdot eps\_m}\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 850000 \lor \neg \left(x \leq 8.5 \cdot 10^{+71} \lor \neg \left(x \leq 4.4 \cdot 10^{+123} \lor \neg \left(x \leq 2.05 \cdot 10^{+167}\right)\right)\right):\\
\;\;\;\;\left(e^{x \cdot eps\_m} - -1\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) \cdot 1 - \frac{\mathsf{fma}\left(-1, eps\_m, 1\right)}{eps\_m}}{2}\\
\end{array}
\end{array}
if x < -8.1999999999999997e-241Initial program 69.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites97.6%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6497.6
Applied rewrites97.6%
Taylor expanded in eps around inf
*-commutativeN/A
lift-*.f6498.0
Applied rewrites98.0%
Taylor expanded in x around 0
Applied rewrites68.3%
if -8.1999999999999997e-241 < x < 8.5e5 or 8.4999999999999996e71 < x < 4.39999999999999984e123 or 2.05e167 < x Initial program 70.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.2%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6491.3
Applied rewrites91.3%
Taylor expanded in x around 0
Applied rewrites71.0%
if 8.5e5 < x < 8.4999999999999996e71 or 4.39999999999999984e123 < x < 2.05e167Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites19.1%
Taylor expanded in x around 0
lower--.f64N/A
inv-powN/A
lower-pow.f6483.3
Applied rewrites83.3%
Taylor expanded in eps around 0
lower-/.f64N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
lower-fma.f6483.3
Applied rewrites83.3%
Final simplification71.3%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= eps_m 1.05e+37) (exp (- x)) (* (- (exp (* x eps_m)) -1.0) 0.5)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 1.05e+37) {
tmp = exp(-x);
} else {
tmp = (exp((x * eps_m)) - -1.0) * 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) :: tmp
if (eps_m <= 1.05d+37) then
tmp = exp(-x)
else
tmp = (exp((x * eps_m)) - (-1.0d0)) * 0.5d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (eps_m <= 1.05e+37) {
tmp = Math.exp(-x);
} else {
tmp = (Math.exp((x * eps_m)) - -1.0) * 0.5;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 1.05e+37: tmp = math.exp(-x) else: tmp = (math.exp((x * eps_m)) - -1.0) * 0.5 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 1.05e+37) tmp = exp(Float64(-x)); else tmp = Float64(Float64(exp(Float64(x * eps_m)) - -1.0) * 0.5); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (eps_m <= 1.05e+37) tmp = exp(-x); else tmp = (exp((x * eps_m)) - -1.0) * 0.5; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 1.05e+37], N[Exp[(-x)], $MachinePrecision], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 1.05 \cdot 10^{+37}:\\
\;\;\;\;e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\left(e^{x \cdot eps\_m} - -1\right) \cdot 0.5\\
\end{array}
\end{array}
if eps < 1.0500000000000001e37Initial program 65.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites97.6%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6483.4
Applied rewrites83.4%
Taylor expanded in eps around 0
lower-exp.f64N/A
lift-neg.f6480.1
Applied rewrites80.1%
if 1.0500000000000001e37 < 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
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites61.4%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -720.0)
(exp (- x))
(if (<= x -5e-222)
(*
(fma
(fma -1.0 (/ (- (* eps_m eps_m) 1.0) (- eps_m 1.0)) (+ -1.0 eps_m))
x
2.0)
0.5)
(if (<= x 2e-208)
1.0
(if (<= x 750.0)
(*
(fma
(fma
-1.0
(- eps_m -1.0)
(/ (+ -1.0 (* eps_m eps_m)) (- eps_m -1.0)))
x
2.0)
0.5)
(if (<= x 2.05e+167)
(/
(- (* (+ 1.0 (/ 1.0 eps_m)) 1.0) (/ (fma -1.0 eps_m 1.0) eps_m))
2.0)
(fma (- (* 0.5 x) 1.0) x 1.0)))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -720.0) {
tmp = exp(-x);
} else if (x <= -5e-222) {
tmp = fma(fma(-1.0, (((eps_m * eps_m) - 1.0) / (eps_m - 1.0)), (-1.0 + eps_m)), x, 2.0) * 0.5;
} else if (x <= 2e-208) {
tmp = 1.0;
} else if (x <= 750.0) {
tmp = fma(fma(-1.0, (eps_m - -1.0), ((-1.0 + (eps_m * eps_m)) / (eps_m - -1.0))), x, 2.0) * 0.5;
} else if (x <= 2.05e+167) {
tmp = (((1.0 + (1.0 / eps_m)) * 1.0) - (fma(-1.0, eps_m, 1.0) / eps_m)) / 2.0;
} else {
tmp = fma(((0.5 * x) - 1.0), x, 1.0);
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -720.0) tmp = exp(Float64(-x)); elseif (x <= -5e-222) tmp = Float64(fma(fma(-1.0, Float64(Float64(Float64(eps_m * eps_m) - 1.0) / Float64(eps_m - 1.0)), Float64(-1.0 + eps_m)), x, 2.0) * 0.5); elseif (x <= 2e-208) tmp = 1.0; elseif (x <= 750.0) tmp = Float64(fma(fma(-1.0, Float64(eps_m - -1.0), Float64(Float64(-1.0 + Float64(eps_m * eps_m)) / Float64(eps_m - -1.0))), x, 2.0) * 0.5); elseif (x <= 2.05e+167) tmp = Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) * 1.0) - Float64(fma(-1.0, eps_m, 1.0) / eps_m)) / 2.0); else tmp = fma(Float64(Float64(0.5 * x) - 1.0), x, 1.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -720.0], N[Exp[(-x)], $MachinePrecision], If[LessEqual[x, -5e-222], N[(N[(N[(-1.0 * N[(N[(N[(eps$95$m * eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision] / N[(eps$95$m - 1.0), $MachinePrecision]), $MachinePrecision] + N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 2e-208], 1.0, If[LessEqual[x, 750.0], N[(N[(N[(-1.0 * N[(eps$95$m - -1.0), $MachinePrecision] + N[(N[(-1.0 + N[(eps$95$m * eps$95$m), $MachinePrecision]), $MachinePrecision] / N[(eps$95$m - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 2.05e+167], N[(N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] - N[(N[(-1.0 * eps$95$m + 1.0), $MachinePrecision] / eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(0.5 * x), $MachinePrecision] - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]]]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -720:\\
\;\;\;\;e^{-x}\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-222}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, \frac{eps\_m \cdot eps\_m - 1}{eps\_m - 1}, -1 + eps\_m\right), x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-208}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 750:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, eps\_m - -1, \frac{-1 + eps\_m \cdot eps\_m}{eps\_m - -1}\right), x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 2.05 \cdot 10^{+167}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) \cdot 1 - \frac{\mathsf{fma}\left(-1, eps\_m, 1\right)}{eps\_m}}{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x - 1, x, 1\right)\\
\end{array}
\end{array}
if x < -720Initial 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
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around 0
lower-exp.f64N/A
lift-neg.f64100.0
Applied rewrites100.0%
if -720 < x < -5.00000000000000008e-222Initial program 53.9%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites96.1%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6465.4
Applied rewrites65.4%
lift-+.f64N/A
flip-+N/A
lower-/.f64N/A
unpow2N/A
metadata-evalN/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f6471.9
Applied rewrites71.9%
if -5.00000000000000008e-222 < x < 2.0000000000000002e-208Initial program 66.9%
Taylor expanded in x around 0
Applied rewrites97.6%
if 2.0000000000000002e-208 < x < 750Initial program 49.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites95.6%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6462.7
Applied rewrites62.7%
lift--.f64N/A
flip--N/A
lower-/.f64N/A
metadata-evalN/A
unpow2N/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lift-+.f6472.0
Applied rewrites72.0%
if 750 < x < 2.05e167Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites23.3%
Taylor expanded in x around 0
lower--.f64N/A
inv-powN/A
lower-pow.f6463.1
Applied rewrites63.1%
Taylor expanded in eps around 0
lower-/.f64N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
lower-fma.f6463.1
Applied rewrites63.1%
if 2.05e167 < x 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
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6475.6
Applied rewrites75.6%
Taylor expanded in eps around 0
lower-exp.f64N/A
lift-neg.f6443.8
Applied rewrites43.8%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6457.8
Applied rewrites57.8%
Final simplification76.6%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -1.35e+122)
(fma (- (* (fma -0.16666666666666666 x 0.5) x) 1.0) x 1.0)
(if (<= x -5e-222)
(*
(fma
(fma -1.0 (/ (- (* eps_m eps_m) 1.0) (- eps_m 1.0)) (+ -1.0 eps_m))
x
2.0)
0.5)
(if (<= x 2e-208)
1.0
(if (<= x 750.0)
(*
(fma
(fma
-1.0
(- eps_m -1.0)
(/ (+ -1.0 (* eps_m eps_m)) (- eps_m -1.0)))
x
2.0)
0.5)
(if (<= x 2.05e+167)
(/
(- (* (+ 1.0 (/ 1.0 eps_m)) 1.0) (/ (fma -1.0 eps_m 1.0) eps_m))
2.0)
(fma (- (* 0.5 x) 1.0) x 1.0)))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -1.35e+122) {
tmp = fma(((fma(-0.16666666666666666, x, 0.5) * x) - 1.0), x, 1.0);
} else if (x <= -5e-222) {
tmp = fma(fma(-1.0, (((eps_m * eps_m) - 1.0) / (eps_m - 1.0)), (-1.0 + eps_m)), x, 2.0) * 0.5;
} else if (x <= 2e-208) {
tmp = 1.0;
} else if (x <= 750.0) {
tmp = fma(fma(-1.0, (eps_m - -1.0), ((-1.0 + (eps_m * eps_m)) / (eps_m - -1.0))), x, 2.0) * 0.5;
} else if (x <= 2.05e+167) {
tmp = (((1.0 + (1.0 / eps_m)) * 1.0) - (fma(-1.0, eps_m, 1.0) / eps_m)) / 2.0;
} else {
tmp = fma(((0.5 * x) - 1.0), x, 1.0);
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -1.35e+122) tmp = fma(Float64(Float64(fma(-0.16666666666666666, x, 0.5) * x) - 1.0), x, 1.0); elseif (x <= -5e-222) tmp = Float64(fma(fma(-1.0, Float64(Float64(Float64(eps_m * eps_m) - 1.0) / Float64(eps_m - 1.0)), Float64(-1.0 + eps_m)), x, 2.0) * 0.5); elseif (x <= 2e-208) tmp = 1.0; elseif (x <= 750.0) tmp = Float64(fma(fma(-1.0, Float64(eps_m - -1.0), Float64(Float64(-1.0 + Float64(eps_m * eps_m)) / Float64(eps_m - -1.0))), x, 2.0) * 0.5); elseif (x <= 2.05e+167) tmp = Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) * 1.0) - Float64(fma(-1.0, eps_m, 1.0) / eps_m)) / 2.0); else tmp = fma(Float64(Float64(0.5 * x) - 1.0), x, 1.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -1.35e+122], N[(N[(N[(N[(-0.16666666666666666 * x + 0.5), $MachinePrecision] * x), $MachinePrecision] - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision], If[LessEqual[x, -5e-222], N[(N[(N[(-1.0 * N[(N[(N[(eps$95$m * eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision] / N[(eps$95$m - 1.0), $MachinePrecision]), $MachinePrecision] + N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 2e-208], 1.0, If[LessEqual[x, 750.0], N[(N[(N[(-1.0 * N[(eps$95$m - -1.0), $MachinePrecision] + N[(N[(-1.0 + N[(eps$95$m * eps$95$m), $MachinePrecision]), $MachinePrecision] / N[(eps$95$m - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 2.05e+167], N[(N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] - N[(N[(-1.0 * eps$95$m + 1.0), $MachinePrecision] / eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(0.5 * x), $MachinePrecision] - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]]]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35 \cdot 10^{+122}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, x, 0.5\right) \cdot x - 1, x, 1\right)\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-222}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, \frac{eps\_m \cdot eps\_m - 1}{eps\_m - 1}, -1 + eps\_m\right), x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-208}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 750:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, eps\_m - -1, \frac{-1 + eps\_m \cdot eps\_m}{eps\_m - -1}\right), x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 2.05 \cdot 10^{+167}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) \cdot 1 - \frac{\mathsf{fma}\left(-1, eps\_m, 1\right)}{eps\_m}}{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x - 1, x, 1\right)\\
\end{array}
\end{array}
if x < -1.3499999999999999e122Initial 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
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around 0
lower-exp.f64N/A
lift-neg.f64100.0
Applied rewrites100.0%
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.f64100.0
Applied rewrites100.0%
if -1.3499999999999999e122 < x < -5.00000000000000008e-222Initial program 60.7%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites96.7%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6456.2
Applied rewrites56.2%
lift-+.f64N/A
flip-+N/A
lower-/.f64N/A
unpow2N/A
metadata-evalN/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f6465.5
Applied rewrites65.5%
if -5.00000000000000008e-222 < x < 2.0000000000000002e-208Initial program 66.9%
Taylor expanded in x around 0
Applied rewrites97.6%
if 2.0000000000000002e-208 < x < 750Initial program 49.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites95.6%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6462.7
Applied rewrites62.7%
lift--.f64N/A
flip--N/A
lower-/.f64N/A
metadata-evalN/A
unpow2N/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lift-+.f6472.0
Applied rewrites72.0%
if 750 < x < 2.05e167Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites23.3%
Taylor expanded in x around 0
lower--.f64N/A
inv-powN/A
lower-pow.f6463.1
Applied rewrites63.1%
Taylor expanded in eps around 0
lower-/.f64N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
lower-fma.f6463.1
Applied rewrites63.1%
if 2.05e167 < x 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
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6475.6
Applied rewrites75.6%
Taylor expanded in eps around 0
lower-exp.f64N/A
lift-neg.f6443.8
Applied rewrites43.8%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6457.8
Applied rewrites57.8%
Final simplification73.5%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -1.35e+122)
(fma (- (* (fma -0.16666666666666666 x 0.5) x) 1.0) x 1.0)
(if (<= x -5e-222)
(*
(fma
(fma -1.0 (/ (- (* eps_m eps_m) 1.0) (- eps_m 1.0)) (+ -1.0 eps_m))
x
2.0)
0.5)
(if (<= x 6.5e-195)
1.0
(*
(fma (fma -1.0 (- eps_m -1.0) (/ (+ -1.0 (* eps_m eps_m)) 1.0)) x 2.0)
0.5)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -1.35e+122) {
tmp = fma(((fma(-0.16666666666666666, x, 0.5) * x) - 1.0), x, 1.0);
} else if (x <= -5e-222) {
tmp = fma(fma(-1.0, (((eps_m * eps_m) - 1.0) / (eps_m - 1.0)), (-1.0 + eps_m)), x, 2.0) * 0.5;
} else if (x <= 6.5e-195) {
tmp = 1.0;
} else {
tmp = fma(fma(-1.0, (eps_m - -1.0), ((-1.0 + (eps_m * eps_m)) / 1.0)), x, 2.0) * 0.5;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -1.35e+122) tmp = fma(Float64(Float64(fma(-0.16666666666666666, x, 0.5) * x) - 1.0), x, 1.0); elseif (x <= -5e-222) tmp = Float64(fma(fma(-1.0, Float64(Float64(Float64(eps_m * eps_m) - 1.0) / Float64(eps_m - 1.0)), Float64(-1.0 + eps_m)), x, 2.0) * 0.5); elseif (x <= 6.5e-195) tmp = 1.0; else tmp = Float64(fma(fma(-1.0, Float64(eps_m - -1.0), Float64(Float64(-1.0 + Float64(eps_m * eps_m)) / 1.0)), x, 2.0) * 0.5); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -1.35e+122], N[(N[(N[(N[(-0.16666666666666666 * x + 0.5), $MachinePrecision] * x), $MachinePrecision] - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision], If[LessEqual[x, -5e-222], N[(N[(N[(-1.0 * N[(N[(N[(eps$95$m * eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision] / N[(eps$95$m - 1.0), $MachinePrecision]), $MachinePrecision] + N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 6.5e-195], 1.0, N[(N[(N[(-1.0 * N[(eps$95$m - -1.0), $MachinePrecision] + N[(N[(-1.0 + N[(eps$95$m * eps$95$m), $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision]), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35 \cdot 10^{+122}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, x, 0.5\right) \cdot x - 1, x, 1\right)\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-222}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, \frac{eps\_m \cdot eps\_m - 1}{eps\_m - 1}, -1 + eps\_m\right), x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 6.5 \cdot 10^{-195}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, eps\_m - -1, \frac{-1 + eps\_m \cdot eps\_m}{1}\right), x, 2\right) \cdot 0.5\\
\end{array}
\end{array}
if x < -1.3499999999999999e122Initial 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
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around 0
lower-exp.f64N/A
lift-neg.f64100.0
Applied rewrites100.0%
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.f64100.0
Applied rewrites100.0%
if -1.3499999999999999e122 < x < -5.00000000000000008e-222Initial program 60.7%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites96.7%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6456.2
Applied rewrites56.2%
lift-+.f64N/A
flip-+N/A
lower-/.f64N/A
unpow2N/A
metadata-evalN/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f6465.5
Applied rewrites65.5%
if -5.00000000000000008e-222 < x < 6.50000000000000004e-195Initial program 66.2%
Taylor expanded in x around 0
Applied rewrites97.7%
if 6.50000000000000004e-195 < x Initial program 79.5%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.1%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6426.4
Applied rewrites26.4%
lift--.f64N/A
flip--N/A
lower-/.f64N/A
metadata-evalN/A
unpow2N/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lift-+.f6439.3
Applied rewrites39.3%
Taylor expanded in eps around 0
Applied rewrites54.8%
Final simplification68.8%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 6.5e-195)
(fma (- (* (fma -0.16666666666666666 x 0.5) x) 1.0) x 1.0)
(*
(fma (fma -1.0 (- eps_m -1.0) (/ (+ -1.0 (* eps_m eps_m)) 1.0)) x 2.0)
0.5)))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 6.5e-195) {
tmp = fma(((fma(-0.16666666666666666, x, 0.5) * x) - 1.0), x, 1.0);
} else {
tmp = fma(fma(-1.0, (eps_m - -1.0), ((-1.0 + (eps_m * eps_m)) / 1.0)), x, 2.0) * 0.5;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 6.5e-195) tmp = fma(Float64(Float64(fma(-0.16666666666666666, x, 0.5) * x) - 1.0), x, 1.0); else tmp = Float64(fma(fma(-1.0, Float64(eps_m - -1.0), Float64(Float64(-1.0 + Float64(eps_m * eps_m)) / 1.0)), x, 2.0) * 0.5); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 6.5e-195], N[(N[(N[(N[(-0.16666666666666666 * x + 0.5), $MachinePrecision] * x), $MachinePrecision] - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision], N[(N[(N[(-1.0 * N[(eps$95$m - -1.0), $MachinePrecision] + N[(N[(-1.0 + N[(eps$95$m * eps$95$m), $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision]), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.5 \cdot 10^{-195}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, x, 0.5\right) \cdot x - 1, x, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, eps\_m - -1, \frac{-1 + eps\_m \cdot eps\_m}{1}\right), x, 2\right) \cdot 0.5\\
\end{array}
\end{array}
if x < 6.50000000000000004e-195Initial program 68.4%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.2%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6498.2
Applied rewrites98.2%
Taylor expanded in eps around 0
lower-exp.f64N/A
lift-neg.f6483.5
Applied rewrites83.5%
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.f6477.4
Applied rewrites77.4%
if 6.50000000000000004e-195 < x Initial program 79.5%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.1%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6426.4
Applied rewrites26.4%
lift--.f64N/A
flip--N/A
lower-/.f64N/A
metadata-evalN/A
unpow2N/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lift-+.f6439.3
Applied rewrites39.3%
Taylor expanded in eps around 0
Applied rewrites54.8%
Final simplification67.0%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 6.2e-30) (fma (- (* (fma -0.16666666666666666 x 0.5) x) 1.0) x 1.0) (* (fma (fma -1.0 1.0 (+ -1.0 eps_m)) x 2.0) 0.5)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 6.2e-30) {
tmp = fma(((fma(-0.16666666666666666, x, 0.5) * x) - 1.0), x, 1.0);
} else {
tmp = fma(fma(-1.0, 1.0, (-1.0 + eps_m)), x, 2.0) * 0.5;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 6.2e-30) tmp = fma(Float64(Float64(fma(-0.16666666666666666, x, 0.5) * x) - 1.0), x, 1.0); else tmp = Float64(fma(fma(-1.0, 1.0, Float64(-1.0 + eps_m)), x, 2.0) * 0.5); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 6.2e-30], N[(N[(N[(N[(-0.16666666666666666 * x + 0.5), $MachinePrecision] * x), $MachinePrecision] - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision], N[(N[(N[(-1.0 * 1.0 + N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.2 \cdot 10^{-30}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, x, 0.5\right) \cdot x - 1, x, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, 1, -1 + eps\_m\right), x, 2\right) \cdot 0.5\\
\end{array}
\end{array}
if x < 6.19999999999999982e-30Initial program 63.9%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.6%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6498.6
Applied rewrites98.6%
Taylor expanded in eps around 0
lower-exp.f64N/A
lift-neg.f6480.6
Applied rewrites80.6%
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.f6475.8
Applied rewrites75.8%
if 6.19999999999999982e-30 < x Initial program 95.1%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites97.2%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f644.8
Applied rewrites4.8%
Taylor expanded in eps around 0
Applied rewrites19.2%
Final simplification58.4%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -155.0) (fma (- (* (fma -0.16666666666666666 x 0.5) x) 1.0) x 1.0) (fma (- (* 0.5 x) 1.0) x 1.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -155.0) {
tmp = fma(((fma(-0.16666666666666666, x, 0.5) * x) - 1.0), x, 1.0);
} else {
tmp = fma(((0.5 * x) - 1.0), x, 1.0);
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -155.0) tmp = fma(Float64(Float64(fma(-0.16666666666666666, x, 0.5) * x) - 1.0), x, 1.0); else tmp = fma(Float64(Float64(0.5 * x) - 1.0), x, 1.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -155.0], N[(N[(N[(N[(-0.16666666666666666 * x + 0.5), $MachinePrecision] * x), $MachinePrecision] - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision], N[(N[(N[(0.5 * x), $MachinePrecision] - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -155:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, x, 0.5\right) \cdot x - 1, x, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x - 1, x, 1\right)\\
\end{array}
\end{array}
if x < -155Initial 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
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around 0
lower-exp.f64N/A
lift-neg.f64100.0
Applied rewrites100.0%
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.f6473.9
Applied rewrites73.9%
if -155 < x Initial program 69.7%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites97.9%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6485.4
Applied rewrites85.4%
Taylor expanded in eps around 0
lower-exp.f64N/A
lift-neg.f6467.4
Applied rewrites67.4%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6458.6
Applied rewrites58.6%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (fma (- (* 0.5 x) 1.0) x 1.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return fma(((0.5 * x) - 1.0), x, 1.0);
}
eps_m = abs(eps) function code(x, eps_m) return fma(Float64(Float64(0.5 * x) - 1.0), x, 1.0) end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(N[(N[(0.5 * x), $MachinePrecision] - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\mathsf{fma}\left(0.5 \cdot x - 1, x, 1\right)
\end{array}
Initial program 73.5%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.2%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6487.2
Applied rewrites87.2%
Taylor expanded in eps around 0
lower-exp.f64N/A
lift-neg.f6471.5
Applied rewrites71.5%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6458.2
Applied rewrites58.2%
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.5%
Taylor expanded in x around 0
Applied rewrites45.5%
herbie shell --seed 2025037
(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))