
(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;
}
real(8) function code(x, eps)
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 11 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;
}
real(8) function code(x, eps)
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}
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= eps 4e-20) (/ (+ (/ (+ x 1.0) (exp x)) (* (+ x 1.0) (exp (- x)))) 2.0) (/ (+ (exp (- (* x eps) x)) (exp (* x (- eps)))) 2.0)))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (eps <= 4e-20) {
tmp = (((x + 1.0) / exp(x)) + ((x + 1.0) * exp(-x))) / 2.0;
} else {
tmp = (exp(((x * eps) - x)) + exp((x * -eps))) / 2.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (eps <= 4d-20) then
tmp = (((x + 1.0d0) / exp(x)) + ((x + 1.0d0) * exp(-x))) / 2.0d0
else
tmp = (exp(((x * eps) - x)) + exp((x * -eps))) / 2.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (eps <= 4e-20) {
tmp = (((x + 1.0) / Math.exp(x)) + ((x + 1.0) * Math.exp(-x))) / 2.0;
} else {
tmp = (Math.exp(((x * eps) - x)) + Math.exp((x * -eps))) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if eps <= 4e-20: tmp = (((x + 1.0) / math.exp(x)) + ((x + 1.0) * math.exp(-x))) / 2.0 else: tmp = (math.exp(((x * eps) - x)) + math.exp((x * -eps))) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (eps <= 4e-20) tmp = Float64(Float64(Float64(Float64(x + 1.0) / exp(x)) + Float64(Float64(x + 1.0) * exp(Float64(-x)))) / 2.0); else tmp = Float64(Float64(exp(Float64(Float64(x * eps) - x)) + exp(Float64(x * Float64(-eps)))) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= 4e-20) tmp = (((x + 1.0) / exp(x)) + ((x + 1.0) * exp(-x))) / 2.0; else tmp = (exp(((x * eps) - x)) + exp((x * -eps))) / 2.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[eps, 4e-20], N[(N[(N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] + N[(N[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(N[(x * eps), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * (-eps)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 4 \cdot 10^{-20}:\\
\;\;\;\;\frac{\frac{x + 1}{e^{x}} + \left(x + 1\right) \cdot e^{-x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \varepsilon - x} + e^{x \cdot \left(-\varepsilon\right)}}{2}\\
\end{array}
\end{array}
if eps < 3.99999999999999978e-20Initial program 62.5%
div-sub62.5%
+-rgt-identity62.5%
div-sub62.5%
Simplified62.5%
Taylor expanded in eps around 0 69.1%
*-commutative69.1%
distribute-lft1-in69.1%
mul-1-neg69.1%
distribute-lft-out69.1%
mul-1-neg69.1%
*-commutative69.1%
distribute-lft1-in69.6%
mul-1-neg69.6%
Simplified69.6%
exp-neg69.6%
un-div-inv69.6%
Applied egg-rr69.6%
if 3.99999999999999978e-20 < eps Initial program 97.0%
div-sub97.0%
+-rgt-identity97.0%
div-sub97.0%
Simplified97.0%
Taylor expanded in eps around inf 100.0%
neg-mul-1100.0%
*-commutative100.0%
mul-1-neg100.0%
exp-prod100.0%
+-commutative100.0%
*-commutative100.0%
remove-double-neg100.0%
mul-1-neg100.0%
sub-neg100.0%
*-commutative100.0%
exp-prod100.0%
exp-prod100.0%
*-commutative100.0%
cancel-sign-sub-inv100.0%
metadata-eval100.0%
*-lft-identity100.0%
exp-prod100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
associate-*r*100.0%
mul-1-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
associate-*r*100.0%
neg-mul-1100.0%
Simplified100.0%
Final simplification77.3%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (/ (+ (exp (* x (+ eps -1.0))) (exp (* x (- -1.0 eps)))) 2.0))
eps = abs(eps);
double code(double x, double eps) {
return (exp((x * (eps + -1.0))) + exp((x * (-1.0 - eps)))) / 2.0;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (exp((x * (eps + (-1.0d0)))) + exp((x * ((-1.0d0) - eps)))) / 2.0d0
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
return (Math.exp((x * (eps + -1.0))) + Math.exp((x * (-1.0 - eps)))) / 2.0;
}
eps = abs(eps) def code(x, eps): return (math.exp((x * (eps + -1.0))) + math.exp((x * (-1.0 - eps)))) / 2.0
eps = abs(eps) function code(x, eps) return Float64(Float64(exp(Float64(x * Float64(eps + -1.0))) + exp(Float64(x * Float64(-1.0 - eps)))) / 2.0) end
eps = abs(eps) function tmp = code(x, eps) tmp = (exp((x * (eps + -1.0))) + exp((x * (-1.0 - eps)))) / 2.0; end
NOTE: eps should be positive before calling this function code[x_, eps_] := N[(N[(N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
eps = |eps|\\
\\
\frac{e^{x \cdot \left(\varepsilon + -1\right)} + e^{x \cdot \left(-1 - \varepsilon\right)}}{2}
\end{array}
Initial program 71.2%
div-sub71.2%
+-rgt-identity71.2%
div-sub71.2%
Simplified71.2%
Taylor expanded in eps around inf 98.9%
neg-mul-198.9%
*-commutative98.9%
mul-1-neg98.9%
exp-prod98.9%
+-commutative98.9%
*-commutative98.9%
remove-double-neg98.9%
mul-1-neg98.9%
sub-neg98.9%
*-commutative98.9%
exp-prod98.9%
exp-prod98.9%
*-commutative98.9%
cancel-sign-sub-inv98.9%
metadata-eval98.9%
*-lft-identity98.9%
exp-prod98.9%
Simplified98.9%
Final simplification98.9%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x 2.85e+156) (/ (+ (exp (* x (- eps))) (exp (* x eps))) 2.0) 0.0))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 2.85e+156) {
tmp = (exp((x * -eps)) + exp((x * eps))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 2.85d+156) then
tmp = (exp((x * -eps)) + exp((x * eps))) / 2.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= 2.85e+156) {
tmp = (Math.exp((x * -eps)) + Math.exp((x * eps))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 2.85e+156: tmp = (math.exp((x * -eps)) + math.exp((x * eps))) / 2.0 else: tmp = 0.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 2.85e+156) tmp = Float64(Float64(exp(Float64(x * Float64(-eps))) + exp(Float64(x * eps))) / 2.0); else tmp = 0.0; end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 2.85e+156) tmp = (exp((x * -eps)) + exp((x * eps))) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, 2.85e+156], N[(N[(N[Exp[N[(x * (-eps)), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.85 \cdot 10^{+156}:\\
\;\;\;\;\frac{e^{x \cdot \left(-\varepsilon\right)} + e^{x \cdot \varepsilon}}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 2.84999999999999999e156Initial program 67.8%
div-sub67.8%
+-rgt-identity67.8%
div-sub67.8%
Simplified67.8%
Taylor expanded in eps around inf 98.8%
neg-mul-198.8%
*-commutative98.8%
mul-1-neg98.8%
exp-prod98.8%
+-commutative98.8%
*-commutative98.8%
remove-double-neg98.8%
mul-1-neg98.8%
sub-neg98.8%
*-commutative98.8%
exp-prod98.8%
exp-prod98.8%
*-commutative98.8%
cancel-sign-sub-inv98.8%
metadata-eval98.8%
*-lft-identity98.8%
exp-prod98.8%
Simplified98.8%
Taylor expanded in eps around inf 93.7%
associate-*r*93.7%
mul-1-neg93.7%
Simplified93.7%
Taylor expanded in x around inf 93.7%
associate-*r*93.7%
neg-mul-193.7%
Simplified93.7%
Taylor expanded in eps around inf 94.1%
*-commutative94.1%
Simplified94.1%
if 2.84999999999999999e156 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 74.5%
div-sub74.5%
rec-exp74.5%
mul-1-neg74.5%
+-inverses74.5%
Simplified74.5%
Final simplification92.0%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (/ (+ (exp (- (* x eps) x)) (exp (* x (- eps)))) 2.0))
eps = abs(eps);
double code(double x, double eps) {
return (exp(((x * eps) - x)) + exp((x * -eps))) / 2.0;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (exp(((x * eps) - x)) + exp((x * -eps))) / 2.0d0
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
return (Math.exp(((x * eps) - x)) + Math.exp((x * -eps))) / 2.0;
}
eps = abs(eps) def code(x, eps): return (math.exp(((x * eps) - x)) + math.exp((x * -eps))) / 2.0
eps = abs(eps) function code(x, eps) return Float64(Float64(exp(Float64(Float64(x * eps) - x)) + exp(Float64(x * Float64(-eps)))) / 2.0) end
eps = abs(eps) function tmp = code(x, eps) tmp = (exp(((x * eps) - x)) + exp((x * -eps))) / 2.0; end
NOTE: eps should be positive before calling this function code[x_, eps_] := N[(N[(N[Exp[N[(N[(x * eps), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * (-eps)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
eps = |eps|\\
\\
\frac{e^{x \cdot \varepsilon - x} + e^{x \cdot \left(-\varepsilon\right)}}{2}
\end{array}
Initial program 71.2%
div-sub71.2%
+-rgt-identity71.2%
div-sub71.2%
Simplified71.2%
Taylor expanded in eps around inf 98.9%
neg-mul-198.9%
*-commutative98.9%
mul-1-neg98.9%
exp-prod98.9%
+-commutative98.9%
*-commutative98.9%
remove-double-neg98.9%
mul-1-neg98.9%
sub-neg98.9%
*-commutative98.9%
exp-prod98.9%
exp-prod98.9%
*-commutative98.9%
cancel-sign-sub-inv98.9%
metadata-eval98.9%
*-lft-identity98.9%
exp-prod98.9%
Simplified98.9%
Taylor expanded in eps around inf 89.8%
associate-*r*89.8%
mul-1-neg89.8%
Simplified89.8%
Taylor expanded in x around inf 89.8%
associate-*r*89.8%
neg-mul-189.8%
Simplified89.8%
Final simplification89.8%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(if (<= x 2e-15)
(/ (+ 1.0 (exp (* x (- -1.0 eps)))) 2.0)
(if (<= x 2e+155)
(/
(+ (+ 1.0 (/ 1.0 eps)) (* (exp (* x (+ 1.0 eps))) (- (/ -1.0 eps) -1.0)))
2.0)
0.0)))eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 2e-15) {
tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0;
} else if (x <= 2e+155) {
tmp = ((1.0 + (1.0 / eps)) + (exp((x * (1.0 + eps))) * ((-1.0 / eps) - -1.0))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 2d-15) then
tmp = (1.0d0 + exp((x * ((-1.0d0) - eps)))) / 2.0d0
else if (x <= 2d+155) then
tmp = ((1.0d0 + (1.0d0 / eps)) + (exp((x * (1.0d0 + eps))) * (((-1.0d0) / eps) - (-1.0d0)))) / 2.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= 2e-15) {
tmp = (1.0 + Math.exp((x * (-1.0 - eps)))) / 2.0;
} else if (x <= 2e+155) {
tmp = ((1.0 + (1.0 / eps)) + (Math.exp((x * (1.0 + eps))) * ((-1.0 / eps) - -1.0))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 2e-15: tmp = (1.0 + math.exp((x * (-1.0 - eps)))) / 2.0 elif x <= 2e+155: tmp = ((1.0 + (1.0 / eps)) + (math.exp((x * (1.0 + eps))) * ((-1.0 / eps) - -1.0))) / 2.0 else: tmp = 0.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 2e-15) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps)))) / 2.0); elseif (x <= 2e+155) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) + Float64(exp(Float64(x * Float64(1.0 + eps))) * Float64(Float64(-1.0 / eps) - -1.0))) / 2.0); else tmp = 0.0; end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 2e-15) tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0; elseif (x <= 2e+155) tmp = ((1.0 + (1.0 / eps)) + (exp((x * (1.0 + eps))) * ((-1.0 / eps) - -1.0))) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, 2e-15], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 2e+155], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(N[Exp[N[(x * N[(1.0 + eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[(-1.0 / eps), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2 \cdot 10^{-15}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - \varepsilon\right)}}{2}\\
\mathbf{elif}\;x \leq 2 \cdot 10^{+155}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) + e^{x \cdot \left(1 + \varepsilon\right)} \cdot \left(\frac{-1}{\varepsilon} - -1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 2.0000000000000002e-15Initial program 63.0%
div-sub63.0%
+-rgt-identity63.0%
div-sub63.0%
Simplified63.0%
Taylor expanded in x around 0 41.6%
Taylor expanded in eps around inf 77.2%
mul-1-neg77.2%
associate-*r*77.2%
+-commutative77.2%
associate-*r*77.2%
mul-1-neg77.2%
distribute-rgt-neg-out77.2%
*-commutative77.2%
+-commutative77.2%
Simplified77.2%
Taylor expanded in x around 0 77.2%
mul-1-neg77.2%
*-commutative77.2%
distribute-rgt-neg-out77.2%
neg-sub077.2%
+-commutative77.2%
associate--r+77.2%
metadata-eval77.2%
Simplified77.2%
if 2.0000000000000002e-15 < x < 2.00000000000000001e155Initial program 100.0%
div-sub100.0%
+-rgt-identity100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around 0 22.2%
add-log-exp22.2%
*-un-lft-identity22.2%
log-prod22.2%
metadata-eval22.2%
add-log-exp22.2%
*-commutative22.2%
add-sqr-sqrt0.0%
sqrt-unprod41.3%
sqr-neg41.3%
sqrt-unprod41.3%
add-sqr-sqrt41.3%
Applied egg-rr41.3%
+-lft-identity41.3%
+-commutative41.3%
Simplified41.3%
if 2.00000000000000001e155 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 74.5%
div-sub74.5%
rec-exp74.5%
mul-1-neg74.5%
+-inverses74.5%
Simplified74.5%
Final simplification72.7%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x 225000.0) (/ (+ 1.0 (exp (* x (- -1.0 eps)))) 2.0) 0.0))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 225000.0) {
tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 225000.0d0) then
tmp = (1.0d0 + exp((x * ((-1.0d0) - eps)))) / 2.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= 225000.0) {
tmp = (1.0 + Math.exp((x * (-1.0 - eps)))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 225000.0: tmp = (1.0 + math.exp((x * (-1.0 - eps)))) / 2.0 else: tmp = 0.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 225000.0) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps)))) / 2.0); else tmp = 0.0; end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 225000.0) tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, 225000.0], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 225000:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - \varepsilon\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 225000Initial program 63.5%
div-sub63.5%
+-rgt-identity63.5%
div-sub63.5%
Simplified63.5%
Taylor expanded in x around 0 42.0%
Taylor expanded in eps around inf 77.1%
mul-1-neg77.1%
associate-*r*77.1%
+-commutative77.1%
associate-*r*77.1%
mul-1-neg77.1%
distribute-rgt-neg-out77.1%
*-commutative77.1%
+-commutative77.1%
Simplified77.1%
Taylor expanded in x around 0 77.1%
mul-1-neg77.1%
*-commutative77.1%
distribute-rgt-neg-out77.1%
neg-sub077.1%
+-commutative77.1%
associate--r+77.1%
metadata-eval77.1%
Simplified77.1%
if 225000 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 59.9%
div-sub59.9%
rec-exp59.9%
mul-1-neg59.9%
+-inverses59.9%
Simplified59.9%
Final simplification73.4%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x 6e-14) (/ (- 2.0 (* x eps)) 2.0) (/ (* x (exp (- x))) 2.0)))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 6e-14) {
tmp = (2.0 - (x * eps)) / 2.0;
} else {
tmp = (x * exp(-x)) / 2.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 6d-14) then
tmp = (2.0d0 - (x * eps)) / 2.0d0
else
tmp = (x * exp(-x)) / 2.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= 6e-14) {
tmp = (2.0 - (x * eps)) / 2.0;
} else {
tmp = (x * Math.exp(-x)) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 6e-14: tmp = (2.0 - (x * eps)) / 2.0 else: tmp = (x * math.exp(-x)) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 6e-14) tmp = Float64(Float64(2.0 - Float64(x * eps)) / 2.0); else tmp = Float64(Float64(x * exp(Float64(-x))) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 6e-14) tmp = (2.0 - (x * eps)) / 2.0; else tmp = (x * exp(-x)) / 2.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, 6e-14], N[(N[(2.0 - N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(x * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6 \cdot 10^{-14}:\\
\;\;\;\;\frac{2 - x \cdot \varepsilon}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot e^{-x}}{2}\\
\end{array}
\end{array}
if x < 5.9999999999999997e-14Initial program 63.0%
div-sub63.0%
+-rgt-identity63.0%
div-sub63.0%
Simplified63.0%
Taylor expanded in x around 0 41.6%
Taylor expanded in x around 0 47.4%
Taylor expanded in eps around inf 63.6%
associate-*r*63.6%
mul-1-neg63.6%
Simplified63.6%
if 5.9999999999999997e-14 < x Initial program 100.0%
div-sub100.0%
+-rgt-identity100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in eps around 0 56.9%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around inf 56.9%
*-commutative56.9%
neg-mul-156.9%
Simplified56.9%
Final simplification62.1%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x 225000.0) (/ (+ 1.0 (exp (- x))) 2.0) 0.0))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 225000.0) {
tmp = (1.0 + exp(-x)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 225000.0d0) then
tmp = (1.0d0 + exp(-x)) / 2.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= 225000.0) {
tmp = (1.0 + Math.exp(-x)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 225000.0: tmp = (1.0 + math.exp(-x)) / 2.0 else: tmp = 0.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 225000.0) tmp = Float64(Float64(1.0 + exp(Float64(-x))) / 2.0); else tmp = 0.0; end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 225000.0) tmp = (1.0 + exp(-x)) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, 225000.0], N[(N[(1.0 + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 225000:\\
\;\;\;\;\frac{1 + e^{-x}}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 225000Initial program 63.5%
div-sub63.5%
+-rgt-identity63.5%
div-sub63.5%
Simplified63.5%
Taylor expanded in eps around inf 98.6%
neg-mul-198.6%
*-commutative98.6%
mul-1-neg98.6%
exp-prod98.6%
+-commutative98.6%
*-commutative98.6%
remove-double-neg98.6%
mul-1-neg98.6%
sub-neg98.6%
*-commutative98.6%
exp-prod98.6%
exp-prod98.6%
*-commutative98.6%
cancel-sign-sub-inv98.6%
metadata-eval98.6%
*-lft-identity98.6%
exp-prod98.6%
Simplified98.6%
Taylor expanded in eps around inf 98.7%
associate-*r*98.7%
mul-1-neg98.7%
Simplified98.7%
Taylor expanded in eps around 0 77.4%
if 225000 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 59.9%
div-sub59.9%
rec-exp59.9%
mul-1-neg59.9%
+-inverses59.9%
Simplified59.9%
Final simplification73.7%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x 6e-14) (/ (- 2.0 (* x eps)) 2.0) 0.0))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 6e-14) {
tmp = (2.0 - (x * eps)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 6d-14) then
tmp = (2.0d0 - (x * eps)) / 2.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= 6e-14) {
tmp = (2.0 - (x * eps)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 6e-14: tmp = (2.0 - (x * eps)) / 2.0 else: tmp = 0.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 6e-14) tmp = Float64(Float64(2.0 - Float64(x * eps)) / 2.0); else tmp = 0.0; end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 6e-14) tmp = (2.0 - (x * eps)) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, 6e-14], N[(N[(2.0 - N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6 \cdot 10^{-14}:\\
\;\;\;\;\frac{2 - x \cdot \varepsilon}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 5.9999999999999997e-14Initial program 63.0%
div-sub63.0%
+-rgt-identity63.0%
div-sub63.0%
Simplified63.0%
Taylor expanded in x around 0 41.6%
Taylor expanded in x around 0 47.4%
Taylor expanded in eps around inf 63.6%
associate-*r*63.6%
mul-1-neg63.6%
Simplified63.6%
if 5.9999999999999997e-14 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 56.8%
div-sub56.8%
rec-exp56.8%
mul-1-neg56.8%
+-inverses56.8%
Simplified56.8%
Final simplification62.1%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x 225000.0) 1.0 0.0))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 225000.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 225000.0d0) then
tmp = 1.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= 225000.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 225000.0: tmp = 1.0 else: tmp = 0.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 225000.0) tmp = 1.0; else tmp = 0.0; end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 225000.0) tmp = 1.0; else tmp = 0.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, 225000.0], 1.0, 0.0]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 225000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 225000Initial program 63.5%
div-sub63.5%
+-rgt-identity63.5%
div-sub63.5%
Simplified63.5%
Taylor expanded in x around 0 59.5%
if 225000 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 59.9%
div-sub59.9%
rec-exp59.9%
mul-1-neg59.9%
+-inverses59.9%
Simplified59.9%
Final simplification59.6%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 0.0)
eps = abs(eps);
double code(double x, double eps) {
return 0.0;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 0.0d0
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
return 0.0;
}
eps = abs(eps) def code(x, eps): return 0.0
eps = abs(eps) function code(x, eps) return 0.0 end
eps = abs(eps) function tmp = code(x, eps) tmp = 0.0; end
NOTE: eps should be positive before calling this function code[x_, eps_] := 0.0
\begin{array}{l}
eps = |eps|\\
\\
0
\end{array}
Initial program 71.2%
Simplified59.0%
Taylor expanded in eps around 0 14.4%
div-sub14.4%
rec-exp14.4%
mul-1-neg14.4%
+-inverses14.6%
Simplified14.6%
Final simplification14.6%
herbie shell --seed 2023216
(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))