
(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 (* (+ (exp (* x (+ -1.0 eps_m))) (pow (exp -1.0) (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))) + pow(exp(-1.0), 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(-1.0) ^ 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[Power[N[Exp[-1.0], $MachinePrecision], 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)} + {\left(e^{-1}\right)}^{\left(\mathsf{fma}\left(x, eps\_m, x\right)\right)}\right) \cdot 0.5
\end{array}
Initial program 73.9%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.4%
lift-exp.f64N/A
lift-neg.f64N/A
lift-fma.f64N/A
mul-1-negN/A
pow-expN/A
lift-exp.f64N/A
lower-pow.f64N/A
lift-fma.f6499.4
Applied rewrites99.4%
Final simplification99.4%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= eps_m 2.15e-5) (exp (- x)) (* (+ (exp (* x eps_m)) (exp (- (fma x eps_m x)))) 0.5)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 2.15e-5) {
tmp = exp(-x);
} else {
tmp = (exp((x * eps_m)) + exp(-fma(x, eps_m, x))) * 0.5;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 2.15e-5) tmp = exp(Float64(-x)); else tmp = Float64(Float64(exp(Float64(x * eps_m)) + exp(Float64(-fma(x, eps_m, x)))) * 0.5); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 2.15e-5], N[Exp[(-x)], $MachinePrecision], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] + N[Exp[(-N[(x * eps$95$m + x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 2.15 \cdot 10^{-5}:\\
\;\;\;\;e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\left(e^{x \cdot eps\_m} + e^{-\mathsf{fma}\left(x, eps\_m, x\right)}\right) \cdot 0.5\\
\end{array}
\end{array}
if eps < 2.1500000000000001e-5Initial program 62.2%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.1%
lift-exp.f64N/A
lift-neg.f64N/A
lift-fma.f64N/A
mul-1-negN/A
pow-expN/A
lift-exp.f64N/A
lower-pow.f64N/A
lift-fma.f6499.1
Applied rewrites99.1%
Taylor expanded in eps around 0
*-commutativeN/A
distribute-rgt-neg-inN/A
pow-expN/A
+-commutativeN/A
*-commutativeN/A
mul-1-negN/A
*-commutativeN/A
+-commutativeN/A
mul-1-negN/A
lift-exp.f64N/A
lift-neg.f6479.1
Applied rewrites79.1%
if 2.1500000000000001e-5 < 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
distribute-lft-neg-inN/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
Final simplification85.6%
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.9%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.4%
Final simplification99.4%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (* (- (exp (* (- x) (- eps_m))) -1.0) 0.5)))
(if (<= x -1.35e-272)
(* (+ 1.0 (exp (- (* x eps_m)))) 0.5)
(if (<= x 970000.0)
t_0
(if (<= x 1.56e+100)
(exp (- x))
(if (<= x 3.3e+275)
t_0
(/
(- (- (/ 1.0 eps_m) -1.0) (* (- (/ 1.0 eps_m) 1.0) 1.0))
2.0)))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = (exp((-x * -eps_m)) - -1.0) * 0.5;
double tmp;
if (x <= -1.35e-272) {
tmp = (1.0 + exp(-(x * eps_m))) * 0.5;
} else if (x <= 970000.0) {
tmp = t_0;
} else if (x <= 1.56e+100) {
tmp = exp(-x);
} else if (x <= 3.3e+275) {
tmp = t_0;
} else {
tmp = (((1.0 / eps_m) - -1.0) - (((1.0 / eps_m) - 1.0) * 1.0)) / 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) :: t_0
real(8) :: tmp
t_0 = (exp((-x * -eps_m)) - (-1.0d0)) * 0.5d0
if (x <= (-1.35d-272)) then
tmp = (1.0d0 + exp(-(x * eps_m))) * 0.5d0
else if (x <= 970000.0d0) then
tmp = t_0
else if (x <= 1.56d+100) then
tmp = exp(-x)
else if (x <= 3.3d+275) then
tmp = t_0
else
tmp = (((1.0d0 / eps_m) - (-1.0d0)) - (((1.0d0 / eps_m) - 1.0d0) * 1.0d0)) / 2.0d0
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 * -eps_m)) - -1.0) * 0.5;
double tmp;
if (x <= -1.35e-272) {
tmp = (1.0 + Math.exp(-(x * eps_m))) * 0.5;
} else if (x <= 970000.0) {
tmp = t_0;
} else if (x <= 1.56e+100) {
tmp = Math.exp(-x);
} else if (x <= 3.3e+275) {
tmp = t_0;
} else {
tmp = (((1.0 / eps_m) - -1.0) - (((1.0 / eps_m) - 1.0) * 1.0)) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = (math.exp((-x * -eps_m)) - -1.0) * 0.5 tmp = 0 if x <= -1.35e-272: tmp = (1.0 + math.exp(-(x * eps_m))) * 0.5 elif x <= 970000.0: tmp = t_0 elif x <= 1.56e+100: tmp = math.exp(-x) elif x <= 3.3e+275: tmp = t_0 else: tmp = (((1.0 / eps_m) - -1.0) - (((1.0 / eps_m) - 1.0) * 1.0)) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(Float64(exp(Float64(Float64(-x) * Float64(-eps_m))) - -1.0) * 0.5) tmp = 0.0 if (x <= -1.35e-272) tmp = Float64(Float64(1.0 + exp(Float64(-Float64(x * eps_m)))) * 0.5); elseif (x <= 970000.0) tmp = t_0; elseif (x <= 1.56e+100) tmp = exp(Float64(-x)); elseif (x <= 3.3e+275) tmp = t_0; else tmp = Float64(Float64(Float64(Float64(1.0 / eps_m) - -1.0) - Float64(Float64(Float64(1.0 / eps_m) - 1.0) * 1.0)) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = (exp((-x * -eps_m)) - -1.0) * 0.5; tmp = 0.0; if (x <= -1.35e-272) tmp = (1.0 + exp(-(x * eps_m))) * 0.5; elseif (x <= 970000.0) tmp = t_0; elseif (x <= 1.56e+100) tmp = exp(-x); elseif (x <= 3.3e+275) tmp = t_0; else tmp = (((1.0 / eps_m) - -1.0) - (((1.0 / eps_m) - 1.0) * 1.0)) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[(N[(N[Exp[N[((-x) * (-eps$95$m)), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[x, -1.35e-272], N[(N[(1.0 + N[Exp[(-N[(x * eps$95$m), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 970000.0], t$95$0, If[LessEqual[x, 1.56e+100], N[Exp[(-x)], $MachinePrecision], If[LessEqual[x, 3.3e+275], t$95$0, N[(N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] - -1.0), $MachinePrecision] - N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := \left(e^{\left(-x\right) \cdot \left(-eps\_m\right)} - -1\right) \cdot 0.5\\
\mathbf{if}\;x \leq -1.35 \cdot 10^{-272}:\\
\;\;\;\;\left(1 + e^{-x \cdot eps\_m}\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 970000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.56 \cdot 10^{+100}:\\
\;\;\;\;e^{-x}\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{+275}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{1}{eps\_m} - -1\right) - \left(\frac{1}{eps\_m} - 1\right) \cdot 1}{2}\\
\end{array}
\end{array}
if x < -1.34999999999999996e-272Initial program 72.4%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.4%
Taylor expanded in x around 0
distribute-lft-neg-in72.0
exp-neg72.0
*-commutative72.0
exp-neg72.0
Applied rewrites72.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6472.2
Applied rewrites72.2%
if -1.34999999999999996e-272 < x < 9.7e5 or 1.55999999999999998e100 < x < 3.30000000000000022e275Initial program 70.4%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
lift-exp.f64N/A
lift-neg.f64N/A
lift-fma.f64N/A
mul-1-negN/A
pow-expN/A
lift-exp.f64N/A
lower-pow.f64N/A
lift-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites69.2%
Taylor expanded in eps around inf
mul-1-negN/A
lower-neg.f6469.1
Applied rewrites69.1%
if 9.7e5 < x < 1.55999999999999998e100Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
lift-exp.f64N/A
lift-neg.f64N/A
lift-fma.f64N/A
mul-1-negN/A
pow-expN/A
lift-exp.f64N/A
lower-pow.f64N/A
lift-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around 0
*-commutativeN/A
distribute-rgt-neg-inN/A
pow-expN/A
+-commutativeN/A
*-commutativeN/A
mul-1-negN/A
*-commutativeN/A
+-commutativeN/A
mul-1-negN/A
lift-exp.f64N/A
lift-neg.f6478.1
Applied rewrites78.1%
if 3.30000000000000022e275 < x Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites2.4%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
inv-powN/A
lower-pow.f64100.0
Applied rewrites100.0%
lift-pow.f64N/A
inv-powN/A
lift-/.f64100.0
Applied rewrites100.0%
Final simplification71.6%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (exp (* x (+ -1.0 eps_m)))))
(if (<= x -1.35e-272)
(* (+ 1.0 (exp (- (* x eps_m)))) 0.5)
(if (<= x 970000.0)
(* (- t_0 (- (fma x eps_m x) 1.0)) 0.5)
(if (<= x 1.56e+100)
(exp (- x))
(if (<= x 7.2e+275)
(* (- t_0 -1.0) 0.5)
(/
(- (- (/ 1.0 eps_m) -1.0) (* (- (/ 1.0 eps_m) 1.0) 1.0))
2.0)))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = exp((x * (-1.0 + eps_m)));
double tmp;
if (x <= -1.35e-272) {
tmp = (1.0 + exp(-(x * eps_m))) * 0.5;
} else if (x <= 970000.0) {
tmp = (t_0 - (fma(x, eps_m, x) - 1.0)) * 0.5;
} else if (x <= 1.56e+100) {
tmp = exp(-x);
} else if (x <= 7.2e+275) {
tmp = (t_0 - -1.0) * 0.5;
} else {
tmp = (((1.0 / eps_m) - -1.0) - (((1.0 / eps_m) - 1.0) * 1.0)) / 2.0;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) t_0 = exp(Float64(x * Float64(-1.0 + eps_m))) tmp = 0.0 if (x <= -1.35e-272) tmp = Float64(Float64(1.0 + exp(Float64(-Float64(x * eps_m)))) * 0.5); elseif (x <= 970000.0) tmp = Float64(Float64(t_0 - Float64(fma(x, eps_m, x) - 1.0)) * 0.5); elseif (x <= 1.56e+100) tmp = exp(Float64(-x)); elseif (x <= 7.2e+275) tmp = Float64(Float64(t_0 - -1.0) * 0.5); else tmp = Float64(Float64(Float64(Float64(1.0 / eps_m) - -1.0) - Float64(Float64(Float64(1.0 / eps_m) - 1.0) * 1.0)) / 2.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[Exp[N[(x * N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.35e-272], N[(N[(1.0 + N[Exp[(-N[(x * eps$95$m), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 970000.0], N[(N[(t$95$0 - N[(N[(x * eps$95$m + x), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 1.56e+100], N[Exp[(-x)], $MachinePrecision], If[LessEqual[x, 7.2e+275], N[(N[(t$95$0 - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] - -1.0), $MachinePrecision] - N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := e^{x \cdot \left(-1 + eps\_m\right)}\\
\mathbf{if}\;x \leq -1.35 \cdot 10^{-272}:\\
\;\;\;\;\left(1 + e^{-x \cdot eps\_m}\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 970000:\\
\;\;\;\;\left(t\_0 - \left(\mathsf{fma}\left(x, eps\_m, x\right) - 1\right)\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 1.56 \cdot 10^{+100}:\\
\;\;\;\;e^{-x}\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{+275}:\\
\;\;\;\;\left(t\_0 - -1\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{1}{eps\_m} - -1\right) - \left(\frac{1}{eps\_m} - 1\right) \cdot 1}{2}\\
\end{array}
\end{array}
if x < -1.34999999999999996e-272Initial program 72.4%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.4%
Taylor expanded in x around 0
distribute-lft-neg-in72.0
exp-neg72.0
*-commutative72.0
exp-neg72.0
Applied rewrites72.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6472.2
Applied rewrites72.2%
if -1.34999999999999996e-272 < x < 9.7e5Initial program 53.3%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in x around 0
*-commutativeN/A
+-commutativeN/A
distribute-rgt1-inN/A
*-commutativeN/A
+-commutativeN/A
lower--.f64N/A
lift-fma.f6488.4
Applied rewrites88.4%
if 9.7e5 < x < 1.55999999999999998e100Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
lift-exp.f64N/A
lift-neg.f64N/A
lift-fma.f64N/A
mul-1-negN/A
pow-expN/A
lift-exp.f64N/A
lower-pow.f64N/A
lift-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around 0
*-commutativeN/A
distribute-rgt-neg-inN/A
pow-expN/A
+-commutativeN/A
*-commutativeN/A
mul-1-negN/A
*-commutativeN/A
+-commutativeN/A
mul-1-negN/A
lift-exp.f64N/A
lift-neg.f6478.1
Applied rewrites78.1%
if 1.55999999999999998e100 < x < 7.1999999999999996e275Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites37.4%
if 7.1999999999999996e275 < x Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites2.4%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
inv-powN/A
lower-pow.f64100.0
Applied rewrites100.0%
lift-pow.f64N/A
inv-powN/A
lift-/.f64100.0
Applied rewrites100.0%
Final simplification71.9%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -1.35e-272)
(* (+ 1.0 (exp (- (* x eps_m)))) 0.5)
(if (<= x 970000.0)
(* (- (exp (* x eps_m)) (- (fma x eps_m x) 1.0)) 0.5)
(if (<= x 1.56e+100)
(exp (- x))
(if (<= x 7.2e+275)
(* (- (exp (* x (+ -1.0 eps_m))) -1.0) 0.5)
(/ (- (- (/ 1.0 eps_m) -1.0) (* (- (/ 1.0 eps_m) 1.0) 1.0)) 2.0))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -1.35e-272) {
tmp = (1.0 + exp(-(x * eps_m))) * 0.5;
} else if (x <= 970000.0) {
tmp = (exp((x * eps_m)) - (fma(x, eps_m, x) - 1.0)) * 0.5;
} else if (x <= 1.56e+100) {
tmp = exp(-x);
} else if (x <= 7.2e+275) {
tmp = (exp((x * (-1.0 + eps_m))) - -1.0) * 0.5;
} else {
tmp = (((1.0 / eps_m) - -1.0) - (((1.0 / eps_m) - 1.0) * 1.0)) / 2.0;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -1.35e-272) tmp = Float64(Float64(1.0 + exp(Float64(-Float64(x * eps_m)))) * 0.5); elseif (x <= 970000.0) tmp = Float64(Float64(exp(Float64(x * eps_m)) - Float64(fma(x, eps_m, x) - 1.0)) * 0.5); elseif (x <= 1.56e+100) tmp = exp(Float64(-x)); elseif (x <= 7.2e+275) tmp = Float64(Float64(exp(Float64(x * Float64(-1.0 + eps_m))) - -1.0) * 0.5); else tmp = Float64(Float64(Float64(Float64(1.0 / eps_m) - -1.0) - Float64(Float64(Float64(1.0 / eps_m) - 1.0) * 1.0)) / 2.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -1.35e-272], N[(N[(1.0 + N[Exp[(-N[(x * eps$95$m), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 970000.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[LessEqual[x, 1.56e+100], N[Exp[(-x)], $MachinePrecision], If[LessEqual[x, 7.2e+275], N[(N[(N[Exp[N[(x * N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] - -1.0), $MachinePrecision] - N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35 \cdot 10^{-272}:\\
\;\;\;\;\left(1 + e^{-x \cdot eps\_m}\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 970000:\\
\;\;\;\;\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 1.56 \cdot 10^{+100}:\\
\;\;\;\;e^{-x}\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{+275}:\\
\;\;\;\;\left(e^{x \cdot \left(-1 + eps\_m\right)} - -1\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{1}{eps\_m} - -1\right) - \left(\frac{1}{eps\_m} - 1\right) \cdot 1}{2}\\
\end{array}
\end{array}
if x < -1.34999999999999996e-272Initial program 72.4%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.4%
Taylor expanded in x around 0
distribute-lft-neg-in72.0
exp-neg72.0
*-commutative72.0
exp-neg72.0
Applied rewrites72.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6472.2
Applied rewrites72.2%
if -1.34999999999999996e-272 < x < 9.7e5Initial program 53.3%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
lift-exp.f64N/A
lift-neg.f64N/A
lift-fma.f64N/A
mul-1-negN/A
pow-expN/A
lift-exp.f64N/A
lower-pow.f64N/A
lift-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
*-commutativeN/A
+-commutativeN/A
distribute-rgt1-inN/A
*-commutativeN/A
+-commutativeN/A
lower--.f64N/A
lift-fma.f6488.4
Applied rewrites88.4%
if 9.7e5 < x < 1.55999999999999998e100Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
lift-exp.f64N/A
lift-neg.f64N/A
lift-fma.f64N/A
mul-1-negN/A
pow-expN/A
lift-exp.f64N/A
lower-pow.f64N/A
lift-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around 0
*-commutativeN/A
distribute-rgt-neg-inN/A
pow-expN/A
+-commutativeN/A
*-commutativeN/A
mul-1-negN/A
*-commutativeN/A
+-commutativeN/A
mul-1-negN/A
lift-exp.f64N/A
lift-neg.f6478.1
Applied rewrites78.1%
if 1.55999999999999998e100 < x < 7.1999999999999996e275Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites37.4%
if 7.1999999999999996e275 < x Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites2.4%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
inv-powN/A
lower-pow.f64100.0
Applied rewrites100.0%
lift-pow.f64N/A
inv-powN/A
lift-/.f64100.0
Applied rewrites100.0%
Final simplification71.9%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -1.35e-272)
(* (+ 1.0 (exp (- (* x eps_m)))) 0.5)
(if (<= x 970000.0)
(* (- (exp (* (- x) (- eps_m))) -1.0) 0.5)
(if (<= x 1.56e+100)
(exp (- x))
(if (<= x 7.2e+275)
(* (- (exp (* x (+ -1.0 eps_m))) -1.0) 0.5)
(/ (- (- (/ 1.0 eps_m) -1.0) (* (- (/ 1.0 eps_m) 1.0) 1.0)) 2.0))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -1.35e-272) {
tmp = (1.0 + exp(-(x * eps_m))) * 0.5;
} else if (x <= 970000.0) {
tmp = (exp((-x * -eps_m)) - -1.0) * 0.5;
} else if (x <= 1.56e+100) {
tmp = exp(-x);
} else if (x <= 7.2e+275) {
tmp = (exp((x * (-1.0 + eps_m))) - -1.0) * 0.5;
} else {
tmp = (((1.0 / eps_m) - -1.0) - (((1.0 / eps_m) - 1.0) * 1.0)) / 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 <= (-1.35d-272)) then
tmp = (1.0d0 + exp(-(x * eps_m))) * 0.5d0
else if (x <= 970000.0d0) then
tmp = (exp((-x * -eps_m)) - (-1.0d0)) * 0.5d0
else if (x <= 1.56d+100) then
tmp = exp(-x)
else if (x <= 7.2d+275) then
tmp = (exp((x * ((-1.0d0) + eps_m))) - (-1.0d0)) * 0.5d0
else
tmp = (((1.0d0 / eps_m) - (-1.0d0)) - (((1.0d0 / eps_m) - 1.0d0) * 1.0d0)) / 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 <= -1.35e-272) {
tmp = (1.0 + Math.exp(-(x * eps_m))) * 0.5;
} else if (x <= 970000.0) {
tmp = (Math.exp((-x * -eps_m)) - -1.0) * 0.5;
} else if (x <= 1.56e+100) {
tmp = Math.exp(-x);
} else if (x <= 7.2e+275) {
tmp = (Math.exp((x * (-1.0 + eps_m))) - -1.0) * 0.5;
} else {
tmp = (((1.0 / eps_m) - -1.0) - (((1.0 / eps_m) - 1.0) * 1.0)) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -1.35e-272: tmp = (1.0 + math.exp(-(x * eps_m))) * 0.5 elif x <= 970000.0: tmp = (math.exp((-x * -eps_m)) - -1.0) * 0.5 elif x <= 1.56e+100: tmp = math.exp(-x) elif x <= 7.2e+275: tmp = (math.exp((x * (-1.0 + eps_m))) - -1.0) * 0.5 else: tmp = (((1.0 / eps_m) - -1.0) - (((1.0 / eps_m) - 1.0) * 1.0)) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -1.35e-272) tmp = Float64(Float64(1.0 + exp(Float64(-Float64(x * eps_m)))) * 0.5); elseif (x <= 970000.0) tmp = Float64(Float64(exp(Float64(Float64(-x) * Float64(-eps_m))) - -1.0) * 0.5); elseif (x <= 1.56e+100) tmp = exp(Float64(-x)); elseif (x <= 7.2e+275) tmp = Float64(Float64(exp(Float64(x * Float64(-1.0 + eps_m))) - -1.0) * 0.5); else tmp = Float64(Float64(Float64(Float64(1.0 / eps_m) - -1.0) - Float64(Float64(Float64(1.0 / eps_m) - 1.0) * 1.0)) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -1.35e-272) tmp = (1.0 + exp(-(x * eps_m))) * 0.5; elseif (x <= 970000.0) tmp = (exp((-x * -eps_m)) - -1.0) * 0.5; elseif (x <= 1.56e+100) tmp = exp(-x); elseif (x <= 7.2e+275) tmp = (exp((x * (-1.0 + eps_m))) - -1.0) * 0.5; else tmp = (((1.0 / eps_m) - -1.0) - (((1.0 / eps_m) - 1.0) * 1.0)) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -1.35e-272], N[(N[(1.0 + N[Exp[(-N[(x * eps$95$m), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 970000.0], N[(N[(N[Exp[N[((-x) * (-eps$95$m)), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 1.56e+100], N[Exp[(-x)], $MachinePrecision], If[LessEqual[x, 7.2e+275], N[(N[(N[Exp[N[(x * N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] - -1.0), $MachinePrecision] - N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35 \cdot 10^{-272}:\\
\;\;\;\;\left(1 + e^{-x \cdot eps\_m}\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 970000:\\
\;\;\;\;\left(e^{\left(-x\right) \cdot \left(-eps\_m\right)} - -1\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 1.56 \cdot 10^{+100}:\\
\;\;\;\;e^{-x}\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{+275}:\\
\;\;\;\;\left(e^{x \cdot \left(-1 + eps\_m\right)} - -1\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{1}{eps\_m} - -1\right) - \left(\frac{1}{eps\_m} - 1\right) \cdot 1}{2}\\
\end{array}
\end{array}
if x < -1.34999999999999996e-272Initial program 72.4%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.4%
Taylor expanded in x around 0
distribute-lft-neg-in72.0
exp-neg72.0
*-commutative72.0
exp-neg72.0
Applied rewrites72.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6472.2
Applied rewrites72.2%
if -1.34999999999999996e-272 < x < 9.7e5Initial program 53.3%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
lift-exp.f64N/A
lift-neg.f64N/A
lift-fma.f64N/A
mul-1-negN/A
pow-expN/A
lift-exp.f64N/A
lower-pow.f64N/A
lift-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites87.5%
Taylor expanded in eps around inf
mul-1-negN/A
lower-neg.f6487.5
Applied rewrites87.5%
if 9.7e5 < x < 1.55999999999999998e100Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
lift-exp.f64N/A
lift-neg.f64N/A
lift-fma.f64N/A
mul-1-negN/A
pow-expN/A
lift-exp.f64N/A
lower-pow.f64N/A
lift-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around 0
*-commutativeN/A
distribute-rgt-neg-inN/A
pow-expN/A
+-commutativeN/A
*-commutativeN/A
mul-1-negN/A
*-commutativeN/A
+-commutativeN/A
mul-1-negN/A
lift-exp.f64N/A
lift-neg.f6478.1
Applied rewrites78.1%
if 1.55999999999999998e100 < x < 7.1999999999999996e275Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites37.4%
if 7.1999999999999996e275 < x Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites2.4%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
inv-powN/A
lower-pow.f64100.0
Applied rewrites100.0%
lift-pow.f64N/A
inv-powN/A
lift-/.f64100.0
Applied rewrites100.0%
Final simplification71.6%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= x -10500000000000.0)
t_0
(if (<= x -6e-223)
(*
(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 5.2e-253)
(* (fma -2.0 x 2.0) 0.5)
(if (<= x 900000.0)
(*
(fma
(fma
-1.0
(- eps_m -1.0)
(/ (+ -1.0 (* eps_m eps_m)) (- eps_m -1.0)))
x
2.0)
0.5)
t_0))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = exp(-x);
double tmp;
if (x <= -10500000000000.0) {
tmp = t_0;
} else if (x <= -6e-223) {
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 <= 5.2e-253) {
tmp = fma(-2.0, x, 2.0) * 0.5;
} else if (x <= 900000.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 {
tmp = t_0;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) t_0 = exp(Float64(-x)) tmp = 0.0 if (x <= -10500000000000.0) tmp = t_0; elseif (x <= -6e-223) 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 <= 5.2e-253) tmp = Float64(fma(-2.0, x, 2.0) * 0.5); elseif (x <= 900000.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); else tmp = t_0; 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, -10500000000000.0], t$95$0, If[LessEqual[x, -6e-223], 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, 5.2e-253], N[(N[(-2.0 * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 900000.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], t$95$0]]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;x \leq -10500000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -6 \cdot 10^{-223}:\\
\;\;\;\;\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 5.2 \cdot 10^{-253}:\\
\;\;\;\;\mathsf{fma}\left(-2, x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 900000:\\
\;\;\;\;\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{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.05e13 or 9e5 < x Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
lift-exp.f64N/A
lift-neg.f64N/A
lift-fma.f64N/A
mul-1-negN/A
pow-expN/A
lift-exp.f64N/A
lower-pow.f64N/A
lift-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around 0
*-commutativeN/A
distribute-rgt-neg-inN/A
pow-expN/A
+-commutativeN/A
*-commutativeN/A
mul-1-negN/A
*-commutativeN/A
+-commutativeN/A
mul-1-negN/A
lift-exp.f64N/A
lift-neg.f6468.5
Applied rewrites68.5%
if -1.05e13 < x < -5.99999999999999983e-223Initial program 63.0%
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--.f6454.9
Applied rewrites54.9%
lift-+.f64N/A
flip-+N/A
lower-/.f64N/A
unpow2N/A
metadata-evalN/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f6472.0
Applied rewrites72.0%
if -5.99999999999999983e-223 < x < 5.2e-253Initial program 59.5%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
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--.f6489.5
Applied rewrites89.5%
Taylor expanded in eps around 0
Applied rewrites89.5%
if 5.2e-253 < x < 9e5Initial program 48.4%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
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.1
Applied rewrites62.1%
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-+.f6477.1
Applied rewrites77.1%
Final simplification74.3%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 5.2e-253)
(* (+ 1.0 (exp (- (* x eps_m)))) 0.5)
(if (<= x 900000.0)
(*
(fma
(fma -1.0 (- eps_m -1.0) (/ (+ -1.0 (* eps_m eps_m)) (- eps_m -1.0)))
x
2.0)
0.5)
(exp (- x)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 5.2e-253) {
tmp = (1.0 + exp(-(x * eps_m))) * 0.5;
} else if (x <= 900000.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 {
tmp = exp(-x);
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 5.2e-253) tmp = Float64(Float64(1.0 + exp(Float64(-Float64(x * eps_m)))) * 0.5); elseif (x <= 900000.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); else tmp = exp(Float64(-x)); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 5.2e-253], N[(N[(1.0 + N[Exp[(-N[(x * eps$95$m), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 900000.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], N[Exp[(-x)], $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.2 \cdot 10^{-253}:\\
\;\;\;\;\left(1 + e^{-x \cdot eps\_m}\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 900000:\\
\;\;\;\;\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{else}:\\
\;\;\;\;e^{-x}\\
\end{array}
\end{array}
if x < 5.2e-253Initial program 71.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.7%
Taylor expanded in x around 0
distribute-lft-neg-in75.7
exp-neg75.7
*-commutative75.7
exp-neg75.7
Applied rewrites75.7%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6475.9
Applied rewrites75.9%
if 5.2e-253 < x < 9e5Initial program 48.4%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
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.1
Applied rewrites62.1%
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-+.f6477.1
Applied rewrites77.1%
if 9e5 < x Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
lift-exp.f64N/A
lift-neg.f64N/A
lift-fma.f64N/A
mul-1-negN/A
pow-expN/A
lift-exp.f64N/A
lower-pow.f64N/A
lift-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around 0
*-commutativeN/A
distribute-rgt-neg-inN/A
pow-expN/A
+-commutativeN/A
*-commutativeN/A
mul-1-negN/A
*-commutativeN/A
+-commutativeN/A
mul-1-negN/A
lift-exp.f64N/A
lift-neg.f6454.2
Applied rewrites54.2%
Final simplification70.2%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -7.4e+124)
(* (fma (* (* x x) -0.3333333333333333) x 2.0) 0.5)
(if (<= x -6e-223)
(*
(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 5.2e-253)
(* (fma -2.0 x 2.0) 0.5)
(if (<= x 57000.0)
(*
(fma
(fma
-1.0
(- eps_m -1.0)
(/ (+ -1.0 (* eps_m eps_m)) (- eps_m -1.0)))
x
2.0)
0.5)
(/ (- (- (/ 1.0 eps_m) -1.0) (* (- (/ 1.0 eps_m) 1.0) 1.0)) 2.0))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -7.4e+124) {
tmp = fma(((x * x) * -0.3333333333333333), x, 2.0) * 0.5;
} else if (x <= -6e-223) {
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 <= 5.2e-253) {
tmp = fma(-2.0, x, 2.0) * 0.5;
} else if (x <= 57000.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 {
tmp = (((1.0 / eps_m) - -1.0) - (((1.0 / eps_m) - 1.0) * 1.0)) / 2.0;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -7.4e+124) tmp = Float64(fma(Float64(Float64(x * x) * -0.3333333333333333), x, 2.0) * 0.5); elseif (x <= -6e-223) 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 <= 5.2e-253) tmp = Float64(fma(-2.0, x, 2.0) * 0.5); elseif (x <= 57000.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); else tmp = Float64(Float64(Float64(Float64(1.0 / eps_m) - -1.0) - Float64(Float64(Float64(1.0 / eps_m) - 1.0) * 1.0)) / 2.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -7.4e+124], N[(N[(N[(N[(x * x), $MachinePrecision] * -0.3333333333333333), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, -6e-223], 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, 5.2e-253], N[(N[(-2.0 * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 57000.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], N[(N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] - -1.0), $MachinePrecision] - N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.4 \cdot 10^{+124}:\\
\;\;\;\;\mathsf{fma}\left(\left(x \cdot x\right) \cdot -0.3333333333333333, x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq -6 \cdot 10^{-223}:\\
\;\;\;\;\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 5.2 \cdot 10^{-253}:\\
\;\;\;\;\mathsf{fma}\left(-2, x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 57000:\\
\;\;\;\;\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{else}:\\
\;\;\;\;\frac{\left(\frac{1}{eps\_m} - -1\right) - \left(\frac{1}{eps\_m} - 1\right) \cdot 1}{2}\\
\end{array}
\end{array}
if x < -7.40000000000000016e124Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in eps around 0
mul-1-negN/A
lower-+.f64N/A
mul-1-negN/A
lower-exp.f64N/A
mul-1-negN/A
lift-neg.f64N/A
mul-1-negN/A
lower-exp.f64N/A
mul-1-negN/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%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
if -7.40000000000000016e124 < x < -5.99999999999999983e-223Initial program 66.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites97.4%
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--.f6449.8
Applied rewrites49.8%
lift-+.f64N/A
flip-+N/A
lower-/.f64N/A
unpow2N/A
metadata-evalN/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f6466.7
Applied rewrites66.7%
if -5.99999999999999983e-223 < x < 5.2e-253Initial program 59.5%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
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--.f6489.5
Applied rewrites89.5%
Taylor expanded in eps around 0
Applied rewrites89.5%
if 5.2e-253 < x < 57000Initial program 48.4%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
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.1
Applied rewrites62.1%
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-+.f6477.1
Applied rewrites77.1%
if 57000 < x Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites28.7%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
inv-powN/A
lower-pow.f6452.2
Applied rewrites52.2%
lift-pow.f64N/A
inv-powN/A
lift-/.f6452.2
Applied rewrites52.2%
Final simplification71.8%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -7.4e+124)
(* (fma (* (* x x) -0.3333333333333333) x 2.0) 0.5)
(if (<= x -6e-223)
(*
(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 5.2e-253)
(* (fma -2.0 x 2.0) 0.5)
(if (<= x 3e+150)
(*
(fma
(fma
-1.0
(- eps_m -1.0)
(/ (+ -1.0 (* eps_m eps_m)) (- eps_m -1.0)))
x
2.0)
0.5)
(* (fma (- x 2.0) x 2.0) 0.5))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -7.4e+124) {
tmp = fma(((x * x) * -0.3333333333333333), x, 2.0) * 0.5;
} else if (x <= -6e-223) {
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 <= 5.2e-253) {
tmp = fma(-2.0, x, 2.0) * 0.5;
} else if (x <= 3e+150) {
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 {
tmp = fma((x - 2.0), x, 2.0) * 0.5;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -7.4e+124) tmp = Float64(fma(Float64(Float64(x * x) * -0.3333333333333333), x, 2.0) * 0.5); elseif (x <= -6e-223) 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 <= 5.2e-253) tmp = Float64(fma(-2.0, x, 2.0) * 0.5); elseif (x <= 3e+150) 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); else tmp = Float64(fma(Float64(x - 2.0), x, 2.0) * 0.5); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -7.4e+124], N[(N[(N[(N[(x * x), $MachinePrecision] * -0.3333333333333333), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, -6e-223], 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, 5.2e-253], N[(N[(-2.0 * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 3e+150], 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], N[(N[(N[(x - 2.0), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision]]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.4 \cdot 10^{+124}:\\
\;\;\;\;\mathsf{fma}\left(\left(x \cdot x\right) \cdot -0.3333333333333333, x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq -6 \cdot 10^{-223}:\\
\;\;\;\;\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 5.2 \cdot 10^{-253}:\\
\;\;\;\;\mathsf{fma}\left(-2, x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 3 \cdot 10^{+150}:\\
\;\;\;\;\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{else}:\\
\;\;\;\;\mathsf{fma}\left(x - 2, x, 2\right) \cdot 0.5\\
\end{array}
\end{array}
if x < -7.40000000000000016e124Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in eps around 0
mul-1-negN/A
lower-+.f64N/A
mul-1-negN/A
lower-exp.f64N/A
mul-1-negN/A
lift-neg.f64N/A
mul-1-negN/A
lower-exp.f64N/A
mul-1-negN/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%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
if -7.40000000000000016e124 < x < -5.99999999999999983e-223Initial program 66.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites97.4%
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--.f6449.8
Applied rewrites49.8%
lift-+.f64N/A
flip-+N/A
lower-/.f64N/A
unpow2N/A
metadata-evalN/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f6466.7
Applied rewrites66.7%
if -5.99999999999999983e-223 < x < 5.2e-253Initial program 59.5%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
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--.f6489.5
Applied rewrites89.5%
Taylor expanded in eps around 0
Applied rewrites89.5%
if 5.2e-253 < x < 3.00000000000000012e150Initial program 65.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
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--.f6442.3
Applied rewrites42.3%
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-+.f6456.4
Applied rewrites56.4%
if 3.00000000000000012e150 < x Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in eps around 0
mul-1-negN/A
lower-+.f64N/A
mul-1-negN/A
lower-exp.f64N/A
mul-1-negN/A
lift-neg.f64N/A
mul-1-negN/A
lower-exp.f64N/A
mul-1-negN/A
lift-neg.f6450.8
Applied rewrites50.8%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6448.6
Applied rewrites48.6%
Final simplification66.7%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 5.2e-253)
(* (fma (* (* x x) -0.3333333333333333) x 2.0) 0.5)
(if (<= x 3e+150)
(*
(fma
(fma -1.0 (- eps_m -1.0) (/ (+ -1.0 (* eps_m eps_m)) (- eps_m -1.0)))
x
2.0)
0.5)
(* (fma (- x 2.0) x 2.0) 0.5))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 5.2e-253) {
tmp = fma(((x * x) * -0.3333333333333333), x, 2.0) * 0.5;
} else if (x <= 3e+150) {
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 {
tmp = fma((x - 2.0), x, 2.0) * 0.5;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 5.2e-253) tmp = Float64(fma(Float64(Float64(x * x) * -0.3333333333333333), x, 2.0) * 0.5); elseif (x <= 3e+150) 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); else tmp = Float64(fma(Float64(x - 2.0), x, 2.0) * 0.5); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 5.2e-253], N[(N[(N[(N[(x * x), $MachinePrecision] * -0.3333333333333333), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 3e+150], 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], N[(N[(N[(x - 2.0), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.2 \cdot 10^{-253}:\\
\;\;\;\;\mathsf{fma}\left(\left(x \cdot x\right) \cdot -0.3333333333333333, x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 3 \cdot 10^{+150}:\\
\;\;\;\;\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{else}:\\
\;\;\;\;\mathsf{fma}\left(x - 2, x, 2\right) \cdot 0.5\\
\end{array}
\end{array}
if x < 5.2e-253Initial program 71.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.7%
Taylor expanded in eps around 0
mul-1-negN/A
lower-+.f64N/A
mul-1-negN/A
lower-exp.f64N/A
mul-1-negN/A
lift-neg.f64N/A
mul-1-negN/A
lower-exp.f64N/A
mul-1-negN/A
lift-neg.f6477.5
Applied rewrites77.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.f6472.9
Applied rewrites72.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6473.1
Applied rewrites73.1%
if 5.2e-253 < x < 3.00000000000000012e150Initial program 65.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
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--.f6442.3
Applied rewrites42.3%
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-+.f6456.4
Applied rewrites56.4%
if 3.00000000000000012e150 < x Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in eps around 0
mul-1-negN/A
lower-+.f64N/A
mul-1-negN/A
lower-exp.f64N/A
mul-1-negN/A
lift-neg.f64N/A
mul-1-negN/A
lower-exp.f64N/A
mul-1-negN/A
lift-neg.f6450.8
Applied rewrites50.8%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6448.6
Applied rewrites48.6%
Final simplification63.2%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 1.45e-102) (* (fma (* (* x x) -0.3333333333333333) x 2.0) 0.5) (* (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 <= 1.45e-102) {
tmp = fma(((x * x) * -0.3333333333333333), x, 2.0) * 0.5;
} 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 <= 1.45e-102) tmp = Float64(fma(Float64(Float64(x * x) * -0.3333333333333333), x, 2.0) * 0.5); 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, 1.45e-102], N[(N[(N[(N[(x * x), $MachinePrecision] * -0.3333333333333333), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $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 1.45 \cdot 10^{-102}:\\
\;\;\;\;\mathsf{fma}\left(\left(x \cdot x\right) \cdot -0.3333333333333333, x, 2\right) \cdot 0.5\\
\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 < 1.44999999999999993e-102Initial program 66.2%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.0%
Taylor expanded in eps around 0
mul-1-negN/A
lower-+.f64N/A
mul-1-negN/A
lower-exp.f64N/A
mul-1-negN/A
lift-neg.f64N/A
mul-1-negN/A
lower-exp.f64N/A
mul-1-negN/A
lift-neg.f6475.0
Applied rewrites75.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.f6471.4
Applied rewrites71.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6471.6
Applied rewrites71.6%
if 1.44999999999999993e-102 < x Initial program 86.2%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
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--.f6417.6
Applied rewrites17.6%
Taylor expanded in eps around 0
Applied rewrites29.2%
Final simplification55.3%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (* (fma (- x 2.0) x 2.0) 0.5))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return fma((x - 2.0), x, 2.0) * 0.5;
}
eps_m = abs(eps) function code(x, eps_m) return Float64(fma(Float64(x - 2.0), x, 2.0) * 0.5) end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(N[(N[(x - 2.0), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\mathsf{fma}\left(x - 2, x, 2\right) \cdot 0.5
\end{array}
Initial program 73.9%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.4%
Taylor expanded in eps around 0
mul-1-negN/A
lower-+.f64N/A
mul-1-negN/A
lower-exp.f64N/A
mul-1-negN/A
lift-neg.f64N/A
mul-1-negN/A
lower-exp.f64N/A
mul-1-negN/A
lift-neg.f6467.3
Applied rewrites67.3%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6457.4
Applied rewrites57.4%
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.9%
Taylor expanded in x around 0
Applied rewrites40.8%
herbie shell --seed 2025061
(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))