
(FPCore (x eps) :precision binary64 (/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))
double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0
end function
public static double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-((1.0 + eps) * x)))) / 2.0;
}
def code(x, eps): return (((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-((1.0 + eps) * x)))) / 2.0
function code(x, eps) return Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(-Float64(Float64(1.0 - eps) * x)))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * exp(Float64(-Float64(Float64(1.0 + eps) * x))))) / 2.0) end
function tmp = code(x, eps) tmp = (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0; end
code[x_, eps_] := N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}
\end{array}
Herbie found 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 1e-8)
(* (- t_0 (* -1.0 t_0)) 0.5)
(/
(-
(* (+ 1.0 (/ 1.0 eps_m)) (exp (- (* (- 1.0 eps_m) x))))
(* (- (/ 1.0 eps_m) 1.0) (/ 1.0 (exp (fma x eps_m x)))))
2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = (x + 1.0) * exp(-x);
double tmp;
if (eps_m <= 1e-8) {
tmp = (t_0 - (-1.0 * t_0)) * 0.5;
} else {
tmp = (((1.0 + (1.0 / eps_m)) * exp(-((1.0 - eps_m) * x))) - (((1.0 / eps_m) - 1.0) * (1.0 / exp(fma(x, eps_m, x))))) / 2.0;
}
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 <= 1e-8) tmp = Float64(Float64(t_0 - Float64(-1.0 * t_0)) * 0.5); else tmp = Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) * exp(Float64(-Float64(Float64(1.0 - eps_m) * x)))) - Float64(Float64(Float64(1.0 / eps_m) - 1.0) * Float64(1.0 / exp(fma(x, eps_m, x))))) / 2.0); end return 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, 1e-8], N[(N[(t$95$0 - N[(-1.0 * t$95$0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], 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[(1.0 / N[Exp[N[(x * eps$95$m + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $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 10^{-8}:\\
\;\;\;\;\left(t\_0 - -1 \cdot t\_0\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\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 \frac{1}{e^{\mathsf{fma}\left(x, eps\_m, x\right)}}}{2}\\
\end{array}
\end{array}
if eps < 1e-8Initial program 35.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
if 1e-8 < eps Initial program 100.0%
lift-exp.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
lift-*.f64N/A
exp-negN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-rgt1-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
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)
2e+39)
1.0
(* (- (fma (- x) (/ (- 1.0 (* eps_m eps_m)) (+ eps_m 1.0)) 1.0) -1.0) 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) <= 2e+39) {
tmp = 1.0;
} else {
tmp = (fma(-x, ((1.0 - (eps_m * eps_m)) / (eps_m + 1.0)), 1.0) - -1.0) * 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(Float64(1.0 - eps_m) * x)))) - Float64(Float64(Float64(1.0 / eps_m) - 1.0) * exp(Float64(-Float64(Float64(1.0 + eps_m) * x))))) / 2.0) <= 2e+39) tmp = 1.0; else tmp = Float64(Float64(fma(Float64(-x), Float64(Float64(1.0 - Float64(eps_m * eps_m)) / Float64(eps_m + 1.0)), 1.0) - -1.0) * 0.5); end return 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], 2e+39], 1.0, N[(N[(N[((-x) * N[(N[(1.0 - N[(eps$95$m * eps$95$m), $MachinePrecision]), $MachinePrecision] / N[(eps$95$m + 1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] - -1.0), $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 2 \cdot 10^{+39}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(-x, \frac{1 - eps\_m \cdot eps\_m}{eps\_m + 1}, 1\right) - -1\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)) < 1.99999999999999988e39Initial program 53.3%
Taylor expanded in x around 0
Applied rewrites74.8%
if 1.99999999999999988e39 < (/.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 99.9%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites52.2%
Taylor expanded in x around 0
distribute-lft-neg-inN/A
rec-expN/A
mul-1-negN/A
distribute-lft-neg-inN/A
+-commutativeN/A
lower-fma.f64N/A
lift-neg.f64N/A
lift--.f6419.3
Applied rewrites19.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
lower-+.f6434.5
Applied rewrites34.5%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (* (+ x 1.0) (exp (- x)))))
(if (<= eps_m 4e-6)
(* (- t_0 (* -1.0 t_0)) 0.5)
(* (- (/ 1.0 (exp (* x (- 1.0 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 <= 4e-6) {
tmp = (t_0 - (-1.0 * t_0)) * 0.5;
} else {
tmp = ((1.0 / exp((x * (1.0 - 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 <= 4d-6) then
tmp = (t_0 - ((-1.0d0) * t_0)) * 0.5d0
else
tmp = ((1.0d0 / exp((x * (1.0d0 - 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 <= 4e-6) {
tmp = (t_0 - (-1.0 * t_0)) * 0.5;
} else {
tmp = ((1.0 / Math.exp((x * (1.0 - 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 <= 4e-6: tmp = (t_0 - (-1.0 * t_0)) * 0.5 else: tmp = ((1.0 / math.exp((x * (1.0 - 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 <= 4e-6) tmp = Float64(Float64(t_0 - Float64(-1.0 * t_0)) * 0.5); else tmp = Float64(Float64(Float64(1.0 / exp(Float64(x * Float64(1.0 - eps_m)))) - Float64(-exp(Float64(-Float64(x * eps_m))))) * 0.5); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = (x + 1.0) * exp(-x); tmp = 0.0; if (eps_m <= 4e-6) tmp = (t_0 - (-1.0 * t_0)) * 0.5; else tmp = ((1.0 / exp((x * (1.0 - 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, 4e-6], N[(N[(t$95$0 - N[(-1.0 * t$95$0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(1.0 / N[Exp[N[(x * N[(1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $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 4 \cdot 10^{-6}:\\
\;\;\;\;\left(t\_0 - -1 \cdot t\_0\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{1}{e^{x \cdot \left(1 - eps\_m\right)}} - \left(-e^{-x \cdot eps\_m}\right)\right) \cdot 0.5\\
\end{array}
\end{array}
if eps < 3.99999999999999982e-6Initial program 36.3%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
if 3.99999999999999982e-6 < eps 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--.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
exp-negN/A
*-commutativeN/A
lower-/.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (* (+ x 1.0) (exp (- x)))))
(if (<= eps_m 0.0036)
(* (- t_0 (* -1.0 t_0)) 0.5)
(* (- (/ 1.0 (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.0036) {
tmp = (t_0 - (-1.0 * t_0)) * 0.5;
} else {
tmp = ((1.0 / 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.0036d0) then
tmp = (t_0 - ((-1.0d0) * t_0)) * 0.5d0
else
tmp = ((1.0d0 / 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.0036) {
tmp = (t_0 - (-1.0 * t_0)) * 0.5;
} else {
tmp = ((1.0 / 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.0036: tmp = (t_0 - (-1.0 * t_0)) * 0.5 else: tmp = ((1.0 / 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.0036) tmp = Float64(Float64(t_0 - Float64(-1.0 * t_0)) * 0.5); else tmp = Float64(Float64(Float64(1.0 / exp(Float64(x * Float64(-eps_m)))) - Float64(-exp(Float64(-Float64(x * eps_m))))) * 0.5); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = (x + 1.0) * exp(-x); tmp = 0.0; if (eps_m <= 0.0036) tmp = (t_0 - (-1.0 * t_0)) * 0.5; else tmp = ((1.0 / 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.0036], N[(N[(t$95$0 - N[(-1.0 * t$95$0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(1.0 / N[Exp[N[(x * (-eps$95$m)), $MachinePrecision]], $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.0036:\\
\;\;\;\;\left(t\_0 - -1 \cdot t\_0\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{1}{e^{x \cdot \left(-eps\_m\right)}} - \left(-e^{-x \cdot eps\_m}\right)\right) \cdot 0.5\\
\end{array}
\end{array}
if eps < 0.0035999999999999999Initial program 37.2%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
if 0.0035999999999999999 < eps 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--.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
exp-negN/A
*-commutativeN/A
lower-/.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around inf
mul-1-negN/A
lower-neg.f6499.7
Applied rewrites99.7%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (* (+ x 1.0) (exp (- x)))))
(if (<= eps_m 0.0036)
(* (- t_0 (* -1.0 t_0)) 0.5)
(* (- (exp (* x eps_m)) (- (exp (- (fma x eps_m x))))) 0.5))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = (x + 1.0) * exp(-x);
double tmp;
if (eps_m <= 0.0036) {
tmp = (t_0 - (-1.0 * t_0)) * 0.5;
} else {
tmp = (exp((x * eps_m)) - -exp(-fma(x, eps_m, x))) * 0.5;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(Float64(x + 1.0) * exp(Float64(-x))) tmp = 0.0 if (eps_m <= 0.0036) tmp = Float64(Float64(t_0 - Float64(-1.0 * t_0)) * 0.5); else tmp = Float64(Float64(exp(Float64(x * eps_m)) - Float64(-exp(Float64(-fma(x, eps_m, x))))) * 0.5); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[(N[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps$95$m, 0.0036], N[(N[(t$95$0 - N[(-1.0 * t$95$0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] - (-N[Exp[(-N[(x * eps$95$m + x), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := \left(x + 1\right) \cdot e^{-x}\\
\mathbf{if}\;eps\_m \leq 0.0036:\\
\;\;\;\;\left(t\_0 - -1 \cdot t\_0\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(e^{x \cdot eps\_m} - \left(-e^{-\mathsf{fma}\left(x, eps\_m, x\right)}\right)\right) \cdot 0.5\\
\end{array}
\end{array}
if eps < 0.0035999999999999999Initial program 37.2%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
if 0.0035999999999999999 < 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-*.f6499.7
Applied rewrites99.7%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (- (exp (- (fma x eps_m x))))))
(if (<= eps_m 1.05e-33)
(* (- (/ 1.0 (* (fma -1.0 x (/ (+ x 1.0) eps_m)) eps_m)) t_0) 0.5)
(if (<= eps_m 0.0036)
(/
(-
(* (+ 1.0 (/ 1.0 eps_m)) (fma (- eps_m 1.0) x 1.0))
(* (- (/ 1.0 eps_m) 1.0) (fma -1.0 (fma x eps_m x) 1.0)))
2.0)
(* (- (exp (* x eps_m)) t_0) 0.5)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = -exp(-fma(x, eps_m, x));
double tmp;
if (eps_m <= 1.05e-33) {
tmp = ((1.0 / (fma(-1.0, x, ((x + 1.0) / eps_m)) * eps_m)) - t_0) * 0.5;
} else if (eps_m <= 0.0036) {
tmp = (((1.0 + (1.0 / eps_m)) * fma((eps_m - 1.0), x, 1.0)) - (((1.0 / eps_m) - 1.0) * fma(-1.0, fma(x, eps_m, x), 1.0))) / 2.0;
} else {
tmp = (exp((x * eps_m)) - t_0) * 0.5;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(-exp(Float64(-fma(x, eps_m, x)))) tmp = 0.0 if (eps_m <= 1.05e-33) tmp = Float64(Float64(Float64(1.0 / Float64(fma(-1.0, x, Float64(Float64(x + 1.0) / eps_m)) * eps_m)) - t_0) * 0.5); elseif (eps_m <= 0.0036) tmp = Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) * fma(Float64(eps_m - 1.0), x, 1.0)) - Float64(Float64(Float64(1.0 / eps_m) - 1.0) * fma(-1.0, fma(x, eps_m, x), 1.0))) / 2.0); else tmp = Float64(Float64(exp(Float64(x * eps_m)) - t_0) * 0.5); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = (-N[Exp[(-N[(x * eps$95$m + x), $MachinePrecision])], $MachinePrecision])}, If[LessEqual[eps$95$m, 1.05e-33], N[(N[(N[(1.0 / N[(N[(-1.0 * x + N[(N[(x + 1.0), $MachinePrecision] / eps$95$m), $MachinePrecision]), $MachinePrecision] * eps$95$m), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[eps$95$m, 0.0036], N[(N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(eps$95$m - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision] * N[(-1.0 * N[(x * eps$95$m + x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision] * 0.5), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := -e^{-\mathsf{fma}\left(x, eps\_m, x\right)}\\
\mathbf{if}\;eps\_m \leq 1.05 \cdot 10^{-33}:\\
\;\;\;\;\left(\frac{1}{\mathsf{fma}\left(-1, x, \frac{x + 1}{eps\_m}\right) \cdot eps\_m} - t\_0\right) \cdot 0.5\\
\mathbf{elif}\;eps\_m \leq 0.0036:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) \cdot \mathsf{fma}\left(eps\_m - 1, x, 1\right) - \left(\frac{1}{eps\_m} - 1\right) \cdot \mathsf{fma}\left(-1, \mathsf{fma}\left(x, eps\_m, x\right), 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\left(e^{x \cdot eps\_m} - t\_0\right) \cdot 0.5\\
\end{array}
\end{array}
if eps < 1.05e-33Initial program 34.4%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites97.8%
lift-exp.f64N/A
lift-neg.f64N/A
lift--.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
exp-negN/A
*-commutativeN/A
lower-/.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6497.8
Applied rewrites97.8%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
lift--.f6467.3
Applied rewrites67.3%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
lower-fma.f64N/A
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f6484.9
Applied rewrites84.9%
if 1.05e-33 < eps < 0.0035999999999999999Initial program 62.4%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
distribute-rgt1-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6432.2
Applied rewrites32.2%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6453.6
Applied rewrites53.6%
if 0.0035999999999999999 < 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-*.f6499.7
Applied rewrites99.7%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (* (- (exp (* (- x) (- 1.0 eps_m))) (- (exp (- (fma x eps_m x))))) 0.5))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return (exp((-x * (1.0 - eps_m))) - -exp(-fma(x, eps_m, x))) * 0.5;
}
eps_m = abs(eps) function code(x, eps_m) return Float64(Float64(exp(Float64(Float64(-x) * Float64(1.0 - eps_m))) - Float64(-exp(Float64(-fma(x, eps_m, x))))) * 0.5) end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(N[(N[Exp[N[((-x) * N[(1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - (-N[Exp[(-N[(x * eps$95$m + x), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\left(e^{\left(-x\right) \cdot \left(1 - eps\_m\right)} - \left(-e^{-\mathsf{fma}\left(x, eps\_m, x\right)}\right)\right) \cdot 0.5
\end{array}
Initial program 73.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.0%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -2.15e-268)
(* (- 1.0 (- (exp (- (* x eps_m))))) 0.5)
(if (<= x 7.2e+93)
(* (- (exp (* x eps_m)) -1.0) 0.5)
(if (<= x 1.2e+167)
(/ (- (* (+ 1.0 (/ 1.0 eps_m)) 1.0) (* (- (/ 1.0 eps_m) 1.0) 1.0)) 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 <= -2.15e-268) {
tmp = (1.0 - -exp(-(x * eps_m))) * 0.5;
} else if (x <= 7.2e+93) {
tmp = (exp((x * eps_m)) - -1.0) * 0.5;
} else if (x <= 1.2e+167) {
tmp = (((1.0 + (1.0 / eps_m)) * 1.0) - (((1.0 / eps_m) - 1.0) * 1.0)) / 2.0;
} else {
tmp = (exp((-x * (1.0 - 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 (x <= (-2.15d-268)) then
tmp = (1.0d0 - -exp(-(x * eps_m))) * 0.5d0
else if (x <= 7.2d+93) then
tmp = (exp((x * eps_m)) - (-1.0d0)) * 0.5d0
else if (x <= 1.2d+167) then
tmp = (((1.0d0 + (1.0d0 / eps_m)) * 1.0d0) - (((1.0d0 / eps_m) - 1.0d0) * 1.0d0)) / 2.0d0
else
tmp = (exp((-x * (1.0d0 - 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 (x <= -2.15e-268) {
tmp = (1.0 - -Math.exp(-(x * eps_m))) * 0.5;
} else if (x <= 7.2e+93) {
tmp = (Math.exp((x * eps_m)) - -1.0) * 0.5;
} else if (x <= 1.2e+167) {
tmp = (((1.0 + (1.0 / eps_m)) * 1.0) - (((1.0 / eps_m) - 1.0) * 1.0)) / 2.0;
} else {
tmp = (Math.exp((-x * (1.0 - eps_m))) - -1.0) * 0.5;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -2.15e-268: tmp = (1.0 - -math.exp(-(x * eps_m))) * 0.5 elif x <= 7.2e+93: tmp = (math.exp((x * eps_m)) - -1.0) * 0.5 elif x <= 1.2e+167: tmp = (((1.0 + (1.0 / eps_m)) * 1.0) - (((1.0 / eps_m) - 1.0) * 1.0)) / 2.0 else: tmp = (math.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 <= -2.15e-268) tmp = Float64(Float64(1.0 - Float64(-exp(Float64(-Float64(x * eps_m))))) * 0.5); elseif (x <= 7.2e+93) tmp = Float64(Float64(exp(Float64(x * eps_m)) - -1.0) * 0.5); elseif (x <= 1.2e+167) tmp = Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) * 1.0) - Float64(Float64(Float64(1.0 / eps_m) - 1.0) * 1.0)) / 2.0); else tmp = Float64(Float64(exp(Float64(Float64(-x) * Float64(1.0 - 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 (x <= -2.15e-268) tmp = (1.0 - -exp(-(x * eps_m))) * 0.5; elseif (x <= 7.2e+93) tmp = (exp((x * eps_m)) - -1.0) * 0.5; elseif (x <= 1.2e+167) tmp = (((1.0 + (1.0 / eps_m)) * 1.0) - (((1.0 / eps_m) - 1.0) * 1.0)) / 2.0; else tmp = (exp((-x * (1.0 - eps_m))) - -1.0) * 0.5; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -2.15e-268], N[(N[(1.0 - (-N[Exp[(-N[(x * eps$95$m), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 7.2e+93], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 1.2e+167], N[(N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] - N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision] * 1.0), $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 -2.15 \cdot 10^{-268}:\\
\;\;\;\;\left(1 - \left(-e^{-x \cdot eps\_m}\right)\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{+93}:\\
\;\;\;\;\left(e^{x \cdot eps\_m} - -1\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{+167}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) \cdot 1 - \left(\frac{1}{eps\_m} - 1\right) \cdot 1}{2}\\
\mathbf{else}:\\
\;\;\;\;\left(e^{\left(-x\right) \cdot \left(1 - eps\_m\right)} - -1\right) \cdot 0.5\\
\end{array}
\end{array}
if x < -2.15e-268Initial program 69.5%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.7%
lift-exp.f64N/A
lift-neg.f64N/A
lift--.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
exp-negN/A
*-commutativeN/A
lower-/.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6498.7
Applied rewrites98.7%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6498.8
Applied rewrites98.8%
Taylor expanded in x around 0
rec-exp98.5
*-commutative98.5
distribute-rgt-neg-in98.5
*-commutative98.5
Applied rewrites98.5%
if -2.15e-268 < x < 7.1999999999999998e93Initial program 62.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.7%
Taylor expanded in x around 0
Applied rewrites88.1%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6488.4
Applied rewrites88.4%
if 7.1999999999999998e93 < x < 1.19999999999999999e167Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites51.5%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6422.1
Applied rewrites22.1%
Taylor expanded in x around 0
Applied rewrites49.3%
if 1.19999999999999999e167 < 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 rewrites52.9%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (* (- (exp (* x eps_m)) -1.0) 0.5)))
(if (<= x -2.15e-268)
(* (- 1.0 (- (exp (- (* x eps_m))))) 0.5)
(if (<= x 7.2e+93)
t_0
(if (<= x 1.2e+167)
(/
(- (* (+ 1.0 (/ 1.0 eps_m)) 1.0) (* (- (/ 1.0 eps_m) 1.0) 1.0))
2.0)
t_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 <= -2.15e-268) {
tmp = (1.0 - -exp(-(x * eps_m))) * 0.5;
} else if (x <= 7.2e+93) {
tmp = t_0;
} else if (x <= 1.2e+167) {
tmp = (((1.0 + (1.0 / eps_m)) * 1.0) - (((1.0 / eps_m) - 1.0) * 1.0)) / 2.0;
} else {
tmp = t_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 <= (-2.15d-268)) then
tmp = (1.0d0 - -exp(-(x * eps_m))) * 0.5d0
else if (x <= 7.2d+93) then
tmp = t_0
else if (x <= 1.2d+167) then
tmp = (((1.0d0 + (1.0d0 / eps_m)) * 1.0d0) - (((1.0d0 / eps_m) - 1.0d0) * 1.0d0)) / 2.0d0
else
tmp = t_0
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 <= -2.15e-268) {
tmp = (1.0 - -Math.exp(-(x * eps_m))) * 0.5;
} else if (x <= 7.2e+93) {
tmp = t_0;
} else if (x <= 1.2e+167) {
tmp = (((1.0 + (1.0 / eps_m)) * 1.0) - (((1.0 / eps_m) - 1.0) * 1.0)) / 2.0;
} else {
tmp = t_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 <= -2.15e-268: tmp = (1.0 - -math.exp(-(x * eps_m))) * 0.5 elif x <= 7.2e+93: tmp = t_0 elif x <= 1.2e+167: tmp = (((1.0 + (1.0 / eps_m)) * 1.0) - (((1.0 / eps_m) - 1.0) * 1.0)) / 2.0 else: tmp = t_0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(Float64(exp(Float64(x * eps_m)) - -1.0) * 0.5) tmp = 0.0 if (x <= -2.15e-268) tmp = Float64(Float64(1.0 - Float64(-exp(Float64(-Float64(x * eps_m))))) * 0.5); elseif (x <= 7.2e+93) tmp = t_0; elseif (x <= 1.2e+167) tmp = Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) * 1.0) - Float64(Float64(Float64(1.0 / eps_m) - 1.0) * 1.0)) / 2.0); else tmp = t_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 <= -2.15e-268) tmp = (1.0 - -exp(-(x * eps_m))) * 0.5; elseif (x <= 7.2e+93) tmp = t_0; elseif (x <= 1.2e+167) tmp = (((1.0 + (1.0 / eps_m)) * 1.0) - (((1.0 / eps_m) - 1.0) * 1.0)) / 2.0; else tmp = t_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, -2.15e-268], N[(N[(1.0 - (-N[Exp[(-N[(x * eps$95$m), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 7.2e+93], t$95$0, If[LessEqual[x, 1.2e+167], N[(N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] - N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := \left(e^{x \cdot eps\_m} - -1\right) \cdot 0.5\\
\mathbf{if}\;x \leq -2.15 \cdot 10^{-268}:\\
\;\;\;\;\left(1 - \left(-e^{-x \cdot eps\_m}\right)\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{+93}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{+167}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) \cdot 1 - \left(\frac{1}{eps\_m} - 1\right) \cdot 1}{2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -2.15e-268Initial program 69.5%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.7%
lift-exp.f64N/A
lift-neg.f64N/A
lift--.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
exp-negN/A
*-commutativeN/A
lower-/.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6498.7
Applied rewrites98.7%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6498.8
Applied rewrites98.8%
Taylor expanded in x around 0
rec-exp98.5
*-commutative98.5
distribute-rgt-neg-in98.5
*-commutative98.5
Applied rewrites98.5%
if -2.15e-268 < x < 7.1999999999999998e93 or 1.19999999999999999e167 < x Initial program 72.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.1%
Taylor expanded in x around 0
Applied rewrites79.3%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6479.3
Applied rewrites79.3%
if 7.1999999999999998e93 < x < 1.19999999999999999e167Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites51.5%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6422.1
Applied rewrites22.1%
Taylor expanded in x around 0
Applied rewrites49.3%
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.55)
(* (- (exp (- x)) -1.0) 0.5)
(if (<= x 7.2e+93)
t_0
(if (<= x 1.2e+167)
(/
(- (* (+ 1.0 (/ 1.0 eps_m)) 1.0) (* (- (/ 1.0 eps_m) 1.0) 1.0))
2.0)
t_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.55) {
tmp = (exp(-x) - -1.0) * 0.5;
} else if (x <= 7.2e+93) {
tmp = t_0;
} else if (x <= 1.2e+167) {
tmp = (((1.0 + (1.0 / eps_m)) * 1.0) - (((1.0 / eps_m) - 1.0) * 1.0)) / 2.0;
} else {
tmp = t_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.55d0)) then
tmp = (exp(-x) - (-1.0d0)) * 0.5d0
else if (x <= 7.2d+93) then
tmp = t_0
else if (x <= 1.2d+167) then
tmp = (((1.0d0 + (1.0d0 / eps_m)) * 1.0d0) - (((1.0d0 / eps_m) - 1.0d0) * 1.0d0)) / 2.0d0
else
tmp = t_0
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.55) {
tmp = (Math.exp(-x) - -1.0) * 0.5;
} else if (x <= 7.2e+93) {
tmp = t_0;
} else if (x <= 1.2e+167) {
tmp = (((1.0 + (1.0 / eps_m)) * 1.0) - (((1.0 / eps_m) - 1.0) * 1.0)) / 2.0;
} else {
tmp = t_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.55: tmp = (math.exp(-x) - -1.0) * 0.5 elif x <= 7.2e+93: tmp = t_0 elif x <= 1.2e+167: tmp = (((1.0 + (1.0 / eps_m)) * 1.0) - (((1.0 / eps_m) - 1.0) * 1.0)) / 2.0 else: tmp = t_0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(Float64(exp(Float64(x * eps_m)) - -1.0) * 0.5) tmp = 0.0 if (x <= -1.55) tmp = Float64(Float64(exp(Float64(-x)) - -1.0) * 0.5); elseif (x <= 7.2e+93) tmp = t_0; elseif (x <= 1.2e+167) tmp = Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) * 1.0) - Float64(Float64(Float64(1.0 / eps_m) - 1.0) * 1.0)) / 2.0); else tmp = t_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.55) tmp = (exp(-x) - -1.0) * 0.5; elseif (x <= 7.2e+93) tmp = t_0; elseif (x <= 1.2e+167) tmp = (((1.0 + (1.0 / eps_m)) * 1.0) - (((1.0 / eps_m) - 1.0) * 1.0)) / 2.0; else tmp = t_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.55], N[(N[(N[Exp[(-x)], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 7.2e+93], t$95$0, If[LessEqual[x, 1.2e+167], N[(N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] - N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := \left(e^{x \cdot eps\_m} - -1\right) \cdot 0.5\\
\mathbf{if}\;x \leq -1.55:\\
\;\;\;\;\left(e^{-x} - -1\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{+93}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{+167}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) \cdot 1 - \left(\frac{1}{eps\_m} - 1\right) \cdot 1}{2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.55000000000000004Initial program 98.9%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites3.1%
Taylor expanded in eps around 0
mul-1-negN/A
lift-neg.f6497.9
Applied rewrites97.9%
if -1.55000000000000004 < x < 7.1999999999999998e93 or 1.19999999999999999e167 < x Initial program 65.9%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites77.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6477.2
Applied rewrites77.2%
if 7.1999999999999998e93 < x < 1.19999999999999999e167Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites51.5%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6422.1
Applied rewrites22.1%
Taylor expanded in x around 0
Applied rewrites49.3%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 2.4e-191)
(* (- (exp (- x)) -1.0) 0.5)
(if (<= x 5e+85)
(* (- (fma (- x) (/ (- 1.0 (* eps_m eps_m)) (+ eps_m 1.0)) 1.0) -1.0) 0.5)
(if (<= x 3e+193)
(/ (- (* (+ 1.0 (/ 1.0 eps_m)) 1.0) (* (- (/ 1.0 eps_m) 1.0) 1.0)) 2.0)
(* (- (* x eps_m) -1.0) 0.5)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 2.4e-191) {
tmp = (exp(-x) - -1.0) * 0.5;
} else if (x <= 5e+85) {
tmp = (fma(-x, ((1.0 - (eps_m * eps_m)) / (eps_m + 1.0)), 1.0) - -1.0) * 0.5;
} else if (x <= 3e+193) {
tmp = (((1.0 + (1.0 / eps_m)) * 1.0) - (((1.0 / eps_m) - 1.0) * 1.0)) / 2.0;
} else {
tmp = ((x * eps_m) - -1.0) * 0.5;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 2.4e-191) tmp = Float64(Float64(exp(Float64(-x)) - -1.0) * 0.5); elseif (x <= 5e+85) tmp = Float64(Float64(fma(Float64(-x), Float64(Float64(1.0 - Float64(eps_m * eps_m)) / Float64(eps_m + 1.0)), 1.0) - -1.0) * 0.5); elseif (x <= 3e+193) tmp = Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) * 1.0) - Float64(Float64(Float64(1.0 / eps_m) - 1.0) * 1.0)) / 2.0); else tmp = Float64(Float64(Float64(x * eps_m) - -1.0) * 0.5); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 2.4e-191], N[(N[(N[Exp[(-x)], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 5e+85], N[(N[(N[((-x) * N[(N[(1.0 - N[(eps$95$m * eps$95$m), $MachinePrecision]), $MachinePrecision] / N[(eps$95$m + 1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 3e+193], N[(N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] - N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(x * eps$95$m), $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.4 \cdot 10^{-191}:\\
\;\;\;\;\left(e^{-x} - -1\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 5 \cdot 10^{+85}:\\
\;\;\;\;\left(\mathsf{fma}\left(-x, \frac{1 - eps\_m \cdot eps\_m}{eps\_m + 1}, 1\right) - -1\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 3 \cdot 10^{+193}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) \cdot 1 - \left(\frac{1}{eps\_m} - 1\right) \cdot 1}{2}\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot eps\_m - -1\right) \cdot 0.5\\
\end{array}
\end{array}
if x < 2.3999999999999999e-191Initial program 65.8%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.1%
Taylor expanded in x around 0
Applied rewrites60.8%
Taylor expanded in eps around 0
mul-1-negN/A
lift-neg.f6484.3
Applied rewrites84.3%
if 2.3999999999999999e-191 < x < 5.0000000000000001e85Initial program 65.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.0%
Taylor expanded in x around 0
Applied rewrites83.5%
Taylor expanded in x around 0
distribute-lft-neg-inN/A
rec-expN/A
mul-1-negN/A
distribute-lft-neg-inN/A
+-commutativeN/A
lower-fma.f64N/A
lift-neg.f64N/A
lift--.f6448.9
Applied rewrites48.9%
lift--.f64N/A
flip--N/A
lower-/.f64N/A
metadata-evalN/A
unpow2N/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6469.0
Applied rewrites69.0%
if 5.0000000000000001e85 < x < 3e193Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites51.4%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6424.4
Applied rewrites24.4%
Taylor expanded in x around 0
Applied rewrites49.3%
if 3e193 < 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 rewrites53.2%
Taylor expanded in x around 0
distribute-lft-neg-inN/A
rec-expN/A
mul-1-negN/A
distribute-lft-neg-inN/A
+-commutativeN/A
lower-fma.f64N/A
lift-neg.f64N/A
lift--.f6444.1
Applied rewrites44.1%
Taylor expanded in eps around inf
*-commutativeN/A
lift-*.f6444.5
Applied rewrites44.5%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (* (- (/ 1.0 eps_m) 1.0) 1.0)) (t_1 (+ 1.0 (/ 1.0 eps_m))))
(if (<= x -480000000.0)
(/
(- (* t_1 (/ (- (* (* -1.0 x) (* -1.0 x)) 1.0) (- (* -1.0 x) 1.0))) t_0)
2.0)
(if (<= x 2.4e-191)
1.0
(if (<= x 5e+85)
(*
(- (fma (- x) (/ (- 1.0 (* eps_m eps_m)) (+ eps_m 1.0)) 1.0) -1.0)
0.5)
(if (<= x 3e+193)
(/ (- (* t_1 1.0) t_0) 2.0)
(* (- (* x eps_m) -1.0) 0.5)))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = ((1.0 / eps_m) - 1.0) * 1.0;
double t_1 = 1.0 + (1.0 / eps_m);
double tmp;
if (x <= -480000000.0) {
tmp = ((t_1 * ((((-1.0 * x) * (-1.0 * x)) - 1.0) / ((-1.0 * x) - 1.0))) - t_0) / 2.0;
} else if (x <= 2.4e-191) {
tmp = 1.0;
} else if (x <= 5e+85) {
tmp = (fma(-x, ((1.0 - (eps_m * eps_m)) / (eps_m + 1.0)), 1.0) - -1.0) * 0.5;
} else if (x <= 3e+193) {
tmp = ((t_1 * 1.0) - t_0) / 2.0;
} else {
tmp = ((x * eps_m) - -1.0) * 0.5;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(Float64(Float64(1.0 / eps_m) - 1.0) * 1.0) t_1 = Float64(1.0 + Float64(1.0 / eps_m)) tmp = 0.0 if (x <= -480000000.0) tmp = Float64(Float64(Float64(t_1 * Float64(Float64(Float64(Float64(-1.0 * x) * Float64(-1.0 * x)) - 1.0) / Float64(Float64(-1.0 * x) - 1.0))) - t_0) / 2.0); elseif (x <= 2.4e-191) tmp = 1.0; elseif (x <= 5e+85) tmp = Float64(Float64(fma(Float64(-x), Float64(Float64(1.0 - Float64(eps_m * eps_m)) / Float64(eps_m + 1.0)), 1.0) - -1.0) * 0.5); elseif (x <= 3e+193) tmp = Float64(Float64(Float64(t_1 * 1.0) - t_0) / 2.0); else tmp = Float64(Float64(Float64(x * eps_m) - -1.0) * 0.5); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision] * 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -480000000.0], N[(N[(N[(t$95$1 * N[(N[(N[(N[(-1.0 * x), $MachinePrecision] * N[(-1.0 * x), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision] / N[(N[(-1.0 * x), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 2.4e-191], 1.0, If[LessEqual[x, 5e+85], N[(N[(N[((-x) * N[(N[(1.0 - N[(eps$95$m * eps$95$m), $MachinePrecision]), $MachinePrecision] / N[(eps$95$m + 1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 3e+193], N[(N[(N[(t$95$1 * 1.0), $MachinePrecision] - t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(x * eps$95$m), $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision]]]]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := \left(\frac{1}{eps\_m} - 1\right) \cdot 1\\
t_1 := 1 + \frac{1}{eps\_m}\\
\mathbf{if}\;x \leq -480000000:\\
\;\;\;\;\frac{t\_1 \cdot \frac{\left(-1 \cdot x\right) \cdot \left(-1 \cdot x\right) - 1}{-1 \cdot x - 1} - t\_0}{2}\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{-191}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 5 \cdot 10^{+85}:\\
\;\;\;\;\left(\mathsf{fma}\left(-x, \frac{1 - eps\_m \cdot eps\_m}{eps\_m + 1}, 1\right) - -1\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 3 \cdot 10^{+193}:\\
\;\;\;\;\frac{t\_1 \cdot 1 - t\_0}{2}\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot eps\_m - -1\right) \cdot 0.5\\
\end{array}
\end{array}
if x < -4.8e8Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites3.1%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f640.1
Applied rewrites0.1%
Taylor expanded in eps around 0
Applied rewrites5.4%
lift-fma.f64N/A
flip-+N/A
lower-/.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6451.7
Applied rewrites51.7%
if -4.8e8 < x < 2.3999999999999999e-191Initial program 54.0%
Taylor expanded in x around 0
Applied rewrites78.7%
if 2.3999999999999999e-191 < x < 5.0000000000000001e85Initial program 65.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.0%
Taylor expanded in x around 0
Applied rewrites83.5%
Taylor expanded in x around 0
distribute-lft-neg-inN/A
rec-expN/A
mul-1-negN/A
distribute-lft-neg-inN/A
+-commutativeN/A
lower-fma.f64N/A
lift-neg.f64N/A
lift--.f6448.9
Applied rewrites48.9%
lift--.f64N/A
flip--N/A
lower-/.f64N/A
metadata-evalN/A
unpow2N/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6469.0
Applied rewrites69.0%
if 5.0000000000000001e85 < x < 3e193Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites51.4%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6424.4
Applied rewrites24.4%
Taylor expanded in x around 0
Applied rewrites49.3%
if 3e193 < 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 rewrites53.2%
Taylor expanded in x around 0
distribute-lft-neg-inN/A
rec-expN/A
mul-1-negN/A
distribute-lft-neg-inN/A
+-commutativeN/A
lower-fma.f64N/A
lift-neg.f64N/A
lift--.f6444.1
Applied rewrites44.1%
Taylor expanded in eps around inf
*-commutativeN/A
lift-*.f6444.5
Applied rewrites44.5%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 2.4e-191)
1.0
(if (<= x 5e+85)
(* (- (fma (- x) (/ (- 1.0 (* eps_m eps_m)) (+ eps_m 1.0)) 1.0) -1.0) 0.5)
(if (<= x 3e+193)
(/ (- (* (+ 1.0 (/ 1.0 eps_m)) 1.0) (* (- (/ 1.0 eps_m) 1.0) 1.0)) 2.0)
(* (- (* x eps_m) -1.0) 0.5)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 2.4e-191) {
tmp = 1.0;
} else if (x <= 5e+85) {
tmp = (fma(-x, ((1.0 - (eps_m * eps_m)) / (eps_m + 1.0)), 1.0) - -1.0) * 0.5;
} else if (x <= 3e+193) {
tmp = (((1.0 + (1.0 / eps_m)) * 1.0) - (((1.0 / eps_m) - 1.0) * 1.0)) / 2.0;
} else {
tmp = ((x * eps_m) - -1.0) * 0.5;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 2.4e-191) tmp = 1.0; elseif (x <= 5e+85) tmp = Float64(Float64(fma(Float64(-x), Float64(Float64(1.0 - Float64(eps_m * eps_m)) / Float64(eps_m + 1.0)), 1.0) - -1.0) * 0.5); elseif (x <= 3e+193) tmp = Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) * 1.0) - Float64(Float64(Float64(1.0 / eps_m) - 1.0) * 1.0)) / 2.0); else tmp = Float64(Float64(Float64(x * eps_m) - -1.0) * 0.5); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 2.4e-191], 1.0, If[LessEqual[x, 5e+85], N[(N[(N[((-x) * N[(N[(1.0 - N[(eps$95$m * eps$95$m), $MachinePrecision]), $MachinePrecision] / N[(eps$95$m + 1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 3e+193], N[(N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] - N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(x * eps$95$m), $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.4 \cdot 10^{-191}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 5 \cdot 10^{+85}:\\
\;\;\;\;\left(\mathsf{fma}\left(-x, \frac{1 - eps\_m \cdot eps\_m}{eps\_m + 1}, 1\right) - -1\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 3 \cdot 10^{+193}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) \cdot 1 - \left(\frac{1}{eps\_m} - 1\right) \cdot 1}{2}\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot eps\_m - -1\right) \cdot 0.5\\
\end{array}
\end{array}
if x < 2.3999999999999999e-191Initial program 65.8%
Taylor expanded in x around 0
Applied rewrites59.5%
if 2.3999999999999999e-191 < x < 5.0000000000000001e85Initial program 65.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.0%
Taylor expanded in x around 0
Applied rewrites83.5%
Taylor expanded in x around 0
distribute-lft-neg-inN/A
rec-expN/A
mul-1-negN/A
distribute-lft-neg-inN/A
+-commutativeN/A
lower-fma.f64N/A
lift-neg.f64N/A
lift--.f6448.9
Applied rewrites48.9%
lift--.f64N/A
flip--N/A
lower-/.f64N/A
metadata-evalN/A
unpow2N/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6469.0
Applied rewrites69.0%
if 5.0000000000000001e85 < x < 3e193Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites51.4%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6424.4
Applied rewrites24.4%
Taylor expanded in x around 0
Applied rewrites49.3%
if 3e193 < 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 rewrites53.2%
Taylor expanded in x around 0
distribute-lft-neg-inN/A
rec-expN/A
mul-1-negN/A
distribute-lft-neg-inN/A
+-commutativeN/A
lower-fma.f64N/A
lift-neg.f64N/A
lift--.f6444.1
Applied rewrites44.1%
Taylor expanded in eps around inf
*-commutativeN/A
lift-*.f6444.5
Applied rewrites44.5%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 0.62) 1.0 (* (- (* x eps_m) -1.0) 0.5)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 0.62) {
tmp = 1.0;
} else {
tmp = ((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 (x <= 0.62d0) then
tmp = 1.0d0
else
tmp = ((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 (x <= 0.62) {
tmp = 1.0;
} else {
tmp = ((x * eps_m) - -1.0) * 0.5;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 0.62: tmp = 1.0 else: tmp = ((x * eps_m) - -1.0) * 0.5 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 0.62) tmp = 1.0; else tmp = Float64(Float64(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 (x <= 0.62) tmp = 1.0; else tmp = ((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[x, 0.62], 1.0, N[(N[(N[(x * eps$95$m), $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.62:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot eps\_m - -1\right) \cdot 0.5\\
\end{array}
\end{array}
if x < 0.619999999999999996Initial program 62.4%
Taylor expanded in x around 0
Applied rewrites61.2%
if 0.619999999999999996 < x Initial program 99.1%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.2%
Taylor expanded in x around 0
Applied rewrites52.1%
Taylor expanded in x around 0
distribute-lft-neg-inN/A
rec-expN/A
mul-1-negN/A
distribute-lft-neg-inN/A
+-commutativeN/A
lower-fma.f64N/A
lift-neg.f64N/A
lift--.f6428.4
Applied rewrites28.4%
Taylor expanded in eps around inf
*-commutativeN/A
lift-*.f6428.8
Applied rewrites28.8%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 1.0)
eps_m = fabs(eps);
double code(double x, double eps_m) {
return 1.0;
}
eps_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, eps_m)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
code = 1.0d0
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
return 1.0;
}
eps_m = math.fabs(eps) def code(x, eps_m): return 1.0
eps_m = abs(eps) function code(x, eps_m) return 1.0 end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = 1.0; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := 1.0
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
1
\end{array}
Initial program 73.0%
Taylor expanded in x around 0
Applied rewrites44.6%
herbie shell --seed 2025095
(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))