
(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 15 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)))))
(t_1 (exp (- x))))
(if (<= t_0 5.0)
(/ (+ (/ (+ 1.0 x) (exp x)) (+ t_1 (* x t_1))) 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 t_1 = exp(-x);
double tmp;
if (t_0 <= 5.0) {
tmp = (((1.0 + x) / exp(x)) + (t_1 + (x * t_1))) / 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) :: t_1
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)))
t_1 = exp(-x)
if (t_0 <= 5.0d0) then
tmp = (((1.0d0 + x) / exp(x)) + (t_1 + (x * t_1))) / 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 t_1 = Math.exp(-x);
double tmp;
if (t_0 <= 5.0) {
tmp = (((1.0 + x) / Math.exp(x)) + (t_1 + (x * t_1))) / 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))) t_1 = math.exp(-x) tmp = 0 if t_0 <= 5.0: tmp = (((1.0 + x) / math.exp(x)) + (t_1 + (x * t_1))) / 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)))) t_1 = exp(Float64(-x)) tmp = 0.0 if (t_0 <= 5.0) tmp = Float64(Float64(Float64(Float64(1.0 + x) / exp(x)) + Float64(t_1 + Float64(x * t_1))) / 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))); t_1 = exp(-x); tmp = 0.0; if (t_0 <= 5.0) tmp = (((1.0 + x) / exp(x)) + (t_1 + (x * t_1))) / 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]}, Block[{t$95$1 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[t$95$0, 5.0], N[(N[(N[(N[(1.0 + x), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] + N[(t$95$1 + N[(x * t$95$1), $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)\\
t_1 := e^{-x}\\
\mathbf{if}\;t_0 \leq 5:\\
\;\;\;\;\frac{\frac{1 + x}{e^{x}} + \left(t_1 + x \cdot t_1\right)}{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))))) < 5Initial program 55.2%
Simplified55.2%
Taylor expanded in eps around 0 100.0%
distribute-rgt1-in100.0%
neg-mul-1100.0%
rec-exp100.0%
un-div-inv100.0%
Applied egg-rr100.0%
if 5 < (-.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 (/ 1.0 eps)) (exp (* x (+ eps -1.0))))
(* (exp (* x (- -1.0 eps))) (- 1.0 (/ 1.0 eps)))))
(t_1 (* (+ 1.0 x) (exp (- x)))))
(if (<= t_0 5.0) (/ (+ t_1 t_1) 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 t_1 = (1.0 + x) * exp(-x);
double tmp;
if (t_0 <= 5.0) {
tmp = (t_1 + t_1) / 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) :: t_1
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)))
t_1 = (1.0d0 + x) * exp(-x)
if (t_0 <= 5.0d0) then
tmp = (t_1 + t_1) / 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 t_1 = (1.0 + x) * Math.exp(-x);
double tmp;
if (t_0 <= 5.0) {
tmp = (t_1 + t_1) / 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))) t_1 = (1.0 + x) * math.exp(-x) tmp = 0 if t_0 <= 5.0: tmp = (t_1 + t_1) / 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)))) t_1 = Float64(Float64(1.0 + x) * exp(Float64(-x))) tmp = 0.0 if (t_0 <= 5.0) tmp = Float64(Float64(t_1 + t_1) / 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))); t_1 = (1.0 + x) * exp(-x); tmp = 0.0; if (t_0 <= 5.0) tmp = (t_1 + t_1) / 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]}, Block[{t$95$1 = N[(N[(1.0 + x), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5.0], N[(N[(t$95$1 + t$95$1), $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)\\
t_1 := \left(1 + x\right) \cdot e^{-x}\\
\mathbf{if}\;t_0 \leq 5:\\
\;\;\;\;\frac{t_1 + t_1}{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))))) < 5Initial program 55.2%
Simplified55.2%
Taylor expanded in eps around 0 100.0%
Simplified100.0%
if 5 < (-.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 -1.0)))) 2.0))
(t_1 (* (+ 1.0 x) (exp (- x))))
(t_2 (/ (+ t_1 t_1) 2.0)))
(if (<= x -1.1e-216)
(/ (+ 1.0 (exp (* x (- -1.0 eps)))) 2.0)
(if (<= x 5900.0)
(/ (+ 1.0 (exp (* eps x))) 2.0)
(if (<= x 1.4e+33)
(/ (+ (+ 1.0 (/ 1.0 eps)) (- 1.0 (/ 1.0 eps))) 2.0)
(if (<= x 5.8e+89)
t_0
(if (<= x 2.2e+165)
t_2
(if (<= x 6.2e+239)
t_0
(if (<= x 1.5e+287) t_2 (/ (/ (expm1 x) eps) 2.0))))))))))
double code(double x, double eps) {
double t_0 = (1.0 + exp((x * (eps + -1.0)))) / 2.0;
double t_1 = (1.0 + x) * exp(-x);
double t_2 = (t_1 + t_1) / 2.0;
double tmp;
if (x <= -1.1e-216) {
tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0;
} else if (x <= 5900.0) {
tmp = (1.0 + exp((eps * x))) / 2.0;
} else if (x <= 1.4e+33) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0;
} else if (x <= 5.8e+89) {
tmp = t_0;
} else if (x <= 2.2e+165) {
tmp = t_2;
} else if (x <= 6.2e+239) {
tmp = t_0;
} else if (x <= 1.5e+287) {
tmp = t_2;
} else {
tmp = (expm1(x) / eps) / 2.0;
}
return tmp;
}
public static double code(double x, double eps) {
double t_0 = (1.0 + Math.exp((x * (eps + -1.0)))) / 2.0;
double t_1 = (1.0 + x) * Math.exp(-x);
double t_2 = (t_1 + t_1) / 2.0;
double tmp;
if (x <= -1.1e-216) {
tmp = (1.0 + Math.exp((x * (-1.0 - eps)))) / 2.0;
} else if (x <= 5900.0) {
tmp = (1.0 + Math.exp((eps * x))) / 2.0;
} else if (x <= 1.4e+33) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0;
} else if (x <= 5.8e+89) {
tmp = t_0;
} else if (x <= 2.2e+165) {
tmp = t_2;
} else if (x <= 6.2e+239) {
tmp = t_0;
} else if (x <= 1.5e+287) {
tmp = t_2;
} else {
tmp = (Math.expm1(x) / eps) / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = (1.0 + math.exp((x * (eps + -1.0)))) / 2.0 t_1 = (1.0 + x) * math.exp(-x) t_2 = (t_1 + t_1) / 2.0 tmp = 0 if x <= -1.1e-216: tmp = (1.0 + math.exp((x * (-1.0 - eps)))) / 2.0 elif x <= 5900.0: tmp = (1.0 + math.exp((eps * x))) / 2.0 elif x <= 1.4e+33: tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0 elif x <= 5.8e+89: tmp = t_0 elif x <= 2.2e+165: tmp = t_2 elif x <= 6.2e+239: tmp = t_0 elif x <= 1.5e+287: tmp = t_2 else: tmp = (math.expm1(x) / eps) / 2.0 return tmp
function code(x, eps) t_0 = Float64(Float64(1.0 + exp(Float64(x * Float64(eps + -1.0)))) / 2.0) t_1 = Float64(Float64(1.0 + x) * exp(Float64(-x))) t_2 = Float64(Float64(t_1 + t_1) / 2.0) tmp = 0.0 if (x <= -1.1e-216) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps)))) / 2.0); elseif (x <= 5900.0) tmp = Float64(Float64(1.0 + exp(Float64(eps * x))) / 2.0); elseif (x <= 1.4e+33) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) + Float64(1.0 - Float64(1.0 / eps))) / 2.0); elseif (x <= 5.8e+89) tmp = t_0; elseif (x <= 2.2e+165) tmp = t_2; elseif (x <= 6.2e+239) tmp = t_0; elseif (x <= 1.5e+287) tmp = t_2; else tmp = Float64(Float64(expm1(x) / eps) / 2.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 + N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(1.0 + x), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$1 + t$95$1), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[x, -1.1e-216], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 5900.0], N[(N[(1.0 + N[Exp[N[(eps * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.4e+33], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 - N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 5.8e+89], t$95$0, If[LessEqual[x, 2.2e+165], t$95$2, If[LessEqual[x, 6.2e+239], t$95$0, If[LessEqual[x, 1.5e+287], t$95$2, N[(N[(N[(Exp[x] - 1), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1 + e^{x \cdot \left(\varepsilon + -1\right)}}{2}\\
t_1 := \left(1 + x\right) \cdot e^{-x}\\
t_2 := \frac{t_1 + t_1}{2}\\
\mathbf{if}\;x \leq -1.1 \cdot 10^{-216}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - \varepsilon\right)}}{2}\\
\mathbf{elif}\;x \leq 5900:\\
\;\;\;\;\frac{1 + e^{\varepsilon \cdot x}}{2}\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{+33}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) + \left(1 - \frac{1}{\varepsilon}\right)}{2}\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{+89}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{+165}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 6.2 \cdot 10^{+239}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{+287}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(x\right)}{\varepsilon}}{2}\\
\end{array}
\end{array}
if x < -1.09999999999999995e-216Initial program 64.9%
Simplified64.9%
Taylor expanded in x around 0 38.7%
Taylor expanded in eps around inf 73.2%
cancel-sign-sub-inv73.2%
metadata-eval73.2%
*-lft-identity73.2%
mul-1-neg73.2%
distribute-rgt-neg-in73.2%
Simplified73.2%
if -1.09999999999999995e-216 < x < 5900Initial program 59.8%
Simplified59.8%
Taylor expanded in x around 0 50.2%
Taylor expanded in eps around inf 89.1%
mul-1-neg89.1%
*-commutative89.1%
distribute-lft-neg-in89.1%
Simplified89.1%
Taylor expanded in eps around inf 89.5%
if 5900 < x < 1.4e33Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 2.5%
Taylor expanded in x around 0 86.2%
if 1.4e33 < x < 5.80000000000000051e89 or 2.1999999999999999e165 < x < 6.20000000000000001e239Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 38.3%
Taylor expanded in eps around inf 38.6%
mul-1-neg38.6%
*-commutative38.6%
distribute-lft-neg-in38.6%
Simplified38.6%
if 5.80000000000000051e89 < x < 2.1999999999999999e165 or 6.20000000000000001e239 < x < 1.4999999999999999e287Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 72.4%
Simplified72.4%
if 1.4999999999999999e287 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in eps around 0 1.0%
expm1-def1.0%
mul-1-neg1.0%
Simplified1.0%
expm1-log1p-u1.0%
expm1-udef1.3%
expm1-udef1.3%
expm1-udef1.3%
add-sqr-sqrt0.0%
sqrt-unprod100.0%
sqr-neg100.0%
sqrt-unprod100.0%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
Final simplification74.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (/ (+ 1.0 (exp (* x (+ eps -1.0)))) 2.0))
(t_1 (exp (- x)))
(t_2 (/ (/ (- t_1 t_1) eps) 2.0)))
(if (<= x -1.1e-216)
(/ (+ 1.0 (exp (* x (- -1.0 eps)))) 2.0)
(if (<= x 16200.0)
(/ (+ 1.0 (exp (* eps x))) 2.0)
(if (<= x 1.35e+35)
(/ (+ (+ 1.0 (/ 1.0 eps)) (- 1.0 (/ 1.0 eps))) 2.0)
(if (<= x 4.2e+94)
t_0
(if (<= x 1.72e+164)
t_2
(if (<= x 5e+236)
t_0
(if (<= x 1.1e+287) t_2 (/ (/ (expm1 x) eps) 2.0))))))))))
double code(double x, double eps) {
double t_0 = (1.0 + exp((x * (eps + -1.0)))) / 2.0;
double t_1 = exp(-x);
double t_2 = ((t_1 - t_1) / eps) / 2.0;
double tmp;
if (x <= -1.1e-216) {
tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0;
} else if (x <= 16200.0) {
tmp = (1.0 + exp((eps * x))) / 2.0;
} else if (x <= 1.35e+35) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0;
} else if (x <= 4.2e+94) {
tmp = t_0;
} else if (x <= 1.72e+164) {
tmp = t_2;
} else if (x <= 5e+236) {
tmp = t_0;
} else if (x <= 1.1e+287) {
tmp = t_2;
} else {
tmp = (expm1(x) / eps) / 2.0;
}
return tmp;
}
public static double code(double x, double eps) {
double t_0 = (1.0 + Math.exp((x * (eps + -1.0)))) / 2.0;
double t_1 = Math.exp(-x);
double t_2 = ((t_1 - t_1) / eps) / 2.0;
double tmp;
if (x <= -1.1e-216) {
tmp = (1.0 + Math.exp((x * (-1.0 - eps)))) / 2.0;
} else if (x <= 16200.0) {
tmp = (1.0 + Math.exp((eps * x))) / 2.0;
} else if (x <= 1.35e+35) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0;
} else if (x <= 4.2e+94) {
tmp = t_0;
} else if (x <= 1.72e+164) {
tmp = t_2;
} else if (x <= 5e+236) {
tmp = t_0;
} else if (x <= 1.1e+287) {
tmp = t_2;
} else {
tmp = (Math.expm1(x) / eps) / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = (1.0 + math.exp((x * (eps + -1.0)))) / 2.0 t_1 = math.exp(-x) t_2 = ((t_1 - t_1) / eps) / 2.0 tmp = 0 if x <= -1.1e-216: tmp = (1.0 + math.exp((x * (-1.0 - eps)))) / 2.0 elif x <= 16200.0: tmp = (1.0 + math.exp((eps * x))) / 2.0 elif x <= 1.35e+35: tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0 elif x <= 4.2e+94: tmp = t_0 elif x <= 1.72e+164: tmp = t_2 elif x <= 5e+236: tmp = t_0 elif x <= 1.1e+287: tmp = t_2 else: tmp = (math.expm1(x) / eps) / 2.0 return tmp
function code(x, eps) t_0 = Float64(Float64(1.0 + exp(Float64(x * Float64(eps + -1.0)))) / 2.0) t_1 = exp(Float64(-x)) t_2 = Float64(Float64(Float64(t_1 - t_1) / eps) / 2.0) tmp = 0.0 if (x <= -1.1e-216) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps)))) / 2.0); elseif (x <= 16200.0) tmp = Float64(Float64(1.0 + exp(Float64(eps * x))) / 2.0); elseif (x <= 1.35e+35) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) + Float64(1.0 - Float64(1.0 / eps))) / 2.0); elseif (x <= 4.2e+94) tmp = t_0; elseif (x <= 1.72e+164) tmp = t_2; elseif (x <= 5e+236) tmp = t_0; elseif (x <= 1.1e+287) tmp = t_2; else tmp = Float64(Float64(expm1(x) / eps) / 2.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 + N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$1 = N[Exp[(-x)], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(t$95$1 - t$95$1), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[x, -1.1e-216], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 16200.0], N[(N[(1.0 + N[Exp[N[(eps * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.35e+35], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 - N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 4.2e+94], t$95$0, If[LessEqual[x, 1.72e+164], t$95$2, If[LessEqual[x, 5e+236], t$95$0, If[LessEqual[x, 1.1e+287], t$95$2, N[(N[(N[(Exp[x] - 1), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1 + e^{x \cdot \left(\varepsilon + -1\right)}}{2}\\
t_1 := e^{-x}\\
t_2 := \frac{\frac{t_1 - t_1}{\varepsilon}}{2}\\
\mathbf{if}\;x \leq -1.1 \cdot 10^{-216}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - \varepsilon\right)}}{2}\\
\mathbf{elif}\;x \leq 16200:\\
\;\;\;\;\frac{1 + e^{\varepsilon \cdot x}}{2}\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{+35}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) + \left(1 - \frac{1}{\varepsilon}\right)}{2}\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{+94}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.72 \cdot 10^{+164}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 5 \cdot 10^{+236}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{+287}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(x\right)}{\varepsilon}}{2}\\
\end{array}
\end{array}
if x < -1.09999999999999995e-216Initial program 64.9%
Simplified64.9%
Taylor expanded in x around 0 38.7%
Taylor expanded in eps around inf 73.2%
cancel-sign-sub-inv73.2%
metadata-eval73.2%
*-lft-identity73.2%
mul-1-neg73.2%
distribute-rgt-neg-in73.2%
Simplified73.2%
if -1.09999999999999995e-216 < x < 16200Initial program 59.8%
Simplified59.8%
Taylor expanded in x around 0 50.2%
Taylor expanded in eps around inf 89.1%
mul-1-neg89.1%
*-commutative89.1%
distribute-lft-neg-in89.1%
Simplified89.1%
Taylor expanded in eps around inf 89.5%
if 16200 < x < 1.35000000000000001e35Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 2.5%
Taylor expanded in x around 0 86.2%
if 1.35000000000000001e35 < x < 4.19999999999999979e94 or 1.7200000000000001e164 < x < 4.9999999999999997e236Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 38.3%
Taylor expanded in eps around inf 38.6%
mul-1-neg38.6%
*-commutative38.6%
distribute-lft-neg-in38.6%
Simplified38.6%
if 4.19999999999999979e94 < x < 1.7200000000000001e164 or 4.9999999999999997e236 < x < 1.10000000000000002e287Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 72.4%
inv-pow72.4%
Applied egg-rr72.4%
unpow-172.4%
rec-exp72.4%
Simplified72.4%
if 1.10000000000000002e287 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in eps around 0 1.0%
expm1-def1.0%
mul-1-neg1.0%
Simplified1.0%
expm1-log1p-u1.0%
expm1-udef1.3%
expm1-udef1.3%
expm1-udef1.3%
add-sqr-sqrt0.0%
sqrt-unprod100.0%
sqr-neg100.0%
sqrt-unprod100.0%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
Simplified100.0%
Final simplification74.3%
(FPCore (x eps)
:precision binary64
(if (<= x -490.0)
(/ (/ (expm1 (- x)) eps) 2.0)
(if (<= x 0.19)
1.0
(if (or (<= x 2.25e+165) (and (not (<= x 4.1e+222)) (<= x 1.25e+287)))
(/ (+ (+ 1.0 (/ 1.0 eps)) (- 1.0 (/ 1.0 eps))) 2.0)
(/ (/ (expm1 x) eps) 2.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -490.0) {
tmp = (expm1(-x) / eps) / 2.0;
} else if (x <= 0.19) {
tmp = 1.0;
} else if ((x <= 2.25e+165) || (!(x <= 4.1e+222) && (x <= 1.25e+287))) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0;
} else {
tmp = (expm1(x) / eps) / 2.0;
}
return tmp;
}
public static double code(double x, double eps) {
double tmp;
if (x <= -490.0) {
tmp = (Math.expm1(-x) / eps) / 2.0;
} else if (x <= 0.19) {
tmp = 1.0;
} else if ((x <= 2.25e+165) || (!(x <= 4.1e+222) && (x <= 1.25e+287))) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0;
} else {
tmp = (Math.expm1(x) / eps) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -490.0: tmp = (math.expm1(-x) / eps) / 2.0 elif x <= 0.19: tmp = 1.0 elif (x <= 2.25e+165) or (not (x <= 4.1e+222) and (x <= 1.25e+287)): tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0 else: tmp = (math.expm1(x) / eps) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -490.0) tmp = Float64(Float64(expm1(Float64(-x)) / eps) / 2.0); elseif (x <= 0.19) tmp = 1.0; elseif ((x <= 2.25e+165) || (!(x <= 4.1e+222) && (x <= 1.25e+287))) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) + Float64(1.0 - Float64(1.0 / eps))) / 2.0); else tmp = Float64(Float64(expm1(x) / eps) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -490.0], N[(N[(N[(Exp[(-x)] - 1), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 0.19], 1.0, If[Or[LessEqual[x, 2.25e+165], And[N[Not[LessEqual[x, 4.1e+222]], $MachinePrecision], LessEqual[x, 1.25e+287]]], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 - N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(Exp[x] - 1), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -490:\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(-x\right)}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq 0.19:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 2.25 \cdot 10^{+165} \lor \neg \left(x \leq 4.1 \cdot 10^{+222}\right) \land x \leq 1.25 \cdot 10^{+287}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) + \left(1 - \frac{1}{\varepsilon}\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(x\right)}{\varepsilon}}{2}\\
\end{array}
\end{array}
if x < -490Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 49.9%
Taylor expanded in eps around 0 51.7%
expm1-def51.7%
mul-1-neg51.7%
Simplified51.7%
if -490 < x < 0.19Initial program 54.6%
Simplified54.6%
Taylor expanded in x around 0 76.1%
if 0.19 < x < 2.2499999999999998e165 or 4.09999999999999987e222 < x < 1.25e287Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 20.2%
Taylor expanded in x around 0 57.7%
if 2.2499999999999998e165 < x < 4.09999999999999987e222 or 1.25e287 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 53.5%
Taylor expanded in eps around 0 1.7%
expm1-def1.7%
mul-1-neg1.7%
Simplified1.7%
expm1-log1p-u1.5%
expm1-udef1.5%
expm1-udef1.5%
expm1-udef1.5%
add-sqr-sqrt0.0%
sqrt-unprod52.3%
sqr-neg52.3%
sqrt-unprod52.3%
add-sqr-sqrt52.3%
Applied egg-rr52.3%
expm1-def52.3%
expm1-log1p52.5%
Simplified52.5%
Final simplification67.2%
(FPCore (x eps)
:precision binary64
(if (<= x -1.1e-216)
(/ (+ 1.0 (exp (* x (- -1.0 eps)))) 2.0)
(if (<= x 1050.0)
(/ (+ 1.0 (exp (* eps x))) 2.0)
(if (<= x 1.72e+164)
(/ (+ (+ 1.0 (/ 1.0 eps)) (- 1.0 (/ 1.0 eps))) 2.0)
(/ (+ 1.0 (exp (* x (+ eps -1.0)))) 2.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -1.1e-216) {
tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0;
} else if (x <= 1050.0) {
tmp = (1.0 + exp((eps * x))) / 2.0;
} else if (x <= 1.72e+164) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0;
} else {
tmp = (1.0 + exp((x * (eps + -1.0)))) / 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.1d-216)) then
tmp = (1.0d0 + exp((x * ((-1.0d0) - eps)))) / 2.0d0
else if (x <= 1050.0d0) then
tmp = (1.0d0 + exp((eps * x))) / 2.0d0
else if (x <= 1.72d+164) then
tmp = ((1.0d0 + (1.0d0 / eps)) + (1.0d0 - (1.0d0 / eps))) / 2.0d0
else
tmp = (1.0d0 + exp((x * (eps + (-1.0d0))))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -1.1e-216) {
tmp = (1.0 + Math.exp((x * (-1.0 - eps)))) / 2.0;
} else if (x <= 1050.0) {
tmp = (1.0 + Math.exp((eps * x))) / 2.0;
} else if (x <= 1.72e+164) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0;
} else {
tmp = (1.0 + Math.exp((x * (eps + -1.0)))) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -1.1e-216: tmp = (1.0 + math.exp((x * (-1.0 - eps)))) / 2.0 elif x <= 1050.0: tmp = (1.0 + math.exp((eps * x))) / 2.0 elif x <= 1.72e+164: tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0 else: tmp = (1.0 + math.exp((x * (eps + -1.0)))) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -1.1e-216) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps)))) / 2.0); elseif (x <= 1050.0) tmp = Float64(Float64(1.0 + exp(Float64(eps * x))) / 2.0); elseif (x <= 1.72e+164) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) + Float64(1.0 - Float64(1.0 / eps))) / 2.0); else tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(eps + -1.0)))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -1.1e-216) tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0; elseif (x <= 1050.0) tmp = (1.0 + exp((eps * x))) / 2.0; elseif (x <= 1.72e+164) tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0; else tmp = (1.0 + exp((x * (eps + -1.0)))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -1.1e-216], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1050.0], N[(N[(1.0 + N[Exp[N[(eps * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.72e+164], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 - N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(1.0 + N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.1 \cdot 10^{-216}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - \varepsilon\right)}}{2}\\
\mathbf{elif}\;x \leq 1050:\\
\;\;\;\;\frac{1 + e^{\varepsilon \cdot x}}{2}\\
\mathbf{elif}\;x \leq 1.72 \cdot 10^{+164}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) + \left(1 - \frac{1}{\varepsilon}\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(\varepsilon + -1\right)}}{2}\\
\end{array}
\end{array}
if x < -1.09999999999999995e-216Initial program 64.9%
Simplified64.9%
Taylor expanded in x around 0 38.7%
Taylor expanded in eps around inf 73.2%
cancel-sign-sub-inv73.2%
metadata-eval73.2%
*-lft-identity73.2%
mul-1-neg73.2%
distribute-rgt-neg-in73.2%
Simplified73.2%
if -1.09999999999999995e-216 < x < 1050Initial program 59.8%
Simplified59.8%
Taylor expanded in x around 0 50.2%
Taylor expanded in eps around inf 89.1%
mul-1-neg89.1%
*-commutative89.1%
distribute-lft-neg-in89.1%
Simplified89.1%
Taylor expanded in eps around inf 89.5%
if 1050 < x < 1.7200000000000001e164Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 17.3%
Taylor expanded in x around 0 58.9%
if 1.7200000000000001e164 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 38.0%
Taylor expanded in eps around inf 38.4%
mul-1-neg38.4%
*-commutative38.4%
distribute-lft-neg-in38.4%
Simplified38.4%
Final simplification71.4%
(FPCore (x eps)
:precision binary64
(if (<= x 0.19)
(/ (+ 2.0 (* x (- -1.0 eps))) 2.0)
(if (or (<= x 3.25e+165) (and (not (<= x 2.9e+222)) (<= x 1.5e+287)))
(/ (+ (+ 1.0 (/ 1.0 eps)) (- 1.0 (/ 1.0 eps))) 2.0)
(/ (/ (expm1 x) eps) 2.0))))
double code(double x, double eps) {
double tmp;
if (x <= 0.19) {
tmp = (2.0 + (x * (-1.0 - eps))) / 2.0;
} else if ((x <= 3.25e+165) || (!(x <= 2.9e+222) && (x <= 1.5e+287))) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0;
} else {
tmp = (expm1(x) / eps) / 2.0;
}
return tmp;
}
public static double code(double x, double eps) {
double tmp;
if (x <= 0.19) {
tmp = (2.0 + (x * (-1.0 - eps))) / 2.0;
} else if ((x <= 3.25e+165) || (!(x <= 2.9e+222) && (x <= 1.5e+287))) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0;
} else {
tmp = (Math.expm1(x) / eps) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 0.19: tmp = (2.0 + (x * (-1.0 - eps))) / 2.0 elif (x <= 3.25e+165) or (not (x <= 2.9e+222) and (x <= 1.5e+287)): tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0 else: tmp = (math.expm1(x) / eps) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 0.19) tmp = Float64(Float64(2.0 + Float64(x * Float64(-1.0 - eps))) / 2.0); elseif ((x <= 3.25e+165) || (!(x <= 2.9e+222) && (x <= 1.5e+287))) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) + Float64(1.0 - Float64(1.0 / eps))) / 2.0); else tmp = Float64(Float64(expm1(x) / eps) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, 0.19], N[(N[(2.0 + N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 3.25e+165], And[N[Not[LessEqual[x, 2.9e+222]], $MachinePrecision], LessEqual[x, 1.5e+287]]], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 - N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(Exp[x] - 1), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.19:\\
\;\;\;\;\frac{2 + x \cdot \left(-1 - \varepsilon\right)}{2}\\
\mathbf{elif}\;x \leq 3.25 \cdot 10^{+165} \lor \neg \left(x \leq 2.9 \cdot 10^{+222}\right) \land x \leq 1.5 \cdot 10^{+287}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) + \left(1 - \frac{1}{\varepsilon}\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(x\right)}{\varepsilon}}{2}\\
\end{array}
\end{array}
if x < 0.19Initial program 62.0%
Simplified62.0%
Taylor expanded in x around 0 42.2%
Taylor expanded in eps around inf 79.3%
cancel-sign-sub-inv79.3%
metadata-eval79.3%
*-lft-identity79.3%
mul-1-neg79.3%
distribute-rgt-neg-in79.3%
Simplified79.3%
Taylor expanded in x around 0 67.0%
if 0.19 < x < 3.2499999999999999e165 or 2.89999999999999981e222 < x < 1.4999999999999999e287Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 20.2%
Taylor expanded in x around 0 57.7%
if 3.2499999999999999e165 < x < 2.89999999999999981e222 or 1.4999999999999999e287 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 53.5%
Taylor expanded in eps around 0 1.7%
expm1-def1.7%
mul-1-neg1.7%
Simplified1.7%
expm1-log1p-u1.5%
expm1-udef1.5%
expm1-udef1.5%
expm1-udef1.5%
add-sqr-sqrt0.0%
sqrt-unprod52.3%
sqr-neg52.3%
sqrt-unprod52.3%
add-sqr-sqrt52.3%
Applied egg-rr52.3%
expm1-def52.3%
expm1-log1p52.5%
Simplified52.5%
Final simplification63.7%
(FPCore (x eps)
:precision binary64
(if (<= x -420.0)
(/ (/ (expm1 (- x)) eps) 2.0)
(if (or (<= x 3350.0) (not (<= x 1.72e+164)))
(/ (+ 1.0 (exp (* eps x))) 2.0)
(/ (+ (+ 1.0 (/ 1.0 eps)) (- 1.0 (/ 1.0 eps))) 2.0))))
double code(double x, double eps) {
double tmp;
if (x <= -420.0) {
tmp = (expm1(-x) / eps) / 2.0;
} else if ((x <= 3350.0) || !(x <= 1.72e+164)) {
tmp = (1.0 + exp((eps * x))) / 2.0;
} else {
tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0;
}
return tmp;
}
public static double code(double x, double eps) {
double tmp;
if (x <= -420.0) {
tmp = (Math.expm1(-x) / eps) / 2.0;
} else if ((x <= 3350.0) || !(x <= 1.72e+164)) {
tmp = (1.0 + Math.exp((eps * x))) / 2.0;
} else {
tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -420.0: tmp = (math.expm1(-x) / eps) / 2.0 elif (x <= 3350.0) or not (x <= 1.72e+164): tmp = (1.0 + math.exp((eps * x))) / 2.0 else: tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -420.0) tmp = Float64(Float64(expm1(Float64(-x)) / eps) / 2.0); elseif ((x <= 3350.0) || !(x <= 1.72e+164)) tmp = Float64(Float64(1.0 + exp(Float64(eps * x))) / 2.0); else tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) + Float64(1.0 - Float64(1.0 / eps))) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -420.0], N[(N[(N[(Exp[(-x)] - 1), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 3350.0], N[Not[LessEqual[x, 1.72e+164]], $MachinePrecision]], N[(N[(1.0 + N[Exp[N[(eps * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 - N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -420:\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(-x\right)}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq 3350 \lor \neg \left(x \leq 1.72 \cdot 10^{+164}\right):\\
\;\;\;\;\frac{1 + e^{\varepsilon \cdot x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) + \left(1 - \frac{1}{\varepsilon}\right)}{2}\\
\end{array}
\end{array}
if x < -420Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 49.9%
Taylor expanded in eps around 0 51.7%
expm1-def51.7%
mul-1-neg51.7%
Simplified51.7%
if -420 < x < 3350 or 1.7200000000000001e164 < x Initial program 65.1%
Simplified65.1%
Taylor expanded in x around 0 43.9%
Taylor expanded in eps around inf 78.0%
mul-1-neg78.0%
*-commutative78.0%
distribute-lft-neg-in78.0%
Simplified78.0%
Taylor expanded in eps around inf 78.4%
if 3350 < x < 1.7200000000000001e164Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 17.3%
Taylor expanded in x around 0 58.9%
Final simplification72.8%
(FPCore (x eps)
:precision binary64
(if (<= x -1.1e-216)
(/ (+ 1.0 (exp (* x (- -1.0 eps)))) 2.0)
(if (or (<= x 12400.0) (not (<= x 2.25e+164)))
(/ (+ 1.0 (exp (* eps x))) 2.0)
(/ (+ (+ 1.0 (/ 1.0 eps)) (- 1.0 (/ 1.0 eps))) 2.0))))
double code(double x, double eps) {
double tmp;
if (x <= -1.1e-216) {
tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0;
} else if ((x <= 12400.0) || !(x <= 2.25e+164)) {
tmp = (1.0 + exp((eps * x))) / 2.0;
} else {
tmp = ((1.0 + (1.0 / eps)) + (1.0 - (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) :: tmp
if (x <= (-1.1d-216)) then
tmp = (1.0d0 + exp((x * ((-1.0d0) - eps)))) / 2.0d0
else if ((x <= 12400.0d0) .or. (.not. (x <= 2.25d+164))) then
tmp = (1.0d0 + exp((eps * x))) / 2.0d0
else
tmp = ((1.0d0 + (1.0d0 / eps)) + (1.0d0 - (1.0d0 / eps))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -1.1e-216) {
tmp = (1.0 + Math.exp((x * (-1.0 - eps)))) / 2.0;
} else if ((x <= 12400.0) || !(x <= 2.25e+164)) {
tmp = (1.0 + Math.exp((eps * x))) / 2.0;
} else {
tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -1.1e-216: tmp = (1.0 + math.exp((x * (-1.0 - eps)))) / 2.0 elif (x <= 12400.0) or not (x <= 2.25e+164): tmp = (1.0 + math.exp((eps * x))) / 2.0 else: tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -1.1e-216) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps)))) / 2.0); elseif ((x <= 12400.0) || !(x <= 2.25e+164)) tmp = Float64(Float64(1.0 + exp(Float64(eps * x))) / 2.0); else tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) + Float64(1.0 - Float64(1.0 / eps))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -1.1e-216) tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0; elseif ((x <= 12400.0) || ~((x <= 2.25e+164))) tmp = (1.0 + exp((eps * x))) / 2.0; else tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -1.1e-216], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 12400.0], N[Not[LessEqual[x, 2.25e+164]], $MachinePrecision]], N[(N[(1.0 + N[Exp[N[(eps * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 - N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.1 \cdot 10^{-216}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - \varepsilon\right)}}{2}\\
\mathbf{elif}\;x \leq 12400 \lor \neg \left(x \leq 2.25 \cdot 10^{+164}\right):\\
\;\;\;\;\frac{1 + e^{\varepsilon \cdot x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) + \left(1 - \frac{1}{\varepsilon}\right)}{2}\\
\end{array}
\end{array}
if x < -1.09999999999999995e-216Initial program 64.9%
Simplified64.9%
Taylor expanded in x around 0 38.7%
Taylor expanded in eps around inf 73.2%
cancel-sign-sub-inv73.2%
metadata-eval73.2%
*-lft-identity73.2%
mul-1-neg73.2%
distribute-rgt-neg-in73.2%
Simplified73.2%
if -1.09999999999999995e-216 < x < 12400 or 2.24999999999999988e164 < x Initial program 72.6%
Simplified72.6%
Taylor expanded in x around 0 46.3%
Taylor expanded in eps around inf 72.9%
mul-1-neg72.9%
*-commutative72.9%
distribute-lft-neg-in72.9%
Simplified72.9%
Taylor expanded in eps around inf 73.2%
if 12400 < x < 2.24999999999999988e164Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 17.3%
Taylor expanded in x around 0 58.9%
Final simplification71.3%
(FPCore (x eps)
:precision binary64
(if (<= x 0.19)
(/ (+ 2.0 (* x (- -1.0 eps))) 2.0)
(if (or (<= x 2.75e+194) (not (<= x 1.9e+222)))
(/ (+ (+ 1.0 (/ 1.0 eps)) (- 1.0 (/ 1.0 eps))) 2.0)
(/ (+ 2.0 (* eps x)) 2.0))))
double code(double x, double eps) {
double tmp;
if (x <= 0.19) {
tmp = (2.0 + (x * (-1.0 - eps))) / 2.0;
} else if ((x <= 2.75e+194) || !(x <= 1.9e+222)) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0;
} else {
tmp = (2.0 + (eps * 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 <= 0.19d0) then
tmp = (2.0d0 + (x * ((-1.0d0) - eps))) / 2.0d0
else if ((x <= 2.75d+194) .or. (.not. (x <= 1.9d+222))) then
tmp = ((1.0d0 + (1.0d0 / eps)) + (1.0d0 - (1.0d0 / eps))) / 2.0d0
else
tmp = (2.0d0 + (eps * x)) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 0.19) {
tmp = (2.0 + (x * (-1.0 - eps))) / 2.0;
} else if ((x <= 2.75e+194) || !(x <= 1.9e+222)) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0;
} else {
tmp = (2.0 + (eps * x)) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 0.19: tmp = (2.0 + (x * (-1.0 - eps))) / 2.0 elif (x <= 2.75e+194) or not (x <= 1.9e+222): tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0 else: tmp = (2.0 + (eps * x)) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 0.19) tmp = Float64(Float64(2.0 + Float64(x * Float64(-1.0 - eps))) / 2.0); elseif ((x <= 2.75e+194) || !(x <= 1.9e+222)) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) + Float64(1.0 - Float64(1.0 / eps))) / 2.0); else tmp = Float64(Float64(2.0 + Float64(eps * x)) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 0.19) tmp = (2.0 + (x * (-1.0 - eps))) / 2.0; elseif ((x <= 2.75e+194) || ~((x <= 1.9e+222))) tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0; else tmp = (2.0 + (eps * x)) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 0.19], N[(N[(2.0 + N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 2.75e+194], N[Not[LessEqual[x, 1.9e+222]], $MachinePrecision]], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 - N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(2.0 + N[(eps * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.19:\\
\;\;\;\;\frac{2 + x \cdot \left(-1 - \varepsilon\right)}{2}\\
\mathbf{elif}\;x \leq 2.75 \cdot 10^{+194} \lor \neg \left(x \leq 1.9 \cdot 10^{+222}\right):\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) + \left(1 - \frac{1}{\varepsilon}\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + \varepsilon \cdot x}{2}\\
\end{array}
\end{array}
if x < 0.19Initial program 62.0%
Simplified62.0%
Taylor expanded in x around 0 42.2%
Taylor expanded in eps around inf 79.3%
cancel-sign-sub-inv79.3%
metadata-eval79.3%
*-lft-identity79.3%
mul-1-neg79.3%
distribute-rgt-neg-in79.3%
Simplified79.3%
Taylor expanded in x around 0 67.0%
if 0.19 < x < 2.75e194 or 1.90000000000000009e222 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 26.2%
Taylor expanded in x around 0 51.6%
if 2.75e194 < x < 1.90000000000000009e222Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 63.7%
Taylor expanded in eps around inf 63.7%
mul-1-neg63.7%
*-commutative63.7%
distribute-lft-neg-in63.7%
Simplified63.7%
Taylor expanded in eps around inf 63.7%
Taylor expanded in eps around 0 27.7%
Final simplification61.5%
(FPCore (x eps)
:precision binary64
(if (<= x 0.19)
(/ (+ 2.0 (* x (- -1.0 eps))) 2.0)
(if (or (<= x 1.1e+193) (not (<= x 2.8e+220)))
(/ (+ (+ 1.0 (/ 1.0 eps)) (/ -1.0 eps)) 2.0)
(/ (+ 2.0 (* eps x)) 2.0))))
double code(double x, double eps) {
double tmp;
if (x <= 0.19) {
tmp = (2.0 + (x * (-1.0 - eps))) / 2.0;
} else if ((x <= 1.1e+193) || !(x <= 2.8e+220)) {
tmp = ((1.0 + (1.0 / eps)) + (-1.0 / eps)) / 2.0;
} else {
tmp = (2.0 + (eps * 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 <= 0.19d0) then
tmp = (2.0d0 + (x * ((-1.0d0) - eps))) / 2.0d0
else if ((x <= 1.1d+193) .or. (.not. (x <= 2.8d+220))) then
tmp = ((1.0d0 + (1.0d0 / eps)) + ((-1.0d0) / eps)) / 2.0d0
else
tmp = (2.0d0 + (eps * x)) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 0.19) {
tmp = (2.0 + (x * (-1.0 - eps))) / 2.0;
} else if ((x <= 1.1e+193) || !(x <= 2.8e+220)) {
tmp = ((1.0 + (1.0 / eps)) + (-1.0 / eps)) / 2.0;
} else {
tmp = (2.0 + (eps * x)) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 0.19: tmp = (2.0 + (x * (-1.0 - eps))) / 2.0 elif (x <= 1.1e+193) or not (x <= 2.8e+220): tmp = ((1.0 + (1.0 / eps)) + (-1.0 / eps)) / 2.0 else: tmp = (2.0 + (eps * x)) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 0.19) tmp = Float64(Float64(2.0 + Float64(x * Float64(-1.0 - eps))) / 2.0); elseif ((x <= 1.1e+193) || !(x <= 2.8e+220)) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) + Float64(-1.0 / eps)) / 2.0); else tmp = Float64(Float64(2.0 + Float64(eps * x)) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 0.19) tmp = (2.0 + (x * (-1.0 - eps))) / 2.0; elseif ((x <= 1.1e+193) || ~((x <= 2.8e+220))) tmp = ((1.0 + (1.0 / eps)) + (-1.0 / eps)) / 2.0; else tmp = (2.0 + (eps * x)) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 0.19], N[(N[(2.0 + N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 1.1e+193], N[Not[LessEqual[x, 2.8e+220]], $MachinePrecision]], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(2.0 + N[(eps * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.19:\\
\;\;\;\;\frac{2 + x \cdot \left(-1 - \varepsilon\right)}{2}\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{+193} \lor \neg \left(x \leq 2.8 \cdot 10^{+220}\right):\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) + \frac{-1}{\varepsilon}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + \varepsilon \cdot x}{2}\\
\end{array}
\end{array}
if x < 0.19Initial program 62.0%
Simplified62.0%
Taylor expanded in x around 0 42.2%
Taylor expanded in eps around inf 79.3%
cancel-sign-sub-inv79.3%
metadata-eval79.3%
*-lft-identity79.3%
mul-1-neg79.3%
distribute-rgt-neg-in79.3%
Simplified79.3%
Taylor expanded in x around 0 67.0%
if 0.19 < x < 1.09999999999999993e193 or 2.8000000000000001e220 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 26.2%
Taylor expanded in x around 0 51.6%
Taylor expanded in eps around 0 51.6%
if 1.09999999999999993e193 < x < 2.8000000000000001e220Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 63.7%
Taylor expanded in eps around inf 63.7%
mul-1-neg63.7%
*-commutative63.7%
distribute-lft-neg-in63.7%
Simplified63.7%
Taylor expanded in eps around inf 63.7%
Taylor expanded in eps around 0 27.7%
Final simplification61.5%
(FPCore (x eps) :precision binary64 (if (<= x -0.00064) (/ (* x (- -1.0 eps)) 2.0) 1.0))
double code(double x, double eps) {
double tmp;
if (x <= -0.00064) {
tmp = (x * (-1.0 - eps)) / 2.0;
} else {
tmp = 1.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.00064d0)) then
tmp = (x * ((-1.0d0) - eps)) / 2.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -0.00064) {
tmp = (x * (-1.0 - eps)) / 2.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -0.00064: tmp = (x * (-1.0 - eps)) / 2.0 else: tmp = 1.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -0.00064) tmp = Float64(Float64(x * Float64(-1.0 - eps)) / 2.0); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -0.00064) tmp = (x * (-1.0 - eps)) / 2.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -0.00064], N[(N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.00064:\\
\;\;\;\;\frac{x \cdot \left(-1 - \varepsilon\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -6.40000000000000052e-4Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 50.1%
Taylor expanded in eps around inf 50.1%
cancel-sign-sub-inv50.1%
metadata-eval50.1%
*-lft-identity50.1%
mul-1-neg50.1%
distribute-rgt-neg-in50.1%
Simplified50.1%
Taylor expanded in x around 0 23.1%
Taylor expanded in x around inf 23.1%
neg-mul-123.1%
distribute-rgt-neg-in23.1%
distribute-neg-in23.1%
metadata-eval23.1%
unsub-neg23.1%
Simplified23.1%
if -6.40000000000000052e-4 < x Initial program 69.7%
Simplified69.7%
Taylor expanded in x around 0 51.9%
Final simplification48.1%
(FPCore (x eps) :precision binary64 (if (<= x -0.00064) (/ (* x (- -1.0 eps)) 2.0) (/ (+ 2.0 (* eps x)) 2.0)))
double code(double x, double eps) {
double tmp;
if (x <= -0.00064) {
tmp = (x * (-1.0 - eps)) / 2.0;
} else {
tmp = (2.0 + (eps * 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 <= (-0.00064d0)) then
tmp = (x * ((-1.0d0) - eps)) / 2.0d0
else
tmp = (2.0d0 + (eps * x)) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -0.00064) {
tmp = (x * (-1.0 - eps)) / 2.0;
} else {
tmp = (2.0 + (eps * x)) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -0.00064: tmp = (x * (-1.0 - eps)) / 2.0 else: tmp = (2.0 + (eps * x)) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -0.00064) tmp = Float64(Float64(x * Float64(-1.0 - eps)) / 2.0); else tmp = Float64(Float64(2.0 + Float64(eps * x)) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -0.00064) tmp = (x * (-1.0 - eps)) / 2.0; else tmp = (2.0 + (eps * x)) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -0.00064], N[(N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(2.0 + N[(eps * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.00064:\\
\;\;\;\;\frac{x \cdot \left(-1 - \varepsilon\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + \varepsilon \cdot x}{2}\\
\end{array}
\end{array}
if x < -6.40000000000000052e-4Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 50.1%
Taylor expanded in eps around inf 50.1%
cancel-sign-sub-inv50.1%
metadata-eval50.1%
*-lft-identity50.1%
mul-1-neg50.1%
distribute-rgt-neg-in50.1%
Simplified50.1%
Taylor expanded in x around 0 23.1%
Taylor expanded in x around inf 23.1%
neg-mul-123.1%
distribute-rgt-neg-in23.1%
distribute-neg-in23.1%
metadata-eval23.1%
unsub-neg23.1%
Simplified23.1%
if -6.40000000000000052e-4 < x Initial program 69.7%
Simplified69.7%
Taylor expanded in x around 0 39.4%
Taylor expanded in eps around inf 69.1%
mul-1-neg69.1%
*-commutative69.1%
distribute-lft-neg-in69.1%
Simplified69.1%
Taylor expanded in eps around inf 69.4%
Taylor expanded in eps around 0 55.5%
Final simplification51.3%
(FPCore (x eps) :precision binary64 (if (<= x -0.00064) (/ (* eps (- x)) 2.0) 1.0))
double code(double x, double eps) {
double tmp;
if (x <= -0.00064) {
tmp = (eps * -x) / 2.0;
} else {
tmp = 1.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.00064d0)) then
tmp = (eps * -x) / 2.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -0.00064) {
tmp = (eps * -x) / 2.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -0.00064: tmp = (eps * -x) / 2.0 else: tmp = 1.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -0.00064) tmp = Float64(Float64(eps * Float64(-x)) / 2.0); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -0.00064) tmp = (eps * -x) / 2.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -0.00064], N[(N[(eps * (-x)), $MachinePrecision] / 2.0), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.00064:\\
\;\;\;\;\frac{\varepsilon \cdot \left(-x\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -6.40000000000000052e-4Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 50.1%
Taylor expanded in eps around inf 50.1%
cancel-sign-sub-inv50.1%
metadata-eval50.1%
*-lft-identity50.1%
mul-1-neg50.1%
distribute-rgt-neg-in50.1%
Simplified50.1%
Taylor expanded in x around 0 23.1%
Taylor expanded in eps around inf 23.1%
neg-mul-123.1%
distribute-rgt-neg-in23.1%
Simplified23.1%
if -6.40000000000000052e-4 < x Initial program 69.7%
Simplified69.7%
Taylor expanded in x around 0 51.9%
Final simplification48.1%
(FPCore (x eps) :precision binary64 1.0)
double code(double x, double eps) {
return 1.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 1.0d0
end function
public static double code(double x, double eps) {
return 1.0;
}
def code(x, eps): return 1.0
function code(x, eps) return 1.0 end
function tmp = code(x, eps) tmp = 1.0; end
code[x_, eps_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 73.6%
Simplified73.6%
Taylor expanded in x around 0 45.6%
Final simplification45.6%
herbie shell --seed 2023331
(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))