
(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 3 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}
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (* (- x -1.0) (exp (- x)))))
(if (<= eps_m 5e-18)
(/ (+ t_0 t_0) 2.0)
(/
(+
(* (+ 1.0 (/ 1.0 eps_m)) (exp (* (+ -1.0 eps_m) x)))
(* (- (/ -1.0 eps_m) -1.0) (pow (exp (fma x eps_m x)) -1.0)))
2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = (x - -1.0) * exp(-x);
double tmp;
if (eps_m <= 5e-18) {
tmp = (t_0 + t_0) / 2.0;
} else {
tmp = (((1.0 + (1.0 / eps_m)) * exp(((-1.0 + eps_m) * x))) + (((-1.0 / eps_m) - -1.0) * pow(exp(fma(x, eps_m, x)), -1.0))) / 2.0;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(Float64(x - -1.0) * exp(Float64(-x))) tmp = 0.0 if (eps_m <= 5e-18) tmp = Float64(Float64(t_0 + t_0) / 2.0); else tmp = Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) * exp(Float64(Float64(-1.0 + eps_m) * x))) + Float64(Float64(Float64(-1.0 / eps_m) - -1.0) * (exp(fma(x, eps_m, x)) ^ -1.0))) / 2.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[(N[(x - -1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps$95$m, 5e-18], N[(N[(t$95$0 + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(N[(-1.0 + eps$95$m), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(-1.0 / eps$95$m), $MachinePrecision] - -1.0), $MachinePrecision] * N[Power[N[Exp[N[(x * eps$95$m + x), $MachinePrecision]], $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := \left(x - -1\right) \cdot e^{-x}\\
\mathbf{if}\;eps\_m \leq 5 \cdot 10^{-18}:\\
\;\;\;\;\frac{t\_0 + t\_0}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) \cdot e^{\left(-1 + eps\_m\right) \cdot x} + \left(\frac{-1}{eps\_m} - -1\right) \cdot {\left(e^{\mathsf{fma}\left(x, eps\_m, x\right)}\right)}^{-1}}{2}\\
\end{array}
\end{array}
if eps < 5.00000000000000036e-18Initial program 64.1%
Taylor expanded in eps around 0
lower--.f64N/A
distribute-rgt1-inN/A
lower-*.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
distribute-rgt1-inN/A
lower-*.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f6472.9
Applied rewrites72.9%
if 5.00000000000000036e-18 < eps Initial program 100.0%
lift-exp.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
lift-*.f64N/A
exp-negN/A
inv-powN/A
lower-pow.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-rgt1-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Final simplification80.3%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (* (- x -1.0) (exp (- x)))))
(if (<= eps_m 5e-18)
(/ (+ t_0 t_0) 2.0)
(/
(-
(* (+ 1.0 (/ 1.0 eps_m)) (exp (* (+ -1.0 eps_m) x)))
(* (- (/ 1.0 eps_m) 1.0) (exp (* (- -1.0 eps_m) x))))
2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = (x - -1.0) * exp(-x);
double tmp;
if (eps_m <= 5e-18) {
tmp = (t_0 + t_0) / 2.0;
} else {
tmp = (((1.0 + (1.0 / eps_m)) * exp(((-1.0 + eps_m) * x))) - (((1.0 / eps_m) - 1.0) * exp(((-1.0 - eps_m) * x)))) / 2.0;
}
return tmp;
}
eps_m = private
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_m)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: t_0
real(8) :: tmp
t_0 = (x - (-1.0d0)) * exp(-x)
if (eps_m <= 5d-18) then
tmp = (t_0 + t_0) / 2.0d0
else
tmp = (((1.0d0 + (1.0d0 / eps_m)) * exp((((-1.0d0) + eps_m) * x))) - (((1.0d0 / eps_m) - 1.0d0) * exp((((-1.0d0) - eps_m) * x)))) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double t_0 = (x - -1.0) * Math.exp(-x);
double tmp;
if (eps_m <= 5e-18) {
tmp = (t_0 + t_0) / 2.0;
} else {
tmp = (((1.0 + (1.0 / eps_m)) * Math.exp(((-1.0 + eps_m) * x))) - (((1.0 / eps_m) - 1.0) * Math.exp(((-1.0 - eps_m) * x)))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = (x - -1.0) * math.exp(-x) tmp = 0 if eps_m <= 5e-18: tmp = (t_0 + t_0) / 2.0 else: tmp = (((1.0 + (1.0 / eps_m)) * math.exp(((-1.0 + eps_m) * x))) - (((1.0 / eps_m) - 1.0) * math.exp(((-1.0 - eps_m) * x)))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(Float64(x - -1.0) * exp(Float64(-x))) tmp = 0.0 if (eps_m <= 5e-18) tmp = Float64(Float64(t_0 + t_0) / 2.0); else tmp = Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) * exp(Float64(Float64(-1.0 + eps_m) * x))) - Float64(Float64(Float64(1.0 / eps_m) - 1.0) * exp(Float64(Float64(-1.0 - eps_m) * x)))) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = (x - -1.0) * exp(-x); tmp = 0.0; if (eps_m <= 5e-18) tmp = (t_0 + t_0) / 2.0; else tmp = (((1.0 + (1.0 / eps_m)) * exp(((-1.0 + eps_m) * x))) - (((1.0 / eps_m) - 1.0) * exp(((-1.0 - eps_m) * x)))) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[(N[(x - -1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps$95$m, 5e-18], N[(N[(t$95$0 + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(N[(-1.0 + eps$95$m), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[N[(N[(-1.0 - eps$95$m), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := \left(x - -1\right) \cdot e^{-x}\\
\mathbf{if}\;eps\_m \leq 5 \cdot 10^{-18}:\\
\;\;\;\;\frac{t\_0 + t\_0}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) \cdot e^{\left(-1 + eps\_m\right) \cdot x} - \left(\frac{1}{eps\_m} - 1\right) \cdot e^{\left(-1 - eps\_m\right) \cdot x}}{2}\\
\end{array}
\end{array}
if eps < 5.00000000000000036e-18Initial program 64.1%
Taylor expanded in eps around 0
lower--.f64N/A
distribute-rgt1-inN/A
lower-*.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
distribute-rgt1-inN/A
lower-*.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f6472.9
Applied rewrites72.9%
if 5.00000000000000036e-18 < eps Initial program 100.0%
Final simplification80.3%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (let* ((t_0 (* (- x -1.0) (exp (- x))))) (/ (+ t_0 t_0) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = (x - -1.0) * exp(-x);
return (t_0 + t_0) / 2.0;
}
eps_m = private
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_m)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: t_0
t_0 = (x - (-1.0d0)) * exp(-x)
code = (t_0 + t_0) / 2.0d0
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double t_0 = (x - -1.0) * Math.exp(-x);
return (t_0 + t_0) / 2.0;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = (x - -1.0) * math.exp(-x) return (t_0 + t_0) / 2.0
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(Float64(x - -1.0) * exp(Float64(-x))) return Float64(Float64(t_0 + t_0) / 2.0) end
eps_m = abs(eps); function tmp = code(x, eps_m) t_0 = (x - -1.0) * exp(-x); tmp = (t_0 + t_0) / 2.0; end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[(N[(x - -1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]}, N[(N[(t$95$0 + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := \left(x - -1\right) \cdot e^{-x}\\
\frac{t\_0 + t\_0}{2}
\end{array}
\end{array}
Initial program 73.9%
Taylor expanded in eps around 0
lower--.f64N/A
distribute-rgt1-inN/A
lower-*.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
distribute-rgt1-inN/A
lower-*.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-neg.f6462.2
Applied rewrites62.2%
Final simplification62.2%
herbie shell --seed 2025057
(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))