
(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}
(FPCore (x eps) :precision binary64 (/ (+ (exp (* x (+ eps -1.0))) (/ 1.0 (exp (+ x (* x eps))))) 2.0))
double code(double x, double eps) {
return (exp((x * (eps + -1.0))) + (1.0 / exp((x + (x * eps))))) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (exp((x * (eps + (-1.0d0)))) + (1.0d0 / exp((x + (x * eps))))) / 2.0d0
end function
public static double code(double x, double eps) {
return (Math.exp((x * (eps + -1.0))) + (1.0 / Math.exp((x + (x * eps))))) / 2.0;
}
def code(x, eps): return (math.exp((x * (eps + -1.0))) + (1.0 / math.exp((x + (x * eps))))) / 2.0
function code(x, eps) return Float64(Float64(exp(Float64(x * Float64(eps + -1.0))) + Float64(1.0 / exp(Float64(x + Float64(x * eps))))) / 2.0) end
function tmp = code(x, eps) tmp = (exp((x * (eps + -1.0))) + (1.0 / exp((x + (x * eps))))) / 2.0; end
code[x_, eps_] := N[(N[(N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(1.0 / N[Exp[N[(x + N[(x * eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{x \cdot \left(\varepsilon + -1\right)} + \frac{1}{e^{x + x \cdot \varepsilon}}}{2}
\end{array}
Initial program 67.0%
Simplified61.4%
Taylor expanded in eps around inf 98.7%
Final simplification98.7%
(FPCore (x eps) :precision binary64 (if (<= x -1e-229) (/ (+ 1.0 (exp (- (* x eps)))) 2.0) (/ (+ (exp (* x (+ eps -1.0))) (exp (- x))) 2.0)))
double code(double x, double eps) {
double tmp;
if (x <= -1e-229) {
tmp = (1.0 + exp(-(x * eps))) / 2.0;
} else {
tmp = (exp((x * (eps + -1.0))) + exp(-x)) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-1d-229)) then
tmp = (1.0d0 + exp(-(x * eps))) / 2.0d0
else
tmp = (exp((x * (eps + (-1.0d0)))) + exp(-x)) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -1e-229) {
tmp = (1.0 + Math.exp(-(x * eps))) / 2.0;
} else {
tmp = (Math.exp((x * (eps + -1.0))) + Math.exp(-x)) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -1e-229: tmp = (1.0 + math.exp(-(x * eps))) / 2.0 else: tmp = (math.exp((x * (eps + -1.0))) + math.exp(-x)) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -1e-229) tmp = Float64(Float64(1.0 + exp(Float64(-Float64(x * eps)))) / 2.0); else tmp = Float64(Float64(exp(Float64(x * Float64(eps + -1.0))) + exp(Float64(-x))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -1e-229) tmp = (1.0 + exp(-(x * eps))) / 2.0; else tmp = (exp((x * (eps + -1.0))) + exp(-x)) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -1e-229], N[(N[(1.0 + N[Exp[(-N[(x * eps), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-229}:\\
\;\;\;\;\frac{1 + e^{-x \cdot \varepsilon}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \left(\varepsilon + -1\right)} + e^{-x}}{2}\\
\end{array}
\end{array}
if x < -1.00000000000000007e-229Initial program 66.0%
Simplified59.2%
Taylor expanded in eps around inf 98.0%
Taylor expanded in x around 0 73.7%
sub-neg73.7%
metadata-eval73.7%
distribute-rgt-in73.7%
neg-mul-173.7%
add-sqr-sqrt73.7%
sqrt-unprod73.3%
sqr-neg73.3%
sqrt-unprod0.0%
add-sqr-sqrt73.7%
+-commutative73.7%
*-commutative73.7%
add-sqr-sqrt0.0%
sqrt-unprod70.8%
sqr-neg70.8%
sqrt-unprod72.7%
add-sqr-sqrt72.7%
cancel-sign-sub-inv72.7%
*-commutative72.7%
sub-neg72.7%
*-commutative72.7%
Applied egg-rr72.7%
sub-neg72.7%
Simplified72.7%
Taylor expanded in eps around inf 72.8%
associate-*r*72.8%
neg-mul-172.8%
*-commutative72.8%
Simplified72.8%
if -1.00000000000000007e-229 < x Initial program 67.7%
Simplified62.8%
Taylor expanded in eps around inf 99.1%
Taylor expanded in eps around 0 84.2%
rec-exp84.2%
Simplified84.2%
Final simplification79.7%
(FPCore (x eps)
:precision binary64
(if (<= x -6e-248)
(/ (+ 1.0 (exp (- (* x eps)))) 2.0)
(if (<= x 9.2e+85)
(/ (+ 1.0 (exp (* x eps))) 2.0)
(/ (* x (/ 2.0 (exp x))) 2.0))))
double code(double x, double eps) {
double tmp;
if (x <= -6e-248) {
tmp = (1.0 + exp(-(x * eps))) / 2.0;
} else if (x <= 9.2e+85) {
tmp = (1.0 + exp((x * eps))) / 2.0;
} else {
tmp = (x * (2.0 / exp(x))) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-6d-248)) then
tmp = (1.0d0 + exp(-(x * eps))) / 2.0d0
else if (x <= 9.2d+85) then
tmp = (1.0d0 + exp((x * eps))) / 2.0d0
else
tmp = (x * (2.0d0 / exp(x))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -6e-248) {
tmp = (1.0 + Math.exp(-(x * eps))) / 2.0;
} else if (x <= 9.2e+85) {
tmp = (1.0 + Math.exp((x * eps))) / 2.0;
} else {
tmp = (x * (2.0 / Math.exp(x))) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -6e-248: tmp = (1.0 + math.exp(-(x * eps))) / 2.0 elif x <= 9.2e+85: tmp = (1.0 + math.exp((x * eps))) / 2.0 else: tmp = (x * (2.0 / math.exp(x))) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -6e-248) tmp = Float64(Float64(1.0 + exp(Float64(-Float64(x * eps)))) / 2.0); elseif (x <= 9.2e+85) tmp = Float64(Float64(1.0 + exp(Float64(x * eps))) / 2.0); else tmp = Float64(Float64(x * Float64(2.0 / exp(x))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -6e-248) tmp = (1.0 + exp(-(x * eps))) / 2.0; elseif (x <= 9.2e+85) tmp = (1.0 + exp((x * eps))) / 2.0; else tmp = (x * (2.0 / exp(x))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -6e-248], N[(N[(1.0 + N[Exp[(-N[(x * eps), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 9.2e+85], N[(N[(1.0 + N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(x * N[(2.0 / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6 \cdot 10^{-248}:\\
\;\;\;\;\frac{1 + e^{-x \cdot \varepsilon}}{2}\\
\mathbf{elif}\;x \leq 9.2 \cdot 10^{+85}:\\
\;\;\;\;\frac{1 + e^{x \cdot \varepsilon}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \frac{2}{e^{x}}}{2}\\
\end{array}
\end{array}
if x < -6.00000000000000027e-248Initial program 66.0%
Simplified59.2%
Taylor expanded in eps around inf 98.0%
Taylor expanded in x around 0 73.7%
sub-neg73.7%
metadata-eval73.7%
distribute-rgt-in73.7%
neg-mul-173.7%
add-sqr-sqrt73.7%
sqrt-unprod73.3%
sqr-neg73.3%
sqrt-unprod0.0%
add-sqr-sqrt73.7%
+-commutative73.7%
*-commutative73.7%
add-sqr-sqrt0.0%
sqrt-unprod70.8%
sqr-neg70.8%
sqrt-unprod72.7%
add-sqr-sqrt72.7%
cancel-sign-sub-inv72.7%
*-commutative72.7%
sub-neg72.7%
*-commutative72.7%
Applied egg-rr72.7%
sub-neg72.7%
Simplified72.7%
Taylor expanded in eps around inf 72.8%
associate-*r*72.8%
neg-mul-172.8%
*-commutative72.8%
Simplified72.8%
if -6.00000000000000027e-248 < x < 9.1999999999999996e85Initial program 57.6%
Simplified51.2%
Taylor expanded in eps around inf 98.8%
Taylor expanded in x around 0 80.2%
Taylor expanded in eps around inf 80.4%
*-commutative80.4%
Simplified80.4%
if 9.1999999999999996e85 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 70.7%
Simplified70.7%
Taylor expanded in eps around 0 70.7%
Taylor expanded in x around inf 70.7%
neg-mul-170.7%
*-commutative70.7%
neg-mul-170.7%
rec-exp70.7%
associate-*r*70.7%
*-commutative70.7%
associate-*r/70.7%
metadata-eval70.7%
Simplified70.7%
Final simplification76.0%
(FPCore (x eps)
:precision binary64
(if (<= x 8e-243)
(/ (+ 1.0 (exp (- x))) 2.0)
(if (<= x 7e+85)
(/ (+ 1.0 (exp (* x eps))) 2.0)
(/ (* x (/ 2.0 (exp x))) 2.0))))
double code(double x, double eps) {
double tmp;
if (x <= 8e-243) {
tmp = (1.0 + exp(-x)) / 2.0;
} else if (x <= 7e+85) {
tmp = (1.0 + exp((x * eps))) / 2.0;
} else {
tmp = (x * (2.0 / exp(x))) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 8d-243) then
tmp = (1.0d0 + exp(-x)) / 2.0d0
else if (x <= 7d+85) then
tmp = (1.0d0 + exp((x * eps))) / 2.0d0
else
tmp = (x * (2.0d0 / exp(x))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 8e-243) {
tmp = (1.0 + Math.exp(-x)) / 2.0;
} else if (x <= 7e+85) {
tmp = (1.0 + Math.exp((x * eps))) / 2.0;
} else {
tmp = (x * (2.0 / Math.exp(x))) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 8e-243: tmp = (1.0 + math.exp(-x)) / 2.0 elif x <= 7e+85: tmp = (1.0 + math.exp((x * eps))) / 2.0 else: tmp = (x * (2.0 / math.exp(x))) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 8e-243) tmp = Float64(Float64(1.0 + exp(Float64(-x))) / 2.0); elseif (x <= 7e+85) tmp = Float64(Float64(1.0 + exp(Float64(x * eps))) / 2.0); else tmp = Float64(Float64(x * Float64(2.0 / exp(x))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 8e-243) tmp = (1.0 + exp(-x)) / 2.0; elseif (x <= 7e+85) tmp = (1.0 + exp((x * eps))) / 2.0; else tmp = (x * (2.0 / exp(x))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 8e-243], N[(N[(1.0 + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 7e+85], N[(N[(1.0 + N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(x * N[(2.0 / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8 \cdot 10^{-243}:\\
\;\;\;\;\frac{1 + e^{-x}}{2}\\
\mathbf{elif}\;x \leq 7 \cdot 10^{+85}:\\
\;\;\;\;\frac{1 + e^{x \cdot \varepsilon}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \frac{2}{e^{x}}}{2}\\
\end{array}
\end{array}
if x < 7.99999999999999996e-243Initial program 61.9%
Simplified56.7%
Taylor expanded in eps around inf 98.5%
Taylor expanded in x around 0 80.4%
Taylor expanded in eps around 0 87.8%
neg-mul-187.8%
Simplified87.8%
if 7.99999999999999996e-243 < x < 7.0000000000000001e85Initial program 60.8%
Simplified51.9%
Taylor expanded in eps around inf 98.3%
Taylor expanded in x around 0 72.2%
Taylor expanded in eps around inf 72.5%
*-commutative72.5%
Simplified72.5%
if 7.0000000000000001e85 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 70.7%
Simplified70.7%
Taylor expanded in eps around 0 70.7%
Taylor expanded in x around inf 70.7%
neg-mul-170.7%
*-commutative70.7%
neg-mul-170.7%
rec-exp70.7%
associate-*r*70.7%
*-commutative70.7%
associate-*r/70.7%
metadata-eval70.7%
Simplified70.7%
Final simplification80.3%
(FPCore (x eps) :precision binary64 (if (<= x 5e-49) (/ (+ 1.0 (exp (- x))) 2.0) (if (<= x 3e+84) (/ (+ 1.0 (exp x)) 2.0) (/ (* x (/ 2.0 (exp x))) 2.0))))
double code(double x, double eps) {
double tmp;
if (x <= 5e-49) {
tmp = (1.0 + exp(-x)) / 2.0;
} else if (x <= 3e+84) {
tmp = (1.0 + exp(x)) / 2.0;
} else {
tmp = (x * (2.0 / exp(x))) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 5d-49) then
tmp = (1.0d0 + exp(-x)) / 2.0d0
else if (x <= 3d+84) then
tmp = (1.0d0 + exp(x)) / 2.0d0
else
tmp = (x * (2.0d0 / exp(x))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 5e-49) {
tmp = (1.0 + Math.exp(-x)) / 2.0;
} else if (x <= 3e+84) {
tmp = (1.0 + Math.exp(x)) / 2.0;
} else {
tmp = (x * (2.0 / Math.exp(x))) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 5e-49: tmp = (1.0 + math.exp(-x)) / 2.0 elif x <= 3e+84: tmp = (1.0 + math.exp(x)) / 2.0 else: tmp = (x * (2.0 / math.exp(x))) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 5e-49) tmp = Float64(Float64(1.0 + exp(Float64(-x))) / 2.0); elseif (x <= 3e+84) tmp = Float64(Float64(1.0 + exp(x)) / 2.0); else tmp = Float64(Float64(x * Float64(2.0 / exp(x))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 5e-49) tmp = (1.0 + exp(-x)) / 2.0; elseif (x <= 3e+84) tmp = (1.0 + exp(x)) / 2.0; else tmp = (x * (2.0 / exp(x))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 5e-49], N[(N[(1.0 + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 3e+84], N[(N[(1.0 + N[Exp[x], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(x * N[(2.0 / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{-49}:\\
\;\;\;\;\frac{1 + e^{-x}}{2}\\
\mathbf{elif}\;x \leq 3 \cdot 10^{+84}:\\
\;\;\;\;\frac{1 + e^{x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \frac{2}{e^{x}}}{2}\\
\end{array}
\end{array}
if x < 4.9999999999999999e-49Initial program 57.9%
Simplified51.5%
Taylor expanded in eps around inf 98.9%
Taylor expanded in x around 0 81.8%
Taylor expanded in eps around 0 84.6%
neg-mul-184.6%
Simplified84.6%
if 4.9999999999999999e-49 < x < 2.99999999999999996e84Initial program 83.9%
Simplified76.1%
Taylor expanded in eps around inf 95.3%
Taylor expanded in x around 0 48.9%
sub-neg48.9%
metadata-eval48.9%
distribute-rgt-in48.9%
neg-mul-148.9%
add-sqr-sqrt0.0%
sqrt-unprod48.7%
sqr-neg48.7%
sqrt-unprod48.7%
add-sqr-sqrt48.7%
+-commutative48.7%
*-commutative48.7%
add-sqr-sqrt48.7%
sqrt-unprod48.7%
sqr-neg48.7%
sqrt-unprod0.0%
add-sqr-sqrt45.5%
cancel-sign-sub-inv45.5%
*-commutative45.5%
sub-neg45.5%
*-commutative45.5%
Applied egg-rr45.5%
sub-neg45.5%
Simplified45.5%
Taylor expanded in eps around 0 56.5%
if 2.99999999999999996e84 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 70.7%
Simplified70.7%
Taylor expanded in eps around 0 70.7%
Taylor expanded in x around inf 70.7%
neg-mul-170.7%
*-commutative70.7%
neg-mul-170.7%
rec-exp70.7%
associate-*r*70.7%
*-commutative70.7%
associate-*r/70.7%
metadata-eval70.7%
Simplified70.7%
Final simplification79.3%
(FPCore (x eps) :precision binary64 (if (<= x 5e-49) (/ (+ 1.0 (exp (- x))) 2.0) (if (<= x 1.5e+85) (/ (+ 1.0 (exp x)) 2.0) 0.0)))
double code(double x, double eps) {
double tmp;
if (x <= 5e-49) {
tmp = (1.0 + exp(-x)) / 2.0;
} else if (x <= 1.5e+85) {
tmp = (1.0 + exp(x)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 5d-49) then
tmp = (1.0d0 + exp(-x)) / 2.0d0
else if (x <= 1.5d+85) then
tmp = (1.0d0 + exp(x)) / 2.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 5e-49) {
tmp = (1.0 + Math.exp(-x)) / 2.0;
} else if (x <= 1.5e+85) {
tmp = (1.0 + Math.exp(x)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 5e-49: tmp = (1.0 + math.exp(-x)) / 2.0 elif x <= 1.5e+85: tmp = (1.0 + math.exp(x)) / 2.0 else: tmp = 0.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 5e-49) tmp = Float64(Float64(1.0 + exp(Float64(-x))) / 2.0); elseif (x <= 1.5e+85) tmp = Float64(Float64(1.0 + exp(x)) / 2.0); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 5e-49) tmp = (1.0 + exp(-x)) / 2.0; elseif (x <= 1.5e+85) tmp = (1.0 + exp(x)) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 5e-49], N[(N[(1.0 + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.5e+85], N[(N[(1.0 + N[Exp[x], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{-49}:\\
\;\;\;\;\frac{1 + e^{-x}}{2}\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{+85}:\\
\;\;\;\;\frac{1 + e^{x}}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 4.9999999999999999e-49Initial program 57.9%
Simplified51.5%
Taylor expanded in eps around inf 98.9%
Taylor expanded in x around 0 81.8%
Taylor expanded in eps around 0 84.6%
neg-mul-184.6%
Simplified84.6%
if 4.9999999999999999e-49 < x < 1.5e85Initial program 83.9%
Simplified76.1%
Taylor expanded in eps around inf 95.3%
Taylor expanded in x around 0 48.9%
sub-neg48.9%
metadata-eval48.9%
distribute-rgt-in48.9%
neg-mul-148.9%
add-sqr-sqrt0.0%
sqrt-unprod48.7%
sqr-neg48.7%
sqrt-unprod48.7%
add-sqr-sqrt48.7%
+-commutative48.7%
*-commutative48.7%
add-sqr-sqrt48.7%
sqrt-unprod48.7%
sqr-neg48.7%
sqrt-unprod0.0%
add-sqr-sqrt45.5%
cancel-sign-sub-inv45.5%
*-commutative45.5%
sub-neg45.5%
*-commutative45.5%
Applied egg-rr45.5%
sub-neg45.5%
Simplified45.5%
Taylor expanded in eps around 0 56.5%
if 1.5e85 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 70.7%
mul-1-neg70.7%
mul-1-neg70.7%
rec-exp70.7%
sub-neg70.7%
div-sub70.7%
mul-1-neg70.7%
rec-exp70.7%
+-inverses70.7%
Simplified70.7%
Final simplification79.3%
(FPCore (x eps) :precision binary64 (if (<= x -3.4e-237) (/ (- 2.0 (* x (+ eps 2.0))) 2.0) (if (<= x 5e+84) (/ (+ 1.0 (exp x)) 2.0) 0.0)))
double code(double x, double eps) {
double tmp;
if (x <= -3.4e-237) {
tmp = (2.0 - (x * (eps + 2.0))) / 2.0;
} else if (x <= 5e+84) {
tmp = (1.0 + exp(x)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-3.4d-237)) then
tmp = (2.0d0 - (x * (eps + 2.0d0))) / 2.0d0
else if (x <= 5d+84) then
tmp = (1.0d0 + exp(x)) / 2.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -3.4e-237) {
tmp = (2.0 - (x * (eps + 2.0))) / 2.0;
} else if (x <= 5e+84) {
tmp = (1.0 + Math.exp(x)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -3.4e-237: tmp = (2.0 - (x * (eps + 2.0))) / 2.0 elif x <= 5e+84: tmp = (1.0 + math.exp(x)) / 2.0 else: tmp = 0.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -3.4e-237) tmp = Float64(Float64(2.0 - Float64(x * Float64(eps + 2.0))) / 2.0); elseif (x <= 5e+84) tmp = Float64(Float64(1.0 + exp(x)) / 2.0); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -3.4e-237) tmp = (2.0 - (x * (eps + 2.0))) / 2.0; elseif (x <= 5e+84) tmp = (1.0 + exp(x)) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -3.4e-237], N[(N[(2.0 - N[(x * N[(eps + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 5e+84], N[(N[(1.0 + N[Exp[x], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.4 \cdot 10^{-237}:\\
\;\;\;\;\frac{2 - x \cdot \left(\varepsilon + 2\right)}{2}\\
\mathbf{elif}\;x \leq 5 \cdot 10^{+84}:\\
\;\;\;\;\frac{1 + e^{x}}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -3.4000000000000002e-237Initial program 66.0%
Simplified59.2%
Taylor expanded in eps around inf 98.0%
Taylor expanded in eps around 0 90.2%
neg-mul-183.5%
Simplified90.2%
Taylor expanded in x around 0 61.5%
mul-1-neg61.5%
unsub-neg61.5%
Simplified61.5%
if -3.4000000000000002e-237 < x < 5.0000000000000001e84Initial program 57.6%
Simplified51.2%
Taylor expanded in eps around inf 98.8%
Taylor expanded in x around 0 80.2%
sub-neg80.2%
metadata-eval80.2%
distribute-rgt-in80.2%
neg-mul-180.2%
add-sqr-sqrt20.2%
sqrt-unprod80.2%
sqr-neg80.2%
sqrt-unprod60.0%
add-sqr-sqrt80.2%
+-commutative80.2%
*-commutative80.2%
add-sqr-sqrt60.0%
sqrt-unprod79.7%
sqr-neg79.7%
sqrt-unprod20.2%
add-sqr-sqrt81.8%
cancel-sign-sub-inv81.8%
*-commutative81.8%
sub-neg81.8%
*-commutative81.8%
Applied egg-rr81.8%
sub-neg81.8%
Simplified81.8%
Taylor expanded in eps around 0 78.5%
if 5.0000000000000001e84 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 70.7%
mul-1-neg70.7%
mul-1-neg70.7%
rec-exp70.7%
sub-neg70.7%
div-sub70.7%
mul-1-neg70.7%
rec-exp70.7%
+-inverses70.7%
Simplified70.7%
Final simplification70.7%
(FPCore (x eps) :precision binary64 (if (<= x 1.0) (/ (- 2.0 (* x (+ eps 2.0))) 2.0) 0.0))
double code(double x, double eps) {
double tmp;
if (x <= 1.0) {
tmp = (2.0 - (x * (eps + 2.0))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 1.0d0) then
tmp = (2.0d0 - (x * (eps + 2.0d0))) / 2.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 1.0) {
tmp = (2.0 - (x * (eps + 2.0))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 1.0: tmp = (2.0 - (x * (eps + 2.0))) / 2.0 else: tmp = 0.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 1.0) tmp = Float64(Float64(2.0 - Float64(x * Float64(eps + 2.0))) / 2.0); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 1.0) tmp = (2.0 - (x * (eps + 2.0))) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 1.0], N[(N[(2.0 - N[(x * N[(eps + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\frac{2 - x \cdot \left(\varepsilon + 2\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1Initial program 58.2%
Simplified51.1%
Taylor expanded in eps around inf 98.3%
Taylor expanded in eps around 0 89.7%
neg-mul-181.5%
Simplified89.7%
Taylor expanded in x around 0 70.2%
mul-1-neg70.2%
unsub-neg70.2%
Simplified70.2%
if 1 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 58.1%
mul-1-neg58.1%
mul-1-neg58.1%
rec-exp58.1%
sub-neg58.1%
div-sub58.1%
mul-1-neg58.1%
rec-exp58.1%
+-inverses58.1%
Simplified58.1%
Final simplification67.6%
(FPCore (x eps) :precision binary64 (if (<= x -2.8e-15) (/ (- (* x eps)) 2.0) (if (<= x 105000000.0) 1.0 0.0)))
double code(double x, double eps) {
double tmp;
if (x <= -2.8e-15) {
tmp = -(x * eps) / 2.0;
} else if (x <= 105000000.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-2.8d-15)) then
tmp = -(x * eps) / 2.0d0
else if (x <= 105000000.0d0) then
tmp = 1.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -2.8e-15) {
tmp = -(x * eps) / 2.0;
} else if (x <= 105000000.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -2.8e-15: tmp = -(x * eps) / 2.0 elif x <= 105000000.0: tmp = 1.0 else: tmp = 0.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -2.8e-15) tmp = Float64(Float64(-Float64(x * eps)) / 2.0); elseif (x <= 105000000.0) tmp = 1.0; else tmp = 0.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -2.8e-15) tmp = -(x * eps) / 2.0; elseif (x <= 105000000.0) tmp = 1.0; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -2.8e-15], N[((-N[(x * eps), $MachinePrecision]) / 2.0), $MachinePrecision], If[LessEqual[x, 105000000.0], 1.0, 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.8 \cdot 10^{-15}:\\
\;\;\;\;\frac{-x \cdot \varepsilon}{2}\\
\mathbf{elif}\;x \leq 105000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -2.80000000000000014e-15Initial program 95.1%
Simplified95.1%
Taylor expanded in eps around inf 95.1%
Taylor expanded in x around 0 59.3%
associate-*r*59.3%
neg-mul-159.3%
Simplified59.3%
Taylor expanded in eps around inf 35.1%
mul-1-neg35.1%
distribute-lft-neg-out35.1%
*-commutative35.1%
Simplified35.1%
if -2.80000000000000014e-15 < x < 1.05e8Initial program 49.8%
Simplified49.8%
Taylor expanded in x around 0 78.6%
if 1.05e8 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 61.4%
mul-1-neg61.4%
mul-1-neg61.4%
rec-exp61.4%
sub-neg61.4%
div-sub61.4%
mul-1-neg61.4%
rec-exp61.4%
+-inverses61.4%
Simplified61.4%
Final simplification68.2%
(FPCore (x eps) :precision binary64 (if (<= x 105000000.0) 1.0 0.0))
double code(double x, double eps) {
double tmp;
if (x <= 105000000.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 105000000.0d0) then
tmp = 1.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 105000000.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 105000000.0: tmp = 1.0 else: tmp = 0.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 105000000.0) tmp = 1.0; else tmp = 0.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 105000000.0) tmp = 1.0; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 105000000.0], 1.0, 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 105000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1.05e8Initial program 58.8%
Simplified58.8%
Taylor expanded in x around 0 63.5%
if 1.05e8 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 61.4%
mul-1-neg61.4%
mul-1-neg61.4%
rec-exp61.4%
sub-neg61.4%
div-sub61.4%
mul-1-neg61.4%
rec-exp61.4%
+-inverses61.4%
Simplified61.4%
Final simplification63.1%
(FPCore (x eps) :precision binary64 0.0)
double code(double x, double eps) {
return 0.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 0.0d0
end function
public static double code(double x, double eps) {
return 0.0;
}
def code(x, eps): return 0.0
function code(x, eps) return 0.0 end
function tmp = code(x, eps) tmp = 0.0; end
code[x_, eps_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 67.0%
Simplified52.2%
Taylor expanded in eps around 0 14.0%
mul-1-neg14.0%
mul-1-neg14.0%
rec-exp14.0%
sub-neg14.0%
div-sub14.0%
mul-1-neg14.0%
rec-exp14.0%
+-inverses14.3%
Simplified14.3%
Final simplification14.3%
herbie shell --seed 2024100
(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))