
(FPCore (x eps) :precision binary64 (/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))
double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0
end function
public static double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-((1.0 + eps) * x)))) / 2.0;
}
def code(x, eps): return (((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-((1.0 + eps) * x)))) / 2.0
function code(x, eps) return Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(-Float64(Float64(1.0 - eps) * x)))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * exp(Float64(-Float64(Float64(1.0 + eps) * x))))) / 2.0) end
function tmp = code(x, eps) tmp = (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0; end
code[x_, eps_] := N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}
\end{array}
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))
double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0
end function
public static double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-((1.0 + eps) * x)))) / 2.0;
}
def code(x, eps): return (((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-((1.0 + eps) * x)))) / 2.0
function code(x, eps) return Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(-Float64(Float64(1.0 - eps) * x)))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * exp(Float64(-Float64(Float64(1.0 + eps) * x))))) / 2.0) end
function tmp = code(x, eps) tmp = (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0; end
code[x_, eps_] := N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}
\end{array}
(FPCore (x eps) :precision binary64 (* (- (exp (* (- x) (- 1.0 eps))) (- (exp (- (fma x eps x))))) 0.5))
double code(double x, double eps) {
return (exp((-x * (1.0 - eps))) - -exp(-fma(x, eps, x))) * 0.5;
}
function code(x, eps) return Float64(Float64(exp(Float64(Float64(-x) * Float64(1.0 - eps))) - Float64(-exp(Float64(-fma(x, eps, x))))) * 0.5) end
code[x_, eps_] := N[(N[(N[Exp[N[((-x) * N[(1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - (-N[Exp[(-N[(x * eps + x), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
\\
\left(e^{\left(-x\right) \cdot \left(1 - \varepsilon\right)} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot 0.5
\end{array}
Initial program 73.3%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.2%
(FPCore (x eps) :precision binary64 (if (<= eps 1.1e-31) (exp (- x)) (* (- (exp (* x eps)) (- (exp (- (* x eps))))) 0.5)))
double code(double x, double eps) {
double tmp;
if (eps <= 1.1e-31) {
tmp = exp(-x);
} else {
tmp = (exp((x * eps)) - -exp(-(x * eps))) * 0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (eps <= 1.1d-31) then
tmp = exp(-x)
else
tmp = (exp((x * eps)) - -exp(-(x * eps))) * 0.5d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= 1.1e-31) {
tmp = Math.exp(-x);
} else {
tmp = (Math.exp((x * eps)) - -Math.exp(-(x * eps))) * 0.5;
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= 1.1e-31: tmp = math.exp(-x) else: tmp = (math.exp((x * eps)) - -math.exp(-(x * eps))) * 0.5 return tmp
function code(x, eps) tmp = 0.0 if (eps <= 1.1e-31) tmp = exp(Float64(-x)); else tmp = Float64(Float64(exp(Float64(x * eps)) - Float64(-exp(Float64(-Float64(x * eps))))) * 0.5); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= 1.1e-31) tmp = exp(-x); else tmp = (exp((x * eps)) - -exp(-(x * eps))) * 0.5; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, 1.1e-31], N[Exp[(-x)], $MachinePrecision], N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] - (-N[Exp[(-N[(x * eps), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 1.1 \cdot 10^{-31}:\\
\;\;\;\;e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\left(e^{x \cdot \varepsilon} - \left(-e^{-x \cdot \varepsilon}\right)\right) \cdot 0.5\\
\end{array}
\end{array}
if eps < 1.10000000000000005e-31Initial program 62.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.0%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6485.4
Applied rewrites85.4%
Taylor expanded in eps around 0
lower-exp.f64N/A
lift-neg.f6477.6
Applied rewrites77.6%
if 1.10000000000000005e-31 < eps Initial program 97.5%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.7%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6497.6
Applied rewrites97.6%
Taylor expanded in eps around inf
*-commutativeN/A
lift-*.f6497.7
Applied rewrites97.7%
(FPCore (x eps)
:precision binary64
(if (<= x -1e-295)
(* (- 1.0 (- (exp (- (* x eps))))) 0.5)
(if (<= x 3800000.0)
(* (- (exp (* (- x) (- 1.0 eps))) (* (+ x (/ (- x 1.0) eps)) eps)) 0.5)
(/ (- (* (+ 1.0 (/ 1.0 eps)) 1.0) (/ (fma -1.0 eps 1.0) eps)) 2.0))))
double code(double x, double eps) {
double tmp;
if (x <= -1e-295) {
tmp = (1.0 - -exp(-(x * eps))) * 0.5;
} else if (x <= 3800000.0) {
tmp = (exp((-x * (1.0 - eps))) - ((x + ((x - 1.0) / eps)) * eps)) * 0.5;
} else {
tmp = (((1.0 + (1.0 / eps)) * 1.0) - (fma(-1.0, eps, 1.0) / eps)) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -1e-295) tmp = Float64(Float64(1.0 - Float64(-exp(Float64(-Float64(x * eps))))) * 0.5); elseif (x <= 3800000.0) tmp = Float64(Float64(exp(Float64(Float64(-x) * Float64(1.0 - eps))) - Float64(Float64(x + Float64(Float64(x - 1.0) / eps)) * eps)) * 0.5); else tmp = Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * 1.0) - Float64(fma(-1.0, eps, 1.0) / eps)) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -1e-295], N[(N[(1.0 - (-N[Exp[(-N[(x * eps), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 3800000.0], N[(N[(N[Exp[N[((-x) * N[(1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[(N[(x + N[(N[(x - 1.0), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] - N[(N[(-1.0 * eps + 1.0), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-295}:\\
\;\;\;\;\left(1 - \left(-e^{-x \cdot \varepsilon}\right)\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 3800000:\\
\;\;\;\;\left(e^{\left(-x\right) \cdot \left(1 - \varepsilon\right)} - \left(x + \frac{x - 1}{\varepsilon}\right) \cdot \varepsilon\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot 1 - \frac{\mathsf{fma}\left(-1, \varepsilon, 1\right)}{\varepsilon}}{2}\\
\end{array}
\end{array}
if x < -1.00000000000000006e-295Initial program 69.1%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.0%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6499.0
Applied rewrites99.0%
Taylor expanded in eps around inf
*-commutativeN/A
lift-*.f6499.4
Applied rewrites99.4%
Taylor expanded in x around 0
Applied rewrites74.1%
if -1.00000000000000006e-295 < x < 3.8e6Initial program 55.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.9%
Taylor expanded in x around 0
lower--.f64N/A
*-commutativeN/A
+-commutativeN/A
distribute-rgt1-inN/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f6485.1
Applied rewrites85.1%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
associate--l+N/A
div-subN/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f6485.1
Applied rewrites85.1%
if 3.8e6 < x Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites28.6%
Taylor expanded in x around 0
lower--.f64N/A
inv-powN/A
lower-pow.f6446.8
Applied rewrites46.8%
Taylor expanded in eps around 0
lower-/.f64N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
lower-fma.f6446.8
Applied rewrites46.8%
(FPCore (x eps)
:precision binary64
(if (<= x -1e-295)
(* (- 1.0 (- (exp (- (* x eps))))) 0.5)
(if (<= x 3800000.0)
(* (- (exp (* x eps)) (- (fma x eps x) 1.0)) 0.5)
(/ (- (* (+ 1.0 (/ 1.0 eps)) 1.0) (/ (fma -1.0 eps 1.0) eps)) 2.0))))
double code(double x, double eps) {
double tmp;
if (x <= -1e-295) {
tmp = (1.0 - -exp(-(x * eps))) * 0.5;
} else if (x <= 3800000.0) {
tmp = (exp((x * eps)) - (fma(x, eps, x) - 1.0)) * 0.5;
} else {
tmp = (((1.0 + (1.0 / eps)) * 1.0) - (fma(-1.0, eps, 1.0) / eps)) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -1e-295) tmp = Float64(Float64(1.0 - Float64(-exp(Float64(-Float64(x * eps))))) * 0.5); elseif (x <= 3800000.0) tmp = Float64(Float64(exp(Float64(x * eps)) - Float64(fma(x, eps, x) - 1.0)) * 0.5); else tmp = Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * 1.0) - Float64(fma(-1.0, eps, 1.0) / eps)) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -1e-295], N[(N[(1.0 - (-N[Exp[(-N[(x * eps), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 3800000.0], N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] - N[(N[(x * eps + x), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] - N[(N[(-1.0 * eps + 1.0), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-295}:\\
\;\;\;\;\left(1 - \left(-e^{-x \cdot \varepsilon}\right)\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 3800000:\\
\;\;\;\;\left(e^{x \cdot \varepsilon} - \left(\mathsf{fma}\left(x, \varepsilon, x\right) - 1\right)\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot 1 - \frac{\mathsf{fma}\left(-1, \varepsilon, 1\right)}{\varepsilon}}{2}\\
\end{array}
\end{array}
if x < -1.00000000000000006e-295Initial program 69.1%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.0%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6499.0
Applied rewrites99.0%
Taylor expanded in eps around inf
*-commutativeN/A
lift-*.f6499.4
Applied rewrites99.4%
Taylor expanded in x around 0
Applied rewrites74.1%
if -1.00000000000000006e-295 < x < 3.8e6Initial program 55.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.9%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6498.1
Applied rewrites98.1%
Taylor expanded in eps around inf
*-commutativeN/A
lift-*.f6498.6
Applied rewrites98.6%
Taylor expanded in x around 0
lower--.f64N/A
*-commutativeN/A
+-commutativeN/A
distribute-rgt1-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6485.1
Applied rewrites85.1%
if 3.8e6 < x Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites28.6%
Taylor expanded in x around 0
lower--.f64N/A
inv-powN/A
lower-pow.f6446.8
Applied rewrites46.8%
Taylor expanded in eps around 0
lower-/.f64N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
lower-fma.f6446.8
Applied rewrites46.8%
(FPCore (x eps)
:precision binary64
(if (<= x -29.0)
(exp (- x))
(if (<= x -2.55e-250)
(* (fma (fma -1.0 (/ (- (* eps eps) 1.0) (- eps 1.0)) eps) x 2.0) 0.5)
(if (<= x 7500000000000.0)
(* (- (exp (* x eps)) -1.0) 0.5)
(/ (- (* (+ 1.0 (/ 1.0 eps)) 1.0) (/ (fma -1.0 eps 1.0) eps)) 2.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -29.0) {
tmp = exp(-x);
} else if (x <= -2.55e-250) {
tmp = fma(fma(-1.0, (((eps * eps) - 1.0) / (eps - 1.0)), eps), x, 2.0) * 0.5;
} else if (x <= 7500000000000.0) {
tmp = (exp((x * eps)) - -1.0) * 0.5;
} else {
tmp = (((1.0 + (1.0 / eps)) * 1.0) - (fma(-1.0, eps, 1.0) / eps)) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -29.0) tmp = exp(Float64(-x)); elseif (x <= -2.55e-250) tmp = Float64(fma(fma(-1.0, Float64(Float64(Float64(eps * eps) - 1.0) / Float64(eps - 1.0)), eps), x, 2.0) * 0.5); elseif (x <= 7500000000000.0) tmp = Float64(Float64(exp(Float64(x * eps)) - -1.0) * 0.5); else tmp = Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * 1.0) - Float64(fma(-1.0, eps, 1.0) / eps)) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -29.0], N[Exp[(-x)], $MachinePrecision], If[LessEqual[x, -2.55e-250], N[(N[(N[(-1.0 * N[(N[(N[(eps * eps), $MachinePrecision] - 1.0), $MachinePrecision] / N[(eps - 1.0), $MachinePrecision]), $MachinePrecision] + eps), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 7500000000000.0], N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] - N[(N[(-1.0 * eps + 1.0), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -29:\\
\;\;\;\;e^{-x}\\
\mathbf{elif}\;x \leq -2.55 \cdot 10^{-250}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, \frac{\varepsilon \cdot \varepsilon - 1}{\varepsilon - 1}, \varepsilon\right), x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 7500000000000:\\
\;\;\;\;\left(e^{x \cdot \varepsilon} - -1\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot 1 - \frac{\mathsf{fma}\left(-1, \varepsilon, 1\right)}{\varepsilon}}{2}\\
\end{array}
\end{array}
if x < -29Initial program 99.4%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.3%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6499.3
Applied rewrites99.3%
Taylor expanded in eps around 0
lower-exp.f64N/A
lift-neg.f6499.0
Applied rewrites99.0%
if -29 < x < -2.5500000000000001e-250Initial program 53.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.6%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6469.1
Applied rewrites69.1%
lift-+.f64N/A
flip-+N/A
lower-/.f64N/A
unpow2N/A
metadata-evalN/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f6476.2
Applied rewrites76.2%
Taylor expanded in eps around inf
Applied rewrites76.2%
if -2.5500000000000001e-250 < x < 7.5e12Initial program 55.3%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.0%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6497.6
Applied rewrites97.6%
Taylor expanded in x around 0
Applied rewrites85.3%
if 7.5e12 < x Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites28.6%
Taylor expanded in x around 0
lower--.f64N/A
inv-powN/A
lower-pow.f6446.6
Applied rewrites46.6%
Taylor expanded in eps around 0
lower-/.f64N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
lower-fma.f6446.6
Applied rewrites46.6%
(FPCore (x eps)
:precision binary64
(if (<= x -1e-295)
(* (- 1.0 (- (exp (- (* x eps))))) 0.5)
(if (<= x 7500000000000.0)
(* (- (exp (* x eps)) -1.0) 0.5)
(/ (- (* (+ 1.0 (/ 1.0 eps)) 1.0) (/ (fma -1.0 eps 1.0) eps)) 2.0))))
double code(double x, double eps) {
double tmp;
if (x <= -1e-295) {
tmp = (1.0 - -exp(-(x * eps))) * 0.5;
} else if (x <= 7500000000000.0) {
tmp = (exp((x * eps)) - -1.0) * 0.5;
} else {
tmp = (((1.0 + (1.0 / eps)) * 1.0) - (fma(-1.0, eps, 1.0) / eps)) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -1e-295) tmp = Float64(Float64(1.0 - Float64(-exp(Float64(-Float64(x * eps))))) * 0.5); elseif (x <= 7500000000000.0) tmp = Float64(Float64(exp(Float64(x * eps)) - -1.0) * 0.5); else tmp = Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * 1.0) - Float64(fma(-1.0, eps, 1.0) / eps)) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -1e-295], N[(N[(1.0 - (-N[Exp[(-N[(x * eps), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 7500000000000.0], N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] - N[(N[(-1.0 * eps + 1.0), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-295}:\\
\;\;\;\;\left(1 - \left(-e^{-x \cdot \varepsilon}\right)\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 7500000000000:\\
\;\;\;\;\left(e^{x \cdot \varepsilon} - -1\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot 1 - \frac{\mathsf{fma}\left(-1, \varepsilon, 1\right)}{\varepsilon}}{2}\\
\end{array}
\end{array}
if x < -1.00000000000000006e-295Initial program 69.1%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.0%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6499.0
Applied rewrites99.0%
Taylor expanded in eps around inf
*-commutativeN/A
lift-*.f6499.4
Applied rewrites99.4%
Taylor expanded in x around 0
Applied rewrites74.1%
if -1.00000000000000006e-295 < x < 7.5e12Initial program 55.5%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.9%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6497.3
Applied rewrites97.3%
Taylor expanded in x around 0
Applied rewrites84.0%
if 7.5e12 < x Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites28.6%
Taylor expanded in x around 0
lower--.f64N/A
inv-powN/A
lower-pow.f6446.6
Applied rewrites46.6%
Taylor expanded in eps around 0
lower-/.f64N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
lower-fma.f6446.6
Applied rewrites46.6%
(FPCore (x eps)
:precision binary64
(if (<= eps 4.4e+220)
(exp (- x))
(*
(fma (fma -1.0 (/ (- (* eps eps) 1.0) (- eps 1.0)) (- (- 1.0 eps))) x 2.0)
0.5)))
double code(double x, double eps) {
double tmp;
if (eps <= 4.4e+220) {
tmp = exp(-x);
} else {
tmp = fma(fma(-1.0, (((eps * eps) - 1.0) / (eps - 1.0)), -(1.0 - eps)), x, 2.0) * 0.5;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 4.4e+220) tmp = exp(Float64(-x)); else tmp = Float64(fma(fma(-1.0, Float64(Float64(Float64(eps * eps) - 1.0) / Float64(eps - 1.0)), Float64(-Float64(1.0 - eps))), x, 2.0) * 0.5); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 4.4e+220], N[Exp[(-x)], $MachinePrecision], N[(N[(N[(-1.0 * N[(N[(N[(eps * eps), $MachinePrecision] - 1.0), $MachinePrecision] / N[(eps - 1.0), $MachinePrecision]), $MachinePrecision] + (-N[(1.0 - eps), $MachinePrecision])), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 4.4 \cdot 10^{+220}:\\
\;\;\;\;e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, \frac{\varepsilon \cdot \varepsilon - 1}{\varepsilon - 1}, -\left(1 - \varepsilon\right)\right), x, 2\right) \cdot 0.5\\
\end{array}
\end{array}
if eps < 4.39999999999999978e220Initial program 70.8%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.2%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6488.2
Applied rewrites88.2%
Taylor expanded in eps around 0
lower-exp.f64N/A
lift-neg.f6473.3
Applied rewrites73.3%
if 4.39999999999999978e220 < eps Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f648.6
Applied rewrites8.6%
lift-+.f64N/A
flip-+N/A
lower-/.f64N/A
unpow2N/A
metadata-evalN/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f6446.6
Applied rewrites46.6%
(FPCore (x eps)
:precision binary64
(if (<= x -1.8e+77)
(* (fma (fma -1.0 (+ eps 1.0) -1.0) x 2.0) 0.5)
(if (<= x -1e-209)
(* (fma (fma -1.0 (/ (- (* eps eps) 1.0) (- eps 1.0)) eps) x 2.0) 0.5)
(if (<= x 2e-243)
1.0
(if (<= x 2400000.0)
(*
(fma
(fma -1.0 (+ eps 1.0) (- (/ (- 1.0 (* eps eps)) (+ eps 1.0))))
x
2.0)
0.5)
(/
(- (* (+ 1.0 (/ 1.0 eps)) 1.0) (/ (fma -1.0 eps 1.0) eps))
2.0))))))
double code(double x, double eps) {
double tmp;
if (x <= -1.8e+77) {
tmp = fma(fma(-1.0, (eps + 1.0), -1.0), x, 2.0) * 0.5;
} else if (x <= -1e-209) {
tmp = fma(fma(-1.0, (((eps * eps) - 1.0) / (eps - 1.0)), eps), x, 2.0) * 0.5;
} else if (x <= 2e-243) {
tmp = 1.0;
} else if (x <= 2400000.0) {
tmp = fma(fma(-1.0, (eps + 1.0), -((1.0 - (eps * eps)) / (eps + 1.0))), x, 2.0) * 0.5;
} else {
tmp = (((1.0 + (1.0 / eps)) * 1.0) - (fma(-1.0, eps, 1.0) / eps)) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -1.8e+77) tmp = Float64(fma(fma(-1.0, Float64(eps + 1.0), -1.0), x, 2.0) * 0.5); elseif (x <= -1e-209) tmp = Float64(fma(fma(-1.0, Float64(Float64(Float64(eps * eps) - 1.0) / Float64(eps - 1.0)), eps), x, 2.0) * 0.5); elseif (x <= 2e-243) tmp = 1.0; elseif (x <= 2400000.0) tmp = Float64(fma(fma(-1.0, Float64(eps + 1.0), Float64(-Float64(Float64(1.0 - Float64(eps * eps)) / Float64(eps + 1.0)))), x, 2.0) * 0.5); else tmp = Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * 1.0) - Float64(fma(-1.0, eps, 1.0) / eps)) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -1.8e+77], N[(N[(N[(-1.0 * N[(eps + 1.0), $MachinePrecision] + -1.0), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, -1e-209], N[(N[(N[(-1.0 * N[(N[(N[(eps * eps), $MachinePrecision] - 1.0), $MachinePrecision] / N[(eps - 1.0), $MachinePrecision]), $MachinePrecision] + eps), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 2e-243], 1.0, If[LessEqual[x, 2400000.0], N[(N[(N[(-1.0 * N[(eps + 1.0), $MachinePrecision] + (-N[(N[(1.0 - N[(eps * eps), $MachinePrecision]), $MachinePrecision] / N[(eps + 1.0), $MachinePrecision]), $MachinePrecision])), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] - N[(N[(-1.0 * eps + 1.0), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.8 \cdot 10^{+77}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon + 1, -1\right), x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq -1 \cdot 10^{-209}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, \frac{\varepsilon \cdot \varepsilon - 1}{\varepsilon - 1}, \varepsilon\right), x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-243}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 2400000:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon + 1, -\frac{1 - \varepsilon \cdot \varepsilon}{\varepsilon + 1}\right), x, 2\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot 1 - \frac{\mathsf{fma}\left(-1, \varepsilon, 1\right)}{\varepsilon}}{2}\\
\end{array}
\end{array}
if x < -1.7999999999999999e77Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f643.3
Applied rewrites3.3%
Taylor expanded in eps around 0
Applied rewrites33.7%
if -1.7999999999999999e77 < x < -1e-209Initial program 60.2%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.2%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6456.4
Applied rewrites56.4%
lift-+.f64N/A
flip-+N/A
lower-/.f64N/A
unpow2N/A
metadata-evalN/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f6468.0
Applied rewrites68.0%
Taylor expanded in eps around inf
Applied rewrites68.0%
if -1e-209 < x < 1.99999999999999999e-243Initial program 53.1%
Taylor expanded in x around 0
Applied rewrites92.2%
if 1.99999999999999999e-243 < x < 2.4e6Initial program 56.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.6%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6465.4
Applied rewrites65.4%
lift--.f64N/A
flip--N/A
lower-/.f64N/A
metadata-evalN/A
unpow2N/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lift-+.f6474.8
Applied rewrites74.8%
if 2.4e6 < x Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites28.6%
Taylor expanded in x around 0
lower--.f64N/A
inv-powN/A
lower-pow.f6446.8
Applied rewrites46.8%
Taylor expanded in eps around 0
lower-/.f64N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
lower-fma.f6446.9
Applied rewrites46.9%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (* eps eps) 1.0)))
(if (<= x -1.8e+77)
(* (fma (fma -1.0 (+ eps 1.0) -1.0) x 2.0) 0.5)
(if (<= x -1e-209)
(* (fma (fma -1.0 (/ t_0 (- eps 1.0)) eps) x 2.0) 0.5)
(if (<= x 2.65e-167)
1.0
(* (fma (fma -1.0 (/ t_0 -1.0) (- (- 1.0 eps))) x 2.0) 0.5))))))
double code(double x, double eps) {
double t_0 = (eps * eps) - 1.0;
double tmp;
if (x <= -1.8e+77) {
tmp = fma(fma(-1.0, (eps + 1.0), -1.0), x, 2.0) * 0.5;
} else if (x <= -1e-209) {
tmp = fma(fma(-1.0, (t_0 / (eps - 1.0)), eps), x, 2.0) * 0.5;
} else if (x <= 2.65e-167) {
tmp = 1.0;
} else {
tmp = fma(fma(-1.0, (t_0 / -1.0), -(1.0 - eps)), x, 2.0) * 0.5;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(eps * eps) - 1.0) tmp = 0.0 if (x <= -1.8e+77) tmp = Float64(fma(fma(-1.0, Float64(eps + 1.0), -1.0), x, 2.0) * 0.5); elseif (x <= -1e-209) tmp = Float64(fma(fma(-1.0, Float64(t_0 / Float64(eps - 1.0)), eps), x, 2.0) * 0.5); elseif (x <= 2.65e-167) tmp = 1.0; else tmp = Float64(fma(fma(-1.0, Float64(t_0 / -1.0), Float64(-Float64(1.0 - eps))), x, 2.0) * 0.5); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(eps * eps), $MachinePrecision] - 1.0), $MachinePrecision]}, If[LessEqual[x, -1.8e+77], N[(N[(N[(-1.0 * N[(eps + 1.0), $MachinePrecision] + -1.0), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, -1e-209], N[(N[(N[(-1.0 * N[(t$95$0 / N[(eps - 1.0), $MachinePrecision]), $MachinePrecision] + eps), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 2.65e-167], 1.0, N[(N[(N[(-1.0 * N[(t$95$0 / -1.0), $MachinePrecision] + (-N[(1.0 - eps), $MachinePrecision])), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \varepsilon \cdot \varepsilon - 1\\
\mathbf{if}\;x \leq -1.8 \cdot 10^{+77}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon + 1, -1\right), x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq -1 \cdot 10^{-209}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, \frac{t\_0}{\varepsilon - 1}, \varepsilon\right), x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 2.65 \cdot 10^{-167}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, \frac{t\_0}{-1}, -\left(1 - \varepsilon\right)\right), x, 2\right) \cdot 0.5\\
\end{array}
\end{array}
if x < -1.7999999999999999e77Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f643.3
Applied rewrites3.3%
Taylor expanded in eps around 0
Applied rewrites33.7%
if -1.7999999999999999e77 < x < -1e-209Initial program 60.2%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.2%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6456.4
Applied rewrites56.4%
lift-+.f64N/A
flip-+N/A
lower-/.f64N/A
unpow2N/A
metadata-evalN/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f6468.0
Applied rewrites68.0%
Taylor expanded in eps around inf
Applied rewrites68.0%
if -1e-209 < x < 2.65e-167Initial program 53.6%
Taylor expanded in x around 0
Applied rewrites88.2%
if 2.65e-167 < x Initial program 84.1%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.2%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6423.0
Applied rewrites23.0%
lift-+.f64N/A
flip-+N/A
lower-/.f64N/A
unpow2N/A
metadata-evalN/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f6435.8
Applied rewrites35.8%
Taylor expanded in eps around 0
Applied rewrites55.4%
(FPCore (x eps)
:precision binary64
(if (<= x -1.8e+77)
(* (fma (fma -1.0 (+ eps 1.0) -1.0) x 2.0) 0.5)
(if (<= x -2.55e-250)
(* (fma (fma -1.0 (/ (- (* eps eps) 1.0) (- eps 1.0)) eps) x 2.0) 0.5)
(* (- (fma (- eps 1.0) x 1.0) -1.0) 0.5))))
double code(double x, double eps) {
double tmp;
if (x <= -1.8e+77) {
tmp = fma(fma(-1.0, (eps + 1.0), -1.0), x, 2.0) * 0.5;
} else if (x <= -2.55e-250) {
tmp = fma(fma(-1.0, (((eps * eps) - 1.0) / (eps - 1.0)), eps), x, 2.0) * 0.5;
} else {
tmp = (fma((eps - 1.0), x, 1.0) - -1.0) * 0.5;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -1.8e+77) tmp = Float64(fma(fma(-1.0, Float64(eps + 1.0), -1.0), x, 2.0) * 0.5); elseif (x <= -2.55e-250) tmp = Float64(fma(fma(-1.0, Float64(Float64(Float64(eps * eps) - 1.0) / Float64(eps - 1.0)), eps), x, 2.0) * 0.5); else tmp = Float64(Float64(fma(Float64(eps - 1.0), x, 1.0) - -1.0) * 0.5); end return tmp end
code[x_, eps_] := If[LessEqual[x, -1.8e+77], N[(N[(N[(-1.0 * N[(eps + 1.0), $MachinePrecision] + -1.0), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, -2.55e-250], N[(N[(N[(-1.0 * N[(N[(N[(eps * eps), $MachinePrecision] - 1.0), $MachinePrecision] / N[(eps - 1.0), $MachinePrecision]), $MachinePrecision] + eps), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(eps - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.8 \cdot 10^{+77}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon + 1, -1\right), x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq -2.55 \cdot 10^{-250}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, \frac{\varepsilon \cdot \varepsilon - 1}{\varepsilon - 1}, \varepsilon\right), x, 2\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\varepsilon - 1, x, 1\right) - -1\right) \cdot 0.5\\
\end{array}
\end{array}
if x < -1.7999999999999999e77Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f643.3
Applied rewrites3.3%
Taylor expanded in eps around 0
Applied rewrites33.7%
if -1.7999999999999999e77 < x < -2.5500000000000001e-250Initial program 59.5%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.4%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6460.3
Applied rewrites60.3%
lift-+.f64N/A
flip-+N/A
lower-/.f64N/A
unpow2N/A
metadata-evalN/A
lower--.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f6469.7
Applied rewrites69.7%
Taylor expanded in eps around inf
Applied rewrites69.7%
if -2.5500000000000001e-250 < x Initial program 74.9%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.5%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6483.2
Applied rewrites83.2%
Taylor expanded in x around 0
Applied rewrites60.3%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6448.0
Applied rewrites48.0%
(FPCore (x eps) :precision binary64 (if (<= x -1e-295) (* (fma (fma -1.0 (+ eps 1.0) -1.0) x 2.0) 0.5) (* (- (fma (- eps 1.0) x 1.0) -1.0) 0.5)))
double code(double x, double eps) {
double tmp;
if (x <= -1e-295) {
tmp = fma(fma(-1.0, (eps + 1.0), -1.0), x, 2.0) * 0.5;
} else {
tmp = (fma((eps - 1.0), x, 1.0) - -1.0) * 0.5;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -1e-295) tmp = Float64(fma(fma(-1.0, Float64(eps + 1.0), -1.0), x, 2.0) * 0.5); else tmp = Float64(Float64(fma(Float64(eps - 1.0), x, 1.0) - -1.0) * 0.5); end return tmp end
code[x_, eps_] := If[LessEqual[x, -1e-295], N[(N[(N[(-1.0 * N[(eps + 1.0), $MachinePrecision] + -1.0), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(eps - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-295}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon + 1, -1\right), x, 2\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\varepsilon - 1, x, 1\right) - -1\right) \cdot 0.5\\
\end{array}
\end{array}
if x < -1.00000000000000006e-295Initial program 69.1%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift--.f6449.1
Applied rewrites49.1%
Taylor expanded in eps around 0
Applied rewrites56.8%
if -1.00000000000000006e-295 < x Initial program 76.4%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.4%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6482.1
Applied rewrites82.1%
Taylor expanded in x around 0
Applied rewrites57.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6444.9
Applied rewrites44.9%
(FPCore (x eps) :precision binary64 (* (- (fma (- eps 1.0) x 1.0) -1.0) 0.5))
double code(double x, double eps) {
return (fma((eps - 1.0), x, 1.0) - -1.0) * 0.5;
}
function code(x, eps) return Float64(Float64(fma(Float64(eps - 1.0), x, 1.0) - -1.0) * 0.5) end
code[x_, eps_] := N[(N[(N[(N[(eps - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
\\
\left(\mathsf{fma}\left(\varepsilon - 1, x, 1\right) - -1\right) \cdot 0.5
\end{array}
Initial program 73.3%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.2%
Taylor expanded in eps around inf
*-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-*.f6489.2
Applied rewrites89.2%
Taylor expanded in x around 0
Applied rewrites64.6%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f6449.7
Applied rewrites49.7%
(FPCore (x eps) :precision binary64 1.0)
double code(double x, double eps) {
return 1.0;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 1.0d0
end function
public static double code(double x, double eps) {
return 1.0;
}
def code(x, eps): return 1.0
function code(x, eps) return 1.0 end
function tmp = code(x, eps) tmp = 1.0; end
code[x_, eps_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 73.3%
Taylor expanded in x around 0
Applied rewrites43.8%
herbie shell --seed 2025093
(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))