
(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}
Sampling outcomes in binary64 precision:
Herbie found 17 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)))) + 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)}} + e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right) \cdot 0.5
\end{array}
Initial program 74.6%
Taylor expanded in eps around inf
Applied rewrites99.2%
Applied rewrites99.2%
Final simplification99.2%
(FPCore (x eps)
:precision binary64
(if (<= x 2.6e+208)
(* (+ (exp (* x eps)) (exp (- (fma x eps x)))) 0.5)
(if (<= x 1.22e+247)
(/ (- (- (pow eps -1.0) -1.0) (* (- (/ 1.0 eps) 1.0) 1.0)) 2.0)
(/
(+
(* (+ 1.0 (/ 1.0 eps)) (exp (* (+ -1.0 eps) x)))
(* (- (/ -1.0 eps) -1.0) (/ 1.0 (fma (- eps -1.0) x 1.0))))
2.0))))
double code(double x, double eps) {
double tmp;
if (x <= 2.6e+208) {
tmp = (exp((x * eps)) + exp(-fma(x, eps, x))) * 0.5;
} else if (x <= 1.22e+247) {
tmp = ((pow(eps, -1.0) - -1.0) - (((1.0 / eps) - 1.0) * 1.0)) / 2.0;
} else {
tmp = (((1.0 + (1.0 / eps)) * exp(((-1.0 + eps) * x))) + (((-1.0 / eps) - -1.0) * (1.0 / fma((eps - -1.0), x, 1.0)))) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 2.6e+208) tmp = Float64(Float64(exp(Float64(x * eps)) + exp(Float64(-fma(x, eps, x)))) * 0.5); elseif (x <= 1.22e+247) tmp = Float64(Float64(Float64((eps ^ -1.0) - -1.0) - Float64(Float64(Float64(1.0 / eps) - 1.0) * 1.0)) / 2.0); else tmp = Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(Float64(-1.0 + eps) * x))) + Float64(Float64(Float64(-1.0 / eps) - -1.0) * Float64(1.0 / fma(Float64(eps - -1.0), x, 1.0)))) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, 2.6e+208], N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] + N[Exp[(-N[(x * eps + x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 1.22e+247], N[(N[(N[(N[Power[eps, -1.0], $MachinePrecision] - -1.0), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 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[(1.0 / N[(N[(eps - -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.6 \cdot 10^{+208}:\\
\;\;\;\;\left(e^{x \cdot \varepsilon} + e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 1.22 \cdot 10^{+247}:\\
\;\;\;\;\frac{\left({\varepsilon}^{-1} - -1\right) - \left(\frac{1}{\varepsilon} - 1\right) \cdot 1}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(-1 + \varepsilon\right) \cdot x} + \left(\frac{-1}{\varepsilon} - -1\right) \cdot \frac{1}{\mathsf{fma}\left(\varepsilon - -1, x, 1\right)}}{2}\\
\end{array}
\end{array}
if x < 2.6e208Initial program 71.7%
Taylor expanded in eps around inf
Applied rewrites99.1%
Taylor expanded in eps around inf
Applied rewrites92.8%
if 2.6e208 < x < 1.22000000000000006e247Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites8.9%
Taylor expanded in x around 0
Applied rewrites87.1%
if 1.22000000000000006e247 < x Initial program 100.0%
lift-exp.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
lift-*.f64N/A
exp-negN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-rgt1-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites47.3%
Final simplification90.5%
(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(x * Float64(-1.0 + eps))) + 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^{x \cdot \left(-1 + \varepsilon\right)} + e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right) \cdot 0.5
\end{array}
Initial program 74.6%
Taylor expanded in eps around inf
Applied rewrites99.2%
Final simplification99.2%
(FPCore (x eps)
:precision binary64
(if (<= x -4e-271)
(* (+ (/ 1.0 (fma x (- 1.0 eps) 1.0)) (exp (- (* x eps)))) 0.5)
(if (<= x 2.6e+208)
(* (- (exp (* x eps)) -1.0) 0.5)
(if (<= x 1.22e+247)
(/ (- (- (pow eps -1.0) -1.0) (* (- (/ 1.0 eps) 1.0) 1.0)) 2.0)
(/
(+
(* (+ 1.0 (/ 1.0 eps)) (exp (* (+ -1.0 eps) x)))
(* (- (/ -1.0 eps) -1.0) (/ 1.0 (fma (- eps -1.0) x 1.0))))
2.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -4e-271) {
tmp = ((1.0 / fma(x, (1.0 - eps), 1.0)) + exp(-(x * eps))) * 0.5;
} else if (x <= 2.6e+208) {
tmp = (exp((x * eps)) - -1.0) * 0.5;
} else if (x <= 1.22e+247) {
tmp = ((pow(eps, -1.0) - -1.0) - (((1.0 / eps) - 1.0) * 1.0)) / 2.0;
} else {
tmp = (((1.0 + (1.0 / eps)) * exp(((-1.0 + eps) * x))) + (((-1.0 / eps) - -1.0) * (1.0 / fma((eps - -1.0), x, 1.0)))) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -4e-271) tmp = Float64(Float64(Float64(1.0 / fma(x, Float64(1.0 - eps), 1.0)) + exp(Float64(-Float64(x * eps)))) * 0.5); elseif (x <= 2.6e+208) tmp = Float64(Float64(exp(Float64(x * eps)) - -1.0) * 0.5); elseif (x <= 1.22e+247) tmp = Float64(Float64(Float64((eps ^ -1.0) - -1.0) - Float64(Float64(Float64(1.0 / eps) - 1.0) * 1.0)) / 2.0); else tmp = Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(Float64(-1.0 + eps) * x))) + Float64(Float64(Float64(-1.0 / eps) - -1.0) * Float64(1.0 / fma(Float64(eps - -1.0), x, 1.0)))) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -4e-271], N[(N[(N[(1.0 / N[(x * N[(1.0 - eps), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + N[Exp[(-N[(x * eps), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 2.6e+208], N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 1.22e+247], N[(N[(N[(N[Power[eps, -1.0], $MachinePrecision] - -1.0), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 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[(1.0 / N[(N[(eps - -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{-271}:\\
\;\;\;\;\left(\frac{1}{\mathsf{fma}\left(x, 1 - \varepsilon, 1\right)} + e^{-x \cdot \varepsilon}\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{+208}:\\
\;\;\;\;\left(e^{x \cdot \varepsilon} - -1\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 1.22 \cdot 10^{+247}:\\
\;\;\;\;\frac{\left({\varepsilon}^{-1} - -1\right) - \left(\frac{1}{\varepsilon} - 1\right) \cdot 1}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(-1 + \varepsilon\right) \cdot x} + \left(\frac{-1}{\varepsilon} - -1\right) \cdot \frac{1}{\mathsf{fma}\left(\varepsilon - -1, x, 1\right)}}{2}\\
\end{array}
\end{array}
if x < -3.99999999999999985e-271Initial program 69.9%
Taylor expanded in eps around inf
Applied rewrites99.2%
Applied rewrites99.2%
Taylor expanded in eps around inf
Applied rewrites99.2%
Taylor expanded in x around 0
Applied rewrites76.2%
if -3.99999999999999985e-271 < x < 2.6e208Initial program 73.2%
Taylor expanded in eps around inf
Applied rewrites99.0%
Taylor expanded in x around 0
Applied rewrites64.9%
Taylor expanded in eps around inf
Applied rewrites65.3%
if 2.6e208 < x < 1.22000000000000006e247Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites8.9%
Taylor expanded in x around 0
Applied rewrites87.1%
if 1.22000000000000006e247 < x Initial program 100.0%
lift-exp.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
lift-*.f64N/A
exp-negN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-rgt1-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites47.3%
Final simplification70.2%
(FPCore (x eps)
:precision binary64
(if (<= x -4e-271)
(* (+ (/ 1.0 (fma x (- 1.0 eps) 1.0)) (exp (- (* x eps)))) 0.5)
(if (<= x 2.6e+208)
(* (- (exp (* x eps)) -1.0) 0.5)
(if (<= x 1.22e+247)
(/ (- (- (pow eps -1.0) -1.0) (* (- (/ 1.0 eps) 1.0) 1.0)) 2.0)
(* (- (exp (* x (+ -1.0 eps))) -1.0) 0.5)))))
double code(double x, double eps) {
double tmp;
if (x <= -4e-271) {
tmp = ((1.0 / fma(x, (1.0 - eps), 1.0)) + exp(-(x * eps))) * 0.5;
} else if (x <= 2.6e+208) {
tmp = (exp((x * eps)) - -1.0) * 0.5;
} else if (x <= 1.22e+247) {
tmp = ((pow(eps, -1.0) - -1.0) - (((1.0 / eps) - 1.0) * 1.0)) / 2.0;
} else {
tmp = (exp((x * (-1.0 + eps))) - -1.0) * 0.5;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -4e-271) tmp = Float64(Float64(Float64(1.0 / fma(x, Float64(1.0 - eps), 1.0)) + exp(Float64(-Float64(x * eps)))) * 0.5); elseif (x <= 2.6e+208) tmp = Float64(Float64(exp(Float64(x * eps)) - -1.0) * 0.5); elseif (x <= 1.22e+247) tmp = Float64(Float64(Float64((eps ^ -1.0) - -1.0) - Float64(Float64(Float64(1.0 / eps) - 1.0) * 1.0)) / 2.0); else tmp = Float64(Float64(exp(Float64(x * Float64(-1.0 + eps))) - -1.0) * 0.5); end return tmp end
code[x_, eps_] := If[LessEqual[x, -4e-271], N[(N[(N[(1.0 / N[(x * N[(1.0 - eps), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + N[Exp[(-N[(x * eps), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 2.6e+208], N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 1.22e+247], N[(N[(N[(N[Power[eps, -1.0], $MachinePrecision] - -1.0), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(x * N[(-1.0 + eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{-271}:\\
\;\;\;\;\left(\frac{1}{\mathsf{fma}\left(x, 1 - \varepsilon, 1\right)} + e^{-x \cdot \varepsilon}\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{+208}:\\
\;\;\;\;\left(e^{x \cdot \varepsilon} - -1\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 1.22 \cdot 10^{+247}:\\
\;\;\;\;\frac{\left({\varepsilon}^{-1} - -1\right) - \left(\frac{1}{\varepsilon} - 1\right) \cdot 1}{2}\\
\mathbf{else}:\\
\;\;\;\;\left(e^{x \cdot \left(-1 + \varepsilon\right)} - -1\right) \cdot 0.5\\
\end{array}
\end{array}
if x < -3.99999999999999985e-271Initial program 69.9%
Taylor expanded in eps around inf
Applied rewrites99.2%
Applied rewrites99.2%
Taylor expanded in eps around inf
Applied rewrites99.2%
Taylor expanded in x around 0
Applied rewrites76.2%
if -3.99999999999999985e-271 < x < 2.6e208Initial program 73.2%
Taylor expanded in eps around inf
Applied rewrites99.0%
Taylor expanded in x around 0
Applied rewrites64.9%
Taylor expanded in eps around inf
Applied rewrites65.3%
if 2.6e208 < x < 1.22000000000000006e247Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites8.9%
Taylor expanded in x around 0
Applied rewrites87.1%
if 1.22000000000000006e247 < x Initial program 100.0%
Taylor expanded in eps around inf
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites47.2%
Final simplification70.2%
(FPCore (x eps) :precision binary64 (if (<= x -4e-271) (* (+ (/ 1.0 (fma x (- 1.0 eps) 1.0)) (exp (- (* x eps)))) 0.5) (* (- (exp (* x eps)) -1.0) 0.5)))
double code(double x, double eps) {
double tmp;
if (x <= -4e-271) {
tmp = ((1.0 / fma(x, (1.0 - eps), 1.0)) + exp(-(x * eps))) * 0.5;
} else {
tmp = (exp((x * eps)) - -1.0) * 0.5;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -4e-271) tmp = Float64(Float64(Float64(1.0 / fma(x, Float64(1.0 - eps), 1.0)) + exp(Float64(-Float64(x * eps)))) * 0.5); else tmp = Float64(Float64(exp(Float64(x * eps)) - -1.0) * 0.5); end return tmp end
code[x_, eps_] := If[LessEqual[x, -4e-271], N[(N[(N[(1.0 / N[(x * N[(1.0 - eps), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + N[Exp[(-N[(x * eps), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{-271}:\\
\;\;\;\;\left(\frac{1}{\mathsf{fma}\left(x, 1 - \varepsilon, 1\right)} + e^{-x \cdot \varepsilon}\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(e^{x \cdot \varepsilon} - -1\right) \cdot 0.5\\
\end{array}
\end{array}
if x < -3.99999999999999985e-271Initial program 69.9%
Taylor expanded in eps around inf
Applied rewrites99.2%
Applied rewrites99.2%
Taylor expanded in eps around inf
Applied rewrites99.2%
Taylor expanded in x around 0
Applied rewrites76.2%
if -3.99999999999999985e-271 < x Initial program 77.8%
Taylor expanded in eps around inf
Applied rewrites99.2%
Taylor expanded in x around 0
Applied rewrites58.2%
Taylor expanded in eps around inf
Applied rewrites58.4%
Final simplification65.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (- eps 1.0) x)) (t_1 (+ 1.0 (/ 1.0 eps))))
(if (<= x -1920000.0)
(* (- (exp (- x)) -1.0) 0.5)
(if (<= x -2.9e-246)
(* (fma (fma -1.0 (/ (- (* eps eps) 1.0) (- eps 1.0)) eps) x 2.0) 0.5)
(if (<= x 9.5e-299)
(* (fma (fma -1.0 (- eps -1.0) -1.0) x 2.0) 0.5)
(if (<= x 9e+23)
(*
(fma
(fma -1.0 (- eps -1.0) (/ (+ -1.0 (* eps eps)) (- eps -1.0)))
x
2.0)
0.5)
(if (<= x 6.9e+149)
(/
(-
(* t_1 (/ (- (* t_0 t_0) 1.0) (- t_0 1.0)))
(* (- (/ 1.0 eps) 1.0) (fma -1.0 (fma x eps x) 1.0)))
2.0)
(/
(+ (* t_1 t_0) (* (- (/ -1.0 eps) -1.0) (fma -1.0 x 1.0)))
2.0))))))))
double code(double x, double eps) {
double t_0 = (eps - 1.0) * x;
double t_1 = 1.0 + (1.0 / eps);
double tmp;
if (x <= -1920000.0) {
tmp = (exp(-x) - -1.0) * 0.5;
} else if (x <= -2.9e-246) {
tmp = fma(fma(-1.0, (((eps * eps) - 1.0) / (eps - 1.0)), eps), x, 2.0) * 0.5;
} else if (x <= 9.5e-299) {
tmp = fma(fma(-1.0, (eps - -1.0), -1.0), x, 2.0) * 0.5;
} else if (x <= 9e+23) {
tmp = fma(fma(-1.0, (eps - -1.0), ((-1.0 + (eps * eps)) / (eps - -1.0))), x, 2.0) * 0.5;
} else if (x <= 6.9e+149) {
tmp = ((t_1 * (((t_0 * t_0) - 1.0) / (t_0 - 1.0))) - (((1.0 / eps) - 1.0) * fma(-1.0, fma(x, eps, x), 1.0))) / 2.0;
} else {
tmp = ((t_1 * t_0) + (((-1.0 / eps) - -1.0) * fma(-1.0, x, 1.0))) / 2.0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(eps - 1.0) * x) t_1 = Float64(1.0 + Float64(1.0 / eps)) tmp = 0.0 if (x <= -1920000.0) tmp = Float64(Float64(exp(Float64(-x)) - -1.0) * 0.5); elseif (x <= -2.9e-246) 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 <= 9.5e-299) tmp = Float64(fma(fma(-1.0, Float64(eps - -1.0), -1.0), x, 2.0) * 0.5); elseif (x <= 9e+23) tmp = Float64(fma(fma(-1.0, Float64(eps - -1.0), Float64(Float64(-1.0 + Float64(eps * eps)) / Float64(eps - -1.0))), x, 2.0) * 0.5); elseif (x <= 6.9e+149) tmp = Float64(Float64(Float64(t_1 * Float64(Float64(Float64(t_0 * t_0) - 1.0) / Float64(t_0 - 1.0))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * fma(-1.0, fma(x, eps, x), 1.0))) / 2.0); else tmp = Float64(Float64(Float64(t_1 * t_0) + Float64(Float64(Float64(-1.0 / eps) - -1.0) * fma(-1.0, x, 1.0))) / 2.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1920000.0], N[(N[(N[Exp[(-x)], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, -2.9e-246], 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, 9.5e-299], N[(N[(N[(-1.0 * N[(eps - -1.0), $MachinePrecision] + -1.0), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 9e+23], 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], If[LessEqual[x, 6.9e+149], N[(N[(N[(t$95$1 * N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] - 1.0), $MachinePrecision] / N[(t$95$0 - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[(-1.0 * N[(x * eps + x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(t$95$1 * t$95$0), $MachinePrecision] + N[(N[(N[(-1.0 / eps), $MachinePrecision] - -1.0), $MachinePrecision] * N[(-1.0 * x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\varepsilon - 1\right) \cdot x\\
t_1 := 1 + \frac{1}{\varepsilon}\\
\mathbf{if}\;x \leq -1920000:\\
\;\;\;\;\left(e^{-x} - -1\right) \cdot 0.5\\
\mathbf{elif}\;x \leq -2.9 \cdot 10^{-246}:\\
\;\;\;\;\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 9.5 \cdot 10^{-299}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon - -1, -1\right), x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 9 \cdot 10^{+23}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon - -1, \frac{-1 + \varepsilon \cdot \varepsilon}{\varepsilon - -1}\right), x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 6.9 \cdot 10^{+149}:\\
\;\;\;\;\frac{t\_1 \cdot \frac{t\_0 \cdot t\_0 - 1}{t\_0 - 1} - \left(\frac{1}{\varepsilon} - 1\right) \cdot \mathsf{fma}\left(-1, \mathsf{fma}\left(x, \varepsilon, x\right), 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1 \cdot t\_0 + \left(\frac{-1}{\varepsilon} - -1\right) \cdot \mathsf{fma}\left(-1, x, 1\right)}{2}\\
\end{array}
\end{array}
if x < -1.92e6Initial program 100.0%
Taylor expanded in eps around inf
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites48.3%
Taylor expanded in eps around 0
Applied rewrites100.0%
if -1.92e6 < x < -2.9e-246Initial program 56.6%
Taylor expanded in eps around inf
Applied rewrites98.8%
Taylor expanded in x around 0
Applied rewrites62.6%
Applied rewrites81.0%
Taylor expanded in eps around inf
Applied rewrites81.0%
if -2.9e-246 < x < 9.5000000000000001e-299Initial program 61.3%
Taylor expanded in eps around inf
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites96.1%
Taylor expanded in eps around 0
Applied rewrites96.0%
if 9.5000000000000001e-299 < x < 8.99999999999999958e23Initial program 61.3%
Taylor expanded in eps around inf
Applied rewrites98.2%
Taylor expanded in x around 0
Applied rewrites55.3%
Applied rewrites68.8%
if 8.99999999999999958e23 < x < 6.9000000000000004e149Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites29.9%
Taylor expanded in x around 0
Applied rewrites35.3%
Applied rewrites52.0%
if 6.9000000000000004e149 < x Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites17.6%
Taylor expanded in x around 0
Applied rewrites16.4%
Taylor expanded in x around inf
Applied rewrites16.4%
Taylor expanded in eps around 0
Applied rewrites38.0%
Final simplification72.0%
(FPCore (x eps)
:precision binary64
(if (<= x -1920000.0)
(* (- (exp (- x)) -1.0) 0.5)
(if (<= x -2.9e-246)
(* (fma (fma -1.0 (/ (- (* eps eps) 1.0) (- eps 1.0)) eps) x 2.0) 0.5)
(* (- (exp (* x eps)) -1.0) 0.5))))
double code(double x, double eps) {
double tmp;
if (x <= -1920000.0) {
tmp = (exp(-x) - -1.0) * 0.5;
} else if (x <= -2.9e-246) {
tmp = fma(fma(-1.0, (((eps * eps) - 1.0) / (eps - 1.0)), eps), x, 2.0) * 0.5;
} else {
tmp = (exp((x * eps)) - -1.0) * 0.5;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -1920000.0) tmp = Float64(Float64(exp(Float64(-x)) - -1.0) * 0.5); elseif (x <= -2.9e-246) 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(exp(Float64(x * eps)) - -1.0) * 0.5); end return tmp end
code[x_, eps_] := If[LessEqual[x, -1920000.0], N[(N[(N[Exp[(-x)], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, -2.9e-246], 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[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1920000:\\
\;\;\;\;\left(e^{-x} - -1\right) \cdot 0.5\\
\mathbf{elif}\;x \leq -2.9 \cdot 10^{-246}:\\
\;\;\;\;\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(e^{x \cdot \varepsilon} - -1\right) \cdot 0.5\\
\end{array}
\end{array}
if x < -1.92e6Initial program 100.0%
Taylor expanded in eps around inf
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites48.3%
Taylor expanded in eps around 0
Applied rewrites100.0%
if -1.92e6 < x < -2.9e-246Initial program 56.6%
Taylor expanded in eps around inf
Applied rewrites98.8%
Taylor expanded in x around 0
Applied rewrites62.6%
Applied rewrites81.0%
Taylor expanded in eps around inf
Applied rewrites81.0%
if -2.9e-246 < x Initial program 77.4%
Taylor expanded in eps around inf
Applied rewrites99.2%
Taylor expanded in x around 0
Applied rewrites59.8%
Taylor expanded in eps around inf
Applied rewrites60.0%
(FPCore (x eps) :precision binary64 (if (<= x -4e-271) (* (+ 1.0 (exp (- (fma x eps x)))) 0.5) (* (- (exp (* x eps)) -1.0) 0.5)))
double code(double x, double eps) {
double tmp;
if (x <= -4e-271) {
tmp = (1.0 + exp(-fma(x, eps, x))) * 0.5;
} else {
tmp = (exp((x * eps)) - -1.0) * 0.5;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -4e-271) tmp = Float64(Float64(1.0 + exp(Float64(-fma(x, eps, x)))) * 0.5); else tmp = Float64(Float64(exp(Float64(x * eps)) - -1.0) * 0.5); end return tmp end
code[x_, eps_] := If[LessEqual[x, -4e-271], N[(N[(1.0 + N[Exp[(-N[(x * eps + x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{-271}:\\
\;\;\;\;\left(1 + e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(e^{x \cdot \varepsilon} - -1\right) \cdot 0.5\\
\end{array}
\end{array}
if x < -3.99999999999999985e-271Initial program 69.9%
Taylor expanded in eps around inf
Applied rewrites99.2%
Taylor expanded in x around 0
Applied rewrites76.1%
if -3.99999999999999985e-271 < x Initial program 77.8%
Taylor expanded in eps around inf
Applied rewrites99.2%
Taylor expanded in x around 0
Applied rewrites58.2%
Taylor expanded in eps around inf
Applied rewrites58.4%
Final simplification65.5%
(FPCore (x eps)
:precision binary64
(if (<= x -1920000.0)
(* (- (exp (- x)) -1.0) 0.5)
(if (<= x -2.9e-246)
(* (fma (fma -1.0 (/ (- (* eps eps) 1.0) (- eps 1.0)) eps) x 2.0) 0.5)
(if (<= x 9.5e-299)
(* (fma (fma -1.0 (- eps -1.0) -1.0) x 2.0) 0.5)
(if (<= x 10500000000.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)) (fma (- eps 1.0) x 1.0))
(* (- (/ 1.0 eps) 1.0) (fma -1.0 x 1.0)))
2.0))))))
double code(double x, double eps) {
double tmp;
if (x <= -1920000.0) {
tmp = (exp(-x) - -1.0) * 0.5;
} else if (x <= -2.9e-246) {
tmp = fma(fma(-1.0, (((eps * eps) - 1.0) / (eps - 1.0)), eps), x, 2.0) * 0.5;
} else if (x <= 9.5e-299) {
tmp = fma(fma(-1.0, (eps - -1.0), -1.0), x, 2.0) * 0.5;
} else if (x <= 10500000000.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)) * fma((eps - 1.0), x, 1.0)) - (((1.0 / eps) - 1.0) * fma(-1.0, x, 1.0))) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -1920000.0) tmp = Float64(Float64(exp(Float64(-x)) - -1.0) * 0.5); elseif (x <= -2.9e-246) 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 <= 9.5e-299) tmp = Float64(fma(fma(-1.0, Float64(eps - -1.0), -1.0), x, 2.0) * 0.5); elseif (x <= 10500000000.0) tmp = Float64(fma(fma(-1.0, Float64(eps - -1.0), 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)) * fma(Float64(eps - 1.0), x, 1.0)) - Float64(Float64(Float64(1.0 / eps) - 1.0) * fma(-1.0, x, 1.0))) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -1920000.0], N[(N[(N[Exp[(-x)], $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, -2.9e-246], 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, 9.5e-299], N[(N[(N[(-1.0 * N[(eps - -1.0), $MachinePrecision] + -1.0), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 10500000000.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] * N[(N[(eps - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[(-1.0 * x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1920000:\\
\;\;\;\;\left(e^{-x} - -1\right) \cdot 0.5\\
\mathbf{elif}\;x \leq -2.9 \cdot 10^{-246}:\\
\;\;\;\;\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 9.5 \cdot 10^{-299}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon - -1, -1\right), x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 10500000000:\\
\;\;\;\;\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 \mathsf{fma}\left(\varepsilon - 1, x, 1\right) - \left(\frac{1}{\varepsilon} - 1\right) \cdot \mathsf{fma}\left(-1, x, 1\right)}{2}\\
\end{array}
\end{array}
if x < -1.92e6Initial program 100.0%
Taylor expanded in eps around inf
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites48.3%
Taylor expanded in eps around 0
Applied rewrites100.0%
if -1.92e6 < x < -2.9e-246Initial program 56.6%
Taylor expanded in eps around inf
Applied rewrites98.8%
Taylor expanded in x around 0
Applied rewrites62.6%
Applied rewrites81.0%
Taylor expanded in eps around inf
Applied rewrites81.0%
if -2.9e-246 < x < 9.5000000000000001e-299Initial program 61.3%
Taylor expanded in eps around inf
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites96.1%
Taylor expanded in eps around 0
Applied rewrites96.0%
if 9.5000000000000001e-299 < x < 1.05e10Initial program 58.3%
Taylor expanded in eps around inf
Applied rewrites98.0%
Taylor expanded in x around 0
Applied rewrites59.5%
Applied rewrites70.9%
if 1.05e10 < x Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites24.3%
Taylor expanded in x around 0
Applied rewrites25.8%
Taylor expanded in eps around 0
Applied rewrites40.4%
Final simplification71.0%
(FPCore (x eps)
:precision binary64
(if (<= x -2.9e-246)
(* (fma (fma -1.0 (/ (- (* eps eps) 1.0) (- eps 1.0)) eps) x 2.0) 0.5)
(if (<= x 9.5e-299)
(* (fma (fma -1.0 (- eps -1.0) -1.0) x 2.0) 0.5)
(if (<= x 10500000000.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)) (fma (- eps 1.0) x 1.0))
(* (- (/ 1.0 eps) 1.0) (fma -1.0 x 1.0)))
2.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -2.9e-246) {
tmp = fma(fma(-1.0, (((eps * eps) - 1.0) / (eps - 1.0)), eps), x, 2.0) * 0.5;
} else if (x <= 9.5e-299) {
tmp = fma(fma(-1.0, (eps - -1.0), -1.0), x, 2.0) * 0.5;
} else if (x <= 10500000000.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)) * fma((eps - 1.0), x, 1.0)) - (((1.0 / eps) - 1.0) * fma(-1.0, x, 1.0))) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -2.9e-246) 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 <= 9.5e-299) tmp = Float64(fma(fma(-1.0, Float64(eps - -1.0), -1.0), x, 2.0) * 0.5); elseif (x <= 10500000000.0) tmp = Float64(fma(fma(-1.0, Float64(eps - -1.0), 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)) * fma(Float64(eps - 1.0), x, 1.0)) - Float64(Float64(Float64(1.0 / eps) - 1.0) * fma(-1.0, x, 1.0))) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -2.9e-246], 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, 9.5e-299], N[(N[(N[(-1.0 * N[(eps - -1.0), $MachinePrecision] + -1.0), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 10500000000.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] * N[(N[(eps - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[(-1.0 * x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.9 \cdot 10^{-246}:\\
\;\;\;\;\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 9.5 \cdot 10^{-299}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon - -1, -1\right), x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 10500000000:\\
\;\;\;\;\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 \mathsf{fma}\left(\varepsilon - 1, x, 1\right) - \left(\frac{1}{\varepsilon} - 1\right) \cdot \mathsf{fma}\left(-1, x, 1\right)}{2}\\
\end{array}
\end{array}
if x < -2.9e-246Initial program 70.0%
Taylor expanded in eps around inf
Applied rewrites99.2%
Taylor expanded in x around 0
Applied rewrites44.2%
Applied rewrites64.7%
Taylor expanded in eps around inf
Applied rewrites64.7%
if -2.9e-246 < x < 9.5000000000000001e-299Initial program 61.3%
Taylor expanded in eps around inf
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites96.1%
Taylor expanded in eps around 0
Applied rewrites96.0%
if 9.5000000000000001e-299 < x < 1.05e10Initial program 58.3%
Taylor expanded in eps around inf
Applied rewrites98.0%
Taylor expanded in x around 0
Applied rewrites59.5%
Applied rewrites70.9%
if 1.05e10 < x Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites24.3%
Taylor expanded in x around 0
Applied rewrites25.8%
Taylor expanded in eps around 0
Applied rewrites40.4%
Final simplification62.6%
(FPCore (x eps)
:precision binary64
(if (<= x -2.9e-246)
(* (fma (fma -1.0 (/ (- (* eps eps) 1.0) (- eps 1.0)) eps) x 2.0) 0.5)
(if (<= x 9.5e-299)
(* (fma (fma -1.0 (- eps -1.0) -1.0) x 2.0) 0.5)
(if (<= x 5.7e+26)
(*
(fma
(fma -1.0 (- eps -1.0) (/ (+ -1.0 (* eps eps)) (- eps -1.0)))
x
2.0)
0.5)
(/
(+
(* (+ 1.0 (/ 1.0 eps)) (* (- eps 1.0) x))
(* (- (/ -1.0 eps) -1.0) (fma -1.0 x 1.0)))
2.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -2.9e-246) {
tmp = fma(fma(-1.0, (((eps * eps) - 1.0) / (eps - 1.0)), eps), x, 2.0) * 0.5;
} else if (x <= 9.5e-299) {
tmp = fma(fma(-1.0, (eps - -1.0), -1.0), x, 2.0) * 0.5;
} else if (x <= 5.7e+26) {
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)) * ((eps - 1.0) * x)) + (((-1.0 / eps) - -1.0) * fma(-1.0, x, 1.0))) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -2.9e-246) 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 <= 9.5e-299) tmp = Float64(fma(fma(-1.0, Float64(eps - -1.0), -1.0), x, 2.0) * 0.5); elseif (x <= 5.7e+26) tmp = Float64(fma(fma(-1.0, Float64(eps - -1.0), 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)) * Float64(Float64(eps - 1.0) * x)) + Float64(Float64(Float64(-1.0 / eps) - -1.0) * fma(-1.0, x, 1.0))) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -2.9e-246], 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, 9.5e-299], N[(N[(N[(-1.0 * N[(eps - -1.0), $MachinePrecision] + -1.0), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 5.7e+26], 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] * N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(-1.0 / eps), $MachinePrecision] - -1.0), $MachinePrecision] * N[(-1.0 * x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.9 \cdot 10^{-246}:\\
\;\;\;\;\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 9.5 \cdot 10^{-299}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon - -1, -1\right), x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 5.7 \cdot 10^{+26}:\\
\;\;\;\;\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 \left(\left(\varepsilon - 1\right) \cdot x\right) + \left(\frac{-1}{\varepsilon} - -1\right) \cdot \mathsf{fma}\left(-1, x, 1\right)}{2}\\
\end{array}
\end{array}
if x < -2.9e-246Initial program 70.0%
Taylor expanded in eps around inf
Applied rewrites99.2%
Taylor expanded in x around 0
Applied rewrites44.2%
Applied rewrites64.7%
Taylor expanded in eps around inf
Applied rewrites64.7%
if -2.9e-246 < x < 9.5000000000000001e-299Initial program 61.3%
Taylor expanded in eps around inf
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites96.1%
Taylor expanded in eps around 0
Applied rewrites96.0%
if 9.5000000000000001e-299 < x < 5.7000000000000003e26Initial program 62.4%
Taylor expanded in eps around inf
Applied rewrites98.2%
Taylor expanded in x around 0
Applied rewrites53.8%
Applied rewrites68.3%
if 5.7000000000000003e26 < x Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites22.1%
Taylor expanded in x around 0
Applied rewrites23.9%
Taylor expanded in x around inf
Applied rewrites23.9%
Taylor expanded in eps around 0
Applied rewrites39.8%
Final simplification62.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (* eps eps) 1.0)))
(if (<= x -2.9e-246)
(* (fma (fma -1.0 (/ t_0 (- eps 1.0)) eps) x 2.0) 0.5)
(if (<= x 9.5e-299)
(* (fma (fma -1.0 (- eps -1.0) -1.0) x 2.0) 0.5)
(* (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 <= -2.9e-246) {
tmp = fma(fma(-1.0, (t_0 / (eps - 1.0)), eps), x, 2.0) * 0.5;
} else if (x <= 9.5e-299) {
tmp = fma(fma(-1.0, (eps - -1.0), -1.0), x, 2.0) * 0.5;
} 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 <= -2.9e-246) tmp = Float64(fma(fma(-1.0, Float64(t_0 / Float64(eps - 1.0)), eps), x, 2.0) * 0.5); elseif (x <= 9.5e-299) tmp = Float64(fma(fma(-1.0, Float64(eps - -1.0), -1.0), x, 2.0) * 0.5); else tmp = Float64(fma(fma(-1.0, Float64(t_0 / -1.0), 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, -2.9e-246], 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, 9.5e-299], N[(N[(N[(-1.0 * N[(eps - -1.0), $MachinePrecision] + -1.0), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], 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 -2.9 \cdot 10^{-246}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, \frac{t\_0}{\varepsilon - 1}, \varepsilon\right), x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-299}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon - -1, -1\right), x, 2\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, \frac{t\_0}{-1}, -1 + \varepsilon\right), x, 2\right) \cdot 0.5\\
\end{array}
\end{array}
if x < -2.9e-246Initial program 70.0%
Taylor expanded in eps around inf
Applied rewrites99.2%
Taylor expanded in x around 0
Applied rewrites44.2%
Applied rewrites64.7%
Taylor expanded in eps around inf
Applied rewrites64.7%
if -2.9e-246 < x < 9.5000000000000001e-299Initial program 61.3%
Taylor expanded in eps around inf
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites96.1%
Taylor expanded in eps around 0
Applied rewrites96.0%
if 9.5000000000000001e-299 < x Initial program 80.4%
Taylor expanded in eps around inf
Applied rewrites99.1%
Taylor expanded in x around 0
Applied rewrites29.4%
Applied rewrites38.0%
Taylor expanded in eps around 0
Applied rewrites57.5%
Final simplification64.0%
(FPCore (x eps) :precision binary64 (if (<= x -2.9e-246) (* (fma (fma -1.0 (/ (- (* eps eps) 1.0) (- eps 1.0)) eps) x 2.0) 0.5) (* (- (fma (- x) (- 1.0 eps) 1.0) -1.0) 0.5)))
double code(double x, double eps) {
double tmp;
if (x <= -2.9e-246) {
tmp = fma(fma(-1.0, (((eps * eps) - 1.0) / (eps - 1.0)), eps), x, 2.0) * 0.5;
} else {
tmp = (fma(-x, (1.0 - eps), 1.0) - -1.0) * 0.5;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -2.9e-246) 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(-x), Float64(1.0 - eps), 1.0) - -1.0) * 0.5); end return tmp end
code[x_, eps_] := If[LessEqual[x, -2.9e-246], 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[((-x) * N[(1.0 - eps), $MachinePrecision] + 1.0), $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.9 \cdot 10^{-246}:\\
\;\;\;\;\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(-x, 1 - \varepsilon, 1\right) - -1\right) \cdot 0.5\\
\end{array}
\end{array}
if x < -2.9e-246Initial program 70.0%
Taylor expanded in eps around inf
Applied rewrites99.2%
Taylor expanded in x around 0
Applied rewrites44.2%
Applied rewrites64.7%
Taylor expanded in eps around inf
Applied rewrites64.7%
if -2.9e-246 < x Initial program 77.4%
Taylor expanded in eps around inf
Applied rewrites99.2%
Taylor expanded in x around 0
Applied rewrites59.8%
Taylor expanded in x around 0
Applied rewrites46.0%
(FPCore (x eps) :precision binary64 (if (<= x -4e-271) (* (fma (fma -1.0 (- eps -1.0) -1.0) x 2.0) 0.5) (* (- (fma (- x) (- 1.0 eps) 1.0) -1.0) 0.5)))
double code(double x, double eps) {
double tmp;
if (x <= -4e-271) {
tmp = fma(fma(-1.0, (eps - -1.0), -1.0), x, 2.0) * 0.5;
} else {
tmp = (fma(-x, (1.0 - eps), 1.0) - -1.0) * 0.5;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -4e-271) tmp = Float64(fma(fma(-1.0, Float64(eps - -1.0), -1.0), x, 2.0) * 0.5); else tmp = Float64(Float64(fma(Float64(-x), Float64(1.0 - eps), 1.0) - -1.0) * 0.5); end return tmp end
code[x_, eps_] := If[LessEqual[x, -4e-271], N[(N[(N[(-1.0 * N[(eps - -1.0), $MachinePrecision] + -1.0), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[((-x) * N[(1.0 - eps), $MachinePrecision] + 1.0), $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{-271}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-1, \varepsilon - -1, -1\right), x, 2\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(-x, 1 - \varepsilon, 1\right) - -1\right) \cdot 0.5\\
\end{array}
\end{array}
if x < -3.99999999999999985e-271Initial program 69.9%
Taylor expanded in eps around inf
Applied rewrites99.2%
Taylor expanded in x around 0
Applied rewrites46.5%
Taylor expanded in eps around 0
Applied rewrites53.3%
if -3.99999999999999985e-271 < x Initial program 77.8%
Taylor expanded in eps around inf
Applied rewrites99.2%
Taylor expanded in x around 0
Applied rewrites58.2%
Taylor expanded in x around 0
Applied rewrites44.5%
Final simplification48.0%
(FPCore (x eps) :precision binary64 (* (- (fma (- x) (- 1.0 eps) 1.0) -1.0) 0.5))
double code(double x, double eps) {
return (fma(-x, (1.0 - eps), 1.0) - -1.0) * 0.5;
}
function code(x, eps) return Float64(Float64(fma(Float64(-x), Float64(1.0 - eps), 1.0) - -1.0) * 0.5) end
code[x_, eps_] := N[(N[(N[((-x) * N[(1.0 - eps), $MachinePrecision] + 1.0), $MachinePrecision] - -1.0), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
\\
\left(\mathsf{fma}\left(-x, 1 - \varepsilon, 1\right) - -1\right) \cdot 0.5
\end{array}
Initial program 74.6%
Taylor expanded in eps around inf
Applied rewrites99.2%
Taylor expanded in x around 0
Applied rewrites62.4%
Taylor expanded in x around 0
Applied rewrites47.1%
(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 74.6%
Taylor expanded in x around 0
Applied rewrites41.9%
herbie shell --seed 2025026
(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))