
(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 9 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 (if (<= eps_m 4e-80) (* (+ (exp (- x)) (exp (* -1.0 x))) 0.5) (* (+ (exp (- (* eps_m x) x)) (exp (* (- eps_m) x))) 0.5)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 4e-80) {
tmp = (exp(-x) + exp((-1.0 * x))) * 0.5;
} else {
tmp = (exp(((eps_m * x) - x)) + exp((-eps_m * x))) * 0.5;
}
return tmp;
}
eps_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, eps_m)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (eps_m <= 4d-80) then
tmp = (exp(-x) + exp(((-1.0d0) * x))) * 0.5d0
else
tmp = (exp(((eps_m * x) - x)) + exp((-eps_m * x))) * 0.5d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (eps_m <= 4e-80) {
tmp = (Math.exp(-x) + Math.exp((-1.0 * x))) * 0.5;
} else {
tmp = (Math.exp(((eps_m * x) - x)) + Math.exp((-eps_m * x))) * 0.5;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 4e-80: tmp = (math.exp(-x) + math.exp((-1.0 * x))) * 0.5 else: tmp = (math.exp(((eps_m * x) - x)) + math.exp((-eps_m * x))) * 0.5 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 4e-80) tmp = Float64(Float64(exp(Float64(-x)) + exp(Float64(-1.0 * x))) * 0.5); else tmp = Float64(Float64(exp(Float64(Float64(eps_m * x) - x)) + exp(Float64(Float64(-eps_m) * x))) * 0.5); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (eps_m <= 4e-80) tmp = (exp(-x) + exp((-1.0 * x))) * 0.5; else tmp = (exp(((eps_m * x) - x)) + exp((-eps_m * x))) * 0.5; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 4e-80], N[(N[(N[Exp[(-x)], $MachinePrecision] + N[Exp[N[(-1.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[Exp[N[(N[(eps$95$m * x), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision] + N[Exp[N[((-eps$95$m) * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 4 \cdot 10^{-80}:\\
\;\;\;\;\left(e^{-x} + e^{-1 \cdot x}\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(e^{eps\_m \cdot x - x} + e^{\left(-eps\_m\right) \cdot x}\right) \cdot 0.5\\
\end{array}
\end{array}
if eps < 3.99999999999999985e-80Initial program 73.2%
Taylor expanded in eps around inf
Applied rewrites98.9%
Applied rewrites98.9%
Taylor expanded in eps around 0
Applied rewrites71.6%
if 3.99999999999999985e-80 < eps Initial program 73.2%
Taylor expanded in eps around inf
Applied rewrites98.9%
Applied rewrites98.9%
Taylor expanded in eps around inf
Applied rewrites92.1%
Applied rewrites92.1%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (* (+ (exp (- (* eps_m x) x)) (exp (* (- -1.0 eps_m) x))) 0.5))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return (exp(((eps_m * x) - x)) + exp(((-1.0 - eps_m) * x))) * 0.5;
}
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 = (exp(((eps_m * x) - x)) + exp((((-1.0d0) - eps_m) * x))) * 0.5d0
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
return (Math.exp(((eps_m * x) - x)) + Math.exp(((-1.0 - eps_m) * x))) * 0.5;
}
eps_m = math.fabs(eps) def code(x, eps_m): return (math.exp(((eps_m * x) - x)) + math.exp(((-1.0 - eps_m) * x))) * 0.5
eps_m = abs(eps) function code(x, eps_m) return Float64(Float64(exp(Float64(Float64(eps_m * x) - x)) + exp(Float64(Float64(-1.0 - eps_m) * x))) * 0.5) end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = (exp(((eps_m * x) - x)) + exp(((-1.0 - eps_m) * x))) * 0.5; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(N[(N[Exp[N[(N[(eps$95$m * x), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(N[(-1.0 - eps$95$m), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\left(e^{eps\_m \cdot x - x} + e^{\left(-1 - eps\_m\right) \cdot x}\right) \cdot 0.5
\end{array}
Initial program 73.2%
Taylor expanded in eps around inf
Applied rewrites98.9%
Applied rewrites98.9%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= eps_m 4.4e+17)
(* (+ (exp (- x)) (exp (* -1.0 x))) 0.5)
(if (<= eps_m 3.8e+156)
(* 0.5 (- (exp (- (* eps_m x) x)) -1.0))
(+ 1.0 (- (/ (+ (fma eps_m eps_m -1.0) 1.0) eps_m) eps_m)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 4.4e+17) {
tmp = (exp(-x) + exp((-1.0 * x))) * 0.5;
} else if (eps_m <= 3.8e+156) {
tmp = 0.5 * (exp(((eps_m * x) - x)) - -1.0);
} else {
tmp = 1.0 + (((fma(eps_m, eps_m, -1.0) + 1.0) / eps_m) - eps_m);
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 4.4e+17) tmp = Float64(Float64(exp(Float64(-x)) + exp(Float64(-1.0 * x))) * 0.5); elseif (eps_m <= 3.8e+156) tmp = Float64(0.5 * Float64(exp(Float64(Float64(eps_m * x) - x)) - -1.0)); else tmp = Float64(1.0 + Float64(Float64(Float64(fma(eps_m, eps_m, -1.0) + 1.0) / eps_m) - eps_m)); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 4.4e+17], N[(N[(N[Exp[(-x)], $MachinePrecision] + N[Exp[N[(-1.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[eps$95$m, 3.8e+156], N[(0.5 * N[(N[Exp[N[(N[(eps$95$m * x), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(N[(N[(eps$95$m * eps$95$m + -1.0), $MachinePrecision] + 1.0), $MachinePrecision] / eps$95$m), $MachinePrecision] - eps$95$m), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 4.4 \cdot 10^{+17}:\\
\;\;\;\;\left(e^{-x} + e^{-1 \cdot x}\right) \cdot 0.5\\
\mathbf{elif}\;eps\_m \leq 3.8 \cdot 10^{+156}:\\
\;\;\;\;0.5 \cdot \left(e^{eps\_m \cdot x - x} - -1\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \left(\frac{\mathsf{fma}\left(eps\_m, eps\_m, -1\right) + 1}{eps\_m} - eps\_m\right)\\
\end{array}
\end{array}
if eps < 4.4e17Initial program 73.2%
Taylor expanded in eps around inf
Applied rewrites98.9%
Applied rewrites98.9%
Taylor expanded in eps around 0
Applied rewrites71.6%
if 4.4e17 < eps < 3.80000000000000024e156Initial program 73.2%
Taylor expanded in eps around inf
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites63.7%
Applied rewrites63.7%
if 3.80000000000000024e156 < eps Initial program 73.2%
Taylor expanded in x around 0
Applied rewrites44.4%
Applied rewrites31.0%
Applied rewrites44.1%
Applied rewrites64.1%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -3.2e+40)
(/ (- (/ (exp (- x)) eps_m) (- (/ 1.0 eps_m) 1.0)) 2.0)
(if (<= x 1e-276)
(* (+ (+ 1.0 (* x (- eps_m 1.0))) (exp (* (- -1.0 eps_m) x))) 0.5)
(* 0.5 (- (exp (- (* eps_m x) x)) -1.0)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -3.2e+40) {
tmp = ((exp(-x) / eps_m) - ((1.0 / eps_m) - 1.0)) / 2.0;
} else if (x <= 1e-276) {
tmp = ((1.0 + (x * (eps_m - 1.0))) + exp(((-1.0 - eps_m) * x))) * 0.5;
} else {
tmp = 0.5 * (exp(((eps_m * x) - x)) - -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 <= (-3.2d+40)) then
tmp = ((exp(-x) / eps_m) - ((1.0d0 / eps_m) - 1.0d0)) / 2.0d0
else if (x <= 1d-276) then
tmp = ((1.0d0 + (x * (eps_m - 1.0d0))) + exp((((-1.0d0) - eps_m) * x))) * 0.5d0
else
tmp = 0.5d0 * (exp(((eps_m * x) - x)) - (-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 <= -3.2e+40) {
tmp = ((Math.exp(-x) / eps_m) - ((1.0 / eps_m) - 1.0)) / 2.0;
} else if (x <= 1e-276) {
tmp = ((1.0 + (x * (eps_m - 1.0))) + Math.exp(((-1.0 - eps_m) * x))) * 0.5;
} else {
tmp = 0.5 * (Math.exp(((eps_m * x) - x)) - -1.0);
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -3.2e+40: tmp = ((math.exp(-x) / eps_m) - ((1.0 / eps_m) - 1.0)) / 2.0 elif x <= 1e-276: tmp = ((1.0 + (x * (eps_m - 1.0))) + math.exp(((-1.0 - eps_m) * x))) * 0.5 else: tmp = 0.5 * (math.exp(((eps_m * x) - x)) - -1.0) return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -3.2e+40) tmp = Float64(Float64(Float64(exp(Float64(-x)) / eps_m) - Float64(Float64(1.0 / eps_m) - 1.0)) / 2.0); elseif (x <= 1e-276) tmp = Float64(Float64(Float64(1.0 + Float64(x * Float64(eps_m - 1.0))) + exp(Float64(Float64(-1.0 - eps_m) * x))) * 0.5); else tmp = Float64(0.5 * Float64(exp(Float64(Float64(eps_m * x) - x)) - -1.0)); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -3.2e+40) tmp = ((exp(-x) / eps_m) - ((1.0 / eps_m) - 1.0)) / 2.0; elseif (x <= 1e-276) tmp = ((1.0 + (x * (eps_m - 1.0))) + exp(((-1.0 - eps_m) * x))) * 0.5; else tmp = 0.5 * (exp(((eps_m * x) - x)) - -1.0); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -3.2e+40], N[(N[(N[(N[Exp[(-x)], $MachinePrecision] / eps$95$m), $MachinePrecision] - N[(N[(1.0 / eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1e-276], N[(N[(N[(1.0 + N[(x * N[(eps$95$m - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Exp[N[(N[(-1.0 - eps$95$m), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(0.5 * N[(N[Exp[N[(N[(eps$95$m * x), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.2 \cdot 10^{+40}:\\
\;\;\;\;\frac{\frac{e^{-x}}{eps\_m} - \left(\frac{1}{eps\_m} - 1\right)}{2}\\
\mathbf{elif}\;x \leq 10^{-276}:\\
\;\;\;\;\left(\left(1 + x \cdot \left(eps\_m - 1\right)\right) + e^{\left(-1 - eps\_m\right) \cdot x}\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{eps\_m \cdot x - x} - -1\right)\\
\end{array}
\end{array}
if x < -3.19999999999999981e40Initial program 73.2%
Taylor expanded in x around 0
Applied rewrites37.8%
Taylor expanded in eps around 0
Applied rewrites19.4%
if -3.19999999999999981e40 < x < 1e-276Initial program 73.2%
Taylor expanded in eps around inf
Applied rewrites98.9%
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites64.1%
if 1e-276 < x Initial program 73.2%
Taylor expanded in eps around inf
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites63.7%
Applied rewrites63.7%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -12500000000000.0)
(/ (- (/ (exp (- x)) eps_m) (- (/ 1.0 eps_m) 1.0)) 2.0)
(if (<= x -8e-128)
(+ 1.0 (- (/ (+ (fma eps_m eps_m -1.0) 1.0) eps_m) eps_m))
(* 0.5 (- (exp (- (* eps_m x) x)) -1.0)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -12500000000000.0) {
tmp = ((exp(-x) / eps_m) - ((1.0 / eps_m) - 1.0)) / 2.0;
} else if (x <= -8e-128) {
tmp = 1.0 + (((fma(eps_m, eps_m, -1.0) + 1.0) / eps_m) - eps_m);
} else {
tmp = 0.5 * (exp(((eps_m * x) - x)) - -1.0);
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -12500000000000.0) tmp = Float64(Float64(Float64(exp(Float64(-x)) / eps_m) - Float64(Float64(1.0 / eps_m) - 1.0)) / 2.0); elseif (x <= -8e-128) tmp = Float64(1.0 + Float64(Float64(Float64(fma(eps_m, eps_m, -1.0) + 1.0) / eps_m) - eps_m)); else tmp = Float64(0.5 * Float64(exp(Float64(Float64(eps_m * x) - x)) - -1.0)); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -12500000000000.0], N[(N[(N[(N[Exp[(-x)], $MachinePrecision] / eps$95$m), $MachinePrecision] - N[(N[(1.0 / eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, -8e-128], N[(1.0 + N[(N[(N[(N[(eps$95$m * eps$95$m + -1.0), $MachinePrecision] + 1.0), $MachinePrecision] / eps$95$m), $MachinePrecision] - eps$95$m), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Exp[N[(N[(eps$95$m * x), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -12500000000000:\\
\;\;\;\;\frac{\frac{e^{-x}}{eps\_m} - \left(\frac{1}{eps\_m} - 1\right)}{2}\\
\mathbf{elif}\;x \leq -8 \cdot 10^{-128}:\\
\;\;\;\;1 + \left(\frac{\mathsf{fma}\left(eps\_m, eps\_m, -1\right) + 1}{eps\_m} - eps\_m\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{eps\_m \cdot x - x} - -1\right)\\
\end{array}
\end{array}
if x < -1.25e13Initial program 73.2%
Taylor expanded in x around 0
Applied rewrites37.8%
Taylor expanded in eps around 0
Applied rewrites19.4%
if -1.25e13 < x < -8.00000000000000043e-128Initial program 73.2%
Taylor expanded in x around 0
Applied rewrites44.4%
Applied rewrites31.0%
Applied rewrites44.1%
Applied rewrites64.1%
if -8.00000000000000043e-128 < x Initial program 73.2%
Taylor expanded in eps around inf
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites63.7%
Applied rewrites63.7%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= eps_m 1.0)
(* eps_m (+ x (fma -1.0 x (/ 1.0 eps_m))))
(if (<= eps_m 3.8e+156)
(* 0.5 (- (exp (- (* eps_m x) x)) -1.0))
(+ 1.0 (- (/ (+ (fma eps_m eps_m -1.0) 1.0) eps_m) eps_m)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 1.0) {
tmp = eps_m * (x + fma(-1.0, x, (1.0 / eps_m)));
} else if (eps_m <= 3.8e+156) {
tmp = 0.5 * (exp(((eps_m * x) - x)) - -1.0);
} else {
tmp = 1.0 + (((fma(eps_m, eps_m, -1.0) + 1.0) / eps_m) - eps_m);
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 1.0) tmp = Float64(eps_m * Float64(x + fma(-1.0, x, Float64(1.0 / eps_m)))); elseif (eps_m <= 3.8e+156) tmp = Float64(0.5 * Float64(exp(Float64(Float64(eps_m * x) - x)) - -1.0)); else tmp = Float64(1.0 + Float64(Float64(Float64(fma(eps_m, eps_m, -1.0) + 1.0) / eps_m) - eps_m)); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 1.0], N[(eps$95$m * N[(x + N[(-1.0 * x + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps$95$m, 3.8e+156], N[(0.5 * N[(N[Exp[N[(N[(eps$95$m * x), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(N[(N[(eps$95$m * eps$95$m + -1.0), $MachinePrecision] + 1.0), $MachinePrecision] / eps$95$m), $MachinePrecision] - eps$95$m), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 1:\\
\;\;\;\;eps\_m \cdot \left(x + \mathsf{fma}\left(-1, x, \frac{1}{eps\_m}\right)\right)\\
\mathbf{elif}\;eps\_m \leq 3.8 \cdot 10^{+156}:\\
\;\;\;\;0.5 \cdot \left(e^{eps\_m \cdot x - x} - -1\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \left(\frac{\mathsf{fma}\left(eps\_m, eps\_m, -1\right) + 1}{eps\_m} - eps\_m\right)\\
\end{array}
\end{array}
if eps < 1Initial program 73.2%
Taylor expanded in x around 0
Applied rewrites44.4%
Applied rewrites31.0%
Applied rewrites38.6%
Taylor expanded in eps around inf
Applied rewrites50.0%
if 1 < eps < 3.80000000000000024e156Initial program 73.2%
Taylor expanded in eps around inf
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites63.7%
Applied rewrites63.7%
if 3.80000000000000024e156 < eps Initial program 73.2%
Taylor expanded in x around 0
Applied rewrites44.4%
Applied rewrites31.0%
Applied rewrites44.1%
Applied rewrites64.1%
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)
1.0001)
(* eps_m (+ x (fma -1.0 x (/ 1.0 eps_m))))
(+ 1.0 (- (/ (+ (fma eps_m eps_m -1.0) 1.0) eps_m) eps_m))))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) <= 1.0001) {
tmp = eps_m * (x + fma(-1.0, x, (1.0 / eps_m)));
} else {
tmp = 1.0 + (((fma(eps_m, eps_m, -1.0) + 1.0) / eps_m) - eps_m);
}
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) <= 1.0001) tmp = Float64(eps_m * Float64(x + fma(-1.0, x, Float64(1.0 / eps_m)))); else tmp = Float64(1.0 + Float64(Float64(Float64(fma(eps_m, eps_m, -1.0) + 1.0) / eps_m) - eps_m)); 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], 1.0001], N[(eps$95$m * N[(x + N[(-1.0 * x + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(N[(N[(eps$95$m * eps$95$m + -1.0), $MachinePrecision] + 1.0), $MachinePrecision] / eps$95$m), $MachinePrecision] - eps$95$m), $MachinePrecision]), $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 1.0001:\\
\;\;\;\;eps\_m \cdot \left(x + \mathsf{fma}\left(-1, x, \frac{1}{eps\_m}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \left(\frac{\mathsf{fma}\left(eps\_m, eps\_m, -1\right) + 1}{eps\_m} - eps\_m\right)\\
\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.00009999999999999Initial program 73.2%
Taylor expanded in x around 0
Applied rewrites44.4%
Applied rewrites31.0%
Applied rewrites38.6%
Taylor expanded in eps around inf
Applied rewrites50.0%
if 1.00009999999999999 < (/.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 73.2%
Taylor expanded in x around 0
Applied rewrites44.4%
Applied rewrites31.0%
Applied rewrites44.1%
Applied rewrites64.1%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 1.0) (- 1.0 x) (* eps_m (+ x (* -1.0 x)))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 1.0) {
tmp = 1.0 - x;
} else {
tmp = eps_m * (x + (-1.0 * x));
}
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.0d0) then
tmp = 1.0d0 - x
else
tmp = eps_m * (x + ((-1.0d0) * x))
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.0) {
tmp = 1.0 - x;
} else {
tmp = eps_m * (x + (-1.0 * x));
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 1.0: tmp = 1.0 - x else: tmp = eps_m * (x + (-1.0 * x)) return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 1.0) tmp = Float64(1.0 - x); else tmp = Float64(eps_m * Float64(x + Float64(-1.0 * x))); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 1.0) tmp = 1.0 - x; else tmp = eps_m * (x + (-1.0 * x)); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 1.0], N[(1.0 - x), $MachinePrecision], N[(eps$95$m * N[(x + N[(-1.0 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;1 - x\\
\mathbf{else}:\\
\;\;\;\;eps\_m \cdot \left(x + -1 \cdot x\right)\\
\end{array}
\end{array}
if x < 1Initial program 73.2%
Taylor expanded in eps around inf
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites43.9%
Applied rewrites43.9%
if 1 < x Initial program 73.2%
Taylor expanded in x around 0
Applied rewrites44.4%
Applied rewrites31.0%
Applied rewrites38.6%
Taylor expanded in eps around inf
Applied rewrites16.3%
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.2%
Taylor expanded in x around 0
Applied rewrites44.5%
herbie shell --seed 2025161
(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))