
(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 8 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
(let* ((t_0
(+
(* (+ 1.0 (/ 1.0 eps)) (exp (* x (+ eps -1.0))))
(* (exp (* x (- -1.0 eps))) (+ 1.0 (/ -1.0 eps))))))
(if (<= t_0 0.0)
(/ (+ (/ (+ 1.0 x) (exp x)) (* (+ 1.0 x) (exp (- x)))) 2.0)
(/ t_0 2.0))))
double code(double x, double eps) {
double t_0 = ((1.0 + (1.0 / eps)) * exp((x * (eps + -1.0)))) + (exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)));
double tmp;
if (t_0 <= 0.0) {
tmp = (((1.0 + x) / exp(x)) + ((1.0 + x) * exp(-x))) / 2.0;
} else {
tmp = t_0 / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = ((1.0d0 + (1.0d0 / eps)) * exp((x * (eps + (-1.0d0))))) + (exp((x * ((-1.0d0) - eps))) * (1.0d0 + ((-1.0d0) / eps)))
if (t_0 <= 0.0d0) then
tmp = (((1.0d0 + x) / exp(x)) + ((1.0d0 + x) * exp(-x))) / 2.0d0
else
tmp = t_0 / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = ((1.0 + (1.0 / eps)) * Math.exp((x * (eps + -1.0)))) + (Math.exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)));
double tmp;
if (t_0 <= 0.0) {
tmp = (((1.0 + x) / Math.exp(x)) + ((1.0 + x) * Math.exp(-x))) / 2.0;
} else {
tmp = t_0 / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = ((1.0 + (1.0 / eps)) * math.exp((x * (eps + -1.0)))) + (math.exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps))) tmp = 0 if t_0 <= 0.0: tmp = (((1.0 + x) / math.exp(x)) + ((1.0 + x) * math.exp(-x))) / 2.0 else: tmp = t_0 / 2.0 return tmp
function code(x, eps) t_0 = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(x * Float64(eps + -1.0)))) + Float64(exp(Float64(x * Float64(-1.0 - eps))) * Float64(1.0 + Float64(-1.0 / eps)))) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(Float64(Float64(Float64(1.0 + x) / exp(x)) + Float64(Float64(1.0 + x) * exp(Float64(-x)))) / 2.0); else tmp = Float64(t_0 / 2.0); end return tmp end
function tmp_2 = code(x, eps) t_0 = ((1.0 + (1.0 / eps)) * exp((x * (eps + -1.0)))) + (exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps))); tmp = 0.0; if (t_0 <= 0.0) tmp = (((1.0 + x) / exp(x)) + ((1.0 + x) * exp(-x))) / 2.0; else tmp = t_0 / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(N[(N[(1.0 + x), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 + x), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(t$95$0 / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 + \frac{1}{\varepsilon}\right) \cdot e^{x \cdot \left(\varepsilon + -1\right)} + e^{x \cdot \left(-1 - \varepsilon\right)} \cdot \left(1 + \frac{-1}{\varepsilon}\right)\\
\mathbf{if}\;t_0 \leq 0:\\
\;\;\;\;\frac{\frac{1 + x}{e^{x}} + \left(1 + x\right) \cdot e^{-x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{2}\\
\end{array}
\end{array}
if (-.f64 (*.f64 (+.f64 1 (/.f64 1 eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 1 eps) x)))) (*.f64 (-.f64 (/.f64 1 eps) 1) (exp.f64 (neg.f64 (*.f64 (+.f64 1 eps) x))))) < 0.0Initial program 37.8%
div-sub37.8%
+-rgt-identity37.8%
div-sub37.8%
Simplified37.8%
Taylor expanded in eps around 0 100.0%
*-commutative100.0%
distribute-lft1-in100.0%
mul-1-neg100.0%
distribute-lft-out100.0%
mul-1-neg100.0%
*-commutative100.0%
distribute-lft1-in100.0%
mul-1-neg100.0%
Simplified100.0%
exp-neg100.0%
un-div-inv100.0%
Applied egg-rr100.0%
if 0.0 < (-.f64 (*.f64 (+.f64 1 (/.f64 1 eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 1 eps) x)))) (*.f64 (-.f64 (/.f64 1 eps) 1) (exp.f64 (neg.f64 (*.f64 (+.f64 1 eps) x))))) Initial program 100.0%
Final simplification100.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (/ (+ 1.0 (exp (* x (- eps)))) 2.0)))
(if (<= eps -31500.0)
t_0
(if (<= eps 1.0)
(/ (+ (/ (+ 1.0 x) (exp x)) (* (+ 1.0 x) (exp (- x)))) 2.0)
(if (<= eps 5e+46) t_0 (/ (+ 1.0 (exp (- (* eps x) x))) 2.0))))))
double code(double x, double eps) {
double t_0 = (1.0 + exp((x * -eps))) / 2.0;
double tmp;
if (eps <= -31500.0) {
tmp = t_0;
} else if (eps <= 1.0) {
tmp = (((1.0 + x) / exp(x)) + ((1.0 + x) * exp(-x))) / 2.0;
} else if (eps <= 5e+46) {
tmp = t_0;
} else {
tmp = (1.0 + exp(((eps * x) - x))) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = (1.0d0 + exp((x * -eps))) / 2.0d0
if (eps <= (-31500.0d0)) then
tmp = t_0
else if (eps <= 1.0d0) then
tmp = (((1.0d0 + x) / exp(x)) + ((1.0d0 + x) * exp(-x))) / 2.0d0
else if (eps <= 5d+46) then
tmp = t_0
else
tmp = (1.0d0 + exp(((eps * x) - x))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = (1.0 + Math.exp((x * -eps))) / 2.0;
double tmp;
if (eps <= -31500.0) {
tmp = t_0;
} else if (eps <= 1.0) {
tmp = (((1.0 + x) / Math.exp(x)) + ((1.0 + x) * Math.exp(-x))) / 2.0;
} else if (eps <= 5e+46) {
tmp = t_0;
} else {
tmp = (1.0 + Math.exp(((eps * x) - x))) / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = (1.0 + math.exp((x * -eps))) / 2.0 tmp = 0 if eps <= -31500.0: tmp = t_0 elif eps <= 1.0: tmp = (((1.0 + x) / math.exp(x)) + ((1.0 + x) * math.exp(-x))) / 2.0 elif eps <= 5e+46: tmp = t_0 else: tmp = (1.0 + math.exp(((eps * x) - x))) / 2.0 return tmp
function code(x, eps) t_0 = Float64(Float64(1.0 + exp(Float64(x * Float64(-eps)))) / 2.0) tmp = 0.0 if (eps <= -31500.0) tmp = t_0; elseif (eps <= 1.0) tmp = Float64(Float64(Float64(Float64(1.0 + x) / exp(x)) + Float64(Float64(1.0 + x) * exp(Float64(-x)))) / 2.0); elseif (eps <= 5e+46) tmp = t_0; else tmp = Float64(Float64(1.0 + exp(Float64(Float64(eps * x) - x))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) t_0 = (1.0 + exp((x * -eps))) / 2.0; tmp = 0.0; if (eps <= -31500.0) tmp = t_0; elseif (eps <= 1.0) tmp = (((1.0 + x) / exp(x)) + ((1.0 + x) * exp(-x))) / 2.0; elseif (eps <= 5e+46) tmp = t_0; else tmp = (1.0 + exp(((eps * x) - x))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 + N[Exp[N[(x * (-eps)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[eps, -31500.0], t$95$0, If[LessEqual[eps, 1.0], N[(N[(N[(N[(1.0 + x), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 + x), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[eps, 5e+46], t$95$0, N[(N[(1.0 + N[Exp[N[(N[(eps * x), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1 + e^{x \cdot \left(-\varepsilon\right)}}{2}\\
\mathbf{if}\;\varepsilon \leq -31500:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq 1:\\
\;\;\;\;\frac{\frac{1 + x}{e^{x}} + \left(1 + x\right) \cdot e^{-x}}{2}\\
\mathbf{elif}\;\varepsilon \leq 5 \cdot 10^{+46}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + e^{\varepsilon \cdot x - x}}{2}\\
\end{array}
\end{array}
if eps < -31500 or 1 < eps < 5.0000000000000002e46Initial program 100.0%
div-sub100.0%
+-rgt-identity100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around 0 47.8%
Taylor expanded in eps around inf 47.8%
*-commutative47.8%
sub-neg47.8%
mul-1-neg47.8%
*-commutative47.8%
+-commutative47.8%
mul-1-neg47.8%
*-commutative47.8%
mul-1-neg47.8%
sub-neg47.8%
Simplified47.8%
add-sqr-sqrt10.8%
sqrt-unprod19.1%
sqr-neg19.1%
sqrt-unprod8.4%
add-sqr-sqrt70.9%
neg-sub070.9%
Applied egg-rr70.9%
neg-sub070.9%
distribute-rgt-neg-in70.9%
sub-neg70.9%
mul-1-neg70.9%
+-commutative70.9%
distribute-neg-in70.9%
mul-1-neg70.9%
remove-double-neg70.9%
metadata-eval70.9%
distribute-rgt-in70.9%
neg-mul-170.9%
sub-neg70.9%
*-commutative70.9%
Simplified70.9%
Taylor expanded in eps around inf 70.9%
if -31500 < eps < 1Initial program 39.5%
div-sub39.5%
+-rgt-identity39.5%
div-sub39.5%
Simplified39.5%
Taylor expanded in eps around 0 100.0%
*-commutative100.0%
distribute-lft1-in100.0%
mul-1-neg100.0%
distribute-lft-out100.0%
mul-1-neg100.0%
*-commutative100.0%
distribute-lft1-in100.0%
mul-1-neg100.0%
Simplified100.0%
exp-neg100.0%
un-div-inv100.0%
Applied egg-rr100.0%
if 5.0000000000000002e46 < eps Initial program 100.0%
div-sub100.0%
+-rgt-identity100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around 0 69.2%
Taylor expanded in eps around inf 69.2%
*-commutative69.2%
sub-neg69.2%
mul-1-neg69.2%
*-commutative69.2%
+-commutative69.2%
mul-1-neg69.2%
*-commutative69.2%
mul-1-neg69.2%
sub-neg69.2%
Simplified69.2%
Taylor expanded in x around inf 69.2%
*-commutative69.2%
Simplified69.2%
Final simplification83.2%
(FPCore (x eps)
:precision binary64
(if (<= x -0.00041)
(/ (+ 1.0 (exp (- x))) 2.0)
(if (<= x 700.0)
(/ (+ 1.0 (exp (* x (- eps)))) 2.0)
(if (<= x 2e+176) (/ (+ 1.0 (exp x)) 2.0) 0.0))))
double code(double x, double eps) {
double tmp;
if (x <= -0.00041) {
tmp = (1.0 + exp(-x)) / 2.0;
} else if (x <= 700.0) {
tmp = (1.0 + exp((x * -eps))) / 2.0;
} else if (x <= 2e+176) {
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 <= (-0.00041d0)) then
tmp = (1.0d0 + exp(-x)) / 2.0d0
else if (x <= 700.0d0) then
tmp = (1.0d0 + exp((x * -eps))) / 2.0d0
else if (x <= 2d+176) 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 <= -0.00041) {
tmp = (1.0 + Math.exp(-x)) / 2.0;
} else if (x <= 700.0) {
tmp = (1.0 + Math.exp((x * -eps))) / 2.0;
} else if (x <= 2e+176) {
tmp = (1.0 + Math.exp(x)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -0.00041: tmp = (1.0 + math.exp(-x)) / 2.0 elif x <= 700.0: tmp = (1.0 + math.exp((x * -eps))) / 2.0 elif x <= 2e+176: tmp = (1.0 + math.exp(x)) / 2.0 else: tmp = 0.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -0.00041) tmp = Float64(Float64(1.0 + exp(Float64(-x))) / 2.0); elseif (x <= 700.0) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-eps)))) / 2.0); elseif (x <= 2e+176) 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 <= -0.00041) tmp = (1.0 + exp(-x)) / 2.0; elseif (x <= 700.0) tmp = (1.0 + exp((x * -eps))) / 2.0; elseif (x <= 2e+176) tmp = (1.0 + exp(x)) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -0.00041], N[(N[(1.0 + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 700.0], N[(N[(1.0 + N[Exp[N[(x * (-eps)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 2e+176], N[(N[(1.0 + N[Exp[x], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.00041:\\
\;\;\;\;\frac{1 + e^{-x}}{2}\\
\mathbf{elif}\;x \leq 700:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-\varepsilon\right)}}{2}\\
\mathbf{elif}\;x \leq 2 \cdot 10^{+176}:\\
\;\;\;\;\frac{1 + e^{x}}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -4.0999999999999999e-4Initial program 100.0%
div-sub100.0%
+-rgt-identity100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around 0 49.9%
Taylor expanded in eps around inf 49.9%
Taylor expanded in eps around 0 93.3%
sub-neg93.3%
mul-1-neg93.3%
neg-mul-193.3%
remove-double-neg93.3%
Simplified93.3%
if -4.0999999999999999e-4 < x < 700Initial program 53.9%
div-sub53.9%
+-rgt-identity53.9%
div-sub53.9%
Simplified53.9%
Taylor expanded in x around 0 37.9%
Taylor expanded in eps around inf 83.2%
*-commutative83.2%
sub-neg83.2%
mul-1-neg83.2%
*-commutative83.2%
+-commutative83.2%
mul-1-neg83.2%
*-commutative83.2%
mul-1-neg83.2%
sub-neg83.2%
Simplified83.2%
add-sqr-sqrt34.5%
sqrt-unprod70.6%
sqr-neg70.6%
sqrt-unprod36.1%
add-sqr-sqrt85.8%
neg-sub085.8%
Applied egg-rr85.8%
neg-sub085.8%
distribute-rgt-neg-in85.8%
sub-neg85.8%
mul-1-neg85.8%
+-commutative85.8%
distribute-neg-in85.8%
mul-1-neg85.8%
remove-double-neg85.8%
metadata-eval85.8%
distribute-rgt-in85.8%
neg-mul-185.8%
sub-neg85.8%
*-commutative85.8%
Simplified85.8%
Taylor expanded in eps around inf 86.3%
if 700 < x < 2e176Initial program 100.0%
div-sub100.0%
+-rgt-identity100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around 0 28.0%
Taylor expanded in eps around inf 28.3%
*-commutative28.3%
sub-neg28.3%
mul-1-neg28.3%
*-commutative28.3%
+-commutative28.3%
mul-1-neg28.3%
*-commutative28.3%
mul-1-neg28.3%
sub-neg28.3%
Simplified28.3%
add-sqr-sqrt2.3%
sqrt-unprod3.1%
sqr-neg3.1%
sqrt-unprod0.8%
add-sqr-sqrt37.4%
neg-sub037.4%
Applied egg-rr37.4%
neg-sub037.4%
distribute-rgt-neg-in37.4%
sub-neg37.4%
mul-1-neg37.4%
+-commutative37.4%
distribute-neg-in37.4%
mul-1-neg37.4%
remove-double-neg37.4%
metadata-eval37.4%
distribute-rgt-in37.4%
neg-mul-137.4%
sub-neg37.4%
*-commutative37.4%
Simplified37.4%
Taylor expanded in eps around 0 62.6%
if 2e176 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 67.2%
div-sub67.2%
rec-exp67.2%
mul-1-neg67.2%
+-inverses67.2%
Simplified67.2%
Final simplification80.3%
(FPCore (x eps) :precision binary64 (if (<= x 0.008) (/ (+ 2.0 (* x x)) 2.0) (if (<= x 6e+179) (/ (+ 1.0 (exp x)) 2.0) 0.0)))
double code(double x, double eps) {
double tmp;
if (x <= 0.008) {
tmp = (2.0 + (x * x)) / 2.0;
} else if (x <= 6e+179) {
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 <= 0.008d0) then
tmp = (2.0d0 + (x * x)) / 2.0d0
else if (x <= 6d+179) 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 <= 0.008) {
tmp = (2.0 + (x * x)) / 2.0;
} else if (x <= 6e+179) {
tmp = (1.0 + Math.exp(x)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 0.008: tmp = (2.0 + (x * x)) / 2.0 elif x <= 6e+179: tmp = (1.0 + math.exp(x)) / 2.0 else: tmp = 0.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 0.008) tmp = Float64(Float64(2.0 + Float64(x * x)) / 2.0); elseif (x <= 6e+179) 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 <= 0.008) tmp = (2.0 + (x * x)) / 2.0; elseif (x <= 6e+179) tmp = (1.0 + exp(x)) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 0.008], N[(N[(2.0 + N[(x * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 6e+179], N[(N[(1.0 + N[Exp[x], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.008:\\
\;\;\;\;\frac{2 + x \cdot x}{2}\\
\mathbf{elif}\;x \leq 6 \cdot 10^{+179}:\\
\;\;\;\;\frac{1 + e^{x}}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 0.0080000000000000002Initial program 61.0%
div-sub61.0%
+-rgt-identity61.0%
div-sub61.0%
Simplified61.0%
Taylor expanded in eps around 0 61.1%
*-commutative61.1%
distribute-lft1-in61.1%
mul-1-neg61.1%
distribute-lft-out61.1%
mul-1-neg61.1%
*-commutative61.1%
distribute-lft1-in61.1%
mul-1-neg61.1%
Simplified61.1%
Taylor expanded in x around 0 61.0%
unpow261.0%
Simplified61.0%
Taylor expanded in x around 0 61.0%
mul-1-neg61.0%
unsub-neg61.0%
unpow261.0%
Simplified61.0%
cancel-sign-sub-inv61.0%
add-sqr-sqrt29.2%
sqrt-unprod60.9%
sqr-neg60.9%
sqrt-prod31.7%
add-sqr-sqrt68.7%
+-commutative68.7%
Applied egg-rr68.7%
if 0.0080000000000000002 < x < 5.9999999999999996e179Initial program 100.0%
div-sub100.0%
+-rgt-identity100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around 0 28.9%
Taylor expanded in eps around inf 29.2%
*-commutative29.2%
sub-neg29.2%
mul-1-neg29.2%
*-commutative29.2%
+-commutative29.2%
mul-1-neg29.2%
*-commutative29.2%
mul-1-neg29.2%
sub-neg29.2%
Simplified29.2%
add-sqr-sqrt2.3%
sqrt-unprod3.1%
sqr-neg3.1%
sqrt-unprod0.8%
add-sqr-sqrt38.0%
neg-sub038.0%
Applied egg-rr38.0%
neg-sub038.0%
distribute-rgt-neg-in38.0%
sub-neg38.0%
mul-1-neg38.0%
+-commutative38.0%
distribute-neg-in38.0%
mul-1-neg38.0%
remove-double-neg38.0%
metadata-eval38.0%
distribute-rgt-in38.0%
neg-mul-138.0%
sub-neg38.0%
*-commutative38.0%
Simplified38.0%
Taylor expanded in eps around 0 60.3%
if 5.9999999999999996e179 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 67.2%
div-sub67.2%
rec-exp67.2%
mul-1-neg67.2%
+-inverses67.2%
Simplified67.2%
Final simplification66.8%
(FPCore (x eps) :precision binary64 (if (<= x -9e-16) (/ (+ 1.0 (exp (- x))) 2.0) (if (<= x 5e+167) (/ (+ 1.0 (exp x)) 2.0) 0.0)))
double code(double x, double eps) {
double tmp;
if (x <= -9e-16) {
tmp = (1.0 + exp(-x)) / 2.0;
} else if (x <= 5e+167) {
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 <= (-9d-16)) then
tmp = (1.0d0 + exp(-x)) / 2.0d0
else if (x <= 5d+167) 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 <= -9e-16) {
tmp = (1.0 + Math.exp(-x)) / 2.0;
} else if (x <= 5e+167) {
tmp = (1.0 + Math.exp(x)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -9e-16: tmp = (1.0 + math.exp(-x)) / 2.0 elif x <= 5e+167: tmp = (1.0 + math.exp(x)) / 2.0 else: tmp = 0.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -9e-16) tmp = Float64(Float64(1.0 + exp(Float64(-x))) / 2.0); elseif (x <= 5e+167) 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 <= -9e-16) tmp = (1.0 + exp(-x)) / 2.0; elseif (x <= 5e+167) tmp = (1.0 + exp(x)) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -9e-16], N[(N[(1.0 + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 5e+167], N[(N[(1.0 + N[Exp[x], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9 \cdot 10^{-16}:\\
\;\;\;\;\frac{1 + e^{-x}}{2}\\
\mathbf{elif}\;x \leq 5 \cdot 10^{+167}:\\
\;\;\;\;\frac{1 + e^{x}}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -9.0000000000000003e-16Initial program 90.9%
div-sub90.9%
+-rgt-identity90.9%
div-sub90.9%
Simplified90.9%
Taylor expanded in x around 0 45.8%
Taylor expanded in eps around inf 52.9%
Taylor expanded in eps around 0 92.2%
sub-neg92.2%
mul-1-neg92.2%
neg-mul-192.2%
remove-double-neg92.2%
Simplified92.2%
if -9.0000000000000003e-16 < x < 4.9999999999999997e167Initial program 66.2%
div-sub66.2%
+-rgt-identity66.2%
div-sub66.2%
Simplified66.2%
Taylor expanded in x around 0 35.7%
Taylor expanded in eps around inf 69.2%
*-commutative69.2%
sub-neg69.2%
mul-1-neg69.2%
*-commutative69.2%
+-commutative69.2%
mul-1-neg69.2%
*-commutative69.2%
mul-1-neg69.2%
sub-neg69.2%
Simplified69.2%
add-sqr-sqrt27.0%
sqrt-unprod53.6%
sqr-neg53.6%
sqrt-unprod26.6%
add-sqr-sqrt74.1%
neg-sub074.1%
Applied egg-rr74.1%
neg-sub074.1%
distribute-rgt-neg-in74.1%
sub-neg74.1%
mul-1-neg74.1%
+-commutative74.1%
distribute-neg-in74.1%
mul-1-neg74.1%
remove-double-neg74.1%
metadata-eval74.1%
distribute-rgt-in74.1%
neg-mul-174.1%
sub-neg74.1%
*-commutative74.1%
Simplified74.1%
Taylor expanded in eps around 0 69.2%
if 4.9999999999999997e167 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 66.2%
div-sub66.2%
rec-exp66.2%
mul-1-neg66.2%
+-inverses66.2%
Simplified66.2%
Final simplification71.7%
(FPCore (x eps) :precision binary64 (if (<= x 54000.0) (/ (+ 2.0 (* x x)) 2.0) 0.0))
double code(double x, double eps) {
double tmp;
if (x <= 54000.0) {
tmp = (2.0 + (x * 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 <= 54000.0d0) then
tmp = (2.0d0 + (x * 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 <= 54000.0) {
tmp = (2.0 + (x * x)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 54000.0: tmp = (2.0 + (x * x)) / 2.0 else: tmp = 0.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 54000.0) tmp = Float64(Float64(2.0 + Float64(x * x)) / 2.0); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 54000.0) tmp = (2.0 + (x * x)) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 54000.0], N[(N[(2.0 + N[(x * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 54000:\\
\;\;\;\;\frac{2 + x \cdot x}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 54000Initial program 62.1%
div-sub62.1%
+-rgt-identity62.1%
div-sub62.1%
Simplified62.1%
Taylor expanded in eps around 0 59.5%
*-commutative59.5%
distribute-lft1-in59.5%
mul-1-neg59.5%
distribute-lft-out59.5%
mul-1-neg59.5%
*-commutative59.5%
distribute-lft1-in59.5%
mul-1-neg59.5%
Simplified59.5%
Taylor expanded in x around 0 59.3%
unpow259.3%
Simplified59.3%
Taylor expanded in x around 0 59.4%
mul-1-neg59.4%
unsub-neg59.4%
unpow259.4%
Simplified59.4%
cancel-sign-sub-inv59.4%
add-sqr-sqrt28.3%
sqrt-unprod59.3%
sqr-neg59.3%
sqrt-prod30.9%
add-sqr-sqrt66.9%
+-commutative66.9%
Applied egg-rr66.9%
if 54000 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 51.4%
div-sub51.4%
rec-exp51.4%
mul-1-neg51.4%
+-inverses51.4%
Simplified51.4%
Final simplification62.2%
(FPCore (x eps) :precision binary64 (if (<= x 54000.0) 1.0 0.0))
double code(double x, double eps) {
double tmp;
if (x <= 54000.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 <= 54000.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 <= 54000.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 54000.0: tmp = 1.0 else: tmp = 0.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 54000.0) tmp = 1.0; else tmp = 0.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 54000.0) tmp = 1.0; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 54000.0], 1.0, 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 54000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 54000Initial program 62.1%
div-sub62.1%
+-rgt-identity62.1%
div-sub62.1%
Simplified62.1%
Taylor expanded in x around 0 59.7%
if 54000 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 51.4%
div-sub51.4%
rec-exp51.4%
mul-1-neg51.4%
+-inverses51.4%
Simplified51.4%
Final simplification57.2%
(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 73.5%
Simplified62.0%
Taylor expanded in eps around 0 17.0%
div-sub17.0%
rec-exp17.0%
mul-1-neg17.0%
+-inverses17.2%
Simplified17.2%
Final simplification17.2%
herbie shell --seed 2023187
(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))