
(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 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))
double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0
end function
public static double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-((1.0 + eps) * x)))) / 2.0;
}
def code(x, eps): return (((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-((1.0 + eps) * x)))) / 2.0
function code(x, eps) return Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(-Float64(Float64(1.0 - eps) * x)))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * exp(Float64(-Float64(Float64(1.0 + eps) * x))))) / 2.0) end
function tmp = code(x, eps) tmp = (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0; end
code[x_, eps_] := N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}
\end{array}
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= eps_m 0.029)
(* (+ t_0 t_0) 0.5)
(* (- (exp (* x eps_m)) (/ -1.0 (exp (fma x eps_m x)))) 0.5))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = exp(-x);
double tmp;
if (eps_m <= 0.029) {
tmp = (t_0 + t_0) * 0.5;
} else {
tmp = (exp((x * eps_m)) - (-1.0 / exp(fma(x, eps_m, x)))) * 0.5;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) t_0 = exp(Float64(-x)) tmp = 0.0 if (eps_m <= 0.029) tmp = Float64(Float64(t_0 + t_0) * 0.5); else tmp = Float64(Float64(exp(Float64(x * eps_m)) - Float64(-1.0 / exp(fma(x, eps_m, x)))) * 0.5); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[eps$95$m, 0.029], N[(N[(t$95$0 + t$95$0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] - N[(-1.0 / N[Exp[N[(x * eps$95$m + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;eps\_m \leq 0.029:\\
\;\;\;\;\left(t\_0 + t\_0\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(e^{x \cdot eps\_m} - \frac{-1}{e^{\mathsf{fma}\left(x, eps\_m, x\right)}}\right) \cdot 0.5\\
\end{array}
\end{array}
if eps < 0.0290000000000000015Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
mult-flip-revN/A
lower-/.f64N/A
lower-exp.f6499.0
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6499.0
Applied rewrites99.0%
Taylor expanded in eps around 0
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lower-exp.f6470.5
Applied rewrites70.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.5
lift-/.f64N/A
lift-exp.f64N/A
rec-expN/A
lift-neg.f64N/A
lift-exp.f6470.5
Applied rewrites70.5%
if 0.0290000000000000015 < eps Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
mult-flip-revN/A
lower-/.f64N/A
lower-exp.f6499.0
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6499.0
Applied rewrites99.0%
Taylor expanded in eps around inf
lower-*.f6485.6
Applied rewrites85.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6485.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6485.6
Applied rewrites85.6%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (* 0.5 (- (exp (- (* x (- 1.0 eps_m)))) (/ -1.0 (exp (fma x eps_m x))))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return 0.5 * (exp(-(x * (1.0 - eps_m))) - (-1.0 / exp(fma(x, eps_m, x))));
}
eps_m = abs(eps) function code(x, eps_m) return Float64(0.5 * Float64(exp(Float64(-Float64(x * Float64(1.0 - eps_m)))) - Float64(-1.0 / exp(fma(x, eps_m, x))))) end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(0.5 * N[(N[Exp[(-N[(x * N[(1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision])], $MachinePrecision] - N[(-1.0 / N[Exp[N[(x * eps$95$m + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
0.5 \cdot \left(e^{-x \cdot \left(1 - eps\_m\right)} - \frac{-1}{e^{\mathsf{fma}\left(x, eps\_m, x\right)}}\right)
\end{array}
Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
mult-flip-revN/A
lower-/.f64N/A
lower-exp.f6499.0
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6499.0
Applied rewrites99.0%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (* (+ (exp (- (fma x eps_m x))) (exp (* (- eps_m 1.0) x))) 0.5))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return (exp(-fma(x, eps_m, x)) + exp(((eps_m - 1.0) * x))) * 0.5;
}
eps_m = abs(eps) function code(x, eps_m) return Float64(Float64(exp(Float64(-fma(x, eps_m, x))) + exp(Float64(Float64(eps_m - 1.0) * x))) * 0.5) end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(N[(N[Exp[(-N[(x * eps$95$m + x), $MachinePrecision])], $MachinePrecision] + N[Exp[N[(N[(eps$95$m - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\left(e^{-\mathsf{fma}\left(x, eps\_m, x\right)} + e^{\left(eps\_m - 1\right) \cdot x}\right) \cdot 0.5
\end{array}
Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.0
Applied rewrites99.0%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (/ -1.0 (+ 1.0 (* x (+ 1.0 eps_m))))) (t_1 (exp (- x))))
(if (<= x -27.0)
(* 0.5 (- t_1 -1.0))
(if (<= x -2e-306)
(* 0.5 (- (+ 1.0 (* x (- eps_m 1.0))) (/ -1.0 (exp (fma x eps_m x)))))
(if (<= x 2.5e+48)
(* 0.5 (- (exp (* eps_m x)) t_0))
(if (<= x 8e+235)
(* (+ t_1 t_1) 0.5)
(* 0.5 (- (exp (- (* x (- 1.0 eps_m)))) t_0))))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = -1.0 / (1.0 + (x * (1.0 + eps_m)));
double t_1 = exp(-x);
double tmp;
if (x <= -27.0) {
tmp = 0.5 * (t_1 - -1.0);
} else if (x <= -2e-306) {
tmp = 0.5 * ((1.0 + (x * (eps_m - 1.0))) - (-1.0 / exp(fma(x, eps_m, x))));
} else if (x <= 2.5e+48) {
tmp = 0.5 * (exp((eps_m * x)) - t_0);
} else if (x <= 8e+235) {
tmp = (t_1 + t_1) * 0.5;
} else {
tmp = 0.5 * (exp(-(x * (1.0 - eps_m))) - t_0);
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(-1.0 / Float64(1.0 + Float64(x * Float64(1.0 + eps_m)))) t_1 = exp(Float64(-x)) tmp = 0.0 if (x <= -27.0) tmp = Float64(0.5 * Float64(t_1 - -1.0)); elseif (x <= -2e-306) tmp = Float64(0.5 * Float64(Float64(1.0 + Float64(x * Float64(eps_m - 1.0))) - Float64(-1.0 / exp(fma(x, eps_m, x))))); elseif (x <= 2.5e+48) tmp = Float64(0.5 * Float64(exp(Float64(eps_m * x)) - t_0)); elseif (x <= 8e+235) tmp = Float64(Float64(t_1 + t_1) * 0.5); else tmp = Float64(0.5 * Float64(exp(Float64(-Float64(x * Float64(1.0 - eps_m)))) - t_0)); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[(-1.0 / N[(1.0 + N[(x * N[(1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[x, -27.0], N[(0.5 * N[(t$95$1 - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2e-306], N[(0.5 * N[(N[(1.0 + N[(x * N[(eps$95$m - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(-1.0 / N[Exp[N[(x * eps$95$m + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.5e+48], N[(0.5 * N[(N[Exp[N[(eps$95$m * x), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8e+235], N[(N[(t$95$1 + t$95$1), $MachinePrecision] * 0.5), $MachinePrecision], N[(0.5 * N[(N[Exp[(-N[(x * N[(1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision])], $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := \frac{-1}{1 + x \cdot \left(1 + eps\_m\right)}\\
t_1 := e^{-x}\\
\mathbf{if}\;x \leq -27:\\
\;\;\;\;0.5 \cdot \left(t\_1 - -1\right)\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-306}:\\
\;\;\;\;0.5 \cdot \left(\left(1 + x \cdot \left(eps\_m - 1\right)\right) - \frac{-1}{e^{\mathsf{fma}\left(x, eps\_m, x\right)}}\right)\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{+48}:\\
\;\;\;\;0.5 \cdot \left(e^{eps\_m \cdot x} - t\_0\right)\\
\mathbf{elif}\;x \leq 8 \cdot 10^{+235}:\\
\;\;\;\;\left(t\_1 + t\_1\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{-x \cdot \left(1 - eps\_m\right)} - t\_0\right)\\
\end{array}
\end{array}
if x < -27Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
Taylor expanded in x around 0
Applied rewrites64.3%
Taylor expanded in eps around 0
lower-exp.f64N/A
lower-neg.f6457.3
Applied rewrites57.3%
if -27 < x < -2.00000000000000006e-306Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
mult-flip-revN/A
lower-/.f64N/A
lower-exp.f6499.0
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6499.0
Applied rewrites99.0%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6464.3
Applied rewrites64.3%
if -2.00000000000000006e-306 < x < 2.49999999999999987e48Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
mult-flip-revN/A
lower-/.f64N/A
lower-exp.f6499.0
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6499.0
Applied rewrites99.0%
Taylor expanded in eps around inf
lower-*.f6485.6
Applied rewrites85.6%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f6464.1
Applied rewrites64.1%
if 2.49999999999999987e48 < x < 8.0000000000000004e235Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
mult-flip-revN/A
lower-/.f64N/A
lower-exp.f6499.0
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6499.0
Applied rewrites99.0%
Taylor expanded in eps around 0
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lower-exp.f6470.5
Applied rewrites70.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.5
lift-/.f64N/A
lift-exp.f64N/A
rec-expN/A
lift-neg.f64N/A
lift-exp.f6470.5
Applied rewrites70.5%
if 8.0000000000000004e235 < x Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
mult-flip-revN/A
lower-/.f64N/A
lower-exp.f6499.0
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6499.0
Applied rewrites99.0%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f6464.5
Applied rewrites64.5%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= x -27.0)
(* 0.5 (- t_0 -1.0))
(if (<= x -2e-306)
(* 0.5 (- (+ 1.0 (* x (- eps_m 1.0))) (/ -1.0 (exp (fma x eps_m x)))))
(if (<= x 2.5e+48)
(* 0.5 (- (exp (* eps_m x)) (/ -1.0 (+ 1.0 (* x (+ 1.0 eps_m))))))
(if (<= x 8e+235)
(* (+ t_0 t_0) 0.5)
(* 0.5 (- (exp (- (* x (- 1.0 eps_m)))) -1.0))))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = exp(-x);
double tmp;
if (x <= -27.0) {
tmp = 0.5 * (t_0 - -1.0);
} else if (x <= -2e-306) {
tmp = 0.5 * ((1.0 + (x * (eps_m - 1.0))) - (-1.0 / exp(fma(x, eps_m, x))));
} else if (x <= 2.5e+48) {
tmp = 0.5 * (exp((eps_m * x)) - (-1.0 / (1.0 + (x * (1.0 + eps_m)))));
} else if (x <= 8e+235) {
tmp = (t_0 + t_0) * 0.5;
} else {
tmp = 0.5 * (exp(-(x * (1.0 - eps_m))) - -1.0);
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) t_0 = exp(Float64(-x)) tmp = 0.0 if (x <= -27.0) tmp = Float64(0.5 * Float64(t_0 - -1.0)); elseif (x <= -2e-306) tmp = Float64(0.5 * Float64(Float64(1.0 + Float64(x * Float64(eps_m - 1.0))) - Float64(-1.0 / exp(fma(x, eps_m, x))))); elseif (x <= 2.5e+48) tmp = Float64(0.5 * Float64(exp(Float64(eps_m * x)) - Float64(-1.0 / Float64(1.0 + Float64(x * Float64(1.0 + eps_m)))))); elseif (x <= 8e+235) tmp = Float64(Float64(t_0 + t_0) * 0.5); else tmp = Float64(0.5 * Float64(exp(Float64(-Float64(x * Float64(1.0 - eps_m)))) - -1.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, -27.0], N[(0.5 * N[(t$95$0 - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2e-306], N[(0.5 * N[(N[(1.0 + N[(x * N[(eps$95$m - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(-1.0 / N[Exp[N[(x * eps$95$m + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.5e+48], N[(0.5 * N[(N[Exp[N[(eps$95$m * x), $MachinePrecision]], $MachinePrecision] - N[(-1.0 / N[(1.0 + N[(x * N[(1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8e+235], N[(N[(t$95$0 + t$95$0), $MachinePrecision] * 0.5), $MachinePrecision], N[(0.5 * N[(N[Exp[(-N[(x * N[(1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision])], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;x \leq -27:\\
\;\;\;\;0.5 \cdot \left(t\_0 - -1\right)\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-306}:\\
\;\;\;\;0.5 \cdot \left(\left(1 + x \cdot \left(eps\_m - 1\right)\right) - \frac{-1}{e^{\mathsf{fma}\left(x, eps\_m, x\right)}}\right)\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{+48}:\\
\;\;\;\;0.5 \cdot \left(e^{eps\_m \cdot x} - \frac{-1}{1 + x \cdot \left(1 + eps\_m\right)}\right)\\
\mathbf{elif}\;x \leq 8 \cdot 10^{+235}:\\
\;\;\;\;\left(t\_0 + t\_0\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{-x \cdot \left(1 - eps\_m\right)} - -1\right)\\
\end{array}
\end{array}
if x < -27Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
Taylor expanded in x around 0
Applied rewrites64.3%
Taylor expanded in eps around 0
lower-exp.f64N/A
lower-neg.f6457.3
Applied rewrites57.3%
if -27 < x < -2.00000000000000006e-306Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
mult-flip-revN/A
lower-/.f64N/A
lower-exp.f6499.0
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6499.0
Applied rewrites99.0%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6464.3
Applied rewrites64.3%
if -2.00000000000000006e-306 < x < 2.49999999999999987e48Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
mult-flip-revN/A
lower-/.f64N/A
lower-exp.f6499.0
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6499.0
Applied rewrites99.0%
Taylor expanded in eps around inf
lower-*.f6485.6
Applied rewrites85.6%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f6464.1
Applied rewrites64.1%
if 2.49999999999999987e48 < x < 8.0000000000000004e235Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
mult-flip-revN/A
lower-/.f64N/A
lower-exp.f6499.0
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6499.0
Applied rewrites99.0%
Taylor expanded in eps around 0
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lower-exp.f6470.5
Applied rewrites70.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.5
lift-/.f64N/A
lift-exp.f64N/A
rec-expN/A
lift-neg.f64N/A
lift-exp.f6470.5
Applied rewrites70.5%
if 8.0000000000000004e235 < x Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
Taylor expanded in x around 0
Applied rewrites64.3%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= x -430.0)
(* 0.5 (- t_0 -1.0))
(if (<= x 1.7e+48)
(* 0.5 (- (exp (* eps_m x)) (- (* x (+ 1.0 eps_m)) 1.0)))
(if (<= x 8e+235)
(* (+ t_0 t_0) 0.5)
(* 0.5 (- (exp (- (* x (- 1.0 eps_m)))) -1.0)))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = exp(-x);
double tmp;
if (x <= -430.0) {
tmp = 0.5 * (t_0 - -1.0);
} else if (x <= 1.7e+48) {
tmp = 0.5 * (exp((eps_m * x)) - ((x * (1.0 + eps_m)) - 1.0));
} else if (x <= 8e+235) {
tmp = (t_0 + t_0) * 0.5;
} else {
tmp = 0.5 * (exp(-(x * (1.0 - eps_m))) - -1.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)
if (x <= (-430.0d0)) then
tmp = 0.5d0 * (t_0 - (-1.0d0))
else if (x <= 1.7d+48) then
tmp = 0.5d0 * (exp((eps_m * x)) - ((x * (1.0d0 + eps_m)) - 1.0d0))
else if (x <= 8d+235) then
tmp = (t_0 + t_0) * 0.5d0
else
tmp = 0.5d0 * (exp(-(x * (1.0d0 - eps_m))) - (-1.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);
double tmp;
if (x <= -430.0) {
tmp = 0.5 * (t_0 - -1.0);
} else if (x <= 1.7e+48) {
tmp = 0.5 * (Math.exp((eps_m * x)) - ((x * (1.0 + eps_m)) - 1.0));
} else if (x <= 8e+235) {
tmp = (t_0 + t_0) * 0.5;
} else {
tmp = 0.5 * (Math.exp(-(x * (1.0 - eps_m))) - -1.0);
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = math.exp(-x) tmp = 0 if x <= -430.0: tmp = 0.5 * (t_0 - -1.0) elif x <= 1.7e+48: tmp = 0.5 * (math.exp((eps_m * x)) - ((x * (1.0 + eps_m)) - 1.0)) elif x <= 8e+235: tmp = (t_0 + t_0) * 0.5 else: tmp = 0.5 * (math.exp(-(x * (1.0 - eps_m))) - -1.0) return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = exp(Float64(-x)) tmp = 0.0 if (x <= -430.0) tmp = Float64(0.5 * Float64(t_0 - -1.0)); elseif (x <= 1.7e+48) tmp = Float64(0.5 * Float64(exp(Float64(eps_m * x)) - Float64(Float64(x * Float64(1.0 + eps_m)) - 1.0))); elseif (x <= 8e+235) tmp = Float64(Float64(t_0 + t_0) * 0.5); else tmp = Float64(0.5 * Float64(exp(Float64(-Float64(x * Float64(1.0 - eps_m)))) - -1.0)); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = exp(-x); tmp = 0.0; if (x <= -430.0) tmp = 0.5 * (t_0 - -1.0); elseif (x <= 1.7e+48) tmp = 0.5 * (exp((eps_m * x)) - ((x * (1.0 + eps_m)) - 1.0)); elseif (x <= 8e+235) tmp = (t_0 + t_0) * 0.5; else tmp = 0.5 * (exp(-(x * (1.0 - eps_m))) - -1.0); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[x, -430.0], N[(0.5 * N[(t$95$0 - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.7e+48], N[(0.5 * N[(N[Exp[N[(eps$95$m * x), $MachinePrecision]], $MachinePrecision] - N[(N[(x * N[(1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8e+235], N[(N[(t$95$0 + t$95$0), $MachinePrecision] * 0.5), $MachinePrecision], N[(0.5 * N[(N[Exp[(-N[(x * N[(1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision])], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;x \leq -430:\\
\;\;\;\;0.5 \cdot \left(t\_0 - -1\right)\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{+48}:\\
\;\;\;\;0.5 \cdot \left(e^{eps\_m \cdot x} - \left(x \cdot \left(1 + eps\_m\right) - 1\right)\right)\\
\mathbf{elif}\;x \leq 8 \cdot 10^{+235}:\\
\;\;\;\;\left(t\_0 + t\_0\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{-x \cdot \left(1 - eps\_m\right)} - -1\right)\\
\end{array}
\end{array}
if x < -430Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
Taylor expanded in x around 0
Applied rewrites64.3%
Taylor expanded in eps around 0
lower-exp.f64N/A
lower-neg.f6457.3
Applied rewrites57.3%
if -430 < x < 1.7000000000000002e48Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-*.f64N/A
lower-+.f6464.5
Applied rewrites64.5%
Taylor expanded in eps around inf
lower-*.f6464.5
Applied rewrites64.5%
if 1.7000000000000002e48 < x < 8.0000000000000004e235Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
mult-flip-revN/A
lower-/.f64N/A
lower-exp.f6499.0
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6499.0
Applied rewrites99.0%
Taylor expanded in eps around 0
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lower-exp.f6470.5
Applied rewrites70.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.5
lift-/.f64N/A
lift-exp.f64N/A
rec-expN/A
lift-neg.f64N/A
lift-exp.f6470.5
Applied rewrites70.5%
if 8.0000000000000004e235 < x Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
Taylor expanded in x around 0
Applied rewrites64.3%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -430.0)
(* 0.5 (- (exp (- x)) -1.0))
(if (<= x 120000000000.0)
(* 0.5 (- (exp (* eps_m x)) (- (* x (+ 1.0 eps_m)) 1.0)))
(if (<= x 8e+235)
(/ (- (+ 1.0 (/ 1.0 eps_m)) (- (/ 1.0 eps_m) 1.0)) 2.0)
(* 0.5 (- (exp (- (* x (- 1.0 eps_m)))) -1.0))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -430.0) {
tmp = 0.5 * (exp(-x) - -1.0);
} else if (x <= 120000000000.0) {
tmp = 0.5 * (exp((eps_m * x)) - ((x * (1.0 + eps_m)) - 1.0));
} else if (x <= 8e+235) {
tmp = ((1.0 + (1.0 / eps_m)) - ((1.0 / eps_m) - 1.0)) / 2.0;
} else {
tmp = 0.5 * (exp(-(x * (1.0 - eps_m))) - -1.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 <= (-430.0d0)) then
tmp = 0.5d0 * (exp(-x) - (-1.0d0))
else if (x <= 120000000000.0d0) then
tmp = 0.5d0 * (exp((eps_m * x)) - ((x * (1.0d0 + eps_m)) - 1.0d0))
else if (x <= 8d+235) then
tmp = ((1.0d0 + (1.0d0 / eps_m)) - ((1.0d0 / eps_m) - 1.0d0)) / 2.0d0
else
tmp = 0.5d0 * (exp(-(x * (1.0d0 - eps_m))) - (-1.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 <= -430.0) {
tmp = 0.5 * (Math.exp(-x) - -1.0);
} else if (x <= 120000000000.0) {
tmp = 0.5 * (Math.exp((eps_m * x)) - ((x * (1.0 + eps_m)) - 1.0));
} else if (x <= 8e+235) {
tmp = ((1.0 + (1.0 / eps_m)) - ((1.0 / eps_m) - 1.0)) / 2.0;
} else {
tmp = 0.5 * (Math.exp(-(x * (1.0 - eps_m))) - -1.0);
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -430.0: tmp = 0.5 * (math.exp(-x) - -1.0) elif x <= 120000000000.0: tmp = 0.5 * (math.exp((eps_m * x)) - ((x * (1.0 + eps_m)) - 1.0)) elif x <= 8e+235: tmp = ((1.0 + (1.0 / eps_m)) - ((1.0 / eps_m) - 1.0)) / 2.0 else: tmp = 0.5 * (math.exp(-(x * (1.0 - eps_m))) - -1.0) return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -430.0) tmp = Float64(0.5 * Float64(exp(Float64(-x)) - -1.0)); elseif (x <= 120000000000.0) tmp = Float64(0.5 * Float64(exp(Float64(eps_m * x)) - Float64(Float64(x * Float64(1.0 + eps_m)) - 1.0))); elseif (x <= 8e+235) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) - Float64(Float64(1.0 / eps_m) - 1.0)) / 2.0); else tmp = Float64(0.5 * Float64(exp(Float64(-Float64(x * Float64(1.0 - eps_m)))) - -1.0)); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -430.0) tmp = 0.5 * (exp(-x) - -1.0); elseif (x <= 120000000000.0) tmp = 0.5 * (exp((eps_m * x)) - ((x * (1.0 + eps_m)) - 1.0)); elseif (x <= 8e+235) tmp = ((1.0 + (1.0 / eps_m)) - ((1.0 / eps_m) - 1.0)) / 2.0; else tmp = 0.5 * (exp(-(x * (1.0 - eps_m))) - -1.0); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -430.0], N[(0.5 * N[(N[Exp[(-x)], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 120000000000.0], N[(0.5 * N[(N[Exp[N[(eps$95$m * x), $MachinePrecision]], $MachinePrecision] - N[(N[(x * N[(1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8e+235], N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] - N[(N[(1.0 / eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(0.5 * N[(N[Exp[(-N[(x * N[(1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision])], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -430:\\
\;\;\;\;0.5 \cdot \left(e^{-x} - -1\right)\\
\mathbf{elif}\;x \leq 120000000000:\\
\;\;\;\;0.5 \cdot \left(e^{eps\_m \cdot x} - \left(x \cdot \left(1 + eps\_m\right) - 1\right)\right)\\
\mathbf{elif}\;x \leq 8 \cdot 10^{+235}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) - \left(\frac{1}{eps\_m} - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{-x \cdot \left(1 - eps\_m\right)} - -1\right)\\
\end{array}
\end{array}
if x < -430Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
Taylor expanded in x around 0
Applied rewrites64.3%
Taylor expanded in eps around 0
lower-exp.f64N/A
lower-neg.f6457.3
Applied rewrites57.3%
if -430 < x < 1.2e11Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-*.f64N/A
lower-+.f6464.5
Applied rewrites64.5%
Taylor expanded in eps around inf
lower-*.f6464.5
Applied rewrites64.5%
if 1.2e11 < x < 8.0000000000000004e235Initial program 74.1%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6439.2
Applied rewrites39.2%
Taylor expanded in x around 0
lower-+.f64N/A
lower-/.f6431.2
Applied rewrites31.2%
if 8.0000000000000004e235 < x Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
Taylor expanded in x around 0
Applied rewrites64.3%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 2e-305)
(* 0.5 (- (exp (- x)) -1.0))
(if (<= x 2.5e+48)
(* (- (exp (* x eps_m)) -1.0) 0.5)
(if (<= x 8e+235)
(/ (- (+ 1.0 (/ 1.0 eps_m)) (- (/ 1.0 eps_m) 1.0)) 2.0)
(* 0.5 (- (exp (- (* x (- 1.0 eps_m)))) -1.0))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 2e-305) {
tmp = 0.5 * (exp(-x) - -1.0);
} else if (x <= 2.5e+48) {
tmp = (exp((x * eps_m)) - -1.0) * 0.5;
} else if (x <= 8e+235) {
tmp = ((1.0 + (1.0 / eps_m)) - ((1.0 / eps_m) - 1.0)) / 2.0;
} else {
tmp = 0.5 * (exp(-(x * (1.0 - eps_m))) - -1.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 <= 2d-305) then
tmp = 0.5d0 * (exp(-x) - (-1.0d0))
else if (x <= 2.5d+48) then
tmp = (exp((x * eps_m)) - (-1.0d0)) * 0.5d0
else if (x <= 8d+235) then
tmp = ((1.0d0 + (1.0d0 / eps_m)) - ((1.0d0 / eps_m) - 1.0d0)) / 2.0d0
else
tmp = 0.5d0 * (exp(-(x * (1.0d0 - eps_m))) - (-1.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 <= 2e-305) {
tmp = 0.5 * (Math.exp(-x) - -1.0);
} else if (x <= 2.5e+48) {
tmp = (Math.exp((x * eps_m)) - -1.0) * 0.5;
} else if (x <= 8e+235) {
tmp = ((1.0 + (1.0 / eps_m)) - ((1.0 / eps_m) - 1.0)) / 2.0;
} else {
tmp = 0.5 * (Math.exp(-(x * (1.0 - eps_m))) - -1.0);
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 2e-305: tmp = 0.5 * (math.exp(-x) - -1.0) elif x <= 2.5e+48: tmp = (math.exp((x * eps_m)) - -1.0) * 0.5 elif x <= 8e+235: tmp = ((1.0 + (1.0 / eps_m)) - ((1.0 / eps_m) - 1.0)) / 2.0 else: tmp = 0.5 * (math.exp(-(x * (1.0 - eps_m))) - -1.0) return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 2e-305) tmp = Float64(0.5 * Float64(exp(Float64(-x)) - -1.0)); elseif (x <= 2.5e+48) tmp = Float64(Float64(exp(Float64(x * eps_m)) - -1.0) * 0.5); elseif (x <= 8e+235) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) - Float64(Float64(1.0 / eps_m) - 1.0)) / 2.0); else tmp = Float64(0.5 * Float64(exp(Float64(-Float64(x * Float64(1.0 - eps_m)))) - -1.0)); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 2e-305) tmp = 0.5 * (exp(-x) - -1.0); elseif (x <= 2.5e+48) tmp = (exp((x * eps_m)) - -1.0) * 0.5; elseif (x <= 8e+235) tmp = ((1.0 + (1.0 / eps_m)) - ((1.0 / eps_m) - 1.0)) / 2.0; else tmp = 0.5 * (exp(-(x * (1.0 - eps_m))) - -1.0); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 2e-305], N[(0.5 * N[(N[Exp[(-x)], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.5e+48], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 8e+235], N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] - N[(N[(1.0 / eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(0.5 * N[(N[Exp[(-N[(x * N[(1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision])], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2 \cdot 10^{-305}:\\
\;\;\;\;0.5 \cdot \left(e^{-x} - -1\right)\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{+48}:\\
\;\;\;\;\left(e^{x \cdot eps\_m} - -1\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 8 \cdot 10^{+235}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) - \left(\frac{1}{eps\_m} - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{-x \cdot \left(1 - eps\_m\right)} - -1\right)\\
\end{array}
\end{array}
if x < 1.99999999999999999e-305Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
Taylor expanded in x around 0
Applied rewrites64.3%
Taylor expanded in eps around 0
lower-exp.f64N/A
lower-neg.f6457.3
Applied rewrites57.3%
if 1.99999999999999999e-305 < x < 2.49999999999999987e48Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
Taylor expanded in x around 0
Applied rewrites64.3%
Taylor expanded in eps around inf
lower-*.f6464.5
Applied rewrites64.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6464.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6464.5
Applied rewrites64.5%
if 2.49999999999999987e48 < x < 8.0000000000000004e235Initial program 74.1%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6439.2
Applied rewrites39.2%
Taylor expanded in x around 0
lower-+.f64N/A
lower-/.f6431.2
Applied rewrites31.2%
if 8.0000000000000004e235 < x Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
Taylor expanded in x around 0
Applied rewrites64.3%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 2e-305)
(* 0.5 (- (exp (- x)) -1.0))
(if (<= x 2.5e+48)
(* (- (exp (* x eps_m)) -1.0) 0.5)
(if (<= x 8.5e+235)
(/ (- (+ 1.0 (/ 1.0 eps_m)) (- (/ 1.0 eps_m) 1.0)) 2.0)
(* 0.5 (+ 2.0 (* x (- x 2.0))))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 2e-305) {
tmp = 0.5 * (exp(-x) - -1.0);
} else if (x <= 2.5e+48) {
tmp = (exp((x * eps_m)) - -1.0) * 0.5;
} else if (x <= 8.5e+235) {
tmp = ((1.0 + (1.0 / eps_m)) - ((1.0 / eps_m) - 1.0)) / 2.0;
} else {
tmp = 0.5 * (2.0 + (x * (x - 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 <= 2d-305) then
tmp = 0.5d0 * (exp(-x) - (-1.0d0))
else if (x <= 2.5d+48) then
tmp = (exp((x * eps_m)) - (-1.0d0)) * 0.5d0
else if (x <= 8.5d+235) then
tmp = ((1.0d0 + (1.0d0 / eps_m)) - ((1.0d0 / eps_m) - 1.0d0)) / 2.0d0
else
tmp = 0.5d0 * (2.0d0 + (x * (x - 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 <= 2e-305) {
tmp = 0.5 * (Math.exp(-x) - -1.0);
} else if (x <= 2.5e+48) {
tmp = (Math.exp((x * eps_m)) - -1.0) * 0.5;
} else if (x <= 8.5e+235) {
tmp = ((1.0 + (1.0 / eps_m)) - ((1.0 / eps_m) - 1.0)) / 2.0;
} else {
tmp = 0.5 * (2.0 + (x * (x - 2.0)));
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 2e-305: tmp = 0.5 * (math.exp(-x) - -1.0) elif x <= 2.5e+48: tmp = (math.exp((x * eps_m)) - -1.0) * 0.5 elif x <= 8.5e+235: tmp = ((1.0 + (1.0 / eps_m)) - ((1.0 / eps_m) - 1.0)) / 2.0 else: tmp = 0.5 * (2.0 + (x * (x - 2.0))) return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 2e-305) tmp = Float64(0.5 * Float64(exp(Float64(-x)) - -1.0)); elseif (x <= 2.5e+48) tmp = Float64(Float64(exp(Float64(x * eps_m)) - -1.0) * 0.5); elseif (x <= 8.5e+235) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) - Float64(Float64(1.0 / eps_m) - 1.0)) / 2.0); else tmp = Float64(0.5 * Float64(2.0 + Float64(x * Float64(x - 2.0)))); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 2e-305) tmp = 0.5 * (exp(-x) - -1.0); elseif (x <= 2.5e+48) tmp = (exp((x * eps_m)) - -1.0) * 0.5; elseif (x <= 8.5e+235) tmp = ((1.0 + (1.0 / eps_m)) - ((1.0 / eps_m) - 1.0)) / 2.0; else tmp = 0.5 * (2.0 + (x * (x - 2.0))); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 2e-305], N[(0.5 * N[(N[Exp[(-x)], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.5e+48], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 8.5e+235], N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] - N[(N[(1.0 / eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(0.5 * N[(2.0 + N[(x * N[(x - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2 \cdot 10^{-305}:\\
\;\;\;\;0.5 \cdot \left(e^{-x} - -1\right)\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{+48}:\\
\;\;\;\;\left(e^{x \cdot eps\_m} - -1\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{+235}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) - \left(\frac{1}{eps\_m} - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(2 + x \cdot \left(x - 2\right)\right)\\
\end{array}
\end{array}
if x < 1.99999999999999999e-305Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
Taylor expanded in x around 0
Applied rewrites64.3%
Taylor expanded in eps around 0
lower-exp.f64N/A
lower-neg.f6457.3
Applied rewrites57.3%
if 1.99999999999999999e-305 < x < 2.49999999999999987e48Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
Taylor expanded in x around 0
Applied rewrites64.3%
Taylor expanded in eps around inf
lower-*.f6464.5
Applied rewrites64.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6464.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6464.5
Applied rewrites64.5%
if 2.49999999999999987e48 < x < 8.50000000000000017e235Initial program 74.1%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6439.2
Applied rewrites39.2%
Taylor expanded in x around 0
lower-+.f64N/A
lower-/.f6431.2
Applied rewrites31.2%
if 8.50000000000000017e235 < x Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
mult-flip-revN/A
lower-/.f64N/A
lower-exp.f6499.0
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6499.0
Applied rewrites99.0%
Taylor expanded in eps around 0
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lower-exp.f6470.5
Applied rewrites70.5%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6457.7
Applied rewrites57.7%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 1.6e-12)
(* 0.5 (- (exp (- x)) -1.0))
(if (<= x 8.5e+235)
(/ (- (+ 1.0 (/ 1.0 eps_m)) (- (/ 1.0 eps_m) 1.0)) 2.0)
(* 0.5 (+ 2.0 (* x (- x 2.0)))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 1.6e-12) {
tmp = 0.5 * (exp(-x) - -1.0);
} else if (x <= 8.5e+235) {
tmp = ((1.0 + (1.0 / eps_m)) - ((1.0 / eps_m) - 1.0)) / 2.0;
} else {
tmp = 0.5 * (2.0 + (x * (x - 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.6d-12) then
tmp = 0.5d0 * (exp(-x) - (-1.0d0))
else if (x <= 8.5d+235) then
tmp = ((1.0d0 + (1.0d0 / eps_m)) - ((1.0d0 / eps_m) - 1.0d0)) / 2.0d0
else
tmp = 0.5d0 * (2.0d0 + (x * (x - 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.6e-12) {
tmp = 0.5 * (Math.exp(-x) - -1.0);
} else if (x <= 8.5e+235) {
tmp = ((1.0 + (1.0 / eps_m)) - ((1.0 / eps_m) - 1.0)) / 2.0;
} else {
tmp = 0.5 * (2.0 + (x * (x - 2.0)));
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 1.6e-12: tmp = 0.5 * (math.exp(-x) - -1.0) elif x <= 8.5e+235: tmp = ((1.0 + (1.0 / eps_m)) - ((1.0 / eps_m) - 1.0)) / 2.0 else: tmp = 0.5 * (2.0 + (x * (x - 2.0))) return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 1.6e-12) tmp = Float64(0.5 * Float64(exp(Float64(-x)) - -1.0)); elseif (x <= 8.5e+235) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) - Float64(Float64(1.0 / eps_m) - 1.0)) / 2.0); else tmp = Float64(0.5 * Float64(2.0 + Float64(x * Float64(x - 2.0)))); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 1.6e-12) tmp = 0.5 * (exp(-x) - -1.0); elseif (x <= 8.5e+235) tmp = ((1.0 + (1.0 / eps_m)) - ((1.0 / eps_m) - 1.0)) / 2.0; else tmp = 0.5 * (2.0 + (x * (x - 2.0))); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 1.6e-12], N[(0.5 * N[(N[Exp[(-x)], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8.5e+235], N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] - N[(N[(1.0 / eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(0.5 * N[(2.0 + N[(x * N[(x - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.6 \cdot 10^{-12}:\\
\;\;\;\;0.5 \cdot \left(e^{-x} - -1\right)\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{+235}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) - \left(\frac{1}{eps\_m} - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(2 + x \cdot \left(x - 2\right)\right)\\
\end{array}
\end{array}
if x < 1.6e-12Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
Taylor expanded in x around 0
Applied rewrites64.3%
Taylor expanded in eps around 0
lower-exp.f64N/A
lower-neg.f6457.3
Applied rewrites57.3%
if 1.6e-12 < x < 8.50000000000000017e235Initial program 74.1%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6439.2
Applied rewrites39.2%
Taylor expanded in x around 0
lower-+.f64N/A
lower-/.f6431.2
Applied rewrites31.2%
if 8.50000000000000017e235 < x Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
mult-flip-revN/A
lower-/.f64N/A
lower-exp.f6499.0
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6499.0
Applied rewrites99.0%
Taylor expanded in eps around 0
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lower-exp.f6470.5
Applied rewrites70.5%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6457.7
Applied rewrites57.7%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 1.1e+124) (* 0.5 (- (exp (- x)) -1.0)) (* 0.5 (+ 2.0 (* x (- x 2.0))))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 1.1e+124) {
tmp = 0.5 * (exp(-x) - -1.0);
} else {
tmp = 0.5 * (2.0 + (x * (x - 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.1d+124) then
tmp = 0.5d0 * (exp(-x) - (-1.0d0))
else
tmp = 0.5d0 * (2.0d0 + (x * (x - 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.1e+124) {
tmp = 0.5 * (Math.exp(-x) - -1.0);
} else {
tmp = 0.5 * (2.0 + (x * (x - 2.0)));
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 1.1e+124: tmp = 0.5 * (math.exp(-x) - -1.0) else: tmp = 0.5 * (2.0 + (x * (x - 2.0))) return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 1.1e+124) tmp = Float64(0.5 * Float64(exp(Float64(-x)) - -1.0)); else tmp = Float64(0.5 * Float64(2.0 + Float64(x * Float64(x - 2.0)))); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 1.1e+124) tmp = 0.5 * (exp(-x) - -1.0); else tmp = 0.5 * (2.0 + (x * (x - 2.0))); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 1.1e+124], N[(0.5 * N[(N[Exp[(-x)], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(2.0 + N[(x * N[(x - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.1 \cdot 10^{+124}:\\
\;\;\;\;0.5 \cdot \left(e^{-x} - -1\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(2 + x \cdot \left(x - 2\right)\right)\\
\end{array}
\end{array}
if x < 1.1e124Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
Taylor expanded in x around 0
Applied rewrites64.3%
Taylor expanded in eps around 0
lower-exp.f64N/A
lower-neg.f6457.3
Applied rewrites57.3%
if 1.1e124 < x Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
mult-flip-revN/A
lower-/.f64N/A
lower-exp.f6499.0
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6499.0
Applied rewrites99.0%
Taylor expanded in eps around 0
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lower-exp.f6470.5
Applied rewrites70.5%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6457.7
Applied rewrites57.7%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (* 0.5 (+ 2.0 (* x (- x 2.0)))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return 0.5 * (2.0 + (x * (x - 2.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 = 0.5d0 * (2.0d0 + (x * (x - 2.0d0)))
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
return 0.5 * (2.0 + (x * (x - 2.0)));
}
eps_m = math.fabs(eps) def code(x, eps_m): return 0.5 * (2.0 + (x * (x - 2.0)))
eps_m = abs(eps) function code(x, eps_m) return Float64(0.5 * Float64(2.0 + Float64(x * Float64(x - 2.0)))) end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = 0.5 * (2.0 + (x * (x - 2.0))); end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(0.5 * N[(2.0 + N[(x * N[(x - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
0.5 \cdot \left(2 + x \cdot \left(x - 2\right)\right)
\end{array}
Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.0
Applied rewrites99.0%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
mult-flip-revN/A
lower-/.f64N/A
lower-exp.f6499.0
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6499.0
Applied rewrites99.0%
Taylor expanded in eps around 0
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lower-exp.f6470.5
Applied rewrites70.5%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6457.7
Applied rewrites57.7%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 1.0)
eps_m = fabs(eps);
double code(double x, double eps_m) {
return 1.0;
}
eps_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, eps_m)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
code = 1.0d0
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
return 1.0;
}
eps_m = math.fabs(eps) def code(x, eps_m): return 1.0
eps_m = abs(eps) function code(x, eps_m) return 1.0 end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = 1.0; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := 1.0
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
1
\end{array}
Initial program 74.1%
Taylor expanded in x around 0
Applied rewrites43.8%
herbie shell --seed 2025142
(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))