
(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 16 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 (- (* x (+ 1.0 eps))))))))
double code(double x, double eps) {
return 0.5 * (exp(-(x * (1.0 - eps))) - (-1.0 * exp(-(x * (1.0 + eps)))));
}
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 * (exp(-(x * (1.0d0 - eps))) - ((-1.0d0) * exp(-(x * (1.0d0 + eps)))))
end function
public static double code(double x, double eps) {
return 0.5 * (Math.exp(-(x * (1.0 - eps))) - (-1.0 * Math.exp(-(x * (1.0 + eps)))));
}
def code(x, eps): return 0.5 * (math.exp(-(x * (1.0 - eps))) - (-1.0 * math.exp(-(x * (1.0 + eps)))))
function code(x, eps) return Float64(0.5 * Float64(exp(Float64(-Float64(x * Float64(1.0 - eps)))) - Float64(-1.0 * exp(Float64(-Float64(x * Float64(1.0 + eps))))))) end
function tmp = code(x, eps) tmp = 0.5 * (exp(-(x * (1.0 - eps))) - (-1.0 * exp(-(x * (1.0 + eps))))); 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 * N[(1.0 + eps), $MachinePrecision]), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
0.5 \cdot \left(e^{-x \cdot \left(1 - \varepsilon\right)} - -1 \cdot e^{-x \cdot \left(1 + \varepsilon\right)}\right)
Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.1%
Applied rewrites99.1%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (/ 1.0 (fabs eps))))
(if (<= x -2e-295)
(* (+ 1.0 (exp (* (- (- (fabs eps)) 1.0) x))) 0.5)
(if (<= x 390000.0)
(* 0.5 (- (exp (* (fabs eps) x)) -1.0))
(if (<= x 6.5e+267)
(/
(-
(* (+ 1.0 t_0) (exp (- (* (* -1.0 (fabs eps)) x))))
(- t_0 1.0))
2.0)
(* x (+ (* 0.5 0.0) (/ x (* x x)))))))))double code(double x, double eps) {
double t_0 = 1.0 / fabs(eps);
double tmp;
if (x <= -2e-295) {
tmp = (1.0 + exp(((-fabs(eps) - 1.0) * x))) * 0.5;
} else if (x <= 390000.0) {
tmp = 0.5 * (exp((fabs(eps) * x)) - -1.0);
} else if (x <= 6.5e+267) {
tmp = (((1.0 + t_0) * exp(-((-1.0 * fabs(eps)) * x))) - (t_0 - 1.0)) / 2.0;
} else {
tmp = x * ((0.5 * 0.0) + (x / (x * 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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 / abs(eps)
if (x <= (-2d-295)) then
tmp = (1.0d0 + exp(((-abs(eps) - 1.0d0) * x))) * 0.5d0
else if (x <= 390000.0d0) then
tmp = 0.5d0 * (exp((abs(eps) * x)) - (-1.0d0))
else if (x <= 6.5d+267) then
tmp = (((1.0d0 + t_0) * exp(-(((-1.0d0) * abs(eps)) * x))) - (t_0 - 1.0d0)) / 2.0d0
else
tmp = x * ((0.5d0 * 0.0d0) + (x / (x * x)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = 1.0 / Math.abs(eps);
double tmp;
if (x <= -2e-295) {
tmp = (1.0 + Math.exp(((-Math.abs(eps) - 1.0) * x))) * 0.5;
} else if (x <= 390000.0) {
tmp = 0.5 * (Math.exp((Math.abs(eps) * x)) - -1.0);
} else if (x <= 6.5e+267) {
tmp = (((1.0 + t_0) * Math.exp(-((-1.0 * Math.abs(eps)) * x))) - (t_0 - 1.0)) / 2.0;
} else {
tmp = x * ((0.5 * 0.0) + (x / (x * x)));
}
return tmp;
}
def code(x, eps): t_0 = 1.0 / math.fabs(eps) tmp = 0 if x <= -2e-295: tmp = (1.0 + math.exp(((-math.fabs(eps) - 1.0) * x))) * 0.5 elif x <= 390000.0: tmp = 0.5 * (math.exp((math.fabs(eps) * x)) - -1.0) elif x <= 6.5e+267: tmp = (((1.0 + t_0) * math.exp(-((-1.0 * math.fabs(eps)) * x))) - (t_0 - 1.0)) / 2.0 else: tmp = x * ((0.5 * 0.0) + (x / (x * x))) return tmp
function code(x, eps) t_0 = Float64(1.0 / abs(eps)) tmp = 0.0 if (x <= -2e-295) tmp = Float64(Float64(1.0 + exp(Float64(Float64(Float64(-abs(eps)) - 1.0) * x))) * 0.5); elseif (x <= 390000.0) tmp = Float64(0.5 * Float64(exp(Float64(abs(eps) * x)) - -1.0)); elseif (x <= 6.5e+267) tmp = Float64(Float64(Float64(Float64(1.0 + t_0) * exp(Float64(-Float64(Float64(-1.0 * abs(eps)) * x)))) - Float64(t_0 - 1.0)) / 2.0); else tmp = Float64(x * Float64(Float64(0.5 * 0.0) + Float64(x / Float64(x * x)))); end return tmp end
function tmp_2 = code(x, eps) t_0 = 1.0 / abs(eps); tmp = 0.0; if (x <= -2e-295) tmp = (1.0 + exp(((-abs(eps) - 1.0) * x))) * 0.5; elseif (x <= 390000.0) tmp = 0.5 * (exp((abs(eps) * x)) - -1.0); elseif (x <= 6.5e+267) tmp = (((1.0 + t_0) * exp(-((-1.0 * abs(eps)) * x))) - (t_0 - 1.0)) / 2.0; else tmp = x * ((0.5 * 0.0) + (x / (x * x))); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 / N[Abs[eps], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2e-295], N[(N[(1.0 + N[Exp[N[(N[((-N[Abs[eps], $MachinePrecision]) - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 390000.0], N[(0.5 * N[(N[Exp[N[(N[Abs[eps], $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 6.5e+267], N[(N[(N[(N[(1.0 + t$95$0), $MachinePrecision] * N[Exp[(-N[(N[(-1.0 * N[Abs[eps], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(x * N[(N[(0.5 * 0.0), $MachinePrecision] + N[(x / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \frac{1}{\left|\varepsilon\right|}\\
\mathbf{if}\;x \leq -2 \cdot 10^{-295}:\\
\;\;\;\;\left(1 + e^{\left(\left(-\left|\varepsilon\right|\right) - 1\right) \cdot x}\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 390000:\\
\;\;\;\;0.5 \cdot \left(e^{\left|\varepsilon\right| \cdot x} - -1\right)\\
\mathbf{elif}\;x \leq 6.5 \cdot 10^{+267}:\\
\;\;\;\;\frac{\left(1 + t\_0\right) \cdot e^{-\left(-1 \cdot \left|\varepsilon\right|\right) \cdot x} - \left(t\_0 - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(0.5 \cdot 0 + \frac{x}{x \cdot x}\right)\\
\end{array}
if x < -2.0000000000000001e-295Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.1%
Applied rewrites99.1%
Taylor expanded in x around 0
Applied rewrites64.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6464.0%
Applied rewrites64.0%
if -2.0000000000000001e-295 < x < 3.9e5Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.1%
Applied rewrites99.1%
Taylor expanded in x around 0
Applied rewrites63.8%
Taylor expanded in eps around inf
lower-*.f6464.0%
Applied rewrites64.0%
if 3.9e5 < x < 6.4999999999999998e267Initial program 74.1%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6438.7%
Applied rewrites38.7%
Taylor expanded in eps around inf
lower-*.f6444.8%
Applied rewrites44.8%
if 6.4999999999999998e267 < x Initial program 74.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites43.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites43.6%
lift-/.f64N/A
mult-flipN/A
rgt-mult-inverseN/A
mult-flip-revN/A
frac-timesN/A
*-rgt-identityN/A
lower-/.f64N/A
lower-*.f6429.8%
Applied rewrites29.8%
Taylor expanded in eps around 0
Applied rewrites29.9%
(FPCore (x eps)
:precision binary64
(if (<= x -2e-295)
(* (+ 1.0 (exp (* (- (- (fabs eps)) 1.0) x))) 0.5)
(if (<= x 6.0)
(* 0.5 (- (exp (* (fabs eps) x)) -1.0))
(if (<= x 1.45e+89)
(* (* 2.0 (exp (- x))) 0.5)
(if (<= x 6.5e+267)
(* 0.5 (- (exp (- (* x (- 1.0 (fabs eps))))) -1.0))
(* x (+ (* 0.5 0.0) (/ x (* x x)))))))))double code(double x, double eps) {
double tmp;
if (x <= -2e-295) {
tmp = (1.0 + exp(((-fabs(eps) - 1.0) * x))) * 0.5;
} else if (x <= 6.0) {
tmp = 0.5 * (exp((fabs(eps) * x)) - -1.0);
} else if (x <= 1.45e+89) {
tmp = (2.0 * exp(-x)) * 0.5;
} else if (x <= 6.5e+267) {
tmp = 0.5 * (exp(-(x * (1.0 - fabs(eps)))) - -1.0);
} else {
tmp = x * ((0.5 * 0.0) + (x / (x * 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 <= (-2d-295)) then
tmp = (1.0d0 + exp(((-abs(eps) - 1.0d0) * x))) * 0.5d0
else if (x <= 6.0d0) then
tmp = 0.5d0 * (exp((abs(eps) * x)) - (-1.0d0))
else if (x <= 1.45d+89) then
tmp = (2.0d0 * exp(-x)) * 0.5d0
else if (x <= 6.5d+267) then
tmp = 0.5d0 * (exp(-(x * (1.0d0 - abs(eps)))) - (-1.0d0))
else
tmp = x * ((0.5d0 * 0.0d0) + (x / (x * x)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -2e-295) {
tmp = (1.0 + Math.exp(((-Math.abs(eps) - 1.0) * x))) * 0.5;
} else if (x <= 6.0) {
tmp = 0.5 * (Math.exp((Math.abs(eps) * x)) - -1.0);
} else if (x <= 1.45e+89) {
tmp = (2.0 * Math.exp(-x)) * 0.5;
} else if (x <= 6.5e+267) {
tmp = 0.5 * (Math.exp(-(x * (1.0 - Math.abs(eps)))) - -1.0);
} else {
tmp = x * ((0.5 * 0.0) + (x / (x * x)));
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -2e-295: tmp = (1.0 + math.exp(((-math.fabs(eps) - 1.0) * x))) * 0.5 elif x <= 6.0: tmp = 0.5 * (math.exp((math.fabs(eps) * x)) - -1.0) elif x <= 1.45e+89: tmp = (2.0 * math.exp(-x)) * 0.5 elif x <= 6.5e+267: tmp = 0.5 * (math.exp(-(x * (1.0 - math.fabs(eps)))) - -1.0) else: tmp = x * ((0.5 * 0.0) + (x / (x * x))) return tmp
function code(x, eps) tmp = 0.0 if (x <= -2e-295) tmp = Float64(Float64(1.0 + exp(Float64(Float64(Float64(-abs(eps)) - 1.0) * x))) * 0.5); elseif (x <= 6.0) tmp = Float64(0.5 * Float64(exp(Float64(abs(eps) * x)) - -1.0)); elseif (x <= 1.45e+89) tmp = Float64(Float64(2.0 * exp(Float64(-x))) * 0.5); elseif (x <= 6.5e+267) tmp = Float64(0.5 * Float64(exp(Float64(-Float64(x * Float64(1.0 - abs(eps))))) - -1.0)); else tmp = Float64(x * Float64(Float64(0.5 * 0.0) + Float64(x / Float64(x * x)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -2e-295) tmp = (1.0 + exp(((-abs(eps) - 1.0) * x))) * 0.5; elseif (x <= 6.0) tmp = 0.5 * (exp((abs(eps) * x)) - -1.0); elseif (x <= 1.45e+89) tmp = (2.0 * exp(-x)) * 0.5; elseif (x <= 6.5e+267) tmp = 0.5 * (exp(-(x * (1.0 - abs(eps)))) - -1.0); else tmp = x * ((0.5 * 0.0) + (x / (x * x))); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -2e-295], N[(N[(1.0 + N[Exp[N[(N[((-N[Abs[eps], $MachinePrecision]) - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 6.0], N[(0.5 * N[(N[Exp[N[(N[Abs[eps], $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.45e+89], N[(N[(2.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 6.5e+267], N[(0.5 * N[(N[Exp[(-N[(x * N[(1.0 - N[Abs[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision])], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(0.5 * 0.0), $MachinePrecision] + N[(x / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-295}:\\
\;\;\;\;\left(1 + e^{\left(\left(-\left|\varepsilon\right|\right) - 1\right) \cdot x}\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 6:\\
\;\;\;\;0.5 \cdot \left(e^{\left|\varepsilon\right| \cdot x} - -1\right)\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{+89}:\\
\;\;\;\;\left(2 \cdot e^{-x}\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 6.5 \cdot 10^{+267}:\\
\;\;\;\;0.5 \cdot \left(e^{-x \cdot \left(1 - \left|\varepsilon\right|\right)} - -1\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(0.5 \cdot 0 + \frac{x}{x \cdot x}\right)\\
\end{array}
if x < -2.0000000000000001e-295Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.1%
Applied rewrites99.1%
Taylor expanded in x around 0
Applied rewrites64.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6464.0%
Applied rewrites64.0%
if -2.0000000000000001e-295 < x < 6Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.1%
Applied rewrites99.1%
Taylor expanded in x around 0
Applied rewrites63.8%
Taylor expanded in eps around inf
lower-*.f6464.0%
Applied rewrites64.0%
if 6 < x < 1.4500000000000001e89Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.1%
Applied rewrites99.1%
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.6%
Applied rewrites70.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.6%
lift--.f64N/A
lift-*.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-*.f6470.6%
Applied rewrites70.6%
if 1.4500000000000001e89 < x < 6.4999999999999998e267Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.1%
Applied rewrites99.1%
Taylor expanded in x around 0
Applied rewrites63.8%
if 6.4999999999999998e267 < x Initial program 74.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites43.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites43.6%
lift-/.f64N/A
mult-flipN/A
rgt-mult-inverseN/A
mult-flip-revN/A
frac-timesN/A
*-rgt-identityN/A
lower-/.f64N/A
lower-*.f6429.8%
Applied rewrites29.8%
Taylor expanded in eps around 0
Applied rewrites29.9%
(FPCore (x eps) :precision binary64 (if (<= (fabs eps) 3.7e+38) (* (* 2.0 (exp (- x))) 0.5) (* 0.5 (- (exp (* (fabs eps) x)) -1.0))))
double code(double x, double eps) {
double tmp;
if (fabs(eps) <= 3.7e+38) {
tmp = (2.0 * exp(-x)) * 0.5;
} else {
tmp = 0.5 * (exp((fabs(eps) * x)) - -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.7d+38) then
tmp = (2.0d0 * exp(-x)) * 0.5d0
else
tmp = 0.5d0 * (exp((abs(eps) * x)) - (-1.0d0))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (Math.abs(eps) <= 3.7e+38) {
tmp = (2.0 * Math.exp(-x)) * 0.5;
} else {
tmp = 0.5 * (Math.exp((Math.abs(eps) * x)) - -1.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if math.fabs(eps) <= 3.7e+38: tmp = (2.0 * math.exp(-x)) * 0.5 else: tmp = 0.5 * (math.exp((math.fabs(eps) * x)) - -1.0) return tmp
function code(x, eps) tmp = 0.0 if (abs(eps) <= 3.7e+38) tmp = Float64(Float64(2.0 * exp(Float64(-x))) * 0.5); else tmp = Float64(0.5 * Float64(exp(Float64(abs(eps) * x)) - -1.0)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (abs(eps) <= 3.7e+38) tmp = (2.0 * exp(-x)) * 0.5; else tmp = 0.5 * (exp((abs(eps) * x)) - -1.0); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[Abs[eps], $MachinePrecision], 3.7e+38], 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] - -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|\varepsilon\right| \leq 3.7 \cdot 10^{+38}:\\
\;\;\;\;\left(2 \cdot e^{-x}\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{\left|\varepsilon\right| \cdot x} - -1\right)\\
\end{array}
if eps < 3.7000000000000001e38Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.1%
Applied rewrites99.1%
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.6%
Applied rewrites70.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.6%
lift--.f64N/A
lift-*.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-*.f6470.6%
Applied rewrites70.6%
if 3.7000000000000001e38 < eps Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.1%
Applied rewrites99.1%
Taylor expanded in x around 0
Applied rewrites63.8%
Taylor expanded in eps around inf
lower-*.f6464.0%
Applied rewrites64.0%
(FPCore (x eps) :precision binary64 (if (<= (fabs eps) 3.7e+38) (* (* 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) <= 3.7e+38) {
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) <= 3.7d+38) 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) <= 3.7e+38) {
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) <= 3.7e+38: 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) <= 3.7e+38) 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) <= 3.7e+38) 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], 3.7e+38], 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 3.7 \cdot 10^{+38}:\\
\;\;\;\;\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 < 3.7000000000000001e38Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.1%
Applied rewrites99.1%
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.6%
Applied rewrites70.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.6%
lift--.f64N/A
lift-*.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-*.f6470.6%
Applied rewrites70.6%
if 3.7000000000000001e38 < eps Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.1%
Applied rewrites99.1%
Taylor expanded in x around 0
Applied rewrites63.8%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (/ 1.0 (fabs eps)))
(t_1 (- t_0 1.0))
(t_2 (- (fabs eps) 1.0))
(t_3 (* (+ 1.0 t_0) t_2))
(t_4 (+ 1.0 (fabs eps)))
(t_5 (* -1.0 (* t_4 t_1))))
(if (<= x -8200.0)
(* 0.5 (- (exp (- x)) -1.0))
(if (<= x -1e-190)
(+
1.0
(*
0.5
(*
x
(-
t_3
(*
-1.0
(*
(/ (- (* (fabs eps) (fabs eps)) (* 1.0 1.0)) t_2)
t_1))))))
(if (<= x 2.3e-251)
(+
1.0
(*
0.5
(* x (- t_3 (* -1.0 (* t_4 (* (- 1.0 (/ 1.0 t_0)) t_0)))))))
(if (<= x 850000.0)
(+
1.0
(*
0.5
(* x (- (/ (* t_2 (- (fabs eps) -1.0)) (fabs eps)) t_5))))
(if (<= x 1.05e+135)
(* x (* 0.5 (- t_3 t_5)))
(if (<= x 4.4e+267)
(* 0.5 (+ 2.0 (* x (- x 2.0))))
(* x (+ (* 0.5 0.0) (/ x (* x x))))))))))))double code(double x, double eps) {
double t_0 = 1.0 / fabs(eps);
double t_1 = t_0 - 1.0;
double t_2 = fabs(eps) - 1.0;
double t_3 = (1.0 + t_0) * t_2;
double t_4 = 1.0 + fabs(eps);
double t_5 = -1.0 * (t_4 * t_1);
double tmp;
if (x <= -8200.0) {
tmp = 0.5 * (exp(-x) - -1.0);
} else if (x <= -1e-190) {
tmp = 1.0 + (0.5 * (x * (t_3 - (-1.0 * ((((fabs(eps) * fabs(eps)) - (1.0 * 1.0)) / t_2) * t_1)))));
} else if (x <= 2.3e-251) {
tmp = 1.0 + (0.5 * (x * (t_3 - (-1.0 * (t_4 * ((1.0 - (1.0 / t_0)) * t_0))))));
} else if (x <= 850000.0) {
tmp = 1.0 + (0.5 * (x * (((t_2 * (fabs(eps) - -1.0)) / fabs(eps)) - t_5)));
} else if (x <= 1.05e+135) {
tmp = x * (0.5 * (t_3 - t_5));
} else if (x <= 4.4e+267) {
tmp = 0.5 * (2.0 + (x * (x - 2.0)));
} else {
tmp = x * ((0.5 * 0.0) + (x / (x * 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) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = 1.0d0 / abs(eps)
t_1 = t_0 - 1.0d0
t_2 = abs(eps) - 1.0d0
t_3 = (1.0d0 + t_0) * t_2
t_4 = 1.0d0 + abs(eps)
t_5 = (-1.0d0) * (t_4 * t_1)
if (x <= (-8200.0d0)) then
tmp = 0.5d0 * (exp(-x) - (-1.0d0))
else if (x <= (-1d-190)) then
tmp = 1.0d0 + (0.5d0 * (x * (t_3 - ((-1.0d0) * ((((abs(eps) * abs(eps)) - (1.0d0 * 1.0d0)) / t_2) * t_1)))))
else if (x <= 2.3d-251) then
tmp = 1.0d0 + (0.5d0 * (x * (t_3 - ((-1.0d0) * (t_4 * ((1.0d0 - (1.0d0 / t_0)) * t_0))))))
else if (x <= 850000.0d0) then
tmp = 1.0d0 + (0.5d0 * (x * (((t_2 * (abs(eps) - (-1.0d0))) / abs(eps)) - t_5)))
else if (x <= 1.05d+135) then
tmp = x * (0.5d0 * (t_3 - t_5))
else if (x <= 4.4d+267) then
tmp = 0.5d0 * (2.0d0 + (x * (x - 2.0d0)))
else
tmp = x * ((0.5d0 * 0.0d0) + (x / (x * x)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = 1.0 / Math.abs(eps);
double t_1 = t_0 - 1.0;
double t_2 = Math.abs(eps) - 1.0;
double t_3 = (1.0 + t_0) * t_2;
double t_4 = 1.0 + Math.abs(eps);
double t_5 = -1.0 * (t_4 * t_1);
double tmp;
if (x <= -8200.0) {
tmp = 0.5 * (Math.exp(-x) - -1.0);
} else if (x <= -1e-190) {
tmp = 1.0 + (0.5 * (x * (t_3 - (-1.0 * ((((Math.abs(eps) * Math.abs(eps)) - (1.0 * 1.0)) / t_2) * t_1)))));
} else if (x <= 2.3e-251) {
tmp = 1.0 + (0.5 * (x * (t_3 - (-1.0 * (t_4 * ((1.0 - (1.0 / t_0)) * t_0))))));
} else if (x <= 850000.0) {
tmp = 1.0 + (0.5 * (x * (((t_2 * (Math.abs(eps) - -1.0)) / Math.abs(eps)) - t_5)));
} else if (x <= 1.05e+135) {
tmp = x * (0.5 * (t_3 - t_5));
} else if (x <= 4.4e+267) {
tmp = 0.5 * (2.0 + (x * (x - 2.0)));
} else {
tmp = x * ((0.5 * 0.0) + (x / (x * x)));
}
return tmp;
}
def code(x, eps): t_0 = 1.0 / math.fabs(eps) t_1 = t_0 - 1.0 t_2 = math.fabs(eps) - 1.0 t_3 = (1.0 + t_0) * t_2 t_4 = 1.0 + math.fabs(eps) t_5 = -1.0 * (t_4 * t_1) tmp = 0 if x <= -8200.0: tmp = 0.5 * (math.exp(-x) - -1.0) elif x <= -1e-190: tmp = 1.0 + (0.5 * (x * (t_3 - (-1.0 * ((((math.fabs(eps) * math.fabs(eps)) - (1.0 * 1.0)) / t_2) * t_1))))) elif x <= 2.3e-251: tmp = 1.0 + (0.5 * (x * (t_3 - (-1.0 * (t_4 * ((1.0 - (1.0 / t_0)) * t_0)))))) elif x <= 850000.0: tmp = 1.0 + (0.5 * (x * (((t_2 * (math.fabs(eps) - -1.0)) / math.fabs(eps)) - t_5))) elif x <= 1.05e+135: tmp = x * (0.5 * (t_3 - t_5)) elif x <= 4.4e+267: tmp = 0.5 * (2.0 + (x * (x - 2.0))) else: tmp = x * ((0.5 * 0.0) + (x / (x * x))) return tmp
function code(x, eps) t_0 = Float64(1.0 / abs(eps)) t_1 = Float64(t_0 - 1.0) t_2 = Float64(abs(eps) - 1.0) t_3 = Float64(Float64(1.0 + t_0) * t_2) t_4 = Float64(1.0 + abs(eps)) t_5 = Float64(-1.0 * Float64(t_4 * t_1)) tmp = 0.0 if (x <= -8200.0) tmp = Float64(0.5 * Float64(exp(Float64(-x)) - -1.0)); elseif (x <= -1e-190) tmp = Float64(1.0 + Float64(0.5 * Float64(x * Float64(t_3 - Float64(-1.0 * Float64(Float64(Float64(Float64(abs(eps) * abs(eps)) - Float64(1.0 * 1.0)) / t_2) * t_1)))))); elseif (x <= 2.3e-251) tmp = Float64(1.0 + Float64(0.5 * Float64(x * Float64(t_3 - Float64(-1.0 * Float64(t_4 * Float64(Float64(1.0 - Float64(1.0 / t_0)) * t_0))))))); elseif (x <= 850000.0) tmp = Float64(1.0 + Float64(0.5 * Float64(x * Float64(Float64(Float64(t_2 * Float64(abs(eps) - -1.0)) / abs(eps)) - t_5)))); elseif (x <= 1.05e+135) tmp = Float64(x * Float64(0.5 * Float64(t_3 - t_5))); elseif (x <= 4.4e+267) tmp = Float64(0.5 * Float64(2.0 + Float64(x * Float64(x - 2.0)))); else tmp = Float64(x * Float64(Float64(0.5 * 0.0) + Float64(x / Float64(x * x)))); end return tmp end
function tmp_2 = code(x, eps) t_0 = 1.0 / abs(eps); t_1 = t_0 - 1.0; t_2 = abs(eps) - 1.0; t_3 = (1.0 + t_0) * t_2; t_4 = 1.0 + abs(eps); t_5 = -1.0 * (t_4 * t_1); tmp = 0.0; if (x <= -8200.0) tmp = 0.5 * (exp(-x) - -1.0); elseif (x <= -1e-190) tmp = 1.0 + (0.5 * (x * (t_3 - (-1.0 * ((((abs(eps) * abs(eps)) - (1.0 * 1.0)) / t_2) * t_1))))); elseif (x <= 2.3e-251) tmp = 1.0 + (0.5 * (x * (t_3 - (-1.0 * (t_4 * ((1.0 - (1.0 / t_0)) * t_0)))))); elseif (x <= 850000.0) tmp = 1.0 + (0.5 * (x * (((t_2 * (abs(eps) - -1.0)) / abs(eps)) - t_5))); elseif (x <= 1.05e+135) tmp = x * (0.5 * (t_3 - t_5)); elseif (x <= 4.4e+267) tmp = 0.5 * (2.0 + (x * (x - 2.0))); else tmp = x * ((0.5 * 0.0) + (x / (x * x))); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 / N[Abs[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - 1.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Abs[eps], $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$3 = N[(N[(1.0 + t$95$0), $MachinePrecision] * t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(1.0 + N[Abs[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(-1.0 * N[(t$95$4 * t$95$1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -8200.0], N[(0.5 * N[(N[Exp[(-x)], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1e-190], N[(1.0 + N[(0.5 * N[(x * N[(t$95$3 - N[(-1.0 * N[(N[(N[(N[(N[Abs[eps], $MachinePrecision] * N[Abs[eps], $MachinePrecision]), $MachinePrecision] - N[(1.0 * 1.0), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.3e-251], N[(1.0 + N[(0.5 * N[(x * N[(t$95$3 - N[(-1.0 * N[(t$95$4 * N[(N[(1.0 - N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 850000.0], N[(1.0 + N[(0.5 * N[(x * N[(N[(N[(t$95$2 * N[(N[Abs[eps], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] / N[Abs[eps], $MachinePrecision]), $MachinePrecision] - t$95$5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.05e+135], N[(x * N[(0.5 * N[(t$95$3 - t$95$5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.4e+267], N[(0.5 * N[(2.0 + N[(x * N[(x - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(0.5 * 0.0), $MachinePrecision] + N[(x / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]]]
\begin{array}{l}
t_0 := \frac{1}{\left|\varepsilon\right|}\\
t_1 := t\_0 - 1\\
t_2 := \left|\varepsilon\right| - 1\\
t_3 := \left(1 + t\_0\right) \cdot t\_2\\
t_4 := 1 + \left|\varepsilon\right|\\
t_5 := -1 \cdot \left(t\_4 \cdot t\_1\right)\\
\mathbf{if}\;x \leq -8200:\\
\;\;\;\;0.5 \cdot \left(e^{-x} - -1\right)\\
\mathbf{elif}\;x \leq -1 \cdot 10^{-190}:\\
\;\;\;\;1 + 0.5 \cdot \left(x \cdot \left(t\_3 - -1 \cdot \left(\frac{\left|\varepsilon\right| \cdot \left|\varepsilon\right| - 1 \cdot 1}{t\_2} \cdot t\_1\right)\right)\right)\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{-251}:\\
\;\;\;\;1 + 0.5 \cdot \left(x \cdot \left(t\_3 - -1 \cdot \left(t\_4 \cdot \left(\left(1 - \frac{1}{t\_0}\right) \cdot t\_0\right)\right)\right)\right)\\
\mathbf{elif}\;x \leq 850000:\\
\;\;\;\;1 + 0.5 \cdot \left(x \cdot \left(\frac{t\_2 \cdot \left(\left|\varepsilon\right| - -1\right)}{\left|\varepsilon\right|} - t\_5\right)\right)\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{+135}:\\
\;\;\;\;x \cdot \left(0.5 \cdot \left(t\_3 - t\_5\right)\right)\\
\mathbf{elif}\;x \leq 4.4 \cdot 10^{+267}:\\
\;\;\;\;0.5 \cdot \left(2 + x \cdot \left(x - 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(0.5 \cdot 0 + \frac{x}{x \cdot x}\right)\\
\end{array}
if x < -8200Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.1%
Applied rewrites99.1%
Taylor expanded in x around 0
Applied rewrites63.8%
Taylor expanded in eps around 0
lower-exp.f64N/A
lower-neg.f6457.0%
Applied rewrites57.0%
if -8200 < x < -1e-190Initial program 74.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites43.7%
lift-+.f64N/A
+-commutativeN/A
flip-+N/A
lower-unsound--.f64N/A
lower-unsound-/.f64N/A
lower-unsound--.f64N/A
lower-unsound-*.f64N/A
lower-unsound-*.f6451.6%
Applied rewrites51.6%
if -1e-190 < x < 2.3000000000000002e-251Initial program 74.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites43.7%
lift--.f64N/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f6444.3%
Applied rewrites44.3%
if 2.3000000000000002e-251 < x < 8.5e5Initial program 74.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites43.7%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
associate-*r/N/A
lower-/.f64N/A
*-lft-identityN/A
+-commutativeN/A
lift-+.f64N/A
lower-*.f6452.3%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6452.3%
Applied rewrites52.3%
if 8.5e5 < x < 1.05e135Initial program 74.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites43.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites43.6%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f64N/A
lower-/.f6416.1%
Applied rewrites16.1%
if 1.05e135 < x < 4.4000000000000002e267Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.1%
Applied rewrites99.1%
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.6%
Applied rewrites70.6%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6457.3%
Applied rewrites57.3%
if 4.4000000000000002e267 < x Initial program 74.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites43.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites43.6%
lift-/.f64N/A
mult-flipN/A
rgt-mult-inverseN/A
mult-flip-revN/A
frac-timesN/A
*-rgt-identityN/A
lower-/.f64N/A
lower-*.f6429.8%
Applied rewrites29.8%
Taylor expanded in eps around 0
Applied rewrites29.9%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (/ 1.0 (fabs eps)))
(t_1 (- t_0 1.0))
(t_2 (+ 1.0 (fabs eps)))
(t_3 (- (fabs eps) 1.0))
(t_4 (* (+ 1.0 t_0) t_3))
(t_5 (* -1.0 (* t_2 t_1))))
(if (<= x -3e+106)
(*
0.5
(+ 2.0 (* x (- (* x (+ 1.0 (* -0.3333333333333333 x))) 2.0))))
(if (<= x -1e-190)
(+
1.0
(*
0.5
(*
x
(-
t_4
(*
-1.0
(*
(/ (- (* (fabs eps) (fabs eps)) (* 1.0 1.0)) t_3)
t_1))))))
(if (<= x 2.3e-251)
(+
1.0
(*
0.5
(* x (- t_4 (* -1.0 (* t_2 (* (- 1.0 (/ 1.0 t_0)) t_0)))))))
(if (<= x 850000.0)
(+
1.0
(*
0.5
(* x (- (/ (* t_3 (- (fabs eps) -1.0)) (fabs eps)) t_5))))
(if (<= x 1.05e+135)
(* x (* 0.5 (- t_4 t_5)))
(if (<= x 5.6e+222)
(* 0.5 (+ 2.0 (* x (- x 2.0))))
(* x (+ (* 0.5 0.0) (/ x (* x x))))))))))))double code(double x, double eps) {
double t_0 = 1.0 / fabs(eps);
double t_1 = t_0 - 1.0;
double t_2 = 1.0 + fabs(eps);
double t_3 = fabs(eps) - 1.0;
double t_4 = (1.0 + t_0) * t_3;
double t_5 = -1.0 * (t_2 * t_1);
double tmp;
if (x <= -3e+106) {
tmp = 0.5 * (2.0 + (x * ((x * (1.0 + (-0.3333333333333333 * x))) - 2.0)));
} else if (x <= -1e-190) {
tmp = 1.0 + (0.5 * (x * (t_4 - (-1.0 * ((((fabs(eps) * fabs(eps)) - (1.0 * 1.0)) / t_3) * t_1)))));
} else if (x <= 2.3e-251) {
tmp = 1.0 + (0.5 * (x * (t_4 - (-1.0 * (t_2 * ((1.0 - (1.0 / t_0)) * t_0))))));
} else if (x <= 850000.0) {
tmp = 1.0 + (0.5 * (x * (((t_3 * (fabs(eps) - -1.0)) / fabs(eps)) - t_5)));
} else if (x <= 1.05e+135) {
tmp = x * (0.5 * (t_4 - t_5));
} else if (x <= 5.6e+222) {
tmp = 0.5 * (2.0 + (x * (x - 2.0)));
} else {
tmp = x * ((0.5 * 0.0) + (x / (x * 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) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = 1.0d0 / abs(eps)
t_1 = t_0 - 1.0d0
t_2 = 1.0d0 + abs(eps)
t_3 = abs(eps) - 1.0d0
t_4 = (1.0d0 + t_0) * t_3
t_5 = (-1.0d0) * (t_2 * t_1)
if (x <= (-3d+106)) then
tmp = 0.5d0 * (2.0d0 + (x * ((x * (1.0d0 + ((-0.3333333333333333d0) * x))) - 2.0d0)))
else if (x <= (-1d-190)) then
tmp = 1.0d0 + (0.5d0 * (x * (t_4 - ((-1.0d0) * ((((abs(eps) * abs(eps)) - (1.0d0 * 1.0d0)) / t_3) * t_1)))))
else if (x <= 2.3d-251) then
tmp = 1.0d0 + (0.5d0 * (x * (t_4 - ((-1.0d0) * (t_2 * ((1.0d0 - (1.0d0 / t_0)) * t_0))))))
else if (x <= 850000.0d0) then
tmp = 1.0d0 + (0.5d0 * (x * (((t_3 * (abs(eps) - (-1.0d0))) / abs(eps)) - t_5)))
else if (x <= 1.05d+135) then
tmp = x * (0.5d0 * (t_4 - t_5))
else if (x <= 5.6d+222) then
tmp = 0.5d0 * (2.0d0 + (x * (x - 2.0d0)))
else
tmp = x * ((0.5d0 * 0.0d0) + (x / (x * x)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = 1.0 / Math.abs(eps);
double t_1 = t_0 - 1.0;
double t_2 = 1.0 + Math.abs(eps);
double t_3 = Math.abs(eps) - 1.0;
double t_4 = (1.0 + t_0) * t_3;
double t_5 = -1.0 * (t_2 * t_1);
double tmp;
if (x <= -3e+106) {
tmp = 0.5 * (2.0 + (x * ((x * (1.0 + (-0.3333333333333333 * x))) - 2.0)));
} else if (x <= -1e-190) {
tmp = 1.0 + (0.5 * (x * (t_4 - (-1.0 * ((((Math.abs(eps) * Math.abs(eps)) - (1.0 * 1.0)) / t_3) * t_1)))));
} else if (x <= 2.3e-251) {
tmp = 1.0 + (0.5 * (x * (t_4 - (-1.0 * (t_2 * ((1.0 - (1.0 / t_0)) * t_0))))));
} else if (x <= 850000.0) {
tmp = 1.0 + (0.5 * (x * (((t_3 * (Math.abs(eps) - -1.0)) / Math.abs(eps)) - t_5)));
} else if (x <= 1.05e+135) {
tmp = x * (0.5 * (t_4 - t_5));
} else if (x <= 5.6e+222) {
tmp = 0.5 * (2.0 + (x * (x - 2.0)));
} else {
tmp = x * ((0.5 * 0.0) + (x / (x * x)));
}
return tmp;
}
def code(x, eps): t_0 = 1.0 / math.fabs(eps) t_1 = t_0 - 1.0 t_2 = 1.0 + math.fabs(eps) t_3 = math.fabs(eps) - 1.0 t_4 = (1.0 + t_0) * t_3 t_5 = -1.0 * (t_2 * t_1) tmp = 0 if x <= -3e+106: tmp = 0.5 * (2.0 + (x * ((x * (1.0 + (-0.3333333333333333 * x))) - 2.0))) elif x <= -1e-190: tmp = 1.0 + (0.5 * (x * (t_4 - (-1.0 * ((((math.fabs(eps) * math.fabs(eps)) - (1.0 * 1.0)) / t_3) * t_1))))) elif x <= 2.3e-251: tmp = 1.0 + (0.5 * (x * (t_4 - (-1.0 * (t_2 * ((1.0 - (1.0 / t_0)) * t_0)))))) elif x <= 850000.0: tmp = 1.0 + (0.5 * (x * (((t_3 * (math.fabs(eps) - -1.0)) / math.fabs(eps)) - t_5))) elif x <= 1.05e+135: tmp = x * (0.5 * (t_4 - t_5)) elif x <= 5.6e+222: tmp = 0.5 * (2.0 + (x * (x - 2.0))) else: tmp = x * ((0.5 * 0.0) + (x / (x * x))) return tmp
function code(x, eps) t_0 = Float64(1.0 / abs(eps)) t_1 = Float64(t_0 - 1.0) t_2 = Float64(1.0 + abs(eps)) t_3 = Float64(abs(eps) - 1.0) t_4 = Float64(Float64(1.0 + t_0) * t_3) t_5 = Float64(-1.0 * Float64(t_2 * t_1)) tmp = 0.0 if (x <= -3e+106) tmp = Float64(0.5 * Float64(2.0 + Float64(x * Float64(Float64(x * Float64(1.0 + Float64(-0.3333333333333333 * x))) - 2.0)))); elseif (x <= -1e-190) tmp = Float64(1.0 + Float64(0.5 * Float64(x * Float64(t_4 - Float64(-1.0 * Float64(Float64(Float64(Float64(abs(eps) * abs(eps)) - Float64(1.0 * 1.0)) / t_3) * t_1)))))); elseif (x <= 2.3e-251) tmp = Float64(1.0 + Float64(0.5 * Float64(x * Float64(t_4 - Float64(-1.0 * Float64(t_2 * Float64(Float64(1.0 - Float64(1.0 / t_0)) * t_0))))))); elseif (x <= 850000.0) tmp = Float64(1.0 + Float64(0.5 * Float64(x * Float64(Float64(Float64(t_3 * Float64(abs(eps) - -1.0)) / abs(eps)) - t_5)))); elseif (x <= 1.05e+135) tmp = Float64(x * Float64(0.5 * Float64(t_4 - t_5))); elseif (x <= 5.6e+222) tmp = Float64(0.5 * Float64(2.0 + Float64(x * Float64(x - 2.0)))); else tmp = Float64(x * Float64(Float64(0.5 * 0.0) + Float64(x / Float64(x * x)))); end return tmp end
function tmp_2 = code(x, eps) t_0 = 1.0 / abs(eps); t_1 = t_0 - 1.0; t_2 = 1.0 + abs(eps); t_3 = abs(eps) - 1.0; t_4 = (1.0 + t_0) * t_3; t_5 = -1.0 * (t_2 * t_1); tmp = 0.0; if (x <= -3e+106) tmp = 0.5 * (2.0 + (x * ((x * (1.0 + (-0.3333333333333333 * x))) - 2.0))); elseif (x <= -1e-190) tmp = 1.0 + (0.5 * (x * (t_4 - (-1.0 * ((((abs(eps) * abs(eps)) - (1.0 * 1.0)) / t_3) * t_1))))); elseif (x <= 2.3e-251) tmp = 1.0 + (0.5 * (x * (t_4 - (-1.0 * (t_2 * ((1.0 - (1.0 / t_0)) * t_0)))))); elseif (x <= 850000.0) tmp = 1.0 + (0.5 * (x * (((t_3 * (abs(eps) - -1.0)) / abs(eps)) - t_5))); elseif (x <= 1.05e+135) tmp = x * (0.5 * (t_4 - t_5)); elseif (x <= 5.6e+222) tmp = 0.5 * (2.0 + (x * (x - 2.0))); else tmp = x * ((0.5 * 0.0) + (x / (x * x))); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 / N[Abs[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - 1.0), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 + N[Abs[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Abs[eps], $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$4 = N[(N[(1.0 + t$95$0), $MachinePrecision] * t$95$3), $MachinePrecision]}, Block[{t$95$5 = N[(-1.0 * N[(t$95$2 * t$95$1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3e+106], N[(0.5 * N[(2.0 + N[(x * N[(N[(x * N[(1.0 + N[(-0.3333333333333333 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1e-190], N[(1.0 + N[(0.5 * N[(x * N[(t$95$4 - N[(-1.0 * N[(N[(N[(N[(N[Abs[eps], $MachinePrecision] * N[Abs[eps], $MachinePrecision]), $MachinePrecision] - N[(1.0 * 1.0), $MachinePrecision]), $MachinePrecision] / t$95$3), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.3e-251], N[(1.0 + N[(0.5 * N[(x * N[(t$95$4 - N[(-1.0 * N[(t$95$2 * N[(N[(1.0 - N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 850000.0], N[(1.0 + N[(0.5 * N[(x * N[(N[(N[(t$95$3 * N[(N[Abs[eps], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] / N[Abs[eps], $MachinePrecision]), $MachinePrecision] - t$95$5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.05e+135], N[(x * N[(0.5 * N[(t$95$4 - t$95$5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.6e+222], N[(0.5 * N[(2.0 + N[(x * N[(x - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(0.5 * 0.0), $MachinePrecision] + N[(x / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]]]
\begin{array}{l}
t_0 := \frac{1}{\left|\varepsilon\right|}\\
t_1 := t\_0 - 1\\
t_2 := 1 + \left|\varepsilon\right|\\
t_3 := \left|\varepsilon\right| - 1\\
t_4 := \left(1 + t\_0\right) \cdot t\_3\\
t_5 := -1 \cdot \left(t\_2 \cdot t\_1\right)\\
\mathbf{if}\;x \leq -3 \cdot 10^{+106}:\\
\;\;\;\;0.5 \cdot \left(2 + x \cdot \left(x \cdot \left(1 + -0.3333333333333333 \cdot x\right) - 2\right)\right)\\
\mathbf{elif}\;x \leq -1 \cdot 10^{-190}:\\
\;\;\;\;1 + 0.5 \cdot \left(x \cdot \left(t\_4 - -1 \cdot \left(\frac{\left|\varepsilon\right| \cdot \left|\varepsilon\right| - 1 \cdot 1}{t\_3} \cdot t\_1\right)\right)\right)\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{-251}:\\
\;\;\;\;1 + 0.5 \cdot \left(x \cdot \left(t\_4 - -1 \cdot \left(t\_2 \cdot \left(\left(1 - \frac{1}{t\_0}\right) \cdot t\_0\right)\right)\right)\right)\\
\mathbf{elif}\;x \leq 850000:\\
\;\;\;\;1 + 0.5 \cdot \left(x \cdot \left(\frac{t\_3 \cdot \left(\left|\varepsilon\right| - -1\right)}{\left|\varepsilon\right|} - t\_5\right)\right)\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{+135}:\\
\;\;\;\;x \cdot \left(0.5 \cdot \left(t\_4 - t\_5\right)\right)\\
\mathbf{elif}\;x \leq 5.6 \cdot 10^{+222}:\\
\;\;\;\;0.5 \cdot \left(2 + x \cdot \left(x - 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(0.5 \cdot 0 + \frac{x}{x \cdot x}\right)\\
\end{array}
if x < -3.0000000000000001e106Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.1%
Applied rewrites99.1%
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.6%
Applied rewrites70.6%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6452.1%
Applied rewrites52.1%
if -3.0000000000000001e106 < x < -1e-190Initial program 74.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites43.7%
lift-+.f64N/A
+-commutativeN/A
flip-+N/A
lower-unsound--.f64N/A
lower-unsound-/.f64N/A
lower-unsound--.f64N/A
lower-unsound-*.f64N/A
lower-unsound-*.f6451.6%
Applied rewrites51.6%
if -1e-190 < x < 2.3000000000000002e-251Initial program 74.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites43.7%
lift--.f64N/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f6444.3%
Applied rewrites44.3%
if 2.3000000000000002e-251 < x < 8.5e5Initial program 74.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites43.7%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
associate-*r/N/A
lower-/.f64N/A
*-lft-identityN/A
+-commutativeN/A
lift-+.f64N/A
lower-*.f6452.3%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6452.3%
Applied rewrites52.3%
if 8.5e5 < x < 1.05e135Initial program 74.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites43.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites43.6%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f64N/A
lower-/.f6416.1%
Applied rewrites16.1%
if 1.05e135 < x < 5.6000000000000003e222Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.1%
Applied rewrites99.1%
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.6%
Applied rewrites70.6%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6457.3%
Applied rewrites57.3%
if 5.6000000000000003e222 < x Initial program 74.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites43.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites43.6%
lift-/.f64N/A
mult-flipN/A
rgt-mult-inverseN/A
mult-flip-revN/A
frac-timesN/A
*-rgt-identityN/A
lower-/.f64N/A
lower-*.f6429.8%
Applied rewrites29.8%
Taylor expanded in eps around 0
Applied rewrites29.9%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (/ 1.0 (fabs eps)))
(t_1 (- t_0 1.0))
(t_2 (* -1.0 (* (+ 1.0 (fabs eps)) t_1)))
(t_3 (- (fabs eps) 1.0))
(t_4 (* (+ 1.0 t_0) t_3)))
(if (<= x -3e+106)
(*
0.5
(+ 2.0 (* x (- (* x (+ 1.0 (* -0.3333333333333333 x))) 2.0))))
(if (<= x -1e-190)
(+
1.0
(*
0.5
(*
x
(-
t_4
(*
-1.0
(*
(/ (- (* (fabs eps) (fabs eps)) (* 1.0 1.0)) t_3)
t_1))))))
(if (<= x 2.3e-251)
(* 2.0 0.5)
(if (<= x 850000.0)
(+
1.0
(*
0.5
(* x (- (/ (* t_3 (- (fabs eps) -1.0)) (fabs eps)) t_2))))
(if (<= x 1.05e+135)
(* x (* 0.5 (- t_4 t_2)))
(if (<= x 5.6e+222)
(* 0.5 (+ 2.0 (* x (- x 2.0))))
(* x (+ (* 0.5 0.0) (/ x (* x x))))))))))))double code(double x, double eps) {
double t_0 = 1.0 / fabs(eps);
double t_1 = t_0 - 1.0;
double t_2 = -1.0 * ((1.0 + fabs(eps)) * t_1);
double t_3 = fabs(eps) - 1.0;
double t_4 = (1.0 + t_0) * t_3;
double tmp;
if (x <= -3e+106) {
tmp = 0.5 * (2.0 + (x * ((x * (1.0 + (-0.3333333333333333 * x))) - 2.0)));
} else if (x <= -1e-190) {
tmp = 1.0 + (0.5 * (x * (t_4 - (-1.0 * ((((fabs(eps) * fabs(eps)) - (1.0 * 1.0)) / t_3) * t_1)))));
} else if (x <= 2.3e-251) {
tmp = 2.0 * 0.5;
} else if (x <= 850000.0) {
tmp = 1.0 + (0.5 * (x * (((t_3 * (fabs(eps) - -1.0)) / fabs(eps)) - t_2)));
} else if (x <= 1.05e+135) {
tmp = x * (0.5 * (t_4 - t_2));
} else if (x <= 5.6e+222) {
tmp = 0.5 * (2.0 + (x * (x - 2.0)));
} else {
tmp = x * ((0.5 * 0.0) + (x / (x * 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) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = 1.0d0 / abs(eps)
t_1 = t_0 - 1.0d0
t_2 = (-1.0d0) * ((1.0d0 + abs(eps)) * t_1)
t_3 = abs(eps) - 1.0d0
t_4 = (1.0d0 + t_0) * t_3
if (x <= (-3d+106)) then
tmp = 0.5d0 * (2.0d0 + (x * ((x * (1.0d0 + ((-0.3333333333333333d0) * x))) - 2.0d0)))
else if (x <= (-1d-190)) then
tmp = 1.0d0 + (0.5d0 * (x * (t_4 - ((-1.0d0) * ((((abs(eps) * abs(eps)) - (1.0d0 * 1.0d0)) / t_3) * t_1)))))
else if (x <= 2.3d-251) then
tmp = 2.0d0 * 0.5d0
else if (x <= 850000.0d0) then
tmp = 1.0d0 + (0.5d0 * (x * (((t_3 * (abs(eps) - (-1.0d0))) / abs(eps)) - t_2)))
else if (x <= 1.05d+135) then
tmp = x * (0.5d0 * (t_4 - t_2))
else if (x <= 5.6d+222) then
tmp = 0.5d0 * (2.0d0 + (x * (x - 2.0d0)))
else
tmp = x * ((0.5d0 * 0.0d0) + (x / (x * x)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = 1.0 / Math.abs(eps);
double t_1 = t_0 - 1.0;
double t_2 = -1.0 * ((1.0 + Math.abs(eps)) * t_1);
double t_3 = Math.abs(eps) - 1.0;
double t_4 = (1.0 + t_0) * t_3;
double tmp;
if (x <= -3e+106) {
tmp = 0.5 * (2.0 + (x * ((x * (1.0 + (-0.3333333333333333 * x))) - 2.0)));
} else if (x <= -1e-190) {
tmp = 1.0 + (0.5 * (x * (t_4 - (-1.0 * ((((Math.abs(eps) * Math.abs(eps)) - (1.0 * 1.0)) / t_3) * t_1)))));
} else if (x <= 2.3e-251) {
tmp = 2.0 * 0.5;
} else if (x <= 850000.0) {
tmp = 1.0 + (0.5 * (x * (((t_3 * (Math.abs(eps) - -1.0)) / Math.abs(eps)) - t_2)));
} else if (x <= 1.05e+135) {
tmp = x * (0.5 * (t_4 - t_2));
} else if (x <= 5.6e+222) {
tmp = 0.5 * (2.0 + (x * (x - 2.0)));
} else {
tmp = x * ((0.5 * 0.0) + (x / (x * x)));
}
return tmp;
}
def code(x, eps): t_0 = 1.0 / math.fabs(eps) t_1 = t_0 - 1.0 t_2 = -1.0 * ((1.0 + math.fabs(eps)) * t_1) t_3 = math.fabs(eps) - 1.0 t_4 = (1.0 + t_0) * t_3 tmp = 0 if x <= -3e+106: tmp = 0.5 * (2.0 + (x * ((x * (1.0 + (-0.3333333333333333 * x))) - 2.0))) elif x <= -1e-190: tmp = 1.0 + (0.5 * (x * (t_4 - (-1.0 * ((((math.fabs(eps) * math.fabs(eps)) - (1.0 * 1.0)) / t_3) * t_1))))) elif x <= 2.3e-251: tmp = 2.0 * 0.5 elif x <= 850000.0: tmp = 1.0 + (0.5 * (x * (((t_3 * (math.fabs(eps) - -1.0)) / math.fabs(eps)) - t_2))) elif x <= 1.05e+135: tmp = x * (0.5 * (t_4 - t_2)) elif x <= 5.6e+222: tmp = 0.5 * (2.0 + (x * (x - 2.0))) else: tmp = x * ((0.5 * 0.0) + (x / (x * x))) return tmp
function code(x, eps) t_0 = Float64(1.0 / abs(eps)) t_1 = Float64(t_0 - 1.0) t_2 = Float64(-1.0 * Float64(Float64(1.0 + abs(eps)) * t_1)) t_3 = Float64(abs(eps) - 1.0) t_4 = Float64(Float64(1.0 + t_0) * t_3) tmp = 0.0 if (x <= -3e+106) tmp = Float64(0.5 * Float64(2.0 + Float64(x * Float64(Float64(x * Float64(1.0 + Float64(-0.3333333333333333 * x))) - 2.0)))); elseif (x <= -1e-190) tmp = Float64(1.0 + Float64(0.5 * Float64(x * Float64(t_4 - Float64(-1.0 * Float64(Float64(Float64(Float64(abs(eps) * abs(eps)) - Float64(1.0 * 1.0)) / t_3) * t_1)))))); elseif (x <= 2.3e-251) tmp = Float64(2.0 * 0.5); elseif (x <= 850000.0) tmp = Float64(1.0 + Float64(0.5 * Float64(x * Float64(Float64(Float64(t_3 * Float64(abs(eps) - -1.0)) / abs(eps)) - t_2)))); elseif (x <= 1.05e+135) tmp = Float64(x * Float64(0.5 * Float64(t_4 - t_2))); elseif (x <= 5.6e+222) tmp = Float64(0.5 * Float64(2.0 + Float64(x * Float64(x - 2.0)))); else tmp = Float64(x * Float64(Float64(0.5 * 0.0) + Float64(x / Float64(x * x)))); end return tmp end
function tmp_2 = code(x, eps) t_0 = 1.0 / abs(eps); t_1 = t_0 - 1.0; t_2 = -1.0 * ((1.0 + abs(eps)) * t_1); t_3 = abs(eps) - 1.0; t_4 = (1.0 + t_0) * t_3; tmp = 0.0; if (x <= -3e+106) tmp = 0.5 * (2.0 + (x * ((x * (1.0 + (-0.3333333333333333 * x))) - 2.0))); elseif (x <= -1e-190) tmp = 1.0 + (0.5 * (x * (t_4 - (-1.0 * ((((abs(eps) * abs(eps)) - (1.0 * 1.0)) / t_3) * t_1))))); elseif (x <= 2.3e-251) tmp = 2.0 * 0.5; elseif (x <= 850000.0) tmp = 1.0 + (0.5 * (x * (((t_3 * (abs(eps) - -1.0)) / abs(eps)) - t_2))); elseif (x <= 1.05e+135) tmp = x * (0.5 * (t_4 - t_2)); elseif (x <= 5.6e+222) tmp = 0.5 * (2.0 + (x * (x - 2.0))); else tmp = x * ((0.5 * 0.0) + (x / (x * x))); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 / N[Abs[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - 1.0), $MachinePrecision]}, Block[{t$95$2 = N[(-1.0 * N[(N[(1.0 + N[Abs[eps], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Abs[eps], $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$4 = N[(N[(1.0 + t$95$0), $MachinePrecision] * t$95$3), $MachinePrecision]}, If[LessEqual[x, -3e+106], N[(0.5 * N[(2.0 + N[(x * N[(N[(x * N[(1.0 + N[(-0.3333333333333333 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1e-190], N[(1.0 + N[(0.5 * N[(x * N[(t$95$4 - N[(-1.0 * N[(N[(N[(N[(N[Abs[eps], $MachinePrecision] * N[Abs[eps], $MachinePrecision]), $MachinePrecision] - N[(1.0 * 1.0), $MachinePrecision]), $MachinePrecision] / t$95$3), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.3e-251], N[(2.0 * 0.5), $MachinePrecision], If[LessEqual[x, 850000.0], N[(1.0 + N[(0.5 * N[(x * N[(N[(N[(t$95$3 * N[(N[Abs[eps], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] / N[Abs[eps], $MachinePrecision]), $MachinePrecision] - t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.05e+135], N[(x * N[(0.5 * N[(t$95$4 - t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.6e+222], N[(0.5 * N[(2.0 + N[(x * N[(x - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(0.5 * 0.0), $MachinePrecision] + N[(x / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]]
\begin{array}{l}
t_0 := \frac{1}{\left|\varepsilon\right|}\\
t_1 := t\_0 - 1\\
t_2 := -1 \cdot \left(\left(1 + \left|\varepsilon\right|\right) \cdot t\_1\right)\\
t_3 := \left|\varepsilon\right| - 1\\
t_4 := \left(1 + t\_0\right) \cdot t\_3\\
\mathbf{if}\;x \leq -3 \cdot 10^{+106}:\\
\;\;\;\;0.5 \cdot \left(2 + x \cdot \left(x \cdot \left(1 + -0.3333333333333333 \cdot x\right) - 2\right)\right)\\
\mathbf{elif}\;x \leq -1 \cdot 10^{-190}:\\
\;\;\;\;1 + 0.5 \cdot \left(x \cdot \left(t\_4 - -1 \cdot \left(\frac{\left|\varepsilon\right| \cdot \left|\varepsilon\right| - 1 \cdot 1}{t\_3} \cdot t\_1\right)\right)\right)\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{-251}:\\
\;\;\;\;2 \cdot 0.5\\
\mathbf{elif}\;x \leq 850000:\\
\;\;\;\;1 + 0.5 \cdot \left(x \cdot \left(\frac{t\_3 \cdot \left(\left|\varepsilon\right| - -1\right)}{\left|\varepsilon\right|} - t\_2\right)\right)\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{+135}:\\
\;\;\;\;x \cdot \left(0.5 \cdot \left(t\_4 - t\_2\right)\right)\\
\mathbf{elif}\;x \leq 5.6 \cdot 10^{+222}:\\
\;\;\;\;0.5 \cdot \left(2 + x \cdot \left(x - 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(0.5 \cdot 0 + \frac{x}{x \cdot x}\right)\\
\end{array}
if x < -3.0000000000000001e106Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.1%
Applied rewrites99.1%
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.6%
Applied rewrites70.6%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6452.1%
Applied rewrites52.1%
if -3.0000000000000001e106 < x < -1e-190Initial program 74.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites43.7%
lift-+.f64N/A
+-commutativeN/A
flip-+N/A
lower-unsound--.f64N/A
lower-unsound-/.f64N/A
lower-unsound--.f64N/A
lower-unsound-*.f64N/A
lower-unsound-*.f6451.6%
Applied rewrites51.6%
if -1e-190 < x < 2.3000000000000002e-251Initial program 74.1%
Taylor expanded in x around 0
Applied rewrites43.7%
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6443.7%
Applied rewrites43.7%
if 2.3000000000000002e-251 < x < 8.5e5Initial program 74.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites43.7%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
associate-*r/N/A
lower-/.f64N/A
*-lft-identityN/A
+-commutativeN/A
lift-+.f64N/A
lower-*.f6452.3%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6452.3%
Applied rewrites52.3%
if 8.5e5 < x < 1.05e135Initial program 74.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites43.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites43.6%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f64N/A
lower-/.f6416.1%
Applied rewrites16.1%
if 1.05e135 < x < 5.6000000000000003e222Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.1%
Applied rewrites99.1%
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.6%
Applied rewrites70.6%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6457.3%
Applied rewrites57.3%
if 5.6000000000000003e222 < x Initial program 74.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites43.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites43.6%
lift-/.f64N/A
mult-flipN/A
rgt-mult-inverseN/A
mult-flip-revN/A
frac-timesN/A
*-rgt-identityN/A
lower-/.f64N/A
lower-*.f6429.8%
Applied rewrites29.8%
Taylor expanded in eps around 0
Applied rewrites29.9%
(FPCore (x eps)
:precision binary64
(if (<= (fabs eps) 8.2e+38)
(* (* 2.0 (exp (- x))) 0.5)
(if (<= (fabs eps) 3.6e+272)
(* 0.5 (+ 2.0 (* x (- x 2.0))))
(+
1.0
(*
0.5
(*
x
(-
(/ (* (- (fabs eps) 1.0) (- (fabs eps) -1.0)) (fabs eps))
(*
-1.0
(* (+ 1.0 (fabs eps)) (- (/ 1.0 (fabs eps)) 1.0))))))))))double code(double x, double eps) {
double tmp;
if (fabs(eps) <= 8.2e+38) {
tmp = (2.0 * exp(-x)) * 0.5;
} else if (fabs(eps) <= 3.6e+272) {
tmp = 0.5 * (2.0 + (x * (x - 2.0)));
} else {
tmp = 1.0 + (0.5 * (x * ((((fabs(eps) - 1.0) * (fabs(eps) - -1.0)) / fabs(eps)) - (-1.0 * ((1.0 + fabs(eps)) * ((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+38) then
tmp = (2.0d0 * exp(-x)) * 0.5d0
else if (abs(eps) <= 3.6d+272) then
tmp = 0.5d0 * (2.0d0 + (x * (x - 2.0d0)))
else
tmp = 1.0d0 + (0.5d0 * (x * ((((abs(eps) - 1.0d0) * (abs(eps) - (-1.0d0))) / abs(eps)) - ((-1.0d0) * ((1.0d0 + abs(eps)) * ((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+38) {
tmp = (2.0 * Math.exp(-x)) * 0.5;
} else if (Math.abs(eps) <= 3.6e+272) {
tmp = 0.5 * (2.0 + (x * (x - 2.0)));
} else {
tmp = 1.0 + (0.5 * (x * ((((Math.abs(eps) - 1.0) * (Math.abs(eps) - -1.0)) / Math.abs(eps)) - (-1.0 * ((1.0 + Math.abs(eps)) * ((1.0 / Math.abs(eps)) - 1.0))))));
}
return tmp;
}
def code(x, eps): tmp = 0 if math.fabs(eps) <= 8.2e+38: tmp = (2.0 * math.exp(-x)) * 0.5 elif math.fabs(eps) <= 3.6e+272: tmp = 0.5 * (2.0 + (x * (x - 2.0))) else: tmp = 1.0 + (0.5 * (x * ((((math.fabs(eps) - 1.0) * (math.fabs(eps) - -1.0)) / math.fabs(eps)) - (-1.0 * ((1.0 + math.fabs(eps)) * ((1.0 / math.fabs(eps)) - 1.0)))))) return tmp
function code(x, eps) tmp = 0.0 if (abs(eps) <= 8.2e+38) tmp = Float64(Float64(2.0 * exp(Float64(-x))) * 0.5); elseif (abs(eps) <= 3.6e+272) tmp = Float64(0.5 * Float64(2.0 + Float64(x * Float64(x - 2.0)))); else tmp = Float64(1.0 + Float64(0.5 * Float64(x * Float64(Float64(Float64(Float64(abs(eps) - 1.0) * Float64(abs(eps) - -1.0)) / abs(eps)) - Float64(-1.0 * Float64(Float64(1.0 + abs(eps)) * Float64(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+38) tmp = (2.0 * exp(-x)) * 0.5; elseif (abs(eps) <= 3.6e+272) tmp = 0.5 * (2.0 + (x * (x - 2.0))); else tmp = 1.0 + (0.5 * (x * ((((abs(eps) - 1.0) * (abs(eps) - -1.0)) / abs(eps)) - (-1.0 * ((1.0 + abs(eps)) * ((1.0 / abs(eps)) - 1.0)))))); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[Abs[eps], $MachinePrecision], 8.2e+38], N[(N[(2.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[N[Abs[eps], $MachinePrecision], 3.6e+272], N[(0.5 * N[(2.0 + N[(x * N[(x - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(0.5 * N[(x * N[(N[(N[(N[(N[Abs[eps], $MachinePrecision] - 1.0), $MachinePrecision] * N[(N[Abs[eps], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] / N[Abs[eps], $MachinePrecision]), $MachinePrecision] - N[(-1.0 * N[(N[(1.0 + N[Abs[eps], $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / N[Abs[eps], $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;\left|\varepsilon\right| \leq 8.2 \cdot 10^{+38}:\\
\;\;\;\;\left(2 \cdot e^{-x}\right) \cdot 0.5\\
\mathbf{elif}\;\left|\varepsilon\right| \leq 3.6 \cdot 10^{+272}:\\
\;\;\;\;0.5 \cdot \left(2 + x \cdot \left(x - 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 + 0.5 \cdot \left(x \cdot \left(\frac{\left(\left|\varepsilon\right| - 1\right) \cdot \left(\left|\varepsilon\right| - -1\right)}{\left|\varepsilon\right|} - -1 \cdot \left(\left(1 + \left|\varepsilon\right|\right) \cdot \left(\frac{1}{\left|\varepsilon\right|} - 1\right)\right)\right)\right)\\
\end{array}
if eps < 8.2000000000000007e38Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.1%
Applied rewrites99.1%
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.6%
Applied rewrites70.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.6%
lift--.f64N/A
lift-*.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-*.f6470.6%
Applied rewrites70.6%
if 8.2000000000000007e38 < eps < 3.5999999999999998e272Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.1%
Applied rewrites99.1%
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.6%
Applied rewrites70.6%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6457.3%
Applied rewrites57.3%
if 3.5999999999999998e272 < eps Initial program 74.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites43.7%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
associate-*r/N/A
lower-/.f64N/A
*-lft-identityN/A
+-commutativeN/A
lift-+.f64N/A
lower-*.f6452.3%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6452.3%
Applied rewrites52.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (/ 1.0 (fabs eps)))
(t_1 (- (fabs eps) 1.0))
(t_2 (* -1.0 (* (+ 1.0 (fabs eps)) (- t_0 1.0)))))
(if (<= x 2.3e-251)
(*
0.5
(+ 2.0 (* x (- (* x (+ 1.0 (* -0.3333333333333333 x))) 2.0))))
(if (<= x 850000.0)
(+
1.0
(*
0.5
(* x (- (/ (* t_1 (- (fabs eps) -1.0)) (fabs eps)) t_2))))
(if (<= x 1.05e+135)
(* x (* 0.5 (- (* (+ 1.0 t_0) t_1) t_2)))
(if (<= x 4.4e+267)
(* 0.5 (+ 2.0 (* x (- x 2.0))))
(* x (+ (* 0.5 0.0) (/ x (* x x))))))))))double code(double x, double eps) {
double t_0 = 1.0 / fabs(eps);
double t_1 = fabs(eps) - 1.0;
double t_2 = -1.0 * ((1.0 + fabs(eps)) * (t_0 - 1.0));
double tmp;
if (x <= 2.3e-251) {
tmp = 0.5 * (2.0 + (x * ((x * (1.0 + (-0.3333333333333333 * x))) - 2.0)));
} else if (x <= 850000.0) {
tmp = 1.0 + (0.5 * (x * (((t_1 * (fabs(eps) - -1.0)) / fabs(eps)) - t_2)));
} else if (x <= 1.05e+135) {
tmp = x * (0.5 * (((1.0 + t_0) * t_1) - t_2));
} else if (x <= 4.4e+267) {
tmp = 0.5 * (2.0 + (x * (x - 2.0)));
} else {
tmp = x * ((0.5 * 0.0) + (x / (x * 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) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = 1.0d0 / abs(eps)
t_1 = abs(eps) - 1.0d0
t_2 = (-1.0d0) * ((1.0d0 + abs(eps)) * (t_0 - 1.0d0))
if (x <= 2.3d-251) then
tmp = 0.5d0 * (2.0d0 + (x * ((x * (1.0d0 + ((-0.3333333333333333d0) * x))) - 2.0d0)))
else if (x <= 850000.0d0) then
tmp = 1.0d0 + (0.5d0 * (x * (((t_1 * (abs(eps) - (-1.0d0))) / abs(eps)) - t_2)))
else if (x <= 1.05d+135) then
tmp = x * (0.5d0 * (((1.0d0 + t_0) * t_1) - t_2))
else if (x <= 4.4d+267) then
tmp = 0.5d0 * (2.0d0 + (x * (x - 2.0d0)))
else
tmp = x * ((0.5d0 * 0.0d0) + (x / (x * x)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = 1.0 / Math.abs(eps);
double t_1 = Math.abs(eps) - 1.0;
double t_2 = -1.0 * ((1.0 + Math.abs(eps)) * (t_0 - 1.0));
double tmp;
if (x <= 2.3e-251) {
tmp = 0.5 * (2.0 + (x * ((x * (1.0 + (-0.3333333333333333 * x))) - 2.0)));
} else if (x <= 850000.0) {
tmp = 1.0 + (0.5 * (x * (((t_1 * (Math.abs(eps) - -1.0)) / Math.abs(eps)) - t_2)));
} else if (x <= 1.05e+135) {
tmp = x * (0.5 * (((1.0 + t_0) * t_1) - t_2));
} else if (x <= 4.4e+267) {
tmp = 0.5 * (2.0 + (x * (x - 2.0)));
} else {
tmp = x * ((0.5 * 0.0) + (x / (x * x)));
}
return tmp;
}
def code(x, eps): t_0 = 1.0 / math.fabs(eps) t_1 = math.fabs(eps) - 1.0 t_2 = -1.0 * ((1.0 + math.fabs(eps)) * (t_0 - 1.0)) tmp = 0 if x <= 2.3e-251: tmp = 0.5 * (2.0 + (x * ((x * (1.0 + (-0.3333333333333333 * x))) - 2.0))) elif x <= 850000.0: tmp = 1.0 + (0.5 * (x * (((t_1 * (math.fabs(eps) - -1.0)) / math.fabs(eps)) - t_2))) elif x <= 1.05e+135: tmp = x * (0.5 * (((1.0 + t_0) * t_1) - t_2)) elif x <= 4.4e+267: tmp = 0.5 * (2.0 + (x * (x - 2.0))) else: tmp = x * ((0.5 * 0.0) + (x / (x * x))) return tmp
function code(x, eps) t_0 = Float64(1.0 / abs(eps)) t_1 = Float64(abs(eps) - 1.0) t_2 = Float64(-1.0 * Float64(Float64(1.0 + abs(eps)) * Float64(t_0 - 1.0))) tmp = 0.0 if (x <= 2.3e-251) tmp = Float64(0.5 * Float64(2.0 + Float64(x * Float64(Float64(x * Float64(1.0 + Float64(-0.3333333333333333 * x))) - 2.0)))); elseif (x <= 850000.0) tmp = Float64(1.0 + Float64(0.5 * Float64(x * Float64(Float64(Float64(t_1 * Float64(abs(eps) - -1.0)) / abs(eps)) - t_2)))); elseif (x <= 1.05e+135) tmp = Float64(x * Float64(0.5 * Float64(Float64(Float64(1.0 + t_0) * t_1) - t_2))); elseif (x <= 4.4e+267) tmp = Float64(0.5 * Float64(2.0 + Float64(x * Float64(x - 2.0)))); else tmp = Float64(x * Float64(Float64(0.5 * 0.0) + Float64(x / Float64(x * x)))); end return tmp end
function tmp_2 = code(x, eps) t_0 = 1.0 / abs(eps); t_1 = abs(eps) - 1.0; t_2 = -1.0 * ((1.0 + abs(eps)) * (t_0 - 1.0)); tmp = 0.0; if (x <= 2.3e-251) tmp = 0.5 * (2.0 + (x * ((x * (1.0 + (-0.3333333333333333 * x))) - 2.0))); elseif (x <= 850000.0) tmp = 1.0 + (0.5 * (x * (((t_1 * (abs(eps) - -1.0)) / abs(eps)) - t_2))); elseif (x <= 1.05e+135) tmp = x * (0.5 * (((1.0 + t_0) * t_1) - t_2)); elseif (x <= 4.4e+267) tmp = 0.5 * (2.0 + (x * (x - 2.0))); else tmp = x * ((0.5 * 0.0) + (x / (x * x))); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 / N[Abs[eps], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Abs[eps], $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$2 = N[(-1.0 * N[(N[(1.0 + N[Abs[eps], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 2.3e-251], N[(0.5 * N[(2.0 + N[(x * N[(N[(x * N[(1.0 + N[(-0.3333333333333333 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 850000.0], N[(1.0 + N[(0.5 * N[(x * N[(N[(N[(t$95$1 * N[(N[Abs[eps], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] / N[Abs[eps], $MachinePrecision]), $MachinePrecision] - t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.05e+135], N[(x * N[(0.5 * N[(N[(N[(1.0 + t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision] - t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.4e+267], N[(0.5 * N[(2.0 + N[(x * N[(x - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(0.5 * 0.0), $MachinePrecision] + N[(x / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
t_0 := \frac{1}{\left|\varepsilon\right|}\\
t_1 := \left|\varepsilon\right| - 1\\
t_2 := -1 \cdot \left(\left(1 + \left|\varepsilon\right|\right) \cdot \left(t\_0 - 1\right)\right)\\
\mathbf{if}\;x \leq 2.3 \cdot 10^{-251}:\\
\;\;\;\;0.5 \cdot \left(2 + x \cdot \left(x \cdot \left(1 + -0.3333333333333333 \cdot x\right) - 2\right)\right)\\
\mathbf{elif}\;x \leq 850000:\\
\;\;\;\;1 + 0.5 \cdot \left(x \cdot \left(\frac{t\_1 \cdot \left(\left|\varepsilon\right| - -1\right)}{\left|\varepsilon\right|} - t\_2\right)\right)\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{+135}:\\
\;\;\;\;x \cdot \left(0.5 \cdot \left(\left(1 + t\_0\right) \cdot t\_1 - t\_2\right)\right)\\
\mathbf{elif}\;x \leq 4.4 \cdot 10^{+267}:\\
\;\;\;\;0.5 \cdot \left(2 + x \cdot \left(x - 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(0.5 \cdot 0 + \frac{x}{x \cdot x}\right)\\
\end{array}
if x < 2.3000000000000002e-251Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.1%
Applied rewrites99.1%
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.6%
Applied rewrites70.6%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6452.1%
Applied rewrites52.1%
if 2.3000000000000002e-251 < x < 8.5e5Initial program 74.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites43.7%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
associate-*r/N/A
lower-/.f64N/A
*-lft-identityN/A
+-commutativeN/A
lift-+.f64N/A
lower-*.f6452.3%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6452.3%
Applied rewrites52.3%
if 8.5e5 < x < 1.05e135Initial program 74.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites43.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites43.6%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f64N/A
lower-/.f6416.1%
Applied rewrites16.1%
if 1.05e135 < x < 4.4000000000000002e267Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.1%
Applied rewrites99.1%
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.6%
Applied rewrites70.6%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6457.3%
Applied rewrites57.3%
if 4.4000000000000002e267 < x Initial program 74.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites43.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites43.6%
lift-/.f64N/A
mult-flipN/A
rgt-mult-inverseN/A
mult-flip-revN/A
frac-timesN/A
*-rgt-identityN/A
lower-/.f64N/A
lower-*.f6429.8%
Applied rewrites29.8%
Taylor expanded in eps around 0
Applied rewrites29.9%
(FPCore (x eps)
:precision binary64
(if (<= x 0.01)
(*
0.5
(+ 2.0 (* x (- (* x (+ 1.0 (* -0.3333333333333333 x))) 2.0))))
(if (<= x 1.05e+135)
(*
x
(*
0.5
(-
(* (+ 1.0 (/ 1.0 eps)) (- eps 1.0))
(* -1.0 (* (+ 1.0 eps) (- (/ 1.0 eps) 1.0))))))
(if (<= x 4.4e+267)
(* 0.5 (+ 2.0 (* x (- x 2.0))))
(* x (+ (* 0.5 0.0) (/ x (* x x))))))))double code(double x, double eps) {
double tmp;
if (x <= 0.01) {
tmp = 0.5 * (2.0 + (x * ((x * (1.0 + (-0.3333333333333333 * x))) - 2.0)));
} else if (x <= 1.05e+135) {
tmp = x * (0.5 * (((1.0 + (1.0 / eps)) * (eps - 1.0)) - (-1.0 * ((1.0 + eps) * ((1.0 / eps) - 1.0)))));
} else if (x <= 4.4e+267) {
tmp = 0.5 * (2.0 + (x * (x - 2.0)));
} else {
tmp = x * ((0.5 * 0.0) + (x / (x * 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 <= 0.01d0) then
tmp = 0.5d0 * (2.0d0 + (x * ((x * (1.0d0 + ((-0.3333333333333333d0) * x))) - 2.0d0)))
else if (x <= 1.05d+135) then
tmp = x * (0.5d0 * (((1.0d0 + (1.0d0 / eps)) * (eps - 1.0d0)) - ((-1.0d0) * ((1.0d0 + eps) * ((1.0d0 / eps) - 1.0d0)))))
else if (x <= 4.4d+267) then
tmp = 0.5d0 * (2.0d0 + (x * (x - 2.0d0)))
else
tmp = x * ((0.5d0 * 0.0d0) + (x / (x * x)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 0.01) {
tmp = 0.5 * (2.0 + (x * ((x * (1.0 + (-0.3333333333333333 * x))) - 2.0)));
} else if (x <= 1.05e+135) {
tmp = x * (0.5 * (((1.0 + (1.0 / eps)) * (eps - 1.0)) - (-1.0 * ((1.0 + eps) * ((1.0 / eps) - 1.0)))));
} else if (x <= 4.4e+267) {
tmp = 0.5 * (2.0 + (x * (x - 2.0)));
} else {
tmp = x * ((0.5 * 0.0) + (x / (x * x)));
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 0.01: tmp = 0.5 * (2.0 + (x * ((x * (1.0 + (-0.3333333333333333 * x))) - 2.0))) elif x <= 1.05e+135: tmp = x * (0.5 * (((1.0 + (1.0 / eps)) * (eps - 1.0)) - (-1.0 * ((1.0 + eps) * ((1.0 / eps) - 1.0))))) elif x <= 4.4e+267: tmp = 0.5 * (2.0 + (x * (x - 2.0))) else: tmp = x * ((0.5 * 0.0) + (x / (x * x))) return tmp
function code(x, eps) tmp = 0.0 if (x <= 0.01) tmp = Float64(0.5 * Float64(2.0 + Float64(x * Float64(Float64(x * Float64(1.0 + Float64(-0.3333333333333333 * x))) - 2.0)))); elseif (x <= 1.05e+135) tmp = Float64(x * Float64(0.5 * Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * Float64(eps - 1.0)) - Float64(-1.0 * Float64(Float64(1.0 + eps) * Float64(Float64(1.0 / eps) - 1.0)))))); elseif (x <= 4.4e+267) tmp = Float64(0.5 * Float64(2.0 + Float64(x * Float64(x - 2.0)))); else tmp = Float64(x * Float64(Float64(0.5 * 0.0) + Float64(x / Float64(x * x)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 0.01) tmp = 0.5 * (2.0 + (x * ((x * (1.0 + (-0.3333333333333333 * x))) - 2.0))); elseif (x <= 1.05e+135) tmp = x * (0.5 * (((1.0 + (1.0 / eps)) * (eps - 1.0)) - (-1.0 * ((1.0 + eps) * ((1.0 / eps) - 1.0))))); elseif (x <= 4.4e+267) tmp = 0.5 * (2.0 + (x * (x - 2.0))); else tmp = x * ((0.5 * 0.0) + (x / (x * x))); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 0.01], N[(0.5 * N[(2.0 + N[(x * N[(N[(x * N[(1.0 + N[(-0.3333333333333333 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.05e+135], N[(x * N[(0.5 * N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[(eps - 1.0), $MachinePrecision]), $MachinePrecision] - N[(-1.0 * N[(N[(1.0 + eps), $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.4e+267], N[(0.5 * N[(2.0 + N[(x * N[(x - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(0.5 * 0.0), $MachinePrecision] + N[(x / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\mathbf{if}\;x \leq 0.01:\\
\;\;\;\;0.5 \cdot \left(2 + x \cdot \left(x \cdot \left(1 + -0.3333333333333333 \cdot x\right) - 2\right)\right)\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{+135}:\\
\;\;\;\;x \cdot \left(0.5 \cdot \left(\left(1 + \frac{1}{\varepsilon}\right) \cdot \left(\varepsilon - 1\right) - -1 \cdot \left(\left(1 + \varepsilon\right) \cdot \left(\frac{1}{\varepsilon} - 1\right)\right)\right)\right)\\
\mathbf{elif}\;x \leq 4.4 \cdot 10^{+267}:\\
\;\;\;\;0.5 \cdot \left(2 + x \cdot \left(x - 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(0.5 \cdot 0 + \frac{x}{x \cdot x}\right)\\
\end{array}
if x < 0.01Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.1%
Applied rewrites99.1%
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.6%
Applied rewrites70.6%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6452.1%
Applied rewrites52.1%
if 0.01 < x < 1.05e135Initial program 74.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites43.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites43.6%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f64N/A
lower-/.f6416.1%
Applied rewrites16.1%
if 1.05e135 < x < 4.4000000000000002e267Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.1%
Applied rewrites99.1%
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.6%
Applied rewrites70.6%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6457.3%
Applied rewrites57.3%
if 4.4000000000000002e267 < x Initial program 74.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites43.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites43.6%
lift-/.f64N/A
mult-flipN/A
rgt-mult-inverseN/A
mult-flip-revN/A
frac-timesN/A
*-rgt-identityN/A
lower-/.f64N/A
lower-*.f6429.8%
Applied rewrites29.8%
Taylor expanded in eps around 0
Applied rewrites29.9%
(FPCore (x eps)
:precision binary64
(if (<= x -11500.0)
(*
0.5
(+ 2.0 (* x (- (* x (+ 1.0 (* -0.3333333333333333 x))) 2.0))))
(if (<= x 5.6e+222)
(* 0.5 (+ 2.0 (* x (- x 2.0))))
(* x (+ (* 0.5 0.0) (/ x (* x x)))))))double code(double x, double eps) {
double tmp;
if (x <= -11500.0) {
tmp = 0.5 * (2.0 + (x * ((x * (1.0 + (-0.3333333333333333 * x))) - 2.0)));
} else if (x <= 5.6e+222) {
tmp = 0.5 * (2.0 + (x * (x - 2.0)));
} else {
tmp = x * ((0.5 * 0.0) + (x / (x * 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 <= (-11500.0d0)) then
tmp = 0.5d0 * (2.0d0 + (x * ((x * (1.0d0 + ((-0.3333333333333333d0) * x))) - 2.0d0)))
else if (x <= 5.6d+222) then
tmp = 0.5d0 * (2.0d0 + (x * (x - 2.0d0)))
else
tmp = x * ((0.5d0 * 0.0d0) + (x / (x * x)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -11500.0) {
tmp = 0.5 * (2.0 + (x * ((x * (1.0 + (-0.3333333333333333 * x))) - 2.0)));
} else if (x <= 5.6e+222) {
tmp = 0.5 * (2.0 + (x * (x - 2.0)));
} else {
tmp = x * ((0.5 * 0.0) + (x / (x * x)));
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -11500.0: tmp = 0.5 * (2.0 + (x * ((x * (1.0 + (-0.3333333333333333 * x))) - 2.0))) elif x <= 5.6e+222: tmp = 0.5 * (2.0 + (x * (x - 2.0))) else: tmp = x * ((0.5 * 0.0) + (x / (x * x))) return tmp
function code(x, eps) tmp = 0.0 if (x <= -11500.0) tmp = Float64(0.5 * Float64(2.0 + Float64(x * Float64(Float64(x * Float64(1.0 + Float64(-0.3333333333333333 * x))) - 2.0)))); elseif (x <= 5.6e+222) tmp = Float64(0.5 * Float64(2.0 + Float64(x * Float64(x - 2.0)))); else tmp = Float64(x * Float64(Float64(0.5 * 0.0) + Float64(x / Float64(x * x)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -11500.0) tmp = 0.5 * (2.0 + (x * ((x * (1.0 + (-0.3333333333333333 * x))) - 2.0))); elseif (x <= 5.6e+222) tmp = 0.5 * (2.0 + (x * (x - 2.0))); else tmp = x * ((0.5 * 0.0) + (x / (x * x))); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -11500.0], N[(0.5 * N[(2.0 + N[(x * N[(N[(x * N[(1.0 + N[(-0.3333333333333333 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.6e+222], N[(0.5 * N[(2.0 + N[(x * N[(x - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(0.5 * 0.0), $MachinePrecision] + N[(x / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;x \leq -11500:\\
\;\;\;\;0.5 \cdot \left(2 + x \cdot \left(x \cdot \left(1 + -0.3333333333333333 \cdot x\right) - 2\right)\right)\\
\mathbf{elif}\;x \leq 5.6 \cdot 10^{+222}:\\
\;\;\;\;0.5 \cdot \left(2 + x \cdot \left(x - 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(0.5 \cdot 0 + \frac{x}{x \cdot x}\right)\\
\end{array}
if x < -11500Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.1%
Applied rewrites99.1%
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.6%
Applied rewrites70.6%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6452.1%
Applied rewrites52.1%
if -11500 < x < 5.6000000000000003e222Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.1%
Applied rewrites99.1%
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.6%
Applied rewrites70.6%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6457.3%
Applied rewrites57.3%
if 5.6000000000000003e222 < x Initial program 74.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites43.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites43.6%
lift-/.f64N/A
mult-flipN/A
rgt-mult-inverseN/A
mult-flip-revN/A
frac-timesN/A
*-rgt-identityN/A
lower-/.f64N/A
lower-*.f6429.8%
Applied rewrites29.8%
Taylor expanded in eps around 0
Applied rewrites29.9%
(FPCore (x eps) :precision binary64 (if (<= x 4.4e+267) (* 0.5 (+ 2.0 (* x (- x 2.0)))) (* x (+ (* 0.5 0.0) (/ x (* x x))))))
double code(double x, double eps) {
double tmp;
if (x <= 4.4e+267) {
tmp = 0.5 * (2.0 + (x * (x - 2.0)));
} else {
tmp = x * ((0.5 * 0.0) + (x / (x * 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 <= 4.4d+267) then
tmp = 0.5d0 * (2.0d0 + (x * (x - 2.0d0)))
else
tmp = x * ((0.5d0 * 0.0d0) + (x / (x * x)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 4.4e+267) {
tmp = 0.5 * (2.0 + (x * (x - 2.0)));
} else {
tmp = x * ((0.5 * 0.0) + (x / (x * x)));
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 4.4e+267: tmp = 0.5 * (2.0 + (x * (x - 2.0))) else: tmp = x * ((0.5 * 0.0) + (x / (x * x))) return tmp
function code(x, eps) tmp = 0.0 if (x <= 4.4e+267) tmp = Float64(0.5 * Float64(2.0 + Float64(x * Float64(x - 2.0)))); else tmp = Float64(x * Float64(Float64(0.5 * 0.0) + Float64(x / Float64(x * x)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 4.4e+267) tmp = 0.5 * (2.0 + (x * (x - 2.0))); else tmp = x * ((0.5 * 0.0) + (x / (x * x))); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 4.4e+267], N[(0.5 * N[(2.0 + N[(x * N[(x - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(0.5 * 0.0), $MachinePrecision] + N[(x / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq 4.4 \cdot 10^{+267}:\\
\;\;\;\;0.5 \cdot \left(2 + x \cdot \left(x - 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(0.5 \cdot 0 + \frac{x}{x \cdot x}\right)\\
\end{array}
if x < 4.4000000000000002e267Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.1%
Applied rewrites99.1%
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.6%
Applied rewrites70.6%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6457.3%
Applied rewrites57.3%
if 4.4000000000000002e267 < x Initial program 74.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites43.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
Applied rewrites43.6%
lift-/.f64N/A
mult-flipN/A
rgt-mult-inverseN/A
mult-flip-revN/A
frac-timesN/A
*-rgt-identityN/A
lower-/.f64N/A
lower-*.f6429.8%
Applied rewrites29.8%
Taylor expanded in eps around 0
Applied rewrites29.9%
(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 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.1%
Applied rewrites99.1%
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.6%
Applied rewrites70.6%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6457.3%
Applied rewrites57.3%
(FPCore (x eps) :precision binary64 (* 2.0 0.5))
double code(double x, double eps) {
return 2.0 * 0.5;
}
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 = 2.0d0 * 0.5d0
end function
public static double code(double x, double eps) {
return 2.0 * 0.5;
}
def code(x, eps): return 2.0 * 0.5
function code(x, eps) return Float64(2.0 * 0.5) end
function tmp = code(x, eps) tmp = 2.0 * 0.5; end
code[x_, eps_] := N[(2.0 * 0.5), $MachinePrecision]
2 \cdot 0.5
Initial program 74.1%
Taylor expanded in x around 0
Applied rewrites43.7%
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6443.7%
Applied rewrites43.7%
(FPCore (x eps) :precision binary64 (- 1.0 x))
double code(double x, double eps) {
return 1.0 - x;
}
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 - x
end function
public static double code(double x, double eps) {
return 1.0 - x;
}
def code(x, eps): return 1.0 - x
function code(x, eps) return Float64(1.0 - x) end
function tmp = code(x, eps) tmp = 1.0 - x; end
code[x_, eps_] := N[(1.0 - x), $MachinePrecision]
1 - x
Initial program 74.1%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-+.f6499.1%
Applied rewrites99.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f6443.2%
Applied rewrites43.2%
lift-+.f64N/A
lift-*.f64N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f6443.2%
Applied rewrites43.2%
herbie shell --seed 2025258
(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))