
(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 11 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}
(FPCore (x eps) :precision binary64 (* (+ (exp (* x (+ -1.0 eps))) (exp (- (fma x eps x)))) 0.5))
double code(double x, double eps) {
return (exp((x * (-1.0 + eps))) + exp(-fma(x, eps, x))) * 0.5;
}
function code(x, eps) return Float64(Float64(exp(Float64(x * Float64(-1.0 + eps))) + exp(Float64(-fma(x, eps, x)))) * 0.5) end
code[x_, eps_] := N[(N[(N[Exp[N[(x * N[(-1.0 + eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[(-N[(x * eps + x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
\\
\left(e^{x \cdot \left(-1 + \varepsilon\right)} + e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right) \cdot 0.5
\end{array}
Initial program 73.1%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
Final simplification99.8%
(FPCore (x eps) :precision binary64 (if (<= eps 1.0) (exp (- x)) (* (+ (exp (* x eps)) (exp (- (* x eps)))) 0.5)))
double code(double x, double eps) {
double tmp;
if (eps <= 1.0) {
tmp = exp(-x);
} else {
tmp = (exp((x * eps)) + exp(-(x * eps))) * 0.5;
}
return tmp;
}
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
real(8) :: tmp
if (eps <= 1.0d0) then
tmp = exp(-x)
else
tmp = (exp((x * eps)) + exp(-(x * eps))) * 0.5d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= 1.0) {
tmp = Math.exp(-x);
} else {
tmp = (Math.exp((x * eps)) + Math.exp(-(x * eps))) * 0.5;
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= 1.0: tmp = math.exp(-x) else: tmp = (math.exp((x * eps)) + math.exp(-(x * eps))) * 0.5 return tmp
function code(x, eps) tmp = 0.0 if (eps <= 1.0) tmp = exp(Float64(-x)); else tmp = Float64(Float64(exp(Float64(x * eps)) + exp(Float64(-Float64(x * eps)))) * 0.5); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= 1.0) tmp = exp(-x); else tmp = (exp((x * eps)) + exp(-(x * eps))) * 0.5; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, 1.0], N[Exp[(-x)], $MachinePrecision], N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] + N[Exp[(-N[(x * eps), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 1:\\
\;\;\;\;e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\left(e^{x \cdot \varepsilon} + e^{-x \cdot \varepsilon}\right) \cdot 0.5\\
\end{array}
\end{array}
if eps < 1Initial program 64.2%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6487.2
Applied rewrites87.2%
Taylor expanded in eps around 0
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-exp.f64N/A
lift-neg.f6477.4
Applied rewrites77.4%
if 1 < eps Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lift-*.f64100.0
Applied rewrites100.0%
Final simplification83.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= x -5.6e-8)
t_0
(if (<= x -5e-244)
(* (fma (fma -1.0 (/ (- (* eps eps) 1.0) (- eps 1.0)) eps) x 2.0) 0.5)
(if (<= x 1e-243)
1.0
(if (<= x 6.9e+68)
(* (+ (fma (- x) (/ (- 1.0 (* eps eps)) (- eps -1.0)) 1.0) 1.0) 0.5)
t_0))))))
double code(double x, double eps) {
double t_0 = exp(-x);
double tmp;
if (x <= -5.6e-8) {
tmp = t_0;
} else if (x <= -5e-244) {
tmp = fma(fma(-1.0, (((eps * eps) - 1.0) / (eps - 1.0)), eps), x, 2.0) * 0.5;
} else if (x <= 1e-243) {
tmp = 1.0;
} else if (x <= 6.9e+68) {
tmp = (fma(-x, ((1.0 - (eps * eps)) / (eps - -1.0)), 1.0) + 1.0) * 0.5;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, eps) t_0 = exp(Float64(-x)) tmp = 0.0 if (x <= -5.6e-8) tmp = t_0; elseif (x <= -5e-244) tmp = Float64(fma(fma(-1.0, Float64(Float64(Float64(eps * eps) - 1.0) / Float64(eps - 1.0)), eps), x, 2.0) * 0.5); elseif (x <= 1e-243) tmp = 1.0; elseif (x <= 6.9e+68) tmp = Float64(Float64(fma(Float64(-x), Float64(Float64(1.0 - Float64(eps * eps)) / Float64(eps - -1.0)), 1.0) + 1.0) * 0.5); else tmp = t_0; end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[x, -5.6e-8], t$95$0, If[LessEqual[x, -5e-244], N[(N[(N[(-1.0 * N[(N[(N[(eps * eps), $MachinePrecision] - 1.0), $MachinePrecision] / N[(eps - 1.0), $MachinePrecision]), $MachinePrecision] + eps), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 1e-243], 1.0, If[LessEqual[x, 6.9e+68], N[(N[(N[((-x) * N[(N[(1.0 - N[(eps * eps), $MachinePrecision]), $MachinePrecision] / N[(eps - -1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] + 1.0), $MachinePrecision] * 0.5), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;x \leq -5.6 \cdot 10^{-8}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-244}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, \frac{\varepsilon \cdot \varepsilon - 1}{\varepsilon - 1}, \varepsilon\right), x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 10^{-243}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 6.9 \cdot 10^{+68}:\\
\;\;\;\;\left(\mathsf{fma}\left(-x, \frac{1 - \varepsilon \cdot \varepsilon}{\varepsilon - -1}, 1\right) + 1\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -5.5999999999999999e-8 or 6.89999999999999993e68 < x Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6477.6
Applied rewrites77.6%
Taylor expanded in eps around 0
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-exp.f64N/A
lift-neg.f6468.3
Applied rewrites68.3%
if -5.5999999999999999e-8 < x < -4.99999999999999998e-244Initial program 56.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.6%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6470.6
Applied rewrites70.6%
lift-+.f64N/A
flip-+N/A
lower-/.f64N/A
unpow2N/A
metadata-evalN/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f6476.0
Applied rewrites76.0%
Taylor expanded in eps around inf
Applied rewrites76.0%
if -4.99999999999999998e-244 < x < 9.99999999999999995e-244Initial program 62.3%
Taylor expanded in x around 0
Applied rewrites94.6%
if 9.99999999999999995e-244 < x < 6.89999999999999993e68Initial program 61.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
distribute-lft-neg-inN/A
+-commutativeN/A
lower-fma.f64N/A
lift-neg.f64N/A
lift--.f6478.3
Applied rewrites78.3%
Taylor expanded in x around 0
Applied rewrites57.5%
lift--.f64N/A
flip--N/A
lower-/.f64N/A
metadata-evalN/A
pow2N/A
lower--.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f6465.9
Applied rewrites65.9%
Final simplification73.4%
(FPCore (x eps) :precision binary64 (if (<= x -1e-265) (* (+ 1.0 (exp (- (* x eps)))) 0.5) (if (<= x 1.8e+102) (* (- (exp (* x eps)) -1.0) 0.5) (exp (- x)))))
double code(double x, double eps) {
double tmp;
if (x <= -1e-265) {
tmp = (1.0 + exp(-(x * eps))) * 0.5;
} else if (x <= 1.8e+102) {
tmp = (exp((x * eps)) - -1.0) * 0.5;
} else {
tmp = exp(-x);
}
return tmp;
}
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
real(8) :: tmp
if (x <= (-1d-265)) then
tmp = (1.0d0 + exp(-(x * eps))) * 0.5d0
else if (x <= 1.8d+102) then
tmp = (exp((x * eps)) - (-1.0d0)) * 0.5d0
else
tmp = exp(-x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -1e-265) {
tmp = (1.0 + Math.exp(-(x * eps))) * 0.5;
} else if (x <= 1.8e+102) {
tmp = (Math.exp((x * eps)) - -1.0) * 0.5;
} else {
tmp = Math.exp(-x);
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -1e-265: tmp = (1.0 + math.exp(-(x * eps))) * 0.5 elif x <= 1.8e+102: tmp = (math.exp((x * eps)) - -1.0) * 0.5 else: tmp = math.exp(-x) return tmp
function code(x, eps) tmp = 0.0 if (x <= -1e-265) tmp = Float64(Float64(1.0 + exp(Float64(-Float64(x * eps)))) * 0.5); elseif (x <= 1.8e+102) tmp = Float64(Float64(exp(Float64(x * eps)) - -1.0) * 0.5); else tmp = exp(Float64(-x)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -1e-265) tmp = (1.0 + exp(-(x * eps))) * 0.5; elseif (x <= 1.8e+102) tmp = (exp((x * eps)) - -1.0) * 0.5; else tmp = exp(-x); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -1e-265], N[(N[(1.0 + N[Exp[(-N[(x * eps), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 1.8e+102], N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], N[Exp[(-x)], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-265}:\\
\;\;\;\;\left(1 + e^{-x \cdot \varepsilon}\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 1.8 \cdot 10^{+102}:\\
\;\;\;\;\left(e^{x \cdot \varepsilon} - -1\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;e^{-x}\\
\end{array}
\end{array}
if x < -9.99999999999999985e-266Initial program 68.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in eps around inf
*-commutativeN/A
lift-*.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites73.8%
if -9.99999999999999985e-266 < x < 1.8000000000000001e102Initial program 65.9%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6491.8
Applied rewrites91.8%
Taylor expanded in eps around inf
*-commutativeN/A
lift-*.f6490.1
Applied rewrites90.1%
Taylor expanded in x around 0
Applied rewrites73.4%
if 1.8000000000000001e102 < x Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6467.5
Applied rewrites67.5%
Taylor expanded in eps around 0
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-exp.f64N/A
lift-neg.f6459.0
Applied rewrites59.0%
Final simplification70.8%
(FPCore (x eps) :precision binary64 (if (<= eps 116.0) (exp (- x)) (* (- (exp (* x eps)) -1.0) 0.5)))
double code(double x, double eps) {
double tmp;
if (eps <= 116.0) {
tmp = exp(-x);
} else {
tmp = (exp((x * eps)) - -1.0) * 0.5;
}
return tmp;
}
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
real(8) :: tmp
if (eps <= 116.0d0) then
tmp = exp(-x)
else
tmp = (exp((x * eps)) - (-1.0d0)) * 0.5d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= 116.0) {
tmp = Math.exp(-x);
} else {
tmp = (Math.exp((x * eps)) - -1.0) * 0.5;
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= 116.0: tmp = math.exp(-x) else: tmp = (math.exp((x * eps)) - -1.0) * 0.5 return tmp
function code(x, eps) tmp = 0.0 if (eps <= 116.0) tmp = exp(Float64(-x)); else tmp = Float64(Float64(exp(Float64(x * eps)) - -1.0) * 0.5); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= 116.0) tmp = exp(-x); else tmp = (exp((x * eps)) - -1.0) * 0.5; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, 116.0], N[Exp[(-x)], $MachinePrecision], N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 116:\\
\;\;\;\;e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\left(e^{x \cdot \varepsilon} - -1\right) \cdot 0.5\\
\end{array}
\end{array}
if eps < 116Initial program 64.5%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6487.3
Applied rewrites87.3%
Taylor expanded in eps around 0
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-exp.f64N/A
lift-neg.f6477.6
Applied rewrites77.6%
if 116 < eps Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lift-*.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites68.0%
(FPCore (x eps)
:precision binary64
(if (<= x -5e-244)
(* (fma (fma -1.0 (/ (- (* eps eps) 1.0) (- eps 1.0)) eps) x 2.0) 0.5)
(if (<= x 1e-243)
1.0
(* (+ (fma (- x) (/ (- 1.0 (* eps eps)) (- eps -1.0)) 1.0) 1.0) 0.5))))
double code(double x, double eps) {
double tmp;
if (x <= -5e-244) {
tmp = fma(fma(-1.0, (((eps * eps) - 1.0) / (eps - 1.0)), eps), x, 2.0) * 0.5;
} else if (x <= 1e-243) {
tmp = 1.0;
} else {
tmp = (fma(-x, ((1.0 - (eps * eps)) / (eps - -1.0)), 1.0) + 1.0) * 0.5;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -5e-244) tmp = Float64(fma(fma(-1.0, Float64(Float64(Float64(eps * eps) - 1.0) / Float64(eps - 1.0)), eps), x, 2.0) * 0.5); elseif (x <= 1e-243) tmp = 1.0; else tmp = Float64(Float64(fma(Float64(-x), Float64(Float64(1.0 - Float64(eps * eps)) / Float64(eps - -1.0)), 1.0) + 1.0) * 0.5); end return tmp end
code[x_, eps_] := If[LessEqual[x, -5e-244], N[(N[(N[(-1.0 * N[(N[(N[(eps * eps), $MachinePrecision] - 1.0), $MachinePrecision] / N[(eps - 1.0), $MachinePrecision]), $MachinePrecision] + eps), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 1e-243], 1.0, N[(N[(N[((-x) * N[(N[(1.0 - N[(eps * eps), $MachinePrecision]), $MachinePrecision] / N[(eps - -1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] + 1.0), $MachinePrecision] * 0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-244}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, \frac{\varepsilon \cdot \varepsilon - 1}{\varepsilon - 1}, \varepsilon\right), x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 10^{-243}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(-x, \frac{1 - \varepsilon \cdot \varepsilon}{\varepsilon - -1}, 1\right) + 1\right) \cdot 0.5\\
\end{array}
\end{array}
if x < -4.99999999999999998e-244Initial program 68.4%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.7%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6451.6
Applied rewrites51.6%
lift-+.f64N/A
flip-+N/A
lower-/.f64N/A
unpow2N/A
metadata-evalN/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f6462.7
Applied rewrites62.7%
Taylor expanded in eps around inf
Applied rewrites62.7%
if -4.99999999999999998e-244 < x < 9.99999999999999995e-244Initial program 62.3%
Taylor expanded in x around 0
Applied rewrites94.6%
if 9.99999999999999995e-244 < x Initial program 79.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in x around 0
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
distribute-lft-neg-inN/A
+-commutativeN/A
lower-fma.f64N/A
lift-neg.f64N/A
lift--.f6452.7
Applied rewrites52.7%
Taylor expanded in x around 0
Applied rewrites35.6%
lift--.f64N/A
flip--N/A
lower-/.f64N/A
metadata-evalN/A
pow2N/A
lower--.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f6441.5
Applied rewrites41.5%
Final simplification56.6%
(FPCore (x eps) :precision binary64 (if (<= x -5e-244) (* (fma (fma -1.0 (/ (- (* eps eps) 1.0) (- eps 1.0)) eps) x 2.0) 0.5) (* (+ (fma (- eps 1.0) x 1.0) 1.0) 0.5)))
double code(double x, double eps) {
double tmp;
if (x <= -5e-244) {
tmp = fma(fma(-1.0, (((eps * eps) - 1.0) / (eps - 1.0)), eps), x, 2.0) * 0.5;
} else {
tmp = (fma((eps - 1.0), x, 1.0) + 1.0) * 0.5;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -5e-244) tmp = Float64(fma(fma(-1.0, Float64(Float64(Float64(eps * eps) - 1.0) / Float64(eps - 1.0)), eps), x, 2.0) * 0.5); else tmp = Float64(Float64(fma(Float64(eps - 1.0), x, 1.0) + 1.0) * 0.5); end return tmp end
code[x_, eps_] := If[LessEqual[x, -5e-244], N[(N[(N[(-1.0 * N[(N[(N[(eps * eps), $MachinePrecision] - 1.0), $MachinePrecision] / N[(eps - 1.0), $MachinePrecision]), $MachinePrecision] + eps), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(eps - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] + 1.0), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-244}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, \frac{\varepsilon \cdot \varepsilon - 1}{\varepsilon - 1}, \varepsilon\right), x, 2\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\varepsilon - 1, x, 1\right) + 1\right) \cdot 0.5\\
\end{array}
\end{array}
if x < -4.99999999999999998e-244Initial program 68.4%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.7%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6451.6
Applied rewrites51.6%
lift-+.f64N/A
flip-+N/A
lower-/.f64N/A
unpow2N/A
metadata-evalN/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f6462.7
Applied rewrites62.7%
Taylor expanded in eps around inf
Applied rewrites62.7%
if -4.99999999999999998e-244 < x Initial program 75.8%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6485.1
Applied rewrites85.1%
Taylor expanded in x around 0
Applied rewrites57.4%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6448.0
Applied rewrites48.0%
Final simplification53.3%
(FPCore (x eps) :precision binary64 (if (<= x -1e-265) (* (fma (fma -1.0 (- eps -1.0) -1.0) x 2.0) 0.5) (* (+ (fma (- eps 1.0) x 1.0) 1.0) 0.5)))
double code(double x, double eps) {
double tmp;
if (x <= -1e-265) {
tmp = fma(fma(-1.0, (eps - -1.0), -1.0), x, 2.0) * 0.5;
} else {
tmp = (fma((eps - 1.0), x, 1.0) + 1.0) * 0.5;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -1e-265) tmp = Float64(fma(fma(-1.0, Float64(eps - -1.0), -1.0), x, 2.0) * 0.5); else tmp = Float64(Float64(fma(Float64(eps - 1.0), x, 1.0) + 1.0) * 0.5); end return tmp end
code[x_, eps_] := If[LessEqual[x, -1e-265], N[(N[(N[(-1.0 * N[(eps - -1.0), $MachinePrecision] + -1.0), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(eps - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] + 1.0), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-265}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon - -1, -1\right), x, 2\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\varepsilon - 1, x, 1\right) + 1\right) \cdot 0.5\\
\end{array}
\end{array}
if x < -9.99999999999999985e-266Initial program 68.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6454.5
Applied rewrites54.5%
Taylor expanded in eps around 0
Applied rewrites57.6%
if -9.99999999999999985e-266 < x Initial program 76.4%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6484.3
Applied rewrites84.3%
Taylor expanded in x around 0
Applied rewrites56.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6446.1
Applied rewrites46.1%
Final simplification50.6%
(FPCore (x eps) :precision binary64 (if (<= x 4.8e-13) (* (fma -2.0 x 2.0) 0.5) (* (+ (* x eps) 1.0) 0.5)))
double code(double x, double eps) {
double tmp;
if (x <= 4.8e-13) {
tmp = fma(-2.0, x, 2.0) * 0.5;
} else {
tmp = ((x * eps) + 1.0) * 0.5;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 4.8e-13) tmp = Float64(fma(-2.0, x, 2.0) * 0.5); else tmp = Float64(Float64(Float64(x * eps) + 1.0) * 0.5); end return tmp end
code[x_, eps_] := If[LessEqual[x, 4.8e-13], N[(N[(-2.0 * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(x * eps), $MachinePrecision] + 1.0), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.8 \cdot 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(-2, x, 2\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \varepsilon + 1\right) \cdot 0.5\\
\end{array}
\end{array}
if x < 4.7999999999999997e-13Initial program 60.9%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6468.0
Applied rewrites68.0%
Taylor expanded in eps around 0
Applied rewrites68.2%
if 4.7999999999999997e-13 < x Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in x around 0
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
distribute-lft-neg-inN/A
+-commutativeN/A
lower-fma.f64N/A
lift-neg.f64N/A
lift--.f6430.6
Applied rewrites30.6%
Taylor expanded in x around 0
Applied rewrites9.4%
Taylor expanded in eps around inf
*-commutativeN/A
lift-*.f649.6
Applied rewrites9.6%
Final simplification49.9%
(FPCore (x eps) :precision binary64 (* (+ (fma (- eps 1.0) x 1.0) 1.0) 0.5))
double code(double x, double eps) {
return (fma((eps - 1.0), x, 1.0) + 1.0) * 0.5;
}
function code(x, eps) return Float64(Float64(fma(Float64(eps - 1.0), x, 1.0) + 1.0) * 0.5) end
code[x_, eps_] := N[(N[(N[(N[(eps - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] + 1.0), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
\\
\left(\mathsf{fma}\left(\varepsilon - 1, x, 1\right) + 1\right) \cdot 0.5
\end{array}
Initial program 73.1%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6490.4
Applied rewrites90.4%
Taylor expanded in x around 0
Applied rewrites65.2%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6451.0
Applied rewrites51.0%
Final simplification51.0%
(FPCore (x eps) :precision binary64 1.0)
double code(double x, double eps) {
return 1.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
end function
public static double code(double x, double eps) {
return 1.0;
}
def code(x, eps): return 1.0
function code(x, eps) return 1.0 end
function tmp = code(x, eps) tmp = 1.0; end
code[x_, eps_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 73.1%
Taylor expanded in x around 0
Applied rewrites47.9%
herbie shell --seed 2025084
(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))