
(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 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))
double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0
end function
public static double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-((1.0 + eps) * x)))) / 2.0;
}
def code(x, eps): return (((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-((1.0 + eps) * x)))) / 2.0
function code(x, eps) return Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(-Float64(Float64(1.0 - eps) * x)))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * exp(Float64(-Float64(Float64(1.0 + eps) * x))))) / 2.0) end
function tmp = code(x, eps) tmp = (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0; end
code[x_, eps_] := N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\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 (* (- (/ 1.0 (exp (* x (- 1.0 eps)))) (- (exp (- (fma x eps x))))) 0.5))
double code(double x, double eps) {
return ((1.0 / exp((x * (1.0 - eps)))) - -exp(-fma(x, eps, x))) * 0.5;
}
function code(x, eps) return Float64(Float64(Float64(1.0 / exp(Float64(x * Float64(1.0 - eps)))) - Float64(-exp(Float64(-fma(x, eps, x))))) * 0.5) end
code[x_, eps_] := N[(N[(N[(1.0 / N[Exp[N[(x * N[(1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - (-N[Exp[(-N[(x * eps + x), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{1}{e^{x \cdot \left(1 - \varepsilon\right)}} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)\right) \cdot 0.5
\end{array}
Initial program 73.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.1%
lift-exp.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
lift--.f64N/A
distribute-lft-neg-outN/A
exp-negN/A
*-commutativeN/A
lower-/.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6499.1
Applied rewrites99.1%
(FPCore (x eps)
:precision binary64
(if (<=
(/
(-
(* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x))))
(* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x)))))
2.0)
0.0)
(* (* (exp (- x)) 2.0) 0.5)
(* (- (/ 1.0 (exp (* (- eps) x))) (- (exp (- (* x eps))))) 0.5)))
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) <= 0.0) {
tmp = (exp(-x) * 2.0) * 0.5;
} else {
tmp = ((1.0 / exp((-eps * x))) - -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 (((((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0) <= 0.0d0) then
tmp = (exp(-x) * 2.0d0) * 0.5d0
else
tmp = ((1.0d0 / exp((-eps * x))) - -exp(-(x * eps))) * 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) <= 0.0) {
tmp = (Math.exp(-x) * 2.0) * 0.5;
} else {
tmp = ((1.0 / Math.exp((-eps * x))) - -Math.exp(-(x * eps))) * 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) <= 0.0: tmp = (math.exp(-x) * 2.0) * 0.5 else: tmp = ((1.0 / math.exp((-eps * x))) - -math.exp(-(x * eps))) * 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) <= 0.0) tmp = Float64(Float64(exp(Float64(-x)) * 2.0) * 0.5); else tmp = Float64(Float64(Float64(1.0 / exp(Float64(Float64(-eps) * x))) - Float64(-exp(Float64(-Float64(x * eps))))) * 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) <= 0.0) tmp = (exp(-x) * 2.0) * 0.5; else tmp = ((1.0 / exp((-eps * x))) - -exp(-(x * eps))) * 0.5; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[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], 0.0], N[(N[(N[Exp[(-x)], $MachinePrecision] * 2.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(1.0 / N[Exp[N[((-eps) * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - (-N[Exp[(-N[(x * eps), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\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 0:\\
\;\;\;\;\left(e^{-x} \cdot 2\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{1}{e^{\left(-\varepsilon\right) \cdot x}} - \left(-e^{-x \cdot \varepsilon}\right)\right) \cdot 0.5\\
\end{array}
\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)) < 0.0Initial program 73.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.1%
Taylor expanded in eps around 0
mul-1-negN/A
lower-+.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f6470.5
Applied rewrites70.5%
Applied rewrites70.5%
if 0.0 < (/.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.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.1%
lift-exp.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
lift--.f64N/A
distribute-lft-neg-outN/A
exp-negN/A
*-commutativeN/A
lower-/.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6499.1
Applied rewrites99.1%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6488.2
Applied rewrites88.2%
Taylor expanded in eps around inf
associate-*r*N/A
mul-1-negN/A
lift-neg.f64N/A
lower-*.f6485.1
Applied rewrites85.1%
(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.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.1%
(FPCore (x eps)
:precision binary64
(if (<=
(/
(-
(* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x))))
(* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x)))))
2.0)
0.0)
(* (* (exp (- x)) 2.0) 0.5)
(* (- (exp (* (- x) (- 1.0 eps))) (- (exp (* (- eps) x)))) 0.5)))
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) <= 0.0) {
tmp = (exp(-x) * 2.0) * 0.5;
} else {
tmp = (exp((-x * (1.0 - eps))) - -exp((-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 (((((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0) <= 0.0d0) then
tmp = (exp(-x) * 2.0d0) * 0.5d0
else
tmp = (exp((-x * (1.0d0 - eps))) - -exp((-eps * x))) * 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) <= 0.0) {
tmp = (Math.exp(-x) * 2.0) * 0.5;
} else {
tmp = (Math.exp((-x * (1.0 - eps))) - -Math.exp((-eps * x))) * 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) <= 0.0: tmp = (math.exp(-x) * 2.0) * 0.5 else: tmp = (math.exp((-x * (1.0 - eps))) - -math.exp((-eps * x))) * 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) <= 0.0) tmp = Float64(Float64(exp(Float64(-x)) * 2.0) * 0.5); else tmp = Float64(Float64(exp(Float64(Float64(-x) * Float64(1.0 - eps))) - Float64(-exp(Float64(Float64(-eps) * x)))) * 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) <= 0.0) tmp = (exp(-x) * 2.0) * 0.5; else tmp = (exp((-x * (1.0 - eps))) - -exp((-eps * x))) * 0.5; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[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], 0.0], N[(N[(N[Exp[(-x)], $MachinePrecision] * 2.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[Exp[N[((-x) * N[(1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - (-N[Exp[N[((-eps) * x), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\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 0:\\
\;\;\;\;\left(e^{-x} \cdot 2\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(e^{\left(-x\right) \cdot \left(1 - \varepsilon\right)} - \left(-e^{\left(-\varepsilon\right) \cdot x}\right)\right) \cdot 0.5\\
\end{array}
\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)) < 0.0Initial program 73.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.1%
Taylor expanded in eps around 0
mul-1-negN/A
lower-+.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f6470.5
Applied rewrites70.5%
Applied rewrites70.5%
if 0.0 < (/.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.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.1%
Taylor expanded in eps around inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f6488.2
Applied rewrites88.2%
(FPCore (x eps)
:precision binary64
(if (<= x -700.0)
(* (* (exp (- x)) 2.0) 0.5)
(if (<= x 1.36e-177)
(* (- (fma (- eps 1.0) x 1.0) (- (exp (- (* x eps))))) 0.5)
(if (<= x 1.4e+36)
(* (- (exp (* (- x) (- eps))) -1.0) 0.5)
(if (<= x 4.2e+110)
(/ (- (+ 1.0 (/ 1.0 eps)) (- (/ 1.0 eps) 1.0)) 2.0)
(fma (- (* 0.3333333333333333 x) 0.5) (* x x) 1.0))))))
double code(double x, double eps) {
double tmp;
if (x <= -700.0) {
tmp = (exp(-x) * 2.0) * 0.5;
} else if (x <= 1.36e-177) {
tmp = (fma((eps - 1.0), x, 1.0) - -exp(-(x * eps))) * 0.5;
} else if (x <= 1.4e+36) {
tmp = (exp((-x * -eps)) - -1.0) * 0.5;
} else if (x <= 4.2e+110) {
tmp = ((1.0 + (1.0 / eps)) - ((1.0 / eps) - 1.0)) / 2.0;
} else {
tmp = fma(((0.3333333333333333 * x) - 0.5), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -700.0) tmp = Float64(Float64(exp(Float64(-x)) * 2.0) * 0.5); elseif (x <= 1.36e-177) tmp = Float64(Float64(fma(Float64(eps - 1.0), x, 1.0) - Float64(-exp(Float64(-Float64(x * eps))))) * 0.5); elseif (x <= 1.4e+36) tmp = Float64(Float64(exp(Float64(Float64(-x) * Float64(-eps))) - -1.0) * 0.5); elseif (x <= 4.2e+110) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) - Float64(Float64(1.0 / eps) - 1.0)) / 2.0); else tmp = fma(Float64(Float64(0.3333333333333333 * x) - 0.5), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -700.0], N[(N[(N[Exp[(-x)], $MachinePrecision] * 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 1.36e-177], N[(N[(N[(N[(eps - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] - (-N[Exp[(-N[(x * eps), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 1.4e+36], N[(N[(N[Exp[N[((-x) * (-eps)), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 4.2e+110], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] - N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(0.3333333333333333 * x), $MachinePrecision] - 0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -700:\\
\;\;\;\;\left(e^{-x} \cdot 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 1.36 \cdot 10^{-177}:\\
\;\;\;\;\left(\mathsf{fma}\left(\varepsilon - 1, x, 1\right) - \left(-e^{-x \cdot \varepsilon}\right)\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{+36}:\\
\;\;\;\;\left(e^{\left(-x\right) \cdot \left(-\varepsilon\right)} - -1\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{+110}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333 \cdot x - 0.5, x \cdot x, 1\right)\\
\end{array}
\end{array}
if x < -700Initial program 73.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.1%
Taylor expanded in eps around 0
mul-1-negN/A
lower-+.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f6470.5
Applied rewrites70.5%
Applied rewrites70.5%
if -700 < x < 1.35999999999999989e-177Initial program 73.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.1%
lift-exp.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
lift--.f64N/A
distribute-lft-neg-outN/A
exp-negN/A
*-commutativeN/A
lower-/.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6499.1
Applied rewrites99.1%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6488.2
Applied rewrites88.2%
Taylor expanded in x around 0
rec-expN/A
distribute-lft-neg-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6463.3
Applied rewrites63.3%
if 1.35999999999999989e-177 < x < 1.4e36Initial program 73.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.1%
Taylor expanded in x around 0
Applied rewrites64.1%
Taylor expanded in eps around inf
mul-1-negN/A
lower-neg.f6464.3
Applied rewrites64.3%
if 1.4e36 < x < 4.2000000000000003e110Initial program 73.6%
Taylor expanded in x around 0
lift-/.f64N/A
lift--.f6438.3
Applied rewrites38.3%
Taylor expanded in x around 0
lift-/.f64N/A
lift-+.f6430.8
Applied rewrites30.8%
if 4.2000000000000003e110 < x Initial program 73.6%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites57.1%
Taylor expanded in x around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6442.1
Applied rewrites42.1%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6452.5
Applied rewrites52.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0
(* (- (exp (* (- x) (- 1.0 eps))) (- (* (+ 1.0 eps) x) 1.0)) 0.5)))
(if (<= eps -4.4e+162)
(* (- (fma (- eps 1.0) x 1.0) (- (exp (- (* x eps))))) 0.5)
(if (<= eps -1.95)
t_0
(if (<= eps 14200.0) (* (* (exp (- x)) 2.0) 0.5) t_0)))))
double code(double x, double eps) {
double t_0 = (exp((-x * (1.0 - eps))) - (((1.0 + eps) * x) - 1.0)) * 0.5;
double tmp;
if (eps <= -4.4e+162) {
tmp = (fma((eps - 1.0), x, 1.0) - -exp(-(x * eps))) * 0.5;
} else if (eps <= -1.95) {
tmp = t_0;
} else if (eps <= 14200.0) {
tmp = (exp(-x) * 2.0) * 0.5;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(exp(Float64(Float64(-x) * Float64(1.0 - eps))) - Float64(Float64(Float64(1.0 + eps) * x) - 1.0)) * 0.5) tmp = 0.0 if (eps <= -4.4e+162) tmp = Float64(Float64(fma(Float64(eps - 1.0), x, 1.0) - Float64(-exp(Float64(-Float64(x * eps))))) * 0.5); elseif (eps <= -1.95) tmp = t_0; elseif (eps <= 14200.0) tmp = Float64(Float64(exp(Float64(-x)) * 2.0) * 0.5); else tmp = t_0; end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(N[Exp[N[((-x) * N[(1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[(N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[eps, -4.4e+162], N[(N[(N[(N[(eps - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] - (-N[Exp[(-N[(x * eps), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[eps, -1.95], t$95$0, If[LessEqual[eps, 14200.0], N[(N[(N[Exp[(-x)], $MachinePrecision] * 2.0), $MachinePrecision] * 0.5), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{\left(-x\right) \cdot \left(1 - \varepsilon\right)} - \left(\left(1 + \varepsilon\right) \cdot x - 1\right)\right) \cdot 0.5\\
\mathbf{if}\;\varepsilon \leq -4.4 \cdot 10^{+162}:\\
\;\;\;\;\left(\mathsf{fma}\left(\varepsilon - 1, x, 1\right) - \left(-e^{-x \cdot \varepsilon}\right)\right) \cdot 0.5\\
\mathbf{elif}\;\varepsilon \leq -1.95:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\varepsilon \leq 14200:\\
\;\;\;\;\left(e^{-x} \cdot 2\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if eps < -4.4000000000000004e162Initial program 73.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.1%
lift-exp.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
lift--.f64N/A
distribute-lft-neg-outN/A
exp-negN/A
*-commutativeN/A
lower-/.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6499.1
Applied rewrites99.1%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6488.2
Applied rewrites88.2%
Taylor expanded in x around 0
rec-expN/A
distribute-lft-neg-outN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6463.3
Applied rewrites63.3%
if -4.4000000000000004e162 < eps < -1.94999999999999996 or 14200 < eps Initial program 73.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.1%
Taylor expanded in x around 0
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6464.0
Applied rewrites64.0%
if -1.94999999999999996 < eps < 14200Initial program 73.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.1%
Taylor expanded in eps around 0
mul-1-negN/A
lower-+.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f6470.5
Applied rewrites70.5%
Applied rewrites70.5%
(FPCore (x eps)
:precision binary64
(if (<= x -80000000000.0)
(* (* (exp (- x)) 2.0) 0.5)
(if (<= x 1.4e+36)
(* (- (exp (* (- x) (- eps))) -1.0) 0.5)
(if (<= x 4.2e+110)
(/ (- (+ 1.0 (/ 1.0 eps)) (- (/ 1.0 eps) 1.0)) 2.0)
(fma (- (* 0.3333333333333333 x) 0.5) (* x x) 1.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -80000000000.0) {
tmp = (exp(-x) * 2.0) * 0.5;
} else if (x <= 1.4e+36) {
tmp = (exp((-x * -eps)) - -1.0) * 0.5;
} else if (x <= 4.2e+110) {
tmp = ((1.0 + (1.0 / eps)) - ((1.0 / eps) - 1.0)) / 2.0;
} else {
tmp = fma(((0.3333333333333333 * x) - 0.5), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -80000000000.0) tmp = Float64(Float64(exp(Float64(-x)) * 2.0) * 0.5); elseif (x <= 1.4e+36) tmp = Float64(Float64(exp(Float64(Float64(-x) * Float64(-eps))) - -1.0) * 0.5); elseif (x <= 4.2e+110) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) - Float64(Float64(1.0 / eps) - 1.0)) / 2.0); else tmp = fma(Float64(Float64(0.3333333333333333 * x) - 0.5), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -80000000000.0], N[(N[(N[Exp[(-x)], $MachinePrecision] * 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 1.4e+36], N[(N[(N[Exp[N[((-x) * (-eps)), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 4.2e+110], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] - N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(0.3333333333333333 * x), $MachinePrecision] - 0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -80000000000:\\
\;\;\;\;\left(e^{-x} \cdot 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{+36}:\\
\;\;\;\;\left(e^{\left(-x\right) \cdot \left(-\varepsilon\right)} - -1\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{+110}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333 \cdot x - 0.5, x \cdot x, 1\right)\\
\end{array}
\end{array}
if x < -8e10Initial program 73.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.1%
Taylor expanded in eps around 0
mul-1-negN/A
lower-+.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f6470.5
Applied rewrites70.5%
Applied rewrites70.5%
if -8e10 < x < 1.4e36Initial program 73.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.1%
Taylor expanded in x around 0
Applied rewrites64.1%
Taylor expanded in eps around inf
mul-1-negN/A
lower-neg.f6464.3
Applied rewrites64.3%
if 1.4e36 < x < 4.2000000000000003e110Initial program 73.6%
Taylor expanded in x around 0
lift-/.f64N/A
lift--.f6438.3
Applied rewrites38.3%
Taylor expanded in x around 0
lift-/.f64N/A
lift-+.f6430.8
Applied rewrites30.8%
if 4.2000000000000003e110 < x Initial program 73.6%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites57.1%
Taylor expanded in x around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6442.1
Applied rewrites42.1%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6452.5
Applied rewrites52.5%
(FPCore (x eps) :precision binary64 (if (<= x 5e+109) (* (* (exp (- x)) 2.0) 0.5) (fma (- (* 0.3333333333333333 x) 0.5) (* x x) 1.0)))
double code(double x, double eps) {
double tmp;
if (x <= 5e+109) {
tmp = (exp(-x) * 2.0) * 0.5;
} else {
tmp = fma(((0.3333333333333333 * x) - 0.5), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 5e+109) tmp = Float64(Float64(exp(Float64(-x)) * 2.0) * 0.5); else tmp = fma(Float64(Float64(0.3333333333333333 * x) - 0.5), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, 5e+109], N[(N[(N[Exp[(-x)], $MachinePrecision] * 2.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(0.3333333333333333 * x), $MachinePrecision] - 0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{+109}:\\
\;\;\;\;\left(e^{-x} \cdot 2\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333 \cdot x - 0.5, x \cdot x, 1\right)\\
\end{array}
\end{array}
if x < 5.0000000000000001e109Initial program 73.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.1%
Taylor expanded in eps around 0
mul-1-negN/A
lower-+.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f6470.5
Applied rewrites70.5%
Applied rewrites70.5%
if 5.0000000000000001e109 < x Initial program 73.6%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites57.1%
Taylor expanded in x around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6442.1
Applied rewrites42.1%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6452.5
Applied rewrites52.5%
(FPCore (x eps)
:precision binary64
(if (<= x 350.0)
(* (fma (- x 2.0) x 2.0) 0.5)
(if (<= x 4.2e+110)
(/ (- (/ 1.0 eps) (- (/ 1.0 eps) 1.0)) 2.0)
(fma (- (* 0.3333333333333333 x) 0.5) (* x x) 1.0))))
double code(double x, double eps) {
double tmp;
if (x <= 350.0) {
tmp = fma((x - 2.0), x, 2.0) * 0.5;
} else if (x <= 4.2e+110) {
tmp = ((1.0 / eps) - ((1.0 / eps) - 1.0)) / 2.0;
} else {
tmp = fma(((0.3333333333333333 * x) - 0.5), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 350.0) tmp = Float64(fma(Float64(x - 2.0), x, 2.0) * 0.5); elseif (x <= 4.2e+110) tmp = Float64(Float64(Float64(1.0 / eps) - Float64(Float64(1.0 / eps) - 1.0)) / 2.0); else tmp = fma(Float64(Float64(0.3333333333333333 * x) - 0.5), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, 350.0], N[(N[(N[(x - 2.0), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 4.2e+110], N[(N[(N[(1.0 / eps), $MachinePrecision] - N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(0.3333333333333333 * x), $MachinePrecision] - 0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 350:\\
\;\;\;\;\mathsf{fma}\left(x - 2, x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{+110}:\\
\;\;\;\;\frac{\frac{1}{\varepsilon} - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333 \cdot x - 0.5, x \cdot x, 1\right)\\
\end{array}
\end{array}
if x < 350Initial program 73.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.1%
Taylor expanded in eps around 0
mul-1-negN/A
lower-+.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f6470.5
Applied rewrites70.5%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6457.4
Applied rewrites57.4%
if 350 < x < 4.2000000000000003e110Initial program 73.6%
Taylor expanded in x around 0
lift-/.f64N/A
lift--.f6438.3
Applied rewrites38.3%
Taylor expanded in x around 0
lift-/.f64N/A
lift-+.f6430.8
Applied rewrites30.8%
Taylor expanded in eps around 0
lift-/.f6419.0
Applied rewrites19.0%
if 4.2000000000000003e110 < x Initial program 73.6%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites57.1%
Taylor expanded in x around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6442.1
Applied rewrites42.1%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6452.5
Applied rewrites52.5%
(FPCore (x eps) :precision binary64 (if (<= x -380.0) (* (fma (- x 2.0) x 2.0) 0.5) (fma (- (* 0.3333333333333333 x) 0.5) (* x x) 1.0)))
double code(double x, double eps) {
double tmp;
if (x <= -380.0) {
tmp = fma((x - 2.0), x, 2.0) * 0.5;
} else {
tmp = fma(((0.3333333333333333 * x) - 0.5), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -380.0) tmp = Float64(fma(Float64(x - 2.0), x, 2.0) * 0.5); else tmp = fma(Float64(Float64(0.3333333333333333 * x) - 0.5), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -380.0], N[(N[(N[(x - 2.0), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(0.3333333333333333 * x), $MachinePrecision] - 0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -380:\\
\;\;\;\;\mathsf{fma}\left(x - 2, x, 2\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333 \cdot x - 0.5, x \cdot x, 1\right)\\
\end{array}
\end{array}
if x < -380Initial program 73.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.1%
Taylor expanded in eps around 0
mul-1-negN/A
lower-+.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f6470.5
Applied rewrites70.5%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6457.4
Applied rewrites57.4%
if -380 < x Initial program 73.6%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites57.1%
Taylor expanded in x around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6442.1
Applied rewrites42.1%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6452.5
Applied rewrites52.5%
(FPCore (x eps) :precision binary64 (* (fma (- x 2.0) x 2.0) 0.5))
double code(double x, double eps) {
return fma((x - 2.0), x, 2.0) * 0.5;
}
function code(x, eps) return Float64(fma(Float64(x - 2.0), x, 2.0) * 0.5) end
code[x_, eps_] := N[(N[(N[(x - 2.0), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x - 2, x, 2\right) \cdot 0.5
\end{array}
Initial program 73.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.1%
Taylor expanded in eps around 0
mul-1-negN/A
lower-+.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f6470.5
Applied rewrites70.5%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6457.4
Applied rewrites57.4%
(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.6%
Taylor expanded in x around 0
Applied rewrites43.1%
herbie shell --seed 2025139
(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))