
(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 13 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 (exp (* x (- -1.0 eps))))
(t_1 (* (+ 1.0 (/ 1.0 eps)) (exp (* x (+ eps -1.0))))))
(if (<= (+ t_1 (* t_0 (+ 1.0 (/ -1.0 eps)))) 2.0)
(/ (+ (/ (+ 1.0 x) (exp x)) (* (+ 1.0 x) (exp (- x)))) 2.0)
(/ (- t_1 (* (log1p (expm1 (+ (/ 1.0 eps) -1.0))) t_0)) 2.0))))
double code(double x, double eps) {
double t_0 = exp((x * (-1.0 - eps)));
double t_1 = (1.0 + (1.0 / eps)) * exp((x * (eps + -1.0)));
double tmp;
if ((t_1 + (t_0 * (1.0 + (-1.0 / eps)))) <= 2.0) {
tmp = (((1.0 + x) / exp(x)) + ((1.0 + x) * exp(-x))) / 2.0;
} else {
tmp = (t_1 - (log1p(expm1(((1.0 / eps) + -1.0))) * t_0)) / 2.0;
}
return tmp;
}
public static double code(double x, double eps) {
double t_0 = Math.exp((x * (-1.0 - eps)));
double t_1 = (1.0 + (1.0 / eps)) * Math.exp((x * (eps + -1.0)));
double tmp;
if ((t_1 + (t_0 * (1.0 + (-1.0 / eps)))) <= 2.0) {
tmp = (((1.0 + x) / Math.exp(x)) + ((1.0 + x) * Math.exp(-x))) / 2.0;
} else {
tmp = (t_1 - (Math.log1p(Math.expm1(((1.0 / eps) + -1.0))) * t_0)) / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = math.exp((x * (-1.0 - eps))) t_1 = (1.0 + (1.0 / eps)) * math.exp((x * (eps + -1.0))) tmp = 0 if (t_1 + (t_0 * (1.0 + (-1.0 / eps)))) <= 2.0: tmp = (((1.0 + x) / math.exp(x)) + ((1.0 + x) * math.exp(-x))) / 2.0 else: tmp = (t_1 - (math.log1p(math.expm1(((1.0 / eps) + -1.0))) * t_0)) / 2.0 return tmp
function code(x, eps) t_0 = exp(Float64(x * Float64(-1.0 - eps))) t_1 = Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(x * Float64(eps + -1.0)))) tmp = 0.0 if (Float64(t_1 + Float64(t_0 * Float64(1.0 + Float64(-1.0 / eps)))) <= 2.0) tmp = Float64(Float64(Float64(Float64(1.0 + x) / exp(x)) + Float64(Float64(1.0 + x) * exp(Float64(-x)))) / 2.0); else tmp = Float64(Float64(t_1 - Float64(log1p(expm1(Float64(Float64(1.0 / eps) + -1.0))) * t_0)) / 2.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$1 + N[(t$95$0 * N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.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[(N[(t$95$1 - N[(N[Log[1 + N[(Exp[N[(N[(1.0 / eps), $MachinePrecision] + -1.0), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{x \cdot \left(-1 - \varepsilon\right)}\\
t_1 := \left(1 + \frac{1}{\varepsilon}\right) \cdot e^{x \cdot \left(\varepsilon + -1\right)}\\
\mathbf{if}\;t_1 + t_0 \cdot \left(1 + \frac{-1}{\varepsilon}\right) \leq 2:\\
\;\;\;\;\frac{\frac{1 + x}{e^{x}} + \left(1 + x\right) \cdot e^{-x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1 - \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{\varepsilon} + -1\right)\right) \cdot 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))))) < 2Initial program 43.7%
div-sub43.7%
+-rgt-identity43.7%
div-sub43.7%
Simplified43.7%
Taylor expanded in eps around 0 100.0%
*-commutative100.0%
distribute-lft1-in100.0%
neg-mul-1100.0%
distribute-lft-out100.0%
mul-1-neg100.0%
*-commutative100.0%
distribute-lft1-in100.0%
neg-mul-1100.0%
Simplified100.0%
exp-neg100.0%
un-div-inv100.0%
Applied egg-rr100.0%
if 2 < (-.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 98.1%
div-sub98.1%
+-rgt-identity98.1%
div-sub98.1%
Simplified98.1%
log1p-expm1-u98.1%
Applied egg-rr98.1%
Final simplification99.2%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ 1.0 (/ 1.0 eps)))
(t_1 (* (exp (* x (- -1.0 eps))) (+ 1.0 (/ -1.0 eps)))))
(if (<= (+ (* t_0 (exp (* x (+ eps -1.0)))) t_1) 0.0)
(/ (+ (/ (+ 1.0 x) (exp x)) (* (+ 1.0 x) (exp (- x)))) 2.0)
(/ (+ (* t_0 (exp (- (* eps x) x))) t_1) 2.0))))
double code(double x, double eps) {
double t_0 = 1.0 + (1.0 / eps);
double t_1 = exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps));
double tmp;
if (((t_0 * exp((x * (eps + -1.0)))) + t_1) <= 0.0) {
tmp = (((1.0 + x) / exp(x)) + ((1.0 + x) * exp(-x))) / 2.0;
} else {
tmp = ((t_0 * exp(((eps * x) - x))) + t_1) / 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) :: t_1
real(8) :: tmp
t_0 = 1.0d0 + (1.0d0 / eps)
t_1 = exp((x * ((-1.0d0) - eps))) * (1.0d0 + ((-1.0d0) / eps))
if (((t_0 * exp((x * (eps + (-1.0d0))))) + t_1) <= 0.0d0) then
tmp = (((1.0d0 + x) / exp(x)) + ((1.0d0 + x) * exp(-x))) / 2.0d0
else
tmp = ((t_0 * exp(((eps * x) - x))) + t_1) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = 1.0 + (1.0 / eps);
double t_1 = Math.exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps));
double tmp;
if (((t_0 * Math.exp((x * (eps + -1.0)))) + t_1) <= 0.0) {
tmp = (((1.0 + x) / Math.exp(x)) + ((1.0 + x) * Math.exp(-x))) / 2.0;
} else {
tmp = ((t_0 * Math.exp(((eps * x) - x))) + t_1) / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = 1.0 + (1.0 / eps) t_1 = math.exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)) tmp = 0 if ((t_0 * math.exp((x * (eps + -1.0)))) + t_1) <= 0.0: tmp = (((1.0 + x) / math.exp(x)) + ((1.0 + x) * math.exp(-x))) / 2.0 else: tmp = ((t_0 * math.exp(((eps * x) - x))) + t_1) / 2.0 return tmp
function code(x, eps) t_0 = Float64(1.0 + Float64(1.0 / eps)) t_1 = Float64(exp(Float64(x * Float64(-1.0 - eps))) * Float64(1.0 + Float64(-1.0 / eps))) tmp = 0.0 if (Float64(Float64(t_0 * exp(Float64(x * Float64(eps + -1.0)))) + t_1) <= 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(Float64(Float64(t_0 * exp(Float64(Float64(eps * x) - x))) + t_1) / 2.0); end return tmp end
function tmp_2 = code(x, eps) t_0 = 1.0 + (1.0 / eps); t_1 = exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)); tmp = 0.0; if (((t_0 * exp((x * (eps + -1.0)))) + t_1) <= 0.0) tmp = (((1.0 + x) / exp(x)) + ((1.0 + x) * exp(-x))) / 2.0; else tmp = ((t_0 * exp(((eps * x) - x))) + t_1) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(t$95$0 * N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision], 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[(N[(N[(t$95$0 * N[Exp[N[(N[(eps * x), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{1}{\varepsilon}\\
t_1 := e^{x \cdot \left(-1 - \varepsilon\right)} \cdot \left(1 + \frac{-1}{\varepsilon}\right)\\
\mathbf{if}\;t_0 \cdot e^{x \cdot \left(\varepsilon + -1\right)} + t_1 \leq 0:\\
\;\;\;\;\frac{\frac{1 + x}{e^{x}} + \left(1 + x\right) \cdot e^{-x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0 \cdot e^{\varepsilon \cdot x - x} + t_1}{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 25.7%
div-sub25.7%
+-rgt-identity25.7%
div-sub25.7%
Simplified25.7%
Taylor expanded in eps around 0 100.0%
*-commutative100.0%
distribute-lft1-in100.0%
neg-mul-1100.0%
distribute-lft-out100.0%
mul-1-neg100.0%
*-commutative100.0%
distribute-lft1-in100.0%
neg-mul-1100.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 98.6%
div-sub98.6%
+-rgt-identity98.6%
div-sub98.6%
Simplified98.6%
Taylor expanded in x around inf 98.6%
*-commutative98.6%
+-commutative98.6%
mul-1-neg98.6%
*-commutative98.6%
distribute-rgt-neg-in98.6%
mul-1-neg98.6%
sub-neg98.6%
mul-1-neg98.6%
distribute-lft-in98.6%
metadata-eval98.6%
neg-mul-198.6%
mul-1-neg98.6%
remove-double-neg98.6%
+-commutative98.6%
distribute-rgt-in98.6%
neg-mul-198.6%
unsub-neg98.6%
Simplified98.6%
Final simplification99.2%
(FPCore (x eps) :precision binary64 (/ (+ (exp (* x (- -1.0 eps))) (exp (- (* eps x) x))) 2.0))
double code(double x, double eps) {
return (exp((x * (-1.0 - eps))) + exp(((eps * x) - x))) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (exp((x * ((-1.0d0) - eps))) + exp(((eps * x) - x))) / 2.0d0
end function
public static double code(double x, double eps) {
return (Math.exp((x * (-1.0 - eps))) + Math.exp(((eps * x) - x))) / 2.0;
}
def code(x, eps): return (math.exp((x * (-1.0 - eps))) + math.exp(((eps * x) - x))) / 2.0
function code(x, eps) return Float64(Float64(exp(Float64(x * Float64(-1.0 - eps))) + exp(Float64(Float64(eps * x) - x))) / 2.0) end
function tmp = code(x, eps) tmp = (exp((x * (-1.0 - eps))) + exp(((eps * x) - x))) / 2.0; end
code[x_, eps_] := N[(N[(N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(N[(eps * x), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{x \cdot \left(-1 - \varepsilon\right)} + e^{\varepsilon \cdot x - x}}{2}
\end{array}
Initial program 66.7%
div-sub66.7%
+-rgt-identity66.7%
div-sub66.7%
Simplified66.7%
Taylor expanded in eps around inf 64.1%
mul-1-neg64.1%
*-commutative64.1%
distribute-rgt-neg-in64.1%
mul-1-neg64.1%
sub-neg64.1%
mul-1-neg64.1%
distribute-lft-in64.1%
metadata-eval64.1%
neg-mul-164.1%
mul-1-neg64.1%
remove-double-neg64.1%
+-commutative64.1%
distribute-rgt-in64.1%
neg-mul-164.1%
unsub-neg64.1%
Simplified64.1%
Taylor expanded in eps around inf 97.0%
mul-1-neg97.0%
+-commutative97.0%
exp-prod97.0%
*-lft-identity97.0%
metadata-eval97.0%
cancel-sign-sub-inv97.0%
exp-prod97.0%
mul-1-neg97.0%
*-commutative97.0%
sub-neg97.0%
mul-1-neg97.0%
remove-double-neg97.0%
+-commutative97.0%
Simplified97.0%
Taylor expanded in eps around inf 97.0%
Taylor expanded in eps around -inf 97.0%
*-commutative97.0%
distribute-rgt-neg-in97.0%
cancel-sign-sub-inv97.0%
metadata-eval97.0%
*-lft-identity97.0%
distribute-neg-in97.0%
metadata-eval97.0%
unsub-neg97.0%
Simplified97.0%
Final simplification97.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* x (- -1.0 eps)))
(t_1 (- (* eps x) x))
(t_2 (/ (+ (exp t_0) (+ 1.0 t_1)) 2.0))
(t_3 (exp t_1)))
(if (<= eps -5.1e+131)
(/ (+ 1.0 t_3) 2.0)
(if (<= eps -1.6)
t_2
(if (<= eps 1.4e-9)
(/ (* 2.0 (exp (- x))) 2.0)
(if (or (<= eps 1.85e+176) (not (<= eps 1e+261)))
(/ (+ t_3 (+ 1.0 t_0)) 2.0)
t_2))))))
double code(double x, double eps) {
double t_0 = x * (-1.0 - eps);
double t_1 = (eps * x) - x;
double t_2 = (exp(t_0) + (1.0 + t_1)) / 2.0;
double t_3 = exp(t_1);
double tmp;
if (eps <= -5.1e+131) {
tmp = (1.0 + t_3) / 2.0;
} else if (eps <= -1.6) {
tmp = t_2;
} else if (eps <= 1.4e-9) {
tmp = (2.0 * exp(-x)) / 2.0;
} else if ((eps <= 1.85e+176) || !(eps <= 1e+261)) {
tmp = (t_3 + (1.0 + t_0)) / 2.0;
} else {
tmp = t_2;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = x * ((-1.0d0) - eps)
t_1 = (eps * x) - x
t_2 = (exp(t_0) + (1.0d0 + t_1)) / 2.0d0
t_3 = exp(t_1)
if (eps <= (-5.1d+131)) then
tmp = (1.0d0 + t_3) / 2.0d0
else if (eps <= (-1.6d0)) then
tmp = t_2
else if (eps <= 1.4d-9) then
tmp = (2.0d0 * exp(-x)) / 2.0d0
else if ((eps <= 1.85d+176) .or. (.not. (eps <= 1d+261))) then
tmp = (t_3 + (1.0d0 + t_0)) / 2.0d0
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = x * (-1.0 - eps);
double t_1 = (eps * x) - x;
double t_2 = (Math.exp(t_0) + (1.0 + t_1)) / 2.0;
double t_3 = Math.exp(t_1);
double tmp;
if (eps <= -5.1e+131) {
tmp = (1.0 + t_3) / 2.0;
} else if (eps <= -1.6) {
tmp = t_2;
} else if (eps <= 1.4e-9) {
tmp = (2.0 * Math.exp(-x)) / 2.0;
} else if ((eps <= 1.85e+176) || !(eps <= 1e+261)) {
tmp = (t_3 + (1.0 + t_0)) / 2.0;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, eps): t_0 = x * (-1.0 - eps) t_1 = (eps * x) - x t_2 = (math.exp(t_0) + (1.0 + t_1)) / 2.0 t_3 = math.exp(t_1) tmp = 0 if eps <= -5.1e+131: tmp = (1.0 + t_3) / 2.0 elif eps <= -1.6: tmp = t_2 elif eps <= 1.4e-9: tmp = (2.0 * math.exp(-x)) / 2.0 elif (eps <= 1.85e+176) or not (eps <= 1e+261): tmp = (t_3 + (1.0 + t_0)) / 2.0 else: tmp = t_2 return tmp
function code(x, eps) t_0 = Float64(x * Float64(-1.0 - eps)) t_1 = Float64(Float64(eps * x) - x) t_2 = Float64(Float64(exp(t_0) + Float64(1.0 + t_1)) / 2.0) t_3 = exp(t_1) tmp = 0.0 if (eps <= -5.1e+131) tmp = Float64(Float64(1.0 + t_3) / 2.0); elseif (eps <= -1.6) tmp = t_2; elseif (eps <= 1.4e-9) tmp = Float64(Float64(2.0 * exp(Float64(-x))) / 2.0); elseif ((eps <= 1.85e+176) || !(eps <= 1e+261)) tmp = Float64(Float64(t_3 + Float64(1.0 + t_0)) / 2.0); else tmp = t_2; end return tmp end
function tmp_2 = code(x, eps) t_0 = x * (-1.0 - eps); t_1 = (eps * x) - x; t_2 = (exp(t_0) + (1.0 + t_1)) / 2.0; t_3 = exp(t_1); tmp = 0.0; if (eps <= -5.1e+131) tmp = (1.0 + t_3) / 2.0; elseif (eps <= -1.6) tmp = t_2; elseif (eps <= 1.4e-9) tmp = (2.0 * exp(-x)) / 2.0; elseif ((eps <= 1.85e+176) || ~((eps <= 1e+261))) tmp = (t_3 + (1.0 + t_0)) / 2.0; else tmp = t_2; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(eps * x), $MachinePrecision] - x), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Exp[t$95$0], $MachinePrecision] + N[(1.0 + t$95$1), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$3 = N[Exp[t$95$1], $MachinePrecision]}, If[LessEqual[eps, -5.1e+131], N[(N[(1.0 + t$95$3), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[eps, -1.6], t$95$2, If[LessEqual[eps, 1.4e-9], N[(N[(2.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[eps, 1.85e+176], N[Not[LessEqual[eps, 1e+261]], $MachinePrecision]], N[(N[(t$95$3 + N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], t$95$2]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(-1 - \varepsilon\right)\\
t_1 := \varepsilon \cdot x - x\\
t_2 := \frac{e^{t_0} + \left(1 + t_1\right)}{2}\\
t_3 := e^{t_1}\\
\mathbf{if}\;\varepsilon \leq -5.1 \cdot 10^{+131}:\\
\;\;\;\;\frac{1 + t_3}{2}\\
\mathbf{elif}\;\varepsilon \leq -1.6:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\varepsilon \leq 1.4 \cdot 10^{-9}:\\
\;\;\;\;\frac{2 \cdot e^{-x}}{2}\\
\mathbf{elif}\;\varepsilon \leq 1.85 \cdot 10^{+176} \lor \neg \left(\varepsilon \leq 10^{+261}\right):\\
\;\;\;\;\frac{t_3 + \left(1 + t_0\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if eps < -5.1000000000000004e131Initial program 100.0%
div-sub100.0%
+-rgt-identity100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
mul-1-neg100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
mul-1-neg100.0%
sub-neg100.0%
mul-1-neg100.0%
distribute-lft-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
mul-1-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-rgt-in100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
mul-1-neg100.0%
+-commutative100.0%
exp-prod100.0%
*-lft-identity100.0%
metadata-eval100.0%
cancel-sign-sub-inv100.0%
exp-prod100.0%
mul-1-neg100.0%
*-commutative100.0%
sub-neg100.0%
mul-1-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in x around 0 67.5%
if -5.1000000000000004e131 < eps < -1.6000000000000001 or 1.8499999999999999e176 < eps < 9.9999999999999993e260Initial program 100.0%
div-sub100.0%
+-rgt-identity100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in eps around inf 97.6%
mul-1-neg97.6%
*-commutative97.6%
distribute-rgt-neg-in97.6%
mul-1-neg97.6%
sub-neg97.6%
mul-1-neg97.6%
distribute-lft-in97.6%
metadata-eval97.6%
neg-mul-197.6%
mul-1-neg97.6%
remove-double-neg97.6%
+-commutative97.6%
distribute-rgt-in97.6%
neg-mul-197.6%
unsub-neg97.6%
Simplified97.6%
Taylor expanded in eps around inf 100.0%
mul-1-neg100.0%
+-commutative100.0%
exp-prod100.0%
*-lft-identity100.0%
metadata-eval100.0%
cancel-sign-sub-inv100.0%
exp-prod100.0%
mul-1-neg100.0%
*-commutative100.0%
sub-neg100.0%
mul-1-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in x around 0 81.6%
*-commutative81.6%
sub-neg81.6%
metadata-eval81.6%
distribute-rgt-out81.6%
neg-mul-181.6%
sub-neg81.6%
*-commutative81.6%
Simplified81.6%
if -1.6000000000000001 < eps < 1.39999999999999992e-9Initial program 25.9%
div-sub25.9%
+-rgt-identity25.9%
div-sub25.9%
Simplified25.9%
Taylor expanded in eps around inf 93.7%
Taylor expanded in eps around 0 93.7%
cancel-sign-sub-inv93.7%
metadata-eval93.7%
distribute-rgt1-in93.7%
metadata-eval93.7%
neg-mul-193.7%
Simplified93.7%
if 1.39999999999999992e-9 < eps < 1.8499999999999999e176 or 9.9999999999999993e260 < eps Initial program 100.0%
div-sub100.0%
+-rgt-identity100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in eps around inf 92.3%
mul-1-neg92.3%
*-commutative92.3%
distribute-rgt-neg-in92.3%
mul-1-neg92.3%
sub-neg92.3%
mul-1-neg92.3%
distribute-lft-in92.3%
metadata-eval92.3%
neg-mul-192.3%
mul-1-neg92.3%
remove-double-neg92.3%
+-commutative92.3%
distribute-rgt-in92.3%
neg-mul-192.3%
unsub-neg92.3%
Simplified92.3%
Taylor expanded in eps around inf 99.3%
mul-1-neg99.3%
+-commutative99.3%
exp-prod99.3%
*-lft-identity99.3%
metadata-eval99.3%
cancel-sign-sub-inv99.3%
exp-prod99.3%
mul-1-neg99.3%
*-commutative99.3%
sub-neg99.3%
mul-1-neg99.3%
remove-double-neg99.3%
+-commutative99.3%
Simplified99.3%
Taylor expanded in eps around inf 99.3%
Taylor expanded in x around 0 80.7%
associate-*r*80.7%
+-commutative80.7%
mul-1-neg80.7%
cancel-sign-sub-inv80.7%
*-commutative80.7%
cancel-sign-sub-inv80.7%
distribute-lft-neg-in80.7%
*-commutative80.7%
distribute-lft-neg-in80.7%
+-commutative80.7%
distribute-neg-in80.7%
metadata-eval80.7%
unsub-neg80.7%
Simplified80.7%
Final simplification85.1%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (exp (- (* eps x) x))))
(if (<= eps -1.85e+58)
(/ (+ 1.0 t_0) 2.0)
(if (<= eps 1.4e-9)
(/ (* 2.0 (exp (- x))) 2.0)
(/ (+ t_0 (+ 1.0 (* x (- -1.0 eps)))) 2.0)))))
double code(double x, double eps) {
double t_0 = exp(((eps * x) - x));
double tmp;
if (eps <= -1.85e+58) {
tmp = (1.0 + t_0) / 2.0;
} else if (eps <= 1.4e-9) {
tmp = (2.0 * exp(-x)) / 2.0;
} else {
tmp = (t_0 + (1.0 + (x * (-1.0 - eps)))) / 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 = exp(((eps * x) - x))
if (eps <= (-1.85d+58)) then
tmp = (1.0d0 + t_0) / 2.0d0
else if (eps <= 1.4d-9) then
tmp = (2.0d0 * exp(-x)) / 2.0d0
else
tmp = (t_0 + (1.0d0 + (x * ((-1.0d0) - eps)))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.exp(((eps * x) - x));
double tmp;
if (eps <= -1.85e+58) {
tmp = (1.0 + t_0) / 2.0;
} else if (eps <= 1.4e-9) {
tmp = (2.0 * Math.exp(-x)) / 2.0;
} else {
tmp = (t_0 + (1.0 + (x * (-1.0 - eps)))) / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = math.exp(((eps * x) - x)) tmp = 0 if eps <= -1.85e+58: tmp = (1.0 + t_0) / 2.0 elif eps <= 1.4e-9: tmp = (2.0 * math.exp(-x)) / 2.0 else: tmp = (t_0 + (1.0 + (x * (-1.0 - eps)))) / 2.0 return tmp
function code(x, eps) t_0 = exp(Float64(Float64(eps * x) - x)) tmp = 0.0 if (eps <= -1.85e+58) tmp = Float64(Float64(1.0 + t_0) / 2.0); elseif (eps <= 1.4e-9) tmp = Float64(Float64(2.0 * exp(Float64(-x))) / 2.0); else tmp = Float64(Float64(t_0 + Float64(1.0 + Float64(x * Float64(-1.0 - eps)))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) t_0 = exp(((eps * x) - x)); tmp = 0.0; if (eps <= -1.85e+58) tmp = (1.0 + t_0) / 2.0; elseif (eps <= 1.4e-9) tmp = (2.0 * exp(-x)) / 2.0; else tmp = (t_0 + (1.0 + (x * (-1.0 - eps)))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[Exp[N[(N[(eps * x), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[eps, -1.85e+58], N[(N[(1.0 + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[eps, 1.4e-9], N[(N[(2.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(t$95$0 + N[(1.0 + N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\varepsilon \cdot x - x}\\
\mathbf{if}\;\varepsilon \leq -1.85 \cdot 10^{+58}:\\
\;\;\;\;\frac{1 + t_0}{2}\\
\mathbf{elif}\;\varepsilon \leq 1.4 \cdot 10^{-9}:\\
\;\;\;\;\frac{2 \cdot e^{-x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0 + \left(1 + x \cdot \left(-1 - \varepsilon\right)\right)}{2}\\
\end{array}
\end{array}
if eps < -1.8500000000000001e58Initial program 100.0%
div-sub100.0%
+-rgt-identity100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
mul-1-neg100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
mul-1-neg100.0%
sub-neg100.0%
mul-1-neg100.0%
distribute-lft-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
mul-1-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
distribute-rgt-in100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
mul-1-neg100.0%
+-commutative100.0%
exp-prod100.0%
*-lft-identity100.0%
metadata-eval100.0%
cancel-sign-sub-inv100.0%
exp-prod100.0%
mul-1-neg100.0%
*-commutative100.0%
sub-neg100.0%
mul-1-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in x around 0 63.2%
if -1.8500000000000001e58 < eps < 1.39999999999999992e-9Initial program 34.9%
div-sub34.9%
+-rgt-identity34.9%
div-sub34.9%
Simplified34.9%
Taylor expanded in eps around inf 94.4%
Taylor expanded in eps around 0 91.0%
cancel-sign-sub-inv91.0%
metadata-eval91.0%
distribute-rgt1-in91.0%
metadata-eval91.0%
neg-mul-191.0%
Simplified91.0%
if 1.39999999999999992e-9 < eps Initial program 100.0%
div-sub100.0%
+-rgt-identity100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in eps around inf 94.3%
mul-1-neg94.3%
*-commutative94.3%
distribute-rgt-neg-in94.3%
mul-1-neg94.3%
sub-neg94.3%
mul-1-neg94.3%
distribute-lft-in94.3%
metadata-eval94.3%
neg-mul-194.3%
mul-1-neg94.3%
remove-double-neg94.3%
+-commutative94.3%
distribute-rgt-in94.3%
neg-mul-194.3%
unsub-neg94.3%
Simplified94.3%
Taylor expanded in eps around inf 99.5%
mul-1-neg99.5%
+-commutative99.5%
exp-prod99.5%
*-lft-identity99.5%
metadata-eval99.5%
cancel-sign-sub-inv99.5%
exp-prod99.5%
mul-1-neg99.5%
*-commutative99.5%
sub-neg99.5%
mul-1-neg99.5%
remove-double-neg99.5%
+-commutative99.5%
Simplified99.5%
Taylor expanded in eps around inf 99.5%
Taylor expanded in x around 0 67.1%
associate-*r*67.1%
+-commutative67.1%
mul-1-neg67.1%
cancel-sign-sub-inv67.1%
*-commutative67.1%
cancel-sign-sub-inv67.1%
distribute-lft-neg-in67.1%
*-commutative67.1%
distribute-lft-neg-in67.1%
+-commutative67.1%
distribute-neg-in67.1%
metadata-eval67.1%
unsub-neg67.1%
Simplified67.1%
Final simplification78.5%
(FPCore (x eps) :precision binary64 (if (or (<= x -1.12e-8) (not (<= x 1900000000000.0))) (/ (/ 2.0 (exp x)) 2.0) (/ (+ 1.0 (exp (- (* eps x) x))) 2.0)))
double code(double x, double eps) {
double tmp;
if ((x <= -1.12e-8) || !(x <= 1900000000000.0)) {
tmp = (2.0 / exp(x)) / 2.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) :: tmp
if ((x <= (-1.12d-8)) .or. (.not. (x <= 1900000000000.0d0))) then
tmp = (2.0d0 / exp(x)) / 2.0d0
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 tmp;
if ((x <= -1.12e-8) || !(x <= 1900000000000.0)) {
tmp = (2.0 / Math.exp(x)) / 2.0;
} else {
tmp = (1.0 + Math.exp(((eps * x) - x))) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -1.12e-8) or not (x <= 1900000000000.0): tmp = (2.0 / math.exp(x)) / 2.0 else: tmp = (1.0 + math.exp(((eps * x) - x))) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if ((x <= -1.12e-8) || !(x <= 1900000000000.0)) tmp = Float64(Float64(2.0 / exp(x)) / 2.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) tmp = 0.0; if ((x <= -1.12e-8) || ~((x <= 1900000000000.0))) tmp = (2.0 / exp(x)) / 2.0; else tmp = (1.0 + exp(((eps * x) - x))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -1.12e-8], N[Not[LessEqual[x, 1900000000000.0]], $MachinePrecision]], N[(N[(2.0 / N[Exp[x], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(1.0 + N[Exp[N[(N[(eps * x), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.12 \cdot 10^{-8} \lor \neg \left(x \leq 1900000000000\right):\\
\;\;\;\;\frac{\frac{2}{e^{x}}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + e^{\varepsilon \cdot x - x}}{2}\\
\end{array}
\end{array}
if x < -1.11999999999999994e-8 or 1.9e12 < x Initial program 96.0%
div-sub96.0%
+-rgt-identity96.0%
div-sub96.0%
Simplified96.0%
Taylor expanded in eps around inf 95.8%
mul-1-neg95.8%
*-commutative95.8%
distribute-rgt-neg-in95.8%
mul-1-neg95.8%
sub-neg95.8%
mul-1-neg95.8%
distribute-lft-in95.8%
metadata-eval95.8%
neg-mul-195.8%
mul-1-neg95.8%
remove-double-neg95.8%
+-commutative95.8%
distribute-rgt-in95.8%
neg-mul-195.8%
unsub-neg95.8%
Simplified95.8%
Taylor expanded in eps around inf 95.6%
mul-1-neg95.6%
+-commutative95.6%
exp-prod95.6%
*-lft-identity95.6%
metadata-eval95.6%
cancel-sign-sub-inv95.6%
exp-prod95.6%
mul-1-neg95.6%
*-commutative95.6%
sub-neg95.6%
mul-1-neg95.6%
remove-double-neg95.6%
+-commutative95.6%
Simplified95.6%
Taylor expanded in eps around 0 64.0%
exp-neg64.0%
associate-*r/64.0%
metadata-eval64.0%
Simplified64.0%
if -1.11999999999999994e-8 < x < 1.9e12Initial program 48.5%
div-sub48.5%
+-rgt-identity48.5%
div-sub48.5%
Simplified48.5%
Taylor expanded in eps around inf 44.4%
mul-1-neg44.4%
*-commutative44.4%
distribute-rgt-neg-in44.4%
mul-1-neg44.4%
sub-neg44.4%
mul-1-neg44.4%
distribute-lft-in44.4%
metadata-eval44.4%
neg-mul-144.4%
mul-1-neg44.4%
remove-double-neg44.4%
+-commutative44.4%
distribute-rgt-in44.4%
neg-mul-144.4%
unsub-neg44.4%
Simplified44.4%
Taylor expanded in eps around inf 97.9%
mul-1-neg97.9%
+-commutative97.9%
exp-prod97.9%
*-lft-identity97.9%
metadata-eval97.9%
cancel-sign-sub-inv97.9%
exp-prod97.9%
mul-1-neg97.9%
*-commutative97.9%
sub-neg97.9%
mul-1-neg97.9%
remove-double-neg97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in eps around inf 97.9%
Taylor expanded in x around 0 86.5%
Final simplification77.9%
(FPCore (x eps) :precision binary64 (/ (* 2.0 (exp (- x))) 2.0))
double code(double x, double eps) {
return (2.0 * exp(-x)) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (2.0d0 * exp(-x)) / 2.0d0
end function
public static double code(double x, double eps) {
return (2.0 * Math.exp(-x)) / 2.0;
}
def code(x, eps): return (2.0 * math.exp(-x)) / 2.0
function code(x, eps) return Float64(Float64(2.0 * exp(Float64(-x))) / 2.0) end
function tmp = code(x, eps) tmp = (2.0 * exp(-x)) / 2.0; end
code[x_, eps_] := N[(N[(2.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{2 \cdot e^{-x}}{2}
\end{array}
Initial program 66.7%
div-sub66.7%
+-rgt-identity66.7%
div-sub66.7%
Simplified66.7%
Taylor expanded in eps around inf 97.0%
Taylor expanded in eps around 0 70.8%
cancel-sign-sub-inv70.8%
metadata-eval70.8%
distribute-rgt1-in70.8%
metadata-eval70.8%
neg-mul-170.8%
Simplified70.8%
Final simplification70.8%
(FPCore (x eps) :precision binary64 (/ (/ 2.0 (exp x)) 2.0))
double code(double x, double eps) {
return (2.0 / exp(x)) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (2.0d0 / exp(x)) / 2.0d0
end function
public static double code(double x, double eps) {
return (2.0 / Math.exp(x)) / 2.0;
}
def code(x, eps): return (2.0 / math.exp(x)) / 2.0
function code(x, eps) return Float64(Float64(2.0 / exp(x)) / 2.0) end
function tmp = code(x, eps) tmp = (2.0 / exp(x)) / 2.0; end
code[x_, eps_] := N[(N[(2.0 / N[Exp[x], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{2}{e^{x}}}{2}
\end{array}
Initial program 66.7%
div-sub66.7%
+-rgt-identity66.7%
div-sub66.7%
Simplified66.7%
Taylor expanded in eps around inf 64.1%
mul-1-neg64.1%
*-commutative64.1%
distribute-rgt-neg-in64.1%
mul-1-neg64.1%
sub-neg64.1%
mul-1-neg64.1%
distribute-lft-in64.1%
metadata-eval64.1%
neg-mul-164.1%
mul-1-neg64.1%
remove-double-neg64.1%
+-commutative64.1%
distribute-rgt-in64.1%
neg-mul-164.1%
unsub-neg64.1%
Simplified64.1%
Taylor expanded in eps around inf 97.0%
mul-1-neg97.0%
+-commutative97.0%
exp-prod97.0%
*-lft-identity97.0%
metadata-eval97.0%
cancel-sign-sub-inv97.0%
exp-prod97.0%
mul-1-neg97.0%
*-commutative97.0%
sub-neg97.0%
mul-1-neg97.0%
remove-double-neg97.0%
+-commutative97.0%
Simplified97.0%
Taylor expanded in eps around 0 70.8%
exp-neg70.8%
associate-*r/70.8%
metadata-eval70.8%
Simplified70.8%
Final simplification70.8%
(FPCore (x eps) :precision binary64 (if (<= x -2.8e+216) (/ (- (/ (* x (* x 0.5)) eps) (/ x eps)) 2.0) (if (<= x 450.0) (/ (+ 2.0 (* eps x)) 2.0) 0.0)))
double code(double x, double eps) {
double tmp;
if (x <= -2.8e+216) {
tmp = (((x * (x * 0.5)) / eps) - (x / eps)) / 2.0;
} else if (x <= 450.0) {
tmp = (2.0 + (eps * 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 <= (-2.8d+216)) then
tmp = (((x * (x * 0.5d0)) / eps) - (x / eps)) / 2.0d0
else if (x <= 450.0d0) then
tmp = (2.0d0 + (eps * 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 <= -2.8e+216) {
tmp = (((x * (x * 0.5)) / eps) - (x / eps)) / 2.0;
} else if (x <= 450.0) {
tmp = (2.0 + (eps * x)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -2.8e+216: tmp = (((x * (x * 0.5)) / eps) - (x / eps)) / 2.0 elif x <= 450.0: tmp = (2.0 + (eps * x)) / 2.0 else: tmp = 0.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -2.8e+216) tmp = Float64(Float64(Float64(Float64(x * Float64(x * 0.5)) / eps) - Float64(x / eps)) / 2.0); elseif (x <= 450.0) tmp = Float64(Float64(2.0 + Float64(eps * x)) / 2.0); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -2.8e+216) tmp = (((x * (x * 0.5)) / eps) - (x / eps)) / 2.0; elseif (x <= 450.0) tmp = (2.0 + (eps * x)) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -2.8e+216], N[(N[(N[(N[(x * N[(x * 0.5), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision] - N[(x / eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 450.0], N[(N[(2.0 + N[(eps * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.8 \cdot 10^{+216}:\\
\;\;\;\;\frac{\frac{x \cdot \left(x \cdot 0.5\right)}{\varepsilon} - \frac{x}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq 450:\\
\;\;\;\;\frac{2 + \varepsilon \cdot x}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -2.79999999999999982e216Initial program 100.0%
div-sub100.0%
+-rgt-identity100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around 0 23.9%
Taylor expanded in eps around 0 78.6%
expm1-def78.6%
neg-mul-178.6%
Simplified78.6%
Taylor expanded in x around 0 78.6%
mul-1-neg78.6%
unsub-neg78.6%
associate-*r/78.6%
unpow278.6%
associate-*r*78.6%
Simplified78.6%
if -2.79999999999999982e216 < x < 450Initial program 54.1%
div-sub54.1%
+-rgt-identity54.1%
div-sub54.1%
Simplified54.1%
Taylor expanded in x around 0 39.8%
Taylor expanded in x around 0 43.5%
Taylor expanded in eps around inf 67.7%
associate-*r*67.7%
mul-1-neg67.7%
Simplified67.7%
if 450 < x Initial program 98.4%
Simplified98.4%
Taylor expanded in eps around 0 45.8%
div-sub45.8%
rec-exp45.8%
neg-mul-145.8%
+-inverses45.8%
Simplified45.8%
Final simplification63.3%
(FPCore (x eps) :precision binary64 (if (<= x -9.2e+216) (* (* eps x) -0.5) (if (<= x 490.0) (/ (+ 2.0 (* eps x)) 2.0) 0.0)))
double code(double x, double eps) {
double tmp;
if (x <= -9.2e+216) {
tmp = (eps * x) * -0.5;
} else if (x <= 490.0) {
tmp = (2.0 + (eps * 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 <= (-9.2d+216)) then
tmp = (eps * x) * (-0.5d0)
else if (x <= 490.0d0) then
tmp = (2.0d0 + (eps * 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 <= -9.2e+216) {
tmp = (eps * x) * -0.5;
} else if (x <= 490.0) {
tmp = (2.0 + (eps * x)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -9.2e+216: tmp = (eps * x) * -0.5 elif x <= 490.0: tmp = (2.0 + (eps * x)) / 2.0 else: tmp = 0.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -9.2e+216) tmp = Float64(Float64(eps * x) * -0.5); elseif (x <= 490.0) tmp = Float64(Float64(2.0 + Float64(eps * x)) / 2.0); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -9.2e+216) tmp = (eps * x) * -0.5; elseif (x <= 490.0) tmp = (2.0 + (eps * x)) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -9.2e+216], N[(N[(eps * x), $MachinePrecision] * -0.5), $MachinePrecision], If[LessEqual[x, 490.0], N[(N[(2.0 + N[(eps * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.2 \cdot 10^{+216}:\\
\;\;\;\;\left(\varepsilon \cdot x\right) \cdot -0.5\\
\mathbf{elif}\;x \leq 490:\\
\;\;\;\;\frac{2 + \varepsilon \cdot x}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -9.19999999999999983e216Initial program 100.0%
div-sub100.0%
+-rgt-identity100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around 0 72.2%
sub-neg72.2%
sub-neg72.2%
metadata-eval72.2%
associate-*r*72.2%
distribute-lft-in72.2%
neg-mul-172.2%
metadata-eval72.2%
*-commutative72.2%
+-commutative72.2%
metadata-eval72.2%
Simplified72.2%
Taylor expanded in eps around inf 72.2%
*-commutative72.2%
Simplified72.2%
if -9.19999999999999983e216 < x < 490Initial program 54.1%
div-sub54.1%
+-rgt-identity54.1%
div-sub54.1%
Simplified54.1%
Taylor expanded in x around 0 39.8%
Taylor expanded in x around 0 43.5%
Taylor expanded in eps around inf 67.7%
associate-*r*67.7%
mul-1-neg67.7%
Simplified67.7%
if 490 < x Initial program 98.4%
Simplified98.4%
Taylor expanded in eps around 0 45.8%
div-sub45.8%
rec-exp45.8%
neg-mul-145.8%
+-inverses45.8%
Simplified45.8%
Final simplification63.0%
(FPCore (x eps) :precision binary64 (if (<= x -1.12e-8) (* (* eps x) -0.5) (if (<= x 450.0) 1.0 0.0)))
double code(double x, double eps) {
double tmp;
if (x <= -1.12e-8) {
tmp = (eps * x) * -0.5;
} else if (x <= 450.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 <= (-1.12d-8)) then
tmp = (eps * x) * (-0.5d0)
else if (x <= 450.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 <= -1.12e-8) {
tmp = (eps * x) * -0.5;
} else if (x <= 450.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -1.12e-8: tmp = (eps * x) * -0.5 elif x <= 450.0: tmp = 1.0 else: tmp = 0.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -1.12e-8) tmp = Float64(Float64(eps * x) * -0.5); elseif (x <= 450.0) tmp = 1.0; else tmp = 0.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -1.12e-8) tmp = (eps * x) * -0.5; elseif (x <= 450.0) tmp = 1.0; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -1.12e-8], N[(N[(eps * x), $MachinePrecision] * -0.5), $MachinePrecision], If[LessEqual[x, 450.0], 1.0, 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.12 \cdot 10^{-8}:\\
\;\;\;\;\left(\varepsilon \cdot x\right) \cdot -0.5\\
\mathbf{elif}\;x \leq 450:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -1.11999999999999994e-8Initial program 90.6%
div-sub90.6%
+-rgt-identity90.6%
div-sub90.6%
Simplified90.6%
Taylor expanded in x around 0 58.7%
sub-neg58.7%
sub-neg58.7%
metadata-eval58.7%
associate-*r*58.7%
distribute-lft-in58.7%
neg-mul-158.7%
metadata-eval58.7%
*-commutative58.7%
+-commutative58.7%
metadata-eval58.7%
Simplified58.7%
Taylor expanded in eps around inf 35.0%
*-commutative35.0%
Simplified35.0%
if -1.11999999999999994e-8 < x < 450Initial program 48.5%
div-sub48.5%
+-rgt-identity48.5%
div-sub48.5%
Simplified48.5%
Taylor expanded in x around 0 76.5%
if 450 < x Initial program 98.4%
Simplified98.4%
Taylor expanded in eps around 0 45.8%
div-sub45.8%
rec-exp45.8%
neg-mul-145.8%
+-inverses45.8%
Simplified45.8%
Final simplification62.7%
(FPCore (x eps) :precision binary64 (if (<= x 490.0) 1.0 0.0))
double code(double x, double eps) {
double tmp;
if (x <= 490.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 <= 490.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 <= 490.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 490.0: tmp = 1.0 else: tmp = 0.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 490.0) tmp = 1.0; else tmp = 0.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 490.0) tmp = 1.0; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 490.0], 1.0, 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 490:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 490Initial program 57.4%
div-sub57.4%
+-rgt-identity57.4%
div-sub57.4%
Simplified57.4%
Taylor expanded in x around 0 61.0%
if 490 < x Initial program 98.4%
Simplified98.4%
Taylor expanded in eps around 0 45.8%
div-sub45.8%
rec-exp45.8%
neg-mul-145.8%
+-inverses45.8%
Simplified45.8%
Final simplification57.5%
(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 66.7%
Simplified59.6%
Taylor expanded in eps around 0 12.2%
div-sub12.1%
rec-exp12.1%
neg-mul-112.1%
+-inverses12.3%
Simplified12.3%
Final simplification12.3%
herbie shell --seed 2023192
(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))