
(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]
\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}
Herbie found 12 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]
\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}
(FPCore (x eps) :precision binary64 (* 0.5 (- (exp (- (* x (- 1.0 eps)))) (/ -1.0 (exp (fma x eps x))))))
double code(double x, double eps) {
return 0.5 * (exp(-(x * (1.0 - eps))) - (-1.0 / exp(fma(x, eps, x))));
}
function code(x, eps) return Float64(0.5 * Float64(exp(Float64(-Float64(x * Float64(1.0 - eps)))) - Float64(-1.0 / exp(fma(x, eps, x))))) end
code[x_, eps_] := N[(0.5 * N[(N[Exp[(-N[(x * N[(1.0 - eps), $MachinePrecision]), $MachinePrecision])], $MachinePrecision] - N[(-1.0 / N[Exp[N[(x * eps + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
0.5 \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - \frac{-1}{e^{\mathsf{fma}\left(x, \varepsilon, x\right)}}\right)
Initial program 73.4%
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-+.f6498.9
Applied rewrites98.9%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower-exp.f6498.9
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft-inN/A
*-rgt-identityN/A
+-commutativeN/A
lower-fma.f6498.9
Applied rewrites98.9%
(FPCore (x eps) :precision binary64 (if (<= (fabs eps) 0.65) (* (* 2.0 (exp (- x))) 0.5) (* 0.5 (- (exp (* (fabs eps) x)) (/ -1.0 (exp (fma x (fabs eps) x)))))))
double code(double x, double eps) {
double tmp;
if (fabs(eps) <= 0.65) {
tmp = (2.0 * exp(-x)) * 0.5;
} else {
tmp = 0.5 * (exp((fabs(eps) * x)) - (-1.0 / exp(fma(x, fabs(eps), x))));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (abs(eps) <= 0.65) tmp = Float64(Float64(2.0 * exp(Float64(-x))) * 0.5); else tmp = Float64(0.5 * Float64(exp(Float64(abs(eps) * x)) - Float64(-1.0 / exp(fma(x, abs(eps), x))))); end return tmp end
code[x_, eps_] := If[LessEqual[N[Abs[eps], $MachinePrecision], 0.65], N[(N[(2.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(0.5 * N[(N[Exp[N[(N[Abs[eps], $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] - N[(-1.0 / N[Exp[N[(x * N[Abs[eps], $MachinePrecision] + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|\varepsilon\right| \leq 0.65:\\
\;\;\;\;\left(2 \cdot e^{-x}\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{\left|\varepsilon\right| \cdot x} - \frac{-1}{e^{\mathsf{fma}\left(x, \left|\varepsilon\right|, x\right)}}\right)\\
\end{array}
if eps < 0.650000000000000022Initial program 73.4%
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-+.f6498.9
Applied rewrites98.9%
Taylor expanded in eps around 0
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f6470.8
Applied rewrites70.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.8
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-*.f6470.8
Applied rewrites70.8%
if 0.650000000000000022 < eps Initial program 73.4%
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-+.f6498.9
Applied rewrites98.9%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower-exp.f6498.9
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft-inN/A
*-rgt-identityN/A
+-commutativeN/A
lower-fma.f6498.9
Applied rewrites98.9%
Taylor expanded in eps around inf
lower-*.f6488.3
Applied rewrites88.3%
(FPCore (x eps) :precision binary64 (* (+ (exp (- (fma x eps x))) (exp (* (- eps 1.0) x))) 0.5))
double code(double x, double eps) {
return (exp(-fma(x, eps, x)) + exp(((eps - 1.0) * x))) * 0.5;
}
function code(x, eps) return Float64(Float64(exp(Float64(-fma(x, eps, x))) + exp(Float64(Float64(eps - 1.0) * x))) * 0.5) end
code[x_, eps_] := N[(N[(N[Exp[(-N[(x * eps + x), $MachinePrecision])], $MachinePrecision] + N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]
\left(e^{-\mathsf{fma}\left(x, \varepsilon, x\right)} + e^{\left(\varepsilon - 1\right) \cdot x}\right) \cdot 0.5
Initial program 73.4%
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-+.f6498.9
Applied rewrites98.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.9
Applied rewrites98.9%
(FPCore (x eps) :precision binary64 (if (<= (fabs eps) 0.65) (* (* 2.0 (exp (- x))) 0.5) (* (+ (exp (- (fma x (fabs eps) x))) (exp (* x (fabs eps)))) 0.5)))
double code(double x, double eps) {
double tmp;
if (fabs(eps) <= 0.65) {
tmp = (2.0 * exp(-x)) * 0.5;
} else {
tmp = (exp(-fma(x, fabs(eps), x)) + exp((x * fabs(eps)))) * 0.5;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (abs(eps) <= 0.65) tmp = Float64(Float64(2.0 * exp(Float64(-x))) * 0.5); else tmp = Float64(Float64(exp(Float64(-fma(x, abs(eps), x))) + exp(Float64(x * abs(eps)))) * 0.5); end return tmp end
code[x_, eps_] := If[LessEqual[N[Abs[eps], $MachinePrecision], 0.65], N[(N[(2.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[Exp[(-N[(x * N[Abs[eps], $MachinePrecision] + x), $MachinePrecision])], $MachinePrecision] + N[Exp[N[(x * N[Abs[eps], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|\varepsilon\right| \leq 0.65:\\
\;\;\;\;\left(2 \cdot e^{-x}\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(e^{-\mathsf{fma}\left(x, \left|\varepsilon\right|, x\right)} + e^{x \cdot \left|\varepsilon\right|}\right) \cdot 0.5\\
\end{array}
if eps < 0.650000000000000022Initial program 73.4%
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-+.f6498.9
Applied rewrites98.9%
Taylor expanded in eps around 0
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f6470.8
Applied rewrites70.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.8
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-*.f6470.8
Applied rewrites70.8%
if 0.650000000000000022 < eps Initial program 73.4%
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-+.f6498.9
Applied rewrites98.9%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower-exp.f6498.9
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft-inN/A
*-rgt-identityN/A
+-commutativeN/A
lower-fma.f6498.9
Applied rewrites98.9%
Taylor expanded in eps around inf
lower-*.f6488.3
Applied rewrites88.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6488.3
Applied rewrites88.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (/ 1.0 (fabs eps))))
(if (<= x -2e+55)
(* 0.5 (- (exp (- x)) -1.0))
(if (<= x -2e-263)
(*
0.5
(-
(+ 1.0 (* x (- (fabs eps) 1.0)))
(/ -1.0 (exp (fma x (fabs eps) x)))))
(if (<= x 750.0)
(* 0.5 (- (exp (* (fabs eps) x)) (- (* x (+ 1.0 (fabs eps))) 1.0)))
(if (<= x 3.2e+59)
(/ (- (+ 1.0 t_0) (- t_0 1.0)) 2.0)
(* 0.5 (- (exp (- (* x (- 1.0 (fabs eps))))) -1.0))))))))double code(double x, double eps) {
double t_0 = 1.0 / fabs(eps);
double tmp;
if (x <= -2e+55) {
tmp = 0.5 * (exp(-x) - -1.0);
} else if (x <= -2e-263) {
tmp = 0.5 * ((1.0 + (x * (fabs(eps) - 1.0))) - (-1.0 / exp(fma(x, fabs(eps), x))));
} else if (x <= 750.0) {
tmp = 0.5 * (exp((fabs(eps) * x)) - ((x * (1.0 + fabs(eps))) - 1.0));
} else if (x <= 3.2e+59) {
tmp = ((1.0 + t_0) - (t_0 - 1.0)) / 2.0;
} else {
tmp = 0.5 * (exp(-(x * (1.0 - fabs(eps)))) - -1.0);
}
return tmp;
}
function code(x, eps) t_0 = Float64(1.0 / abs(eps)) tmp = 0.0 if (x <= -2e+55) tmp = Float64(0.5 * Float64(exp(Float64(-x)) - -1.0)); elseif (x <= -2e-263) tmp = Float64(0.5 * Float64(Float64(1.0 + Float64(x * Float64(abs(eps) - 1.0))) - Float64(-1.0 / exp(fma(x, abs(eps), x))))); elseif (x <= 750.0) tmp = Float64(0.5 * Float64(exp(Float64(abs(eps) * x)) - Float64(Float64(x * Float64(1.0 + abs(eps))) - 1.0))); elseif (x <= 3.2e+59) tmp = Float64(Float64(Float64(1.0 + t_0) - Float64(t_0 - 1.0)) / 2.0); else tmp = Float64(0.5 * Float64(exp(Float64(-Float64(x * Float64(1.0 - abs(eps))))) - -1.0)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 / N[Abs[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2e+55], N[(0.5 * N[(N[Exp[(-x)], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2e-263], N[(0.5 * N[(N[(1.0 + N[(x * N[(N[Abs[eps], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(-1.0 / N[Exp[N[(x * N[Abs[eps], $MachinePrecision] + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 750.0], N[(0.5 * N[(N[Exp[N[(N[Abs[eps], $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] - N[(N[(x * N[(1.0 + N[Abs[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.2e+59], N[(N[(N[(1.0 + t$95$0), $MachinePrecision] - N[(t$95$0 - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(0.5 * N[(N[Exp[(-N[(x * N[(1.0 - N[Abs[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision])], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \frac{1}{\left|\varepsilon\right|}\\
\mathbf{if}\;x \leq -2 \cdot 10^{+55}:\\
\;\;\;\;0.5 \cdot \left(e^{-x} - -1\right)\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-263}:\\
\;\;\;\;0.5 \cdot \left(\left(1 + x \cdot \left(\left|\varepsilon\right| - 1\right)\right) - \frac{-1}{e^{\mathsf{fma}\left(x, \left|\varepsilon\right|, x\right)}}\right)\\
\mathbf{elif}\;x \leq 750:\\
\;\;\;\;0.5 \cdot \left(e^{\left|\varepsilon\right| \cdot x} - \left(x \cdot \left(1 + \left|\varepsilon\right|\right) - 1\right)\right)\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{+59}:\\
\;\;\;\;\frac{\left(1 + t\_0\right) - \left(t\_0 - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{-x \cdot \left(1 - \left|\varepsilon\right|\right)} - -1\right)\\
\end{array}
if x < -2.00000000000000002e55Initial program 73.4%
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-+.f6498.9
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites64.3%
Taylor expanded in eps around inf
lower-*.f6464.5
Applied rewrites64.5%
Taylor expanded in eps around 0
lower-exp.f64N/A
lower-neg.f6457.2
Applied rewrites57.2%
if -2.00000000000000002e55 < x < -2e-263Initial program 73.4%
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-+.f6498.9
Applied rewrites98.9%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower-exp.f6498.9
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft-inN/A
*-rgt-identityN/A
+-commutativeN/A
lower-fma.f6498.9
Applied rewrites98.9%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6464.0
Applied rewrites64.0%
if -2e-263 < x < 750Initial program 73.4%
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-+.f6498.9
Applied rewrites98.9%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower-exp.f6498.9
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft-inN/A
*-rgt-identityN/A
+-commutativeN/A
lower-fma.f6498.9
Applied rewrites98.9%
Taylor expanded in eps around inf
lower-*.f6488.3
Applied rewrites88.3%
Taylor expanded in x around 0
lower--.f64N/A
lower-*.f64N/A
lower-+.f6464.5
Applied rewrites64.5%
if 750 < x < 3.19999999999999982e59Initial program 73.4%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6438.5
Applied rewrites38.5%
Taylor expanded in x around 0
lower-+.f64N/A
lower-/.f6431.3
Applied rewrites31.3%
if 3.19999999999999982e59 < x Initial program 73.4%
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-+.f6498.9
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites64.3%
(FPCore (x eps)
:precision binary64
(if (<= (fabs eps) 3.95e+65)
(* (* 2.0 (exp (- x))) 0.5)
(if (<= (fabs eps) 1.8e+255)
(* 0.5 (- (exp (* (fabs eps) x)) (- (* x (+ 1.0 (fabs eps))) 1.0)))
(* 0.5 (- (exp (- (* x (- 1.0 (fabs eps))))) -1.0)))))double code(double x, double eps) {
double tmp;
if (fabs(eps) <= 3.95e+65) {
tmp = (2.0 * exp(-x)) * 0.5;
} else if (fabs(eps) <= 1.8e+255) {
tmp = 0.5 * (exp((fabs(eps) * x)) - ((x * (1.0 + fabs(eps))) - 1.0));
} else {
tmp = 0.5 * (exp(-(x * (1.0 - fabs(eps)))) - -1.0);
}
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 (abs(eps) <= 3.95d+65) then
tmp = (2.0d0 * exp(-x)) * 0.5d0
else if (abs(eps) <= 1.8d+255) then
tmp = 0.5d0 * (exp((abs(eps) * x)) - ((x * (1.0d0 + abs(eps))) - 1.0d0))
else
tmp = 0.5d0 * (exp(-(x * (1.0d0 - abs(eps)))) - (-1.0d0))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (Math.abs(eps) <= 3.95e+65) {
tmp = (2.0 * Math.exp(-x)) * 0.5;
} else if (Math.abs(eps) <= 1.8e+255) {
tmp = 0.5 * (Math.exp((Math.abs(eps) * x)) - ((x * (1.0 + Math.abs(eps))) - 1.0));
} else {
tmp = 0.5 * (Math.exp(-(x * (1.0 - Math.abs(eps)))) - -1.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if math.fabs(eps) <= 3.95e+65: tmp = (2.0 * math.exp(-x)) * 0.5 elif math.fabs(eps) <= 1.8e+255: tmp = 0.5 * (math.exp((math.fabs(eps) * x)) - ((x * (1.0 + math.fabs(eps))) - 1.0)) else: tmp = 0.5 * (math.exp(-(x * (1.0 - math.fabs(eps)))) - -1.0) return tmp
function code(x, eps) tmp = 0.0 if (abs(eps) <= 3.95e+65) tmp = Float64(Float64(2.0 * exp(Float64(-x))) * 0.5); elseif (abs(eps) <= 1.8e+255) tmp = Float64(0.5 * Float64(exp(Float64(abs(eps) * x)) - Float64(Float64(x * Float64(1.0 + abs(eps))) - 1.0))); else tmp = Float64(0.5 * Float64(exp(Float64(-Float64(x * Float64(1.0 - abs(eps))))) - -1.0)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (abs(eps) <= 3.95e+65) tmp = (2.0 * exp(-x)) * 0.5; elseif (abs(eps) <= 1.8e+255) tmp = 0.5 * (exp((abs(eps) * x)) - ((x * (1.0 + abs(eps))) - 1.0)); else tmp = 0.5 * (exp(-(x * (1.0 - abs(eps)))) - -1.0); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[Abs[eps], $MachinePrecision], 3.95e+65], N[(N[(2.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[N[Abs[eps], $MachinePrecision], 1.8e+255], N[(0.5 * N[(N[Exp[N[(N[Abs[eps], $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] - N[(N[(x * N[(1.0 + N[Abs[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Exp[(-N[(x * N[(1.0 - N[Abs[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision])], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;\left|\varepsilon\right| \leq 3.95 \cdot 10^{+65}:\\
\;\;\;\;\left(2 \cdot e^{-x}\right) \cdot 0.5\\
\mathbf{elif}\;\left|\varepsilon\right| \leq 1.8 \cdot 10^{+255}:\\
\;\;\;\;0.5 \cdot \left(e^{\left|\varepsilon\right| \cdot x} - \left(x \cdot \left(1 + \left|\varepsilon\right|\right) - 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{-x \cdot \left(1 - \left|\varepsilon\right|\right)} - -1\right)\\
\end{array}
if eps < 3.9499999999999999e65Initial program 73.4%
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-+.f6498.9
Applied rewrites98.9%
Taylor expanded in eps around 0
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f6470.8
Applied rewrites70.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.8
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-*.f6470.8
Applied rewrites70.8%
if 3.9499999999999999e65 < eps < 1.7999999999999999e255Initial program 73.4%
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-+.f6498.9
Applied rewrites98.9%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower-exp.f6498.9
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
distribute-lft-inN/A
*-rgt-identityN/A
+-commutativeN/A
lower-fma.f6498.9
Applied rewrites98.9%
Taylor expanded in eps around inf
lower-*.f6488.3
Applied rewrites88.3%
Taylor expanded in x around 0
lower--.f64N/A
lower-*.f64N/A
lower-+.f6464.5
Applied rewrites64.5%
if 1.7999999999999999e255 < eps Initial program 73.4%
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-+.f6498.9
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites64.3%
(FPCore (x eps) :precision binary64 (if (<= (fabs eps) 8.2e+62) (* (* 2.0 (exp (- x))) 0.5) (* (- (exp (* x (fabs eps))) -1.0) 0.5)))
double code(double x, double eps) {
double tmp;
if (fabs(eps) <= 8.2e+62) {
tmp = (2.0 * exp(-x)) * 0.5;
} else {
tmp = (exp((x * fabs(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 (abs(eps) <= 8.2d+62) then
tmp = (2.0d0 * exp(-x)) * 0.5d0
else
tmp = (exp((x * abs(eps))) - (-1.0d0)) * 0.5d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (Math.abs(eps) <= 8.2e+62) {
tmp = (2.0 * Math.exp(-x)) * 0.5;
} else {
tmp = (Math.exp((x * Math.abs(eps))) - -1.0) * 0.5;
}
return tmp;
}
def code(x, eps): tmp = 0 if math.fabs(eps) <= 8.2e+62: tmp = (2.0 * math.exp(-x)) * 0.5 else: tmp = (math.exp((x * math.fabs(eps))) - -1.0) * 0.5 return tmp
function code(x, eps) tmp = 0.0 if (abs(eps) <= 8.2e+62) tmp = Float64(Float64(2.0 * exp(Float64(-x))) * 0.5); else tmp = Float64(Float64(exp(Float64(x * abs(eps))) - -1.0) * 0.5); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (abs(eps) <= 8.2e+62) tmp = (2.0 * exp(-x)) * 0.5; else tmp = (exp((x * abs(eps))) - -1.0) * 0.5; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[Abs[eps], $MachinePrecision], 8.2e+62], N[(N[(2.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[Exp[N[(x * N[Abs[eps], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|\varepsilon\right| \leq 8.2 \cdot 10^{+62}:\\
\;\;\;\;\left(2 \cdot e^{-x}\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(e^{x \cdot \left|\varepsilon\right|} - -1\right) \cdot 0.5\\
\end{array}
if eps < 8.19999999999999967e62Initial program 73.4%
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-+.f6498.9
Applied rewrites98.9%
Taylor expanded in eps around 0
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f6470.8
Applied rewrites70.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.8
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-*.f6470.8
Applied rewrites70.8%
if 8.19999999999999967e62 < eps Initial program 73.4%
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-+.f6498.9
Applied rewrites98.9%
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%
(FPCore (x eps) :precision binary64 (if (<= (fabs eps) 8.2e+62) (* (* 2.0 (exp (- x))) 0.5) (* 0.5 (- (exp (- (* x (- 1.0 (fabs eps))))) -1.0))))
double code(double x, double eps) {
double tmp;
if (fabs(eps) <= 8.2e+62) {
tmp = (2.0 * exp(-x)) * 0.5;
} else {
tmp = 0.5 * (exp(-(x * (1.0 - fabs(eps)))) - -1.0);
}
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 (abs(eps) <= 8.2d+62) then
tmp = (2.0d0 * exp(-x)) * 0.5d0
else
tmp = 0.5d0 * (exp(-(x * (1.0d0 - abs(eps)))) - (-1.0d0))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (Math.abs(eps) <= 8.2e+62) {
tmp = (2.0 * Math.exp(-x)) * 0.5;
} else {
tmp = 0.5 * (Math.exp(-(x * (1.0 - Math.abs(eps)))) - -1.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if math.fabs(eps) <= 8.2e+62: tmp = (2.0 * math.exp(-x)) * 0.5 else: tmp = 0.5 * (math.exp(-(x * (1.0 - math.fabs(eps)))) - -1.0) return tmp
function code(x, eps) tmp = 0.0 if (abs(eps) <= 8.2e+62) tmp = Float64(Float64(2.0 * exp(Float64(-x))) * 0.5); else tmp = Float64(0.5 * Float64(exp(Float64(-Float64(x * Float64(1.0 - abs(eps))))) - -1.0)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (abs(eps) <= 8.2e+62) tmp = (2.0 * exp(-x)) * 0.5; else tmp = 0.5 * (exp(-(x * (1.0 - abs(eps)))) - -1.0); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[Abs[eps], $MachinePrecision], 8.2e+62], N[(N[(2.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(0.5 * N[(N[Exp[(-N[(x * N[(1.0 - N[Abs[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision])], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|\varepsilon\right| \leq 8.2 \cdot 10^{+62}:\\
\;\;\;\;\left(2 \cdot e^{-x}\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{-x \cdot \left(1 - \left|\varepsilon\right|\right)} - -1\right)\\
\end{array}
if eps < 8.19999999999999967e62Initial program 73.4%
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-+.f6498.9
Applied rewrites98.9%
Taylor expanded in eps around 0
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f6470.8
Applied rewrites70.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.8
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-*.f6470.8
Applied rewrites70.8%
if 8.19999999999999967e62 < eps Initial program 73.4%
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-+.f6498.9
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites64.3%
(FPCore (x eps) :precision binary64 (if (<= (fabs eps) 195000000000.0) (* (* 2.0 (exp (- x))) 0.5) (* 0.5 (+ 2.0 (* x (- x 2.0))))))
double code(double x, double eps) {
double tmp;
if (fabs(eps) <= 195000000000.0) {
tmp = (2.0 * exp(-x)) * 0.5;
} else {
tmp = 0.5 * (2.0 + (x * (x - 2.0)));
}
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 (abs(eps) <= 195000000000.0d0) then
tmp = (2.0d0 * exp(-x)) * 0.5d0
else
tmp = 0.5d0 * (2.0d0 + (x * (x - 2.0d0)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (Math.abs(eps) <= 195000000000.0) {
tmp = (2.0 * Math.exp(-x)) * 0.5;
} else {
tmp = 0.5 * (2.0 + (x * (x - 2.0)));
}
return tmp;
}
def code(x, eps): tmp = 0 if math.fabs(eps) <= 195000000000.0: tmp = (2.0 * math.exp(-x)) * 0.5 else: tmp = 0.5 * (2.0 + (x * (x - 2.0))) return tmp
function code(x, eps) tmp = 0.0 if (abs(eps) <= 195000000000.0) tmp = Float64(Float64(2.0 * exp(Float64(-x))) * 0.5); else tmp = Float64(0.5 * Float64(2.0 + Float64(x * Float64(x - 2.0)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (abs(eps) <= 195000000000.0) tmp = (2.0 * exp(-x)) * 0.5; else tmp = 0.5 * (2.0 + (x * (x - 2.0))); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[Abs[eps], $MachinePrecision], 195000000000.0], N[(N[(2.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(0.5 * N[(2.0 + N[(x * N[(x - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|\varepsilon\right| \leq 195000000000:\\
\;\;\;\;\left(2 \cdot e^{-x}\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(2 + x \cdot \left(x - 2\right)\right)\\
\end{array}
if eps < 1.95e11Initial program 73.4%
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-+.f6498.9
Applied rewrites98.9%
Taylor expanded in eps around 0
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f6470.8
Applied rewrites70.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.8
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-*.f6470.8
Applied rewrites70.8%
if 1.95e11 < eps Initial program 73.4%
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-+.f6498.9
Applied rewrites98.9%
Taylor expanded in eps around 0
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f6470.8
Applied rewrites70.8%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6457.3
Applied rewrites57.3%
(FPCore (x eps)
:precision binary64
(if (<= x 3.4e-97)
(* 0.5 (- (exp (- x)) -1.0))
(if (<= x 5.7e+194)
(* (- (fma (- (fabs eps) 1.0) x 1.0) -1.0) 0.5)
(* 0.5 (+ 2.0 (* x (- x 2.0)))))))double code(double x, double eps) {
double tmp;
if (x <= 3.4e-97) {
tmp = 0.5 * (exp(-x) - -1.0);
} else if (x <= 5.7e+194) {
tmp = (fma((fabs(eps) - 1.0), x, 1.0) - -1.0) * 0.5;
} else {
tmp = 0.5 * (2.0 + (x * (x - 2.0)));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 3.4e-97) tmp = Float64(0.5 * Float64(exp(Float64(-x)) - -1.0)); elseif (x <= 5.7e+194) tmp = Float64(Float64(fma(Float64(abs(eps) - 1.0), x, 1.0) - -1.0) * 0.5); else tmp = Float64(0.5 * Float64(2.0 + Float64(x * Float64(x - 2.0)))); end return tmp end
code[x_, eps_] := If[LessEqual[x, 3.4e-97], N[(0.5 * N[(N[Exp[(-x)], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.7e+194], N[(N[(N[(N[(N[Abs[eps], $MachinePrecision] - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(0.5 * N[(2.0 + N[(x * N[(x - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;x \leq 3.4 \cdot 10^{-97}:\\
\;\;\;\;0.5 \cdot \left(e^{-x} - -1\right)\\
\mathbf{elif}\;x \leq 5.7 \cdot 10^{+194}:\\
\;\;\;\;\left(\mathsf{fma}\left(\left|\varepsilon\right| - 1, x, 1\right) - -1\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(2 + x \cdot \left(x - 2\right)\right)\\
\end{array}
if x < 3.3999999999999999e-97Initial program 73.4%
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-+.f6498.9
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites64.3%
Taylor expanded in eps around inf
lower-*.f6464.5
Applied rewrites64.5%
Taylor expanded in eps around 0
lower-exp.f64N/A
lower-neg.f6457.2
Applied rewrites57.2%
if 3.3999999999999999e-97 < x < 5.69999999999999983e194Initial program 73.4%
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-+.f6498.9
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites64.3%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6449.8
Applied rewrites49.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6449.8
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6449.8
Applied rewrites49.8%
if 5.69999999999999983e194 < x Initial program 73.4%
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-+.f6498.9
Applied rewrites98.9%
Taylor expanded in eps around 0
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f6470.8
Applied rewrites70.8%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6457.3
Applied rewrites57.3%
(FPCore (x eps) :precision binary64 (* 0.5 (+ 2.0 (* x (- x 2.0)))))
double code(double x, double eps) {
return 0.5 * (2.0 + (x * (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 = 0.5d0 * (2.0d0 + (x * (x - 2.0d0)))
end function
public static double code(double x, double eps) {
return 0.5 * (2.0 + (x * (x - 2.0)));
}
def code(x, eps): return 0.5 * (2.0 + (x * (x - 2.0)))
function code(x, eps) return Float64(0.5 * Float64(2.0 + Float64(x * Float64(x - 2.0)))) end
function tmp = code(x, eps) tmp = 0.5 * (2.0 + (x * (x - 2.0))); end
code[x_, eps_] := N[(0.5 * N[(2.0 + N[(x * N[(x - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
0.5 \cdot \left(2 + x \cdot \left(x - 2\right)\right)
Initial program 73.4%
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-+.f6498.9
Applied rewrites98.9%
Taylor expanded in eps around 0
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f6470.8
Applied rewrites70.8%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6457.3
Applied rewrites57.3%
(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
1
Initial program 73.4%
Taylor expanded in x around 0
Applied rewrites44.1%
herbie shell --seed 2025170
(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))