
(FPCore (x eps) :precision binary64 (/ (- (* (+ 1 (/ 1 eps)) (exp (- (* (- 1 eps) x)))) (* (- (/ 1 eps) 1) (exp (- (* (+ 1 eps) x))))) 2))
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 + N[(1 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1 / eps), $MachinePrecision] - 1), $MachinePrecision] * N[Exp[(-N[(N[(1 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2), $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 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (/ (- (* (+ 1 (/ 1 eps)) (exp (- (* (- 1 eps) x)))) (* (- (/ 1 eps) 1) (exp (- (* (+ 1 eps) x))))) 2))
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 + N[(1 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1 / eps), $MachinePrecision] - 1), $MachinePrecision] * N[Exp[(-N[(N[(1 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2), $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 (if (<= (fabs eps) 3512807709348987/18014398509481984) (* (/ (+ (- x -1) (- x -1)) (exp x)) 1/2) (* (+ (exp (* (- (- (fabs eps)) 1) x)) (exp (* (fabs eps) x))) 1/2)))
double code(double x, double eps) {
double tmp;
if (fabs(eps) <= 0.195) {
tmp = (((x - -1.0) + (x - -1.0)) / exp(x)) * 0.5;
} else {
tmp = (exp(((-fabs(eps) - 1.0) * x)) + exp((fabs(eps) * x))) * 0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (abs(eps) <= 0.195d0) then
tmp = (((x - (-1.0d0)) + (x - (-1.0d0))) / exp(x)) * 0.5d0
else
tmp = (exp(((-abs(eps) - 1.0d0) * x)) + exp((abs(eps) * x))) * 0.5d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (Math.abs(eps) <= 0.195) {
tmp = (((x - -1.0) + (x - -1.0)) / Math.exp(x)) * 0.5;
} else {
tmp = (Math.exp(((-Math.abs(eps) - 1.0) * x)) + Math.exp((Math.abs(eps) * x))) * 0.5;
}
return tmp;
}
def code(x, eps): tmp = 0 if math.fabs(eps) <= 0.195: tmp = (((x - -1.0) + (x - -1.0)) / math.exp(x)) * 0.5 else: tmp = (math.exp(((-math.fabs(eps) - 1.0) * x)) + math.exp((math.fabs(eps) * x))) * 0.5 return tmp
function code(x, eps) tmp = 0.0 if (abs(eps) <= 0.195) tmp = Float64(Float64(Float64(Float64(x - -1.0) + Float64(x - -1.0)) / exp(x)) * 0.5); else tmp = Float64(Float64(exp(Float64(Float64(Float64(-abs(eps)) - 1.0) * x)) + exp(Float64(abs(eps) * x))) * 0.5); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (abs(eps) <= 0.195) tmp = (((x - -1.0) + (x - -1.0)) / exp(x)) * 0.5; else tmp = (exp(((-abs(eps) - 1.0) * x)) + exp((abs(eps) * x))) * 0.5; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[Abs[eps], $MachinePrecision], 3512807709348987/18014398509481984], N[(N[(N[(N[(x - -1), $MachinePrecision] + N[(x - -1), $MachinePrecision]), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision], N[(N[(N[Exp[N[(N[((-N[Abs[eps], $MachinePrecision]) - 1), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(N[Abs[eps], $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|\varepsilon\right| \leq \frac{3512807709348987}{18014398509481984}:\\
\;\;\;\;\frac{\left(x - -1\right) + \left(x - -1\right)}{e^{x}} \cdot \frac{1}{2}\\
\mathbf{else}:\\
\;\;\;\;\left(e^{\left(\left(-\left|\varepsilon\right|\right) - 1\right) \cdot x} + e^{\left|\varepsilon\right| \cdot x}\right) \cdot \frac{1}{2}\\
\end{array}
if eps < 0.19500000000000001Initial program 73.0%
Taylor expanded in eps around 0
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-+.f64N/A
Applied rewrites57.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6457.4%
Applied rewrites57.5%
if 0.19500000000000001 < eps Initial program 73.0%
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%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.1%
Applied rewrites99.1%
Taylor expanded in eps around inf
lower-*.f6488.6%
Applied rewrites88.6%
(FPCore (x eps) :precision binary64 (* (+ (exp (* (- (- eps) 1) x)) (exp (* (- eps 1) x))) 1/2))
double code(double x, double eps) {
return (exp(((-eps - 1.0) * x)) + exp(((eps - 1.0) * x))) * 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 = (exp(((-eps - 1.0d0) * x)) + exp(((eps - 1.0d0) * x))) * 0.5d0
end function
public static double code(double x, double eps) {
return (Math.exp(((-eps - 1.0) * x)) + Math.exp(((eps - 1.0) * x))) * 0.5;
}
def code(x, eps): return (math.exp(((-eps - 1.0) * x)) + math.exp(((eps - 1.0) * x))) * 0.5
function code(x, eps) return Float64(Float64(exp(Float64(Float64(Float64(-eps) - 1.0) * x)) + exp(Float64(Float64(eps - 1.0) * x))) * 0.5) end
function tmp = code(x, eps) tmp = (exp(((-eps - 1.0) * x)) + exp(((eps - 1.0) * x))) * 0.5; end
code[x_, eps_] := N[(N[(N[Exp[N[(N[((-eps) - 1), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(N[(eps - 1), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision]
\left(e^{\left(\left(-\varepsilon\right) - 1\right) \cdot x} + e^{\left(\varepsilon - 1\right) \cdot x}\right) \cdot \frac{1}{2}
Initial program 73.0%
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%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.1%
Applied rewrites99.1%
(FPCore (x eps)
:precision binary64
(if (<=
x
-6032057205060441/3016028602530220424421062271578867838525126125874252890898307532480811172246863646685486789069132871854112712507200418582406770249989531589552959798883475511096677545853948017425342019529539590198394174553047792145043723038206885734470238620775335376572758801465612196212014773714996912064944617579072807182486470656)
(* 1/2 (- 1 (* -1 (exp (- (* x (+ 1 (fabs eps))))))))
(if (<= x 19999999999999999862796380718940425895318388736)
(* (+ 1 (exp (* (fabs eps) x))) 1/2)
(* (* (exp (- x)) 2) 1/2))))double code(double x, double eps) {
double tmp;
if (x <= -2e-300) {
tmp = 0.5 * (1.0 - (-1.0 * exp(-(x * (1.0 + fabs(eps))))));
} else if (x <= 2e+46) {
tmp = (1.0 + exp((fabs(eps) * x))) * 0.5;
} else {
tmp = (exp(-x) * 2.0) * 0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-2d-300)) then
tmp = 0.5d0 * (1.0d0 - ((-1.0d0) * exp(-(x * (1.0d0 + abs(eps))))))
else if (x <= 2d+46) then
tmp = (1.0d0 + exp((abs(eps) * x))) * 0.5d0
else
tmp = (exp(-x) * 2.0d0) * 0.5d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -2e-300) {
tmp = 0.5 * (1.0 - (-1.0 * Math.exp(-(x * (1.0 + Math.abs(eps))))));
} else if (x <= 2e+46) {
tmp = (1.0 + Math.exp((Math.abs(eps) * x))) * 0.5;
} else {
tmp = (Math.exp(-x) * 2.0) * 0.5;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -2e-300: tmp = 0.5 * (1.0 - (-1.0 * math.exp(-(x * (1.0 + math.fabs(eps)))))) elif x <= 2e+46: tmp = (1.0 + math.exp((math.fabs(eps) * x))) * 0.5 else: tmp = (math.exp(-x) * 2.0) * 0.5 return tmp
function code(x, eps) tmp = 0.0 if (x <= -2e-300) tmp = Float64(0.5 * Float64(1.0 - Float64(-1.0 * exp(Float64(-Float64(x * Float64(1.0 + abs(eps)))))))); elseif (x <= 2e+46) tmp = Float64(Float64(1.0 + exp(Float64(abs(eps) * x))) * 0.5); else tmp = Float64(Float64(exp(Float64(-x)) * 2.0) * 0.5); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -2e-300) tmp = 0.5 * (1.0 - (-1.0 * exp(-(x * (1.0 + abs(eps)))))); elseif (x <= 2e+46) tmp = (1.0 + exp((abs(eps) * x))) * 0.5; else tmp = (exp(-x) * 2.0) * 0.5; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -6032057205060441/3016028602530220424421062271578867838525126125874252890898307532480811172246863646685486789069132871854112712507200418582406770249989531589552959798883475511096677545853948017425342019529539590198394174553047792145043723038206885734470238620775335376572758801465612196212014773714996912064944617579072807182486470656], N[(1/2 * N[(1 - N[(-1 * N[Exp[(-N[(x * N[(1 + N[Abs[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 19999999999999999862796380718940425895318388736], N[(N[(1 + N[Exp[N[(N[Abs[eps], $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision], N[(N[(N[Exp[(-x)], $MachinePrecision] * 2), $MachinePrecision] * 1/2), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;x \leq \frac{-6032057205060441}{3016028602530220424421062271578867838525126125874252890898307532480811172246863646685486789069132871854112712507200418582406770249989531589552959798883475511096677545853948017425342019529539590198394174553047792145043723038206885734470238620775335376572758801465612196212014773714996912064944617579072807182486470656}:\\
\;\;\;\;\frac{1}{2} \cdot \left(1 - -1 \cdot e^{-x \cdot \left(1 + \left|\varepsilon\right|\right)}\right)\\
\mathbf{elif}\;x \leq 19999999999999999862796380718940425895318388736:\\
\;\;\;\;\left(1 + e^{\left|\varepsilon\right| \cdot x}\right) \cdot \frac{1}{2}\\
\mathbf{else}:\\
\;\;\;\;\left(e^{-x} \cdot 2\right) \cdot \frac{1}{2}\\
\end{array}
if x < -2.0000000000000001e-300Initial program 73.0%
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 -2.0000000000000001e-300 < x < 2e46Initial program 73.0%
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%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.1%
Applied rewrites99.1%
Taylor expanded in eps around inf
lower-*.f6488.6%
Applied rewrites88.6%
Taylor expanded in x around 0
Applied rewrites64.5%
if 2e46 < x Initial program 73.0%
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%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.1%
Applied rewrites99.1%
Taylor expanded in eps around 0
lower-*.f64N/A
lower-exp.f64N/A
lower-*.f6470.1%
Applied rewrites70.1%
lift-*.f64N/A
*-commutativeN/A
lift-exp.f64N/A
lift-*.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
lift-exp.f6470.1%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6470.1%
Applied rewrites70.1%
(FPCore (x eps)
:precision binary64
(if (<=
x
-6032057205060441/3016028602530220424421062271578867838525126125874252890898307532480811172246863646685486789069132871854112712507200418582406770249989531589552959798883475511096677545853948017425342019529539590198394174553047792145043723038206885734470238620775335376572758801465612196212014773714996912064944617579072807182486470656)
(* 1/2 (- 1 (* -1 (exp (- (* x (+ 1 (fabs eps))))))))
(if (<= x 19999999999999999862796380718940425895318388736)
(* (+ 1 (exp (* (fabs eps) x))) 1/2)
(* (/ (+ (- x -1) (- x -1)) (exp x)) 1/2))))double code(double x, double eps) {
double tmp;
if (x <= -2e-300) {
tmp = 0.5 * (1.0 - (-1.0 * exp(-(x * (1.0 + fabs(eps))))));
} else if (x <= 2e+46) {
tmp = (1.0 + exp((fabs(eps) * x))) * 0.5;
} else {
tmp = (((x - -1.0) + (x - -1.0)) / exp(x)) * 0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-2d-300)) then
tmp = 0.5d0 * (1.0d0 - ((-1.0d0) * exp(-(x * (1.0d0 + abs(eps))))))
else if (x <= 2d+46) then
tmp = (1.0d0 + exp((abs(eps) * x))) * 0.5d0
else
tmp = (((x - (-1.0d0)) + (x - (-1.0d0))) / exp(x)) * 0.5d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -2e-300) {
tmp = 0.5 * (1.0 - (-1.0 * Math.exp(-(x * (1.0 + Math.abs(eps))))));
} else if (x <= 2e+46) {
tmp = (1.0 + Math.exp((Math.abs(eps) * x))) * 0.5;
} else {
tmp = (((x - -1.0) + (x - -1.0)) / Math.exp(x)) * 0.5;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -2e-300: tmp = 0.5 * (1.0 - (-1.0 * math.exp(-(x * (1.0 + math.fabs(eps)))))) elif x <= 2e+46: tmp = (1.0 + math.exp((math.fabs(eps) * x))) * 0.5 else: tmp = (((x - -1.0) + (x - -1.0)) / math.exp(x)) * 0.5 return tmp
function code(x, eps) tmp = 0.0 if (x <= -2e-300) tmp = Float64(0.5 * Float64(1.0 - Float64(-1.0 * exp(Float64(-Float64(x * Float64(1.0 + abs(eps)))))))); elseif (x <= 2e+46) tmp = Float64(Float64(1.0 + exp(Float64(abs(eps) * x))) * 0.5); else tmp = Float64(Float64(Float64(Float64(x - -1.0) + Float64(x - -1.0)) / exp(x)) * 0.5); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -2e-300) tmp = 0.5 * (1.0 - (-1.0 * exp(-(x * (1.0 + abs(eps)))))); elseif (x <= 2e+46) tmp = (1.0 + exp((abs(eps) * x))) * 0.5; else tmp = (((x - -1.0) + (x - -1.0)) / exp(x)) * 0.5; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -6032057205060441/3016028602530220424421062271578867838525126125874252890898307532480811172246863646685486789069132871854112712507200418582406770249989531589552959798883475511096677545853948017425342019529539590198394174553047792145043723038206885734470238620775335376572758801465612196212014773714996912064944617579072807182486470656], N[(1/2 * N[(1 - N[(-1 * N[Exp[(-N[(x * N[(1 + N[Abs[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 19999999999999999862796380718940425895318388736], N[(N[(1 + N[Exp[N[(N[Abs[eps], $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision], N[(N[(N[(N[(x - -1), $MachinePrecision] + N[(x - -1), $MachinePrecision]), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;x \leq \frac{-6032057205060441}{3016028602530220424421062271578867838525126125874252890898307532480811172246863646685486789069132871854112712507200418582406770249989531589552959798883475511096677545853948017425342019529539590198394174553047792145043723038206885734470238620775335376572758801465612196212014773714996912064944617579072807182486470656}:\\
\;\;\;\;\frac{1}{2} \cdot \left(1 - -1 \cdot e^{-x \cdot \left(1 + \left|\varepsilon\right|\right)}\right)\\
\mathbf{elif}\;x \leq 19999999999999999862796380718940425895318388736:\\
\;\;\;\;\left(1 + e^{\left|\varepsilon\right| \cdot x}\right) \cdot \frac{1}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x - -1\right) + \left(x - -1\right)}{e^{x}} \cdot \frac{1}{2}\\
\end{array}
if x < -2.0000000000000001e-300Initial program 73.0%
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 -2.0000000000000001e-300 < x < 2e46Initial program 73.0%
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%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.1%
Applied rewrites99.1%
Taylor expanded in eps around inf
lower-*.f6488.6%
Applied rewrites88.6%
Taylor expanded in x around 0
Applied rewrites64.5%
if 2e46 < x Initial program 73.0%
Taylor expanded in eps around 0
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-+.f64N/A
Applied rewrites57.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6457.4%
Applied rewrites57.5%
(FPCore (x eps) :precision binary64 (if (<= (fabs eps) 94999999999999995027949442561445199872) (* (* (exp (- x)) 2) 1/2) (* (+ 1 (exp (* (fabs eps) x))) 1/2)))
double code(double x, double eps) {
double tmp;
if (fabs(eps) <= 9.5e+37) {
tmp = (exp(-x) * 2.0) * 0.5;
} else {
tmp = (1.0 + exp((fabs(eps) * x))) * 0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (abs(eps) <= 9.5d+37) then
tmp = (exp(-x) * 2.0d0) * 0.5d0
else
tmp = (1.0d0 + exp((abs(eps) * x))) * 0.5d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (Math.abs(eps) <= 9.5e+37) {
tmp = (Math.exp(-x) * 2.0) * 0.5;
} else {
tmp = (1.0 + Math.exp((Math.abs(eps) * x))) * 0.5;
}
return tmp;
}
def code(x, eps): tmp = 0 if math.fabs(eps) <= 9.5e+37: tmp = (math.exp(-x) * 2.0) * 0.5 else: tmp = (1.0 + math.exp((math.fabs(eps) * x))) * 0.5 return tmp
function code(x, eps) tmp = 0.0 if (abs(eps) <= 9.5e+37) tmp = Float64(Float64(exp(Float64(-x)) * 2.0) * 0.5); else tmp = Float64(Float64(1.0 + exp(Float64(abs(eps) * x))) * 0.5); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (abs(eps) <= 9.5e+37) tmp = (exp(-x) * 2.0) * 0.5; else tmp = (1.0 + exp((abs(eps) * x))) * 0.5; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[Abs[eps], $MachinePrecision], 94999999999999995027949442561445199872], N[(N[(N[Exp[(-x)], $MachinePrecision] * 2), $MachinePrecision] * 1/2), $MachinePrecision], N[(N[(1 + N[Exp[N[(N[Abs[eps], $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|\varepsilon\right| \leq 94999999999999995027949442561445199872:\\
\;\;\;\;\left(e^{-x} \cdot 2\right) \cdot \frac{1}{2}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + e^{\left|\varepsilon\right| \cdot x}\right) \cdot \frac{1}{2}\\
\end{array}
if eps < 9.4999999999999995e37Initial program 73.0%
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%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.1%
Applied rewrites99.1%
Taylor expanded in eps around 0
lower-*.f64N/A
lower-exp.f64N/A
lower-*.f6470.1%
Applied rewrites70.1%
lift-*.f64N/A
*-commutativeN/A
lift-exp.f64N/A
lift-*.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
lift-exp.f6470.1%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6470.1%
Applied rewrites70.1%
if 9.4999999999999995e37 < eps Initial program 73.0%
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%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.1%
Applied rewrites99.1%
Taylor expanded in eps around inf
lower-*.f6488.6%
Applied rewrites88.6%
Taylor expanded in x around 0
Applied rewrites64.5%
(FPCore (x eps)
:precision binary64
(if (<=
(fabs eps)
4200000000000000259547572063149966815813128127108259927169943245193807723488603782330037791698095292567457170557823028095081566830920435527163929535154945160713535366880771451178801327025282867003392)
(* (* (exp (- x)) 2) 1/2)
(/
(-
(+ 1 (/ 1 (fabs eps)))
(-
(/
1
(/
(fabs eps)
(-
(*
(* (* (- (fabs eps) -1) x) (/ (- (fabs eps) 1) (fabs eps)))
(fabs eps))
-1)))
1))
2)))double code(double x, double eps) {
double tmp;
if (fabs(eps) <= 4.2e+198) {
tmp = (exp(-x) * 2.0) * 0.5;
} else {
tmp = ((1.0 + (1.0 / fabs(eps))) - ((1.0 / (fabs(eps) / (((((fabs(eps) - -1.0) * x) * ((fabs(eps) - 1.0) / fabs(eps))) * fabs(eps)) - -1.0))) - 1.0)) / 2.0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (abs(eps) <= 4.2d+198) then
tmp = (exp(-x) * 2.0d0) * 0.5d0
else
tmp = ((1.0d0 + (1.0d0 / abs(eps))) - ((1.0d0 / (abs(eps) / (((((abs(eps) - (-1.0d0)) * x) * ((abs(eps) - 1.0d0) / abs(eps))) * abs(eps)) - (-1.0d0)))) - 1.0d0)) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (Math.abs(eps) <= 4.2e+198) {
tmp = (Math.exp(-x) * 2.0) * 0.5;
} else {
tmp = ((1.0 + (1.0 / Math.abs(eps))) - ((1.0 / (Math.abs(eps) / (((((Math.abs(eps) - -1.0) * x) * ((Math.abs(eps) - 1.0) / Math.abs(eps))) * Math.abs(eps)) - -1.0))) - 1.0)) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if math.fabs(eps) <= 4.2e+198: tmp = (math.exp(-x) * 2.0) * 0.5 else: tmp = ((1.0 + (1.0 / math.fabs(eps))) - ((1.0 / (math.fabs(eps) / (((((math.fabs(eps) - -1.0) * x) * ((math.fabs(eps) - 1.0) / math.fabs(eps))) * math.fabs(eps)) - -1.0))) - 1.0)) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (abs(eps) <= 4.2e+198) tmp = Float64(Float64(exp(Float64(-x)) * 2.0) * 0.5); else tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / abs(eps))) - Float64(Float64(1.0 / Float64(abs(eps) / Float64(Float64(Float64(Float64(Float64(abs(eps) - -1.0) * x) * Float64(Float64(abs(eps) - 1.0) / abs(eps))) * abs(eps)) - -1.0))) - 1.0)) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (abs(eps) <= 4.2e+198) tmp = (exp(-x) * 2.0) * 0.5; else tmp = ((1.0 + (1.0 / abs(eps))) - ((1.0 / (abs(eps) / (((((abs(eps) - -1.0) * x) * ((abs(eps) - 1.0) / abs(eps))) * abs(eps)) - -1.0))) - 1.0)) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[Abs[eps], $MachinePrecision], 4200000000000000259547572063149966815813128127108259927169943245193807723488603782330037791698095292567457170557823028095081566830920435527163929535154945160713535366880771451178801327025282867003392], N[(N[(N[Exp[(-x)], $MachinePrecision] * 2), $MachinePrecision] * 1/2), $MachinePrecision], N[(N[(N[(1 + N[(1 / N[Abs[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(1 / N[(N[Abs[eps], $MachinePrecision] / N[(N[(N[(N[(N[(N[Abs[eps], $MachinePrecision] - -1), $MachinePrecision] * x), $MachinePrecision] * N[(N[(N[Abs[eps], $MachinePrecision] - 1), $MachinePrecision] / N[Abs[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Abs[eps], $MachinePrecision]), $MachinePrecision] - -1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1), $MachinePrecision]), $MachinePrecision] / 2), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|\varepsilon\right| \leq 4200000000000000259547572063149966815813128127108259927169943245193807723488603782330037791698095292567457170557823028095081566830920435527163929535154945160713535366880771451178801327025282867003392:\\
\;\;\;\;\left(e^{-x} \cdot 2\right) \cdot \frac{1}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\left|\varepsilon\right|}\right) - \left(\frac{1}{\frac{\left|\varepsilon\right|}{\left(\left(\left(\left|\varepsilon\right| - -1\right) \cdot x\right) \cdot \frac{\left|\varepsilon\right| - 1}{\left|\varepsilon\right|}\right) \cdot \left|\varepsilon\right| - -1}} - 1\right)}{2}\\
\end{array}
if eps < 4.2000000000000003e198Initial program 73.0%
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%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.1%
Applied rewrites99.1%
Taylor expanded in eps around 0
lower-*.f64N/A
lower-exp.f64N/A
lower-*.f6470.1%
Applied rewrites70.1%
lift-*.f64N/A
*-commutativeN/A
lift-exp.f64N/A
lift-*.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
lift-exp.f6470.1%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6470.1%
Applied rewrites70.1%
if 4.2000000000000003e198 < eps Initial program 73.0%
Taylor expanded in x around 0
lower-+.f64N/A
lower-/.f6437.6%
Applied rewrites37.6%
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-/.f6423.6%
Applied rewrites23.6%
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
Applied rewrites30.3%
(FPCore (x eps)
:precision binary64
(if (<= (fabs eps) 3512807709348987/18014398509481984)
(* 1/2 (/ -4 (- (* (* (- (* 2/3 x) 1) x) x) 2)))
(if (<=
(fabs eps)
131999999999999999827056903170405592854753811920539301339283833622256165996931172376387097399098462440422467456220713849431020442499736547195457715787159345896667024903899286690296999949407092736)
(* (+ 2 (* x (- x 2))) 1/2)
(/
(-
(+ 1 (/ 1 (fabs eps)))
(/ (* (- (* x (fabs eps)) 1) (fabs eps)) (fabs eps)))
2))))double code(double x, double eps) {
double tmp;
if (fabs(eps) <= 0.195) {
tmp = 0.5 * (-4.0 / (((((0.6666666666666666 * x) - 1.0) * x) * x) - 2.0));
} else if (fabs(eps) <= 1.32e+194) {
tmp = (2.0 + (x * (x - 2.0))) * 0.5;
} else {
tmp = ((1.0 + (1.0 / fabs(eps))) - ((((x * fabs(eps)) - 1.0) * fabs(eps)) / fabs(eps))) / 2.0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (abs(eps) <= 0.195d0) then
tmp = 0.5d0 * ((-4.0d0) / (((((0.6666666666666666d0 * x) - 1.0d0) * x) * x) - 2.0d0))
else if (abs(eps) <= 1.32d+194) then
tmp = (2.0d0 + (x * (x - 2.0d0))) * 0.5d0
else
tmp = ((1.0d0 + (1.0d0 / abs(eps))) - ((((x * abs(eps)) - 1.0d0) * abs(eps)) / abs(eps))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (Math.abs(eps) <= 0.195) {
tmp = 0.5 * (-4.0 / (((((0.6666666666666666 * x) - 1.0) * x) * x) - 2.0));
} else if (Math.abs(eps) <= 1.32e+194) {
tmp = (2.0 + (x * (x - 2.0))) * 0.5;
} else {
tmp = ((1.0 + (1.0 / Math.abs(eps))) - ((((x * Math.abs(eps)) - 1.0) * Math.abs(eps)) / Math.abs(eps))) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if math.fabs(eps) <= 0.195: tmp = 0.5 * (-4.0 / (((((0.6666666666666666 * x) - 1.0) * x) * x) - 2.0)) elif math.fabs(eps) <= 1.32e+194: tmp = (2.0 + (x * (x - 2.0))) * 0.5 else: tmp = ((1.0 + (1.0 / math.fabs(eps))) - ((((x * math.fabs(eps)) - 1.0) * math.fabs(eps)) / math.fabs(eps))) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (abs(eps) <= 0.195) tmp = Float64(0.5 * Float64(-4.0 / Float64(Float64(Float64(Float64(Float64(0.6666666666666666 * x) - 1.0) * x) * x) - 2.0))); elseif (abs(eps) <= 1.32e+194) tmp = Float64(Float64(2.0 + Float64(x * Float64(x - 2.0))) * 0.5); else tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / abs(eps))) - Float64(Float64(Float64(Float64(x * abs(eps)) - 1.0) * abs(eps)) / abs(eps))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (abs(eps) <= 0.195) tmp = 0.5 * (-4.0 / (((((0.6666666666666666 * x) - 1.0) * x) * x) - 2.0)); elseif (abs(eps) <= 1.32e+194) tmp = (2.0 + (x * (x - 2.0))) * 0.5; else tmp = ((1.0 + (1.0 / abs(eps))) - ((((x * abs(eps)) - 1.0) * abs(eps)) / abs(eps))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[Abs[eps], $MachinePrecision], 3512807709348987/18014398509481984], N[(1/2 * N[(-4 / N[(N[(N[(N[(N[(2/3 * x), $MachinePrecision] - 1), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] - 2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Abs[eps], $MachinePrecision], 131999999999999999827056903170405592854753811920539301339283833622256165996931172376387097399098462440422467456220713849431020442499736547195457715787159345896667024903899286690296999949407092736], N[(N[(2 + N[(x * N[(x - 2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision], N[(N[(N[(1 + N[(1 / N[Abs[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[(x * N[Abs[eps], $MachinePrecision]), $MachinePrecision] - 1), $MachinePrecision] * N[Abs[eps], $MachinePrecision]), $MachinePrecision] / N[Abs[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;\left|\varepsilon\right| \leq \frac{3512807709348987}{18014398509481984}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{-4}{\left(\left(\frac{2}{3} \cdot x - 1\right) \cdot x\right) \cdot x - 2}\\
\mathbf{elif}\;\left|\varepsilon\right| \leq 131999999999999999827056903170405592854753811920539301339283833622256165996931172376387097399098462440422467456220713849431020442499736547195457715787159345896667024903899286690296999949407092736:\\
\;\;\;\;\left(2 + x \cdot \left(x - 2\right)\right) \cdot \frac{1}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\left|\varepsilon\right|}\right) - \frac{\left(x \cdot \left|\varepsilon\right| - 1\right) \cdot \left|\varepsilon\right|}{\left|\varepsilon\right|}}{2}\\
\end{array}
if eps < 0.19500000000000001Initial program 73.0%
Taylor expanded in eps around 0
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-+.f64N/A
Applied rewrites57.4%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f6452.6%
Applied rewrites52.6%
lift-+.f64N/A
+-commutativeN/A
flip-+N/A
lower-unsound-/.f64N/A
Applied rewrites45.2%
Taylor expanded in x around 0
Applied rewrites52.7%
if 0.19500000000000001 < eps < 1.32e194Initial program 73.0%
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%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.1%
Applied rewrites99.1%
Taylor expanded in eps around 0
lower-*.f64N/A
lower-exp.f64N/A
lower-*.f6470.1%
Applied rewrites70.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6456.7%
Applied rewrites56.7%
if 1.32e194 < eps Initial program 73.0%
Taylor expanded in x around 0
lower-+.f64N/A
lower-/.f6437.6%
Applied rewrites37.6%
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-/.f6423.6%
Applied rewrites23.6%
Taylor expanded in eps around inf
lower-*.f64N/A
lower--.f64N/A
lower-/.f6421.9%
Applied rewrites21.9%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-/.f64N/A
sub-to-fractionN/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower--.f6428.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6428.6%
Applied rewrites28.6%
(FPCore (x eps)
:precision binary64
(if (<= (fabs eps) 3512807709348987/18014398509481984)
(* 1/2 (/ -4 (- (* (* (- (* 2/3 x) 1) x) x) 2)))
(if (<=
(fabs eps)
131999999999999999827056903170405592854753811920539301339283833622256165996931172376387097399098462440422467456220713849431020442499736547195457715787159345896667024903899286690296999949407092736)
(* (+ 2 (* x (- x 2))) 1/2)
(/
(-
(+ 1 (/ 1 (fabs eps)))
(-
(/
1
(/
(fabs eps)
(-
(*
(* (* (- (fabs eps) -1) x) (/ (- (fabs eps) 1) (fabs eps)))
(fabs eps))
-1)))
1))
2))))double code(double x, double eps) {
double tmp;
if (fabs(eps) <= 0.195) {
tmp = 0.5 * (-4.0 / (((((0.6666666666666666 * x) - 1.0) * x) * x) - 2.0));
} else if (fabs(eps) <= 1.32e+194) {
tmp = (2.0 + (x * (x - 2.0))) * 0.5;
} else {
tmp = ((1.0 + (1.0 / fabs(eps))) - ((1.0 / (fabs(eps) / (((((fabs(eps) - -1.0) * x) * ((fabs(eps) - 1.0) / fabs(eps))) * fabs(eps)) - -1.0))) - 1.0)) / 2.0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (abs(eps) <= 0.195d0) then
tmp = 0.5d0 * ((-4.0d0) / (((((0.6666666666666666d0 * x) - 1.0d0) * x) * x) - 2.0d0))
else if (abs(eps) <= 1.32d+194) then
tmp = (2.0d0 + (x * (x - 2.0d0))) * 0.5d0
else
tmp = ((1.0d0 + (1.0d0 / abs(eps))) - ((1.0d0 / (abs(eps) / (((((abs(eps) - (-1.0d0)) * x) * ((abs(eps) - 1.0d0) / abs(eps))) * abs(eps)) - (-1.0d0)))) - 1.0d0)) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (Math.abs(eps) <= 0.195) {
tmp = 0.5 * (-4.0 / (((((0.6666666666666666 * x) - 1.0) * x) * x) - 2.0));
} else if (Math.abs(eps) <= 1.32e+194) {
tmp = (2.0 + (x * (x - 2.0))) * 0.5;
} else {
tmp = ((1.0 + (1.0 / Math.abs(eps))) - ((1.0 / (Math.abs(eps) / (((((Math.abs(eps) - -1.0) * x) * ((Math.abs(eps) - 1.0) / Math.abs(eps))) * Math.abs(eps)) - -1.0))) - 1.0)) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if math.fabs(eps) <= 0.195: tmp = 0.5 * (-4.0 / (((((0.6666666666666666 * x) - 1.0) * x) * x) - 2.0)) elif math.fabs(eps) <= 1.32e+194: tmp = (2.0 + (x * (x - 2.0))) * 0.5 else: tmp = ((1.0 + (1.0 / math.fabs(eps))) - ((1.0 / (math.fabs(eps) / (((((math.fabs(eps) - -1.0) * x) * ((math.fabs(eps) - 1.0) / math.fabs(eps))) * math.fabs(eps)) - -1.0))) - 1.0)) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (abs(eps) <= 0.195) tmp = Float64(0.5 * Float64(-4.0 / Float64(Float64(Float64(Float64(Float64(0.6666666666666666 * x) - 1.0) * x) * x) - 2.0))); elseif (abs(eps) <= 1.32e+194) tmp = Float64(Float64(2.0 + Float64(x * Float64(x - 2.0))) * 0.5); else tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / abs(eps))) - Float64(Float64(1.0 / Float64(abs(eps) / Float64(Float64(Float64(Float64(Float64(abs(eps) - -1.0) * x) * Float64(Float64(abs(eps) - 1.0) / abs(eps))) * abs(eps)) - -1.0))) - 1.0)) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (abs(eps) <= 0.195) tmp = 0.5 * (-4.0 / (((((0.6666666666666666 * x) - 1.0) * x) * x) - 2.0)); elseif (abs(eps) <= 1.32e+194) tmp = (2.0 + (x * (x - 2.0))) * 0.5; else tmp = ((1.0 + (1.0 / abs(eps))) - ((1.0 / (abs(eps) / (((((abs(eps) - -1.0) * x) * ((abs(eps) - 1.0) / abs(eps))) * abs(eps)) - -1.0))) - 1.0)) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[Abs[eps], $MachinePrecision], 3512807709348987/18014398509481984], N[(1/2 * N[(-4 / N[(N[(N[(N[(N[(2/3 * x), $MachinePrecision] - 1), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] - 2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Abs[eps], $MachinePrecision], 131999999999999999827056903170405592854753811920539301339283833622256165996931172376387097399098462440422467456220713849431020442499736547195457715787159345896667024903899286690296999949407092736], N[(N[(2 + N[(x * N[(x - 2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision], N[(N[(N[(1 + N[(1 / N[Abs[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(1 / N[(N[Abs[eps], $MachinePrecision] / N[(N[(N[(N[(N[(N[Abs[eps], $MachinePrecision] - -1), $MachinePrecision] * x), $MachinePrecision] * N[(N[(N[Abs[eps], $MachinePrecision] - 1), $MachinePrecision] / N[Abs[eps], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Abs[eps], $MachinePrecision]), $MachinePrecision] - -1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1), $MachinePrecision]), $MachinePrecision] / 2), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;\left|\varepsilon\right| \leq \frac{3512807709348987}{18014398509481984}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{-4}{\left(\left(\frac{2}{3} \cdot x - 1\right) \cdot x\right) \cdot x - 2}\\
\mathbf{elif}\;\left|\varepsilon\right| \leq 131999999999999999827056903170405592854753811920539301339283833622256165996931172376387097399098462440422467456220713849431020442499736547195457715787159345896667024903899286690296999949407092736:\\
\;\;\;\;\left(2 + x \cdot \left(x - 2\right)\right) \cdot \frac{1}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\left|\varepsilon\right|}\right) - \left(\frac{1}{\frac{\left|\varepsilon\right|}{\left(\left(\left(\left|\varepsilon\right| - -1\right) \cdot x\right) \cdot \frac{\left|\varepsilon\right| - 1}{\left|\varepsilon\right|}\right) \cdot \left|\varepsilon\right| - -1}} - 1\right)}{2}\\
\end{array}
if eps < 0.19500000000000001Initial program 73.0%
Taylor expanded in eps around 0
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-+.f64N/A
Applied rewrites57.4%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f6452.6%
Applied rewrites52.6%
lift-+.f64N/A
+-commutativeN/A
flip-+N/A
lower-unsound-/.f64N/A
Applied rewrites45.2%
Taylor expanded in x around 0
Applied rewrites52.7%
if 0.19500000000000001 < eps < 1.32e194Initial program 73.0%
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%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.1%
Applied rewrites99.1%
Taylor expanded in eps around 0
lower-*.f64N/A
lower-exp.f64N/A
lower-*.f6470.1%
Applied rewrites70.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6456.7%
Applied rewrites56.7%
if 1.32e194 < eps Initial program 73.0%
Taylor expanded in x around 0
lower-+.f64N/A
lower-/.f6437.6%
Applied rewrites37.6%
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-/.f6423.6%
Applied rewrites23.6%
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
Applied rewrites30.3%
(FPCore (x eps) :precision binary64 (if (<= x 6313494200355439/2475880078570760549798248448) (* (+ 2 (* x (- (* x (+ 1 (* -1/3 x))) 2))) 1/2) (/ (- (+ 1 (/ 1 eps)) (- (/ 1 eps) 1)) 2)))
double code(double x, double eps) {
double tmp;
if (x <= 2.55e-12) {
tmp = (2.0 + (x * ((x * (1.0 + (-0.3333333333333333 * x))) - 2.0))) * 0.5;
} else {
tmp = ((1.0 + (1.0 / eps)) - ((1.0 / eps) - 1.0)) / 2.0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 2.55d-12) then
tmp = (2.0d0 + (x * ((x * (1.0d0 + ((-0.3333333333333333d0) * x))) - 2.0d0))) * 0.5d0
else
tmp = ((1.0d0 + (1.0d0 / eps)) - ((1.0d0 / eps) - 1.0d0)) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 2.55e-12) {
tmp = (2.0 + (x * ((x * (1.0 + (-0.3333333333333333 * x))) - 2.0))) * 0.5;
} else {
tmp = ((1.0 + (1.0 / eps)) - ((1.0 / eps) - 1.0)) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 2.55e-12: tmp = (2.0 + (x * ((x * (1.0 + (-0.3333333333333333 * x))) - 2.0))) * 0.5 else: tmp = ((1.0 + (1.0 / eps)) - ((1.0 / eps) - 1.0)) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 2.55e-12) tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(x * Float64(1.0 + Float64(-0.3333333333333333 * x))) - 2.0))) * 0.5); else tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) - Float64(Float64(1.0 / eps) - 1.0)) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 2.55e-12) tmp = (2.0 + (x * ((x * (1.0 + (-0.3333333333333333 * x))) - 2.0))) * 0.5; else tmp = ((1.0 + (1.0 / eps)) - ((1.0 / eps) - 1.0)) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 6313494200355439/2475880078570760549798248448], N[(N[(2 + N[(x * N[(N[(x * N[(1 + N[(-1/3 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision], N[(N[(N[(1 + N[(1 / eps), $MachinePrecision]), $MachinePrecision] - N[(N[(1 / eps), $MachinePrecision] - 1), $MachinePrecision]), $MachinePrecision] / 2), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq \frac{6313494200355439}{2475880078570760549798248448}:\\
\;\;\;\;\left(2 + x \cdot \left(x \cdot \left(1 + \frac{-1}{3} \cdot x\right) - 2\right)\right) \cdot \frac{1}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\end{array}
if x < 2.5499999999999998e-12Initial program 73.0%
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%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.1%
Applied rewrites99.1%
Taylor expanded in eps around 0
lower-*.f64N/A
lower-exp.f64N/A
lower-*.f6470.1%
Applied rewrites70.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6451.6%
Applied rewrites51.6%
if 2.5499999999999998e-12 < x Initial program 73.0%
Taylor expanded in x around 0
lower-+.f64N/A
lower-/.f6437.6%
Applied rewrites37.6%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6430.7%
Applied rewrites30.7%
(FPCore (x eps)
:precision binary64
(if (<=
(/
(-
(* (+ 1 (/ 1 eps)) (exp (- (* (- 1 eps) x))))
(* (- (/ 1 eps) 1) (exp (- (* (+ 1 eps) x)))))
2)
2000)
(* 1/2 (/ -4 (- (* (* (- (* 2/3 x) 1) x) x) 2)))
(* (+ 2 (* x (- x 2))) 1/2)))double code(double x, double eps) {
double tmp;
if (((((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0) <= 2000.0) {
tmp = 0.5 * (-4.0 / (((((0.6666666666666666 * x) - 1.0) * x) * x) - 2.0));
} else {
tmp = (2.0 + (x * (x - 2.0))) * 0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (((((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0) <= 2000.0d0) then
tmp = 0.5d0 * ((-4.0d0) / (((((0.6666666666666666d0 * x) - 1.0d0) * x) * x) - 2.0d0))
else
tmp = (2.0d0 + (x * (x - 2.0d0))) * 0.5d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (((((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-((1.0 + eps) * x)))) / 2.0) <= 2000.0) {
tmp = 0.5 * (-4.0 / (((((0.6666666666666666 * x) - 1.0) * x) * x) - 2.0));
} else {
tmp = (2.0 + (x * (x - 2.0))) * 0.5;
}
return tmp;
}
def code(x, eps): tmp = 0 if ((((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-((1.0 + eps) * x)))) / 2.0) <= 2000.0: tmp = 0.5 * (-4.0 / (((((0.6666666666666666 * x) - 1.0) * x) * x) - 2.0)) else: tmp = (2.0 + (x * (x - 2.0))) * 0.5 return tmp
function code(x, eps) tmp = 0.0 if (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) <= 2000.0) tmp = Float64(0.5 * Float64(-4.0 / Float64(Float64(Float64(Float64(Float64(0.6666666666666666 * x) - 1.0) * x) * x) - 2.0))); else tmp = Float64(Float64(2.0 + Float64(x * Float64(x - 2.0))) * 0.5); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (((((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0) <= 2000.0) tmp = 0.5 * (-4.0 / (((((0.6666666666666666 * x) - 1.0) * x) * x) - 2.0)); else tmp = (2.0 + (x * (x - 2.0))) * 0.5; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[(N[(N[(N[(1 + N[(1 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1 / eps), $MachinePrecision] - 1), $MachinePrecision] * N[Exp[(-N[(N[(1 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2), $MachinePrecision], 2000], N[(1/2 * N[(-4 / N[(N[(N[(N[(N[(2/3 * x), $MachinePrecision] - 1), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] - 2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2 + N[(x * N[(x - 2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\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} \leq 2000:\\
\;\;\;\;\frac{1}{2} \cdot \frac{-4}{\left(\left(\frac{2}{3} \cdot x - 1\right) \cdot x\right) \cdot x - 2}\\
\mathbf{else}:\\
\;\;\;\;\left(2 + x \cdot \left(x - 2\right)\right) \cdot \frac{1}{2}\\
\end{array}
if (/.f64 (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) #s(literal 2 binary64)) < 2e3Initial program 73.0%
Taylor expanded in eps around 0
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-+.f64N/A
Applied rewrites57.4%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f6452.6%
Applied rewrites52.6%
lift-+.f64N/A
+-commutativeN/A
flip-+N/A
lower-unsound-/.f64N/A
Applied rewrites45.2%
Taylor expanded in x around 0
Applied rewrites52.7%
if 2e3 < (/.f64 (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) #s(literal 2 binary64)) Initial program 73.0%
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%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.1%
Applied rewrites99.1%
Taylor expanded in eps around 0
lower-*.f64N/A
lower-exp.f64N/A
lower-*.f6470.1%
Applied rewrites70.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6456.7%
Applied rewrites56.7%
(FPCore (x eps) :precision binary64 (if (<= x -7385903388887613/9007199254740992) (* (+ 2 (* x (- (* x (+ 1 (* -1/3 x))) 2))) 1/2) (* 1/2 (- 2 (* (- 1 (* 2/3 x)) (* x x))))))
double code(double x, double eps) {
double tmp;
if (x <= -0.82) {
tmp = (2.0 + (x * ((x * (1.0 + (-0.3333333333333333 * x))) - 2.0))) * 0.5;
} else {
tmp = 0.5 * (2.0 - ((1.0 - (0.6666666666666666 * 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.82d0)) then
tmp = (2.0d0 + (x * ((x * (1.0d0 + ((-0.3333333333333333d0) * x))) - 2.0d0))) * 0.5d0
else
tmp = 0.5d0 * (2.0d0 - ((1.0d0 - (0.6666666666666666d0 * x)) * (x * x)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -0.82) {
tmp = (2.0 + (x * ((x * (1.0 + (-0.3333333333333333 * x))) - 2.0))) * 0.5;
} else {
tmp = 0.5 * (2.0 - ((1.0 - (0.6666666666666666 * x)) * (x * x)));
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -0.82: tmp = (2.0 + (x * ((x * (1.0 + (-0.3333333333333333 * x))) - 2.0))) * 0.5 else: tmp = 0.5 * (2.0 - ((1.0 - (0.6666666666666666 * x)) * (x * x))) return tmp
function code(x, eps) tmp = 0.0 if (x <= -0.82) tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(x * Float64(1.0 + Float64(-0.3333333333333333 * x))) - 2.0))) * 0.5); else tmp = Float64(0.5 * Float64(2.0 - Float64(Float64(1.0 - Float64(0.6666666666666666 * x)) * Float64(x * x)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -0.82) tmp = (2.0 + (x * ((x * (1.0 + (-0.3333333333333333 * x))) - 2.0))) * 0.5; else tmp = 0.5 * (2.0 - ((1.0 - (0.6666666666666666 * x)) * (x * x))); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -7385903388887613/9007199254740992], N[(N[(2 + N[(x * N[(N[(x * N[(1 + N[(-1/3 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision], N[(1/2 * N[(2 - N[(N[(1 - N[(2/3 * x), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq \frac{-7385903388887613}{9007199254740992}:\\
\;\;\;\;\left(2 + x \cdot \left(x \cdot \left(1 + \frac{-1}{3} \cdot x\right) - 2\right)\right) \cdot \frac{1}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2} \cdot \left(2 - \left(1 - \frac{2}{3} \cdot x\right) \cdot \left(x \cdot x\right)\right)\\
\end{array}
if x < -0.81999999999999995Initial program 73.0%
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%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.1%
Applied rewrites99.1%
Taylor expanded in eps around 0
lower-*.f64N/A
lower-exp.f64N/A
lower-*.f6470.1%
Applied rewrites70.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6451.6%
Applied rewrites51.6%
if -0.81999999999999995 < x Initial program 73.0%
Taylor expanded in eps around 0
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-+.f64N/A
Applied rewrites57.4%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f6452.6%
Applied rewrites52.6%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
distribute-lft-neg-outN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
lower-*.f64N/A
lower--.f6452.6%
lift-pow.f64N/A
unpow2N/A
lower-*.f6452.6%
Applied rewrites52.6%
(FPCore (x eps) :precision binary64 (if (<= x -7385903388887613/9007199254740992) (* (+ 2 (* x (- x 2))) 1/2) (* 1/2 (- 2 (* (- 1 (* 2/3 x)) (* x x))))))
double code(double x, double eps) {
double tmp;
if (x <= -0.82) {
tmp = (2.0 + (x * (x - 2.0))) * 0.5;
} else {
tmp = 0.5 * (2.0 - ((1.0 - (0.6666666666666666 * 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.82d0)) then
tmp = (2.0d0 + (x * (x - 2.0d0))) * 0.5d0
else
tmp = 0.5d0 * (2.0d0 - ((1.0d0 - (0.6666666666666666d0 * x)) * (x * x)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -0.82) {
tmp = (2.0 + (x * (x - 2.0))) * 0.5;
} else {
tmp = 0.5 * (2.0 - ((1.0 - (0.6666666666666666 * x)) * (x * x)));
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -0.82: tmp = (2.0 + (x * (x - 2.0))) * 0.5 else: tmp = 0.5 * (2.0 - ((1.0 - (0.6666666666666666 * x)) * (x * x))) return tmp
function code(x, eps) tmp = 0.0 if (x <= -0.82) tmp = Float64(Float64(2.0 + Float64(x * Float64(x - 2.0))) * 0.5); else tmp = Float64(0.5 * Float64(2.0 - Float64(Float64(1.0 - Float64(0.6666666666666666 * x)) * Float64(x * x)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -0.82) tmp = (2.0 + (x * (x - 2.0))) * 0.5; else tmp = 0.5 * (2.0 - ((1.0 - (0.6666666666666666 * x)) * (x * x))); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -7385903388887613/9007199254740992], N[(N[(2 + N[(x * N[(x - 2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision], N[(1/2 * N[(2 - N[(N[(1 - N[(2/3 * x), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq \frac{-7385903388887613}{9007199254740992}:\\
\;\;\;\;\left(2 + x \cdot \left(x - 2\right)\right) \cdot \frac{1}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2} \cdot \left(2 - \left(1 - \frac{2}{3} \cdot x\right) \cdot \left(x \cdot x\right)\right)\\
\end{array}
if x < -0.81999999999999995Initial program 73.0%
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%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.1%
Applied rewrites99.1%
Taylor expanded in eps around 0
lower-*.f64N/A
lower-exp.f64N/A
lower-*.f6470.1%
Applied rewrites70.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6456.7%
Applied rewrites56.7%
if -0.81999999999999995 < x Initial program 73.0%
Taylor expanded in eps around 0
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-+.f64N/A
Applied rewrites57.4%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f6452.6%
Applied rewrites52.6%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
distribute-lft-neg-outN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
lower-*.f64N/A
lower--.f6452.6%
lift-pow.f64N/A
unpow2N/A
lower-*.f6452.6%
Applied rewrites52.6%
(FPCore (x eps) :precision binary64 (* (+ 2 (* x (- x 2))) 1/2))
double code(double x, double eps) {
return (2.0 + (x * (x - 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 + (x * (x - 2.0d0))) * 0.5d0
end function
public static double code(double x, double eps) {
return (2.0 + (x * (x - 2.0))) * 0.5;
}
def code(x, eps): return (2.0 + (x * (x - 2.0))) * 0.5
function code(x, eps) return Float64(Float64(2.0 + Float64(x * Float64(x - 2.0))) * 0.5) end
function tmp = code(x, eps) tmp = (2.0 + (x * (x - 2.0))) * 0.5; end
code[x_, eps_] := N[(N[(2 + N[(x * N[(x - 2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision]
\left(2 + x \cdot \left(x - 2\right)\right) \cdot \frac{1}{2}
Initial program 73.0%
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%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.1%
Applied rewrites99.1%
Taylor expanded in eps around 0
lower-*.f64N/A
lower-exp.f64N/A
lower-*.f6470.1%
Applied rewrites70.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f6456.7%
Applied rewrites56.7%
(FPCore (x eps) :precision binary64 (* 2 1/2))
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 * 1/2), $MachinePrecision]
2 \cdot \frac{1}{2}
Initial program 73.0%
Taylor expanded in x around 0
Applied rewrites43.8%
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6443.8%
Applied rewrites43.8%
(FPCore (x eps) :precision binary64 (- 1 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 - x), $MachinePrecision]
1 - x
Initial program 73.0%
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.3%
Applied rewrites43.3%
lift-+.f64N/A
lift-*.f64N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f6443.3%
Applied rewrites43.3%
herbie shell --seed 2025271 -o generate:evaluate
(FPCore (x eps)
:name "NMSE Section 6.1 mentioned, A"
:precision binary64
(/ (- (* (+ 1 (/ 1 eps)) (exp (- (* (- 1 eps) x)))) (* (- (/ 1 eps) 1) (exp (- (* (+ 1 eps) x))))) 2))