
(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 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))
double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0
end function
public static double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-((1.0 + eps) * x)))) / 2.0;
}
def code(x, eps): return (((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-((1.0 + eps) * x)))) / 2.0
function code(x, eps) return Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(-Float64(Float64(1.0 - eps) * x)))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * exp(Float64(-Float64(Float64(1.0 + eps) * x))))) / 2.0) end
function tmp = code(x, eps) tmp = (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0; end
code[x_, eps_] := N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}
\end{array}
(FPCore (x eps) :precision binary64 (/ (+ (exp (- (* eps x) x)) (/ 1.0 (exp (fma eps x x)))) 2.0))
double code(double x, double eps) {
return (exp(((eps * x) - x)) + (1.0 / exp(fma(eps, x, x)))) / 2.0;
}
function code(x, eps) return Float64(Float64(exp(Float64(Float64(eps * x) - x)) + Float64(1.0 / exp(fma(eps, x, x)))) / 2.0) end
code[x_, eps_] := N[(N[(N[Exp[N[(N[(eps * x), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision] + N[(1.0 / N[Exp[N[(eps * x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{\varepsilon \cdot x - x} + \frac{1}{e^{\mathsf{fma}\left(\varepsilon, x, x\right)}}}{2}
\end{array}
Initial program 74.6%
Simplified74.6%
Taylor expanded in eps around inf 99.3%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (if (<= eps 1.8e-93) (/ (+ (exp (- x)) (+ x (- 1.0 x))) 2.0) (/ (+ (exp (- (* eps x) x)) (exp (* eps (- x)))) 2.0)))
double code(double x, double eps) {
double tmp;
if (eps <= 1.8e-93) {
tmp = (exp(-x) + (x + (1.0 - x))) / 2.0;
} else {
tmp = (exp(((eps * x) - x)) + exp((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 (eps <= 1.8d-93) then
tmp = (exp(-x) + (x + (1.0d0 - x))) / 2.0d0
else
tmp = (exp(((eps * x) - x)) + exp((eps * -x))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= 1.8e-93) {
tmp = (Math.exp(-x) + (x + (1.0 - x))) / 2.0;
} else {
tmp = (Math.exp(((eps * x) - x)) + Math.exp((eps * -x))) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= 1.8e-93: tmp = (math.exp(-x) + (x + (1.0 - x))) / 2.0 else: tmp = (math.exp(((eps * x) - x)) + math.exp((eps * -x))) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (eps <= 1.8e-93) tmp = Float64(Float64(exp(Float64(-x)) + Float64(x + Float64(1.0 - x))) / 2.0); else tmp = Float64(Float64(exp(Float64(Float64(eps * x) - x)) + exp(Float64(eps * Float64(-x)))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= 1.8e-93) tmp = (exp(-x) + (x + (1.0 - x))) / 2.0; else tmp = (exp(((eps * x) - x)) + exp((eps * -x))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, 1.8e-93], N[(N[(N[Exp[(-x)], $MachinePrecision] + N[(x + N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(N[(eps * x), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(eps * (-x)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 1.8 \cdot 10^{-93}:\\
\;\;\;\;\frac{e^{-x} + \left(x + \left(1 - x\right)\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{\varepsilon \cdot x - x} + e^{\varepsilon \cdot \left(-x\right)}}{2}\\
\end{array}
\end{array}
if eps < 1.8000000000000001e-93Initial program 63.2%
Simplified63.2%
Taylor expanded in x around 0 27.5%
associate-*r*27.5%
mul-1-neg27.5%
distribute-lft-out27.5%
*-rgt-identity27.5%
cancel-sign-sub-inv27.5%
Simplified27.5%
Taylor expanded in eps around inf 63.2%
Taylor expanded in eps around 0 79.1%
mul-1-neg79.1%
distribute-lft-in79.1%
*-lft-identity79.1%
cancel-sign-sub-inv79.1%
metadata-eval79.1%
*-lft-identity79.1%
*-lft-identity79.1%
Simplified79.1%
if 1.8000000000000001e-93 < eps Initial program 90.8%
Simplified90.9%
Taylor expanded in eps around inf 99.3%
div-inv99.3%
rec-exp99.3%
fma-udef99.3%
*-commutative99.3%
distribute-neg-in99.3%
+-commutative99.3%
sub-neg99.3%
neg-mul-199.3%
*-commutative99.3%
distribute-rgt-out--99.3%
Applied egg-rr99.3%
*-lft-identity99.3%
Simplified99.3%
Taylor expanded in eps around inf 99.3%
mul-1-neg99.3%
*-commutative99.3%
Simplified99.3%
Final simplification87.5%
(FPCore (x eps) :precision binary64 (/ (+ (exp (- (* eps x) x)) (exp (* x (- -1.0 eps)))) 2.0))
double code(double x, double eps) {
return (exp(((eps * x) - x)) + exp((x * (-1.0 - eps)))) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (exp(((eps * x) - x)) + exp((x * ((-1.0d0) - eps)))) / 2.0d0
end function
public static double code(double x, double eps) {
return (Math.exp(((eps * x) - x)) + Math.exp((x * (-1.0 - eps)))) / 2.0;
}
def code(x, eps): return (math.exp(((eps * x) - x)) + math.exp((x * (-1.0 - eps)))) / 2.0
function code(x, eps) return Float64(Float64(exp(Float64(Float64(eps * x) - x)) + exp(Float64(x * Float64(-1.0 - eps)))) / 2.0) end
function tmp = code(x, eps) tmp = (exp(((eps * x) - x)) + exp((x * (-1.0 - eps)))) / 2.0; end
code[x_, eps_] := N[(N[(N[Exp[N[(N[(eps * x), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{\varepsilon \cdot x - x} + e^{x \cdot \left(-1 - \varepsilon\right)}}{2}
\end{array}
Initial program 74.6%
Simplified74.6%
Taylor expanded in eps around inf 99.3%
div-inv99.3%
rec-exp99.3%
fma-udef99.3%
*-commutative99.3%
distribute-neg-in99.3%
+-commutative99.3%
sub-neg99.3%
neg-mul-199.3%
*-commutative99.3%
distribute-rgt-out--99.3%
Applied egg-rr99.3%
*-lft-identity99.3%
Simplified99.3%
Final simplification99.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ 1.0 (/ 1.0 eps))) (t_1 (exp (- x))))
(if (<= x -250000000.0)
(/ (+ 1.0 t_1) 2.0)
(if (<= x -1.55e-162)
(/
(+ 2.0 (fma 0.5 (* (* (* x x) t_0) (* eps eps)) (* eps (* x t_0))))
2.0)
(if (<= x 9e+60)
(/ (+ 1.0 (exp (* eps x))) 2.0)
(if (<= x 7e+253)
(/
(+ (* t_0 (exp (* x (+ eps -1.0)))) (+ x (- (- 1.0 x) (* eps x))))
2.0)
(if (<= x 2.8e+283)
(/ (+ (exp (- (* eps x) x)) 1.0) 2.0)
(/ (+ t_1 (+ x (- 1.0 x))) 2.0))))))))
double code(double x, double eps) {
double t_0 = 1.0 + (1.0 / eps);
double t_1 = exp(-x);
double tmp;
if (x <= -250000000.0) {
tmp = (1.0 + t_1) / 2.0;
} else if (x <= -1.55e-162) {
tmp = (2.0 + fma(0.5, (((x * x) * t_0) * (eps * eps)), (eps * (x * t_0)))) / 2.0;
} else if (x <= 9e+60) {
tmp = (1.0 + exp((eps * x))) / 2.0;
} else if (x <= 7e+253) {
tmp = ((t_0 * exp((x * (eps + -1.0)))) + (x + ((1.0 - x) - (eps * x)))) / 2.0;
} else if (x <= 2.8e+283) {
tmp = (exp(((eps * x) - x)) + 1.0) / 2.0;
} else {
tmp = (t_1 + (x + (1.0 - x))) / 2.0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(1.0 + Float64(1.0 / eps)) t_1 = exp(Float64(-x)) tmp = 0.0 if (x <= -250000000.0) tmp = Float64(Float64(1.0 + t_1) / 2.0); elseif (x <= -1.55e-162) tmp = Float64(Float64(2.0 + fma(0.5, Float64(Float64(Float64(x * x) * t_0) * Float64(eps * eps)), Float64(eps * Float64(x * t_0)))) / 2.0); elseif (x <= 9e+60) tmp = Float64(Float64(1.0 + exp(Float64(eps * x))) / 2.0); elseif (x <= 7e+253) tmp = Float64(Float64(Float64(t_0 * exp(Float64(x * Float64(eps + -1.0)))) + Float64(x + Float64(Float64(1.0 - x) - Float64(eps * x)))) / 2.0); elseif (x <= 2.8e+283) tmp = Float64(Float64(exp(Float64(Float64(eps * x) - x)) + 1.0) / 2.0); else tmp = Float64(Float64(t_1 + Float64(x + Float64(1.0 - x))) / 2.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[x, -250000000.0], N[(N[(1.0 + t$95$1), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, -1.55e-162], N[(N[(2.0 + N[(0.5 * N[(N[(N[(x * x), $MachinePrecision] * t$95$0), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision] + N[(eps * N[(x * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 9e+60], N[(N[(1.0 + N[Exp[N[(eps * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 7e+253], N[(N[(N[(t$95$0 * N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(x + N[(N[(1.0 - x), $MachinePrecision] - N[(eps * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 2.8e+283], N[(N[(N[Exp[N[(N[(eps * x), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(t$95$1 + N[(x + N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{1}{\varepsilon}\\
t_1 := e^{-x}\\
\mathbf{if}\;x \leq -250000000:\\
\;\;\;\;\frac{1 + t_1}{2}\\
\mathbf{elif}\;x \leq -1.55 \cdot 10^{-162}:\\
\;\;\;\;\frac{2 + \mathsf{fma}\left(0.5, \left(\left(x \cdot x\right) \cdot t_0\right) \cdot \left(\varepsilon \cdot \varepsilon\right), \varepsilon \cdot \left(x \cdot t_0\right)\right)}{2}\\
\mathbf{elif}\;x \leq 9 \cdot 10^{+60}:\\
\;\;\;\;\frac{1 + e^{\varepsilon \cdot x}}{2}\\
\mathbf{elif}\;x \leq 7 \cdot 10^{+253}:\\
\;\;\;\;\frac{t_0 \cdot e^{x \cdot \left(\varepsilon + -1\right)} + \left(x + \left(\left(1 - x\right) - \varepsilon \cdot x\right)\right)}{2}\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{+283}:\\
\;\;\;\;\frac{e^{\varepsilon \cdot x - x} + 1}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1 + \left(x + \left(1 - x\right)\right)}{2}\\
\end{array}
\end{array}
if x < -2.5e8Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in x around 0 52.9%
Taylor expanded in eps around 0 100.0%
if -2.5e8 < x < -1.5499999999999999e-162Initial program 56.3%
Simplified56.3%
Taylor expanded in x around 0 34.9%
Taylor expanded in eps around inf 32.5%
*-commutative32.5%
Simplified32.5%
Taylor expanded in x around 0 88.3%
fma-def88.3%
*-commutative88.3%
unpow288.3%
unpow288.3%
Simplified88.3%
if -1.5499999999999999e-162 < x < 9.00000000000000026e60Initial program 58.0%
Simplified58.0%
Taylor expanded in x around 0 40.9%
Taylor expanded in eps around inf 43.4%
*-commutative43.4%
Simplified43.4%
Taylor expanded in eps around inf 82.3%
*-commutative82.3%
Simplified82.3%
if 9.00000000000000026e60 < x < 6.99999999999999955e253Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 21.5%
associate-*r*21.5%
mul-1-neg21.5%
distribute-lft-out21.5%
*-rgt-identity21.5%
cancel-sign-sub-inv21.5%
Simplified21.5%
Taylor expanded in eps around inf 71.5%
if 6.99999999999999955e253 < x < 2.80000000000000004e283Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in x around 0 46.2%
if 2.80000000000000004e283 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 1.0%
associate-*r*1.0%
mul-1-neg1.0%
distribute-lft-out1.0%
*-rgt-identity1.0%
cancel-sign-sub-inv1.0%
Simplified1.0%
Taylor expanded in eps around inf 1.4%
Taylor expanded in eps around 0 67.2%
mul-1-neg67.2%
distribute-lft-in67.2%
*-lft-identity67.2%
cancel-sign-sub-inv67.2%
metadata-eval67.2%
*-lft-identity67.2%
*-lft-identity67.2%
Simplified67.2%
Final simplification82.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (exp (* eps x))) (t_1 (+ 1.0 (/ 1.0 eps))) (t_2 (exp (- x))))
(if (<= x -250000000.0)
(/ (+ 1.0 t_2) 2.0)
(if (<= x -1.55e-162)
(/
(+ 2.0 (fma 0.5 (* (* (* x x) t_1) (* eps eps)) (* eps (* x t_1))))
2.0)
(if (<= x 300.0)
(/ (+ 1.0 t_0) 2.0)
(if (<= x 7.6e+228)
(/ (+ (+ 1.0 (* t_1 t_0)) (/ -1.0 eps)) 2.0)
(if (<= x 7e+253)
(/ (+ t_2 (+ x (- 1.0 x))) 2.0)
(/ (+ (exp (- (* eps x) x)) 1.0) 2.0))))))))
double code(double x, double eps) {
double t_0 = exp((eps * x));
double t_1 = 1.0 + (1.0 / eps);
double t_2 = exp(-x);
double tmp;
if (x <= -250000000.0) {
tmp = (1.0 + t_2) / 2.0;
} else if (x <= -1.55e-162) {
tmp = (2.0 + fma(0.5, (((x * x) * t_1) * (eps * eps)), (eps * (x * t_1)))) / 2.0;
} else if (x <= 300.0) {
tmp = (1.0 + t_0) / 2.0;
} else if (x <= 7.6e+228) {
tmp = ((1.0 + (t_1 * t_0)) + (-1.0 / eps)) / 2.0;
} else if (x <= 7e+253) {
tmp = (t_2 + (x + (1.0 - x))) / 2.0;
} else {
tmp = (exp(((eps * x) - x)) + 1.0) / 2.0;
}
return tmp;
}
function code(x, eps) t_0 = exp(Float64(eps * x)) t_1 = Float64(1.0 + Float64(1.0 / eps)) t_2 = exp(Float64(-x)) tmp = 0.0 if (x <= -250000000.0) tmp = Float64(Float64(1.0 + t_2) / 2.0); elseif (x <= -1.55e-162) tmp = Float64(Float64(2.0 + fma(0.5, Float64(Float64(Float64(x * x) * t_1) * Float64(eps * eps)), Float64(eps * Float64(x * t_1)))) / 2.0); elseif (x <= 300.0) tmp = Float64(Float64(1.0 + t_0) / 2.0); elseif (x <= 7.6e+228) tmp = Float64(Float64(Float64(1.0 + Float64(t_1 * t_0)) + Float64(-1.0 / eps)) / 2.0); elseif (x <= 7e+253) tmp = Float64(Float64(t_2 + Float64(x + Float64(1.0 - x))) / 2.0); else tmp = Float64(Float64(exp(Float64(Float64(eps * x) - x)) + 1.0) / 2.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[Exp[N[(eps * x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[x, -250000000.0], N[(N[(1.0 + t$95$2), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, -1.55e-162], N[(N[(2.0 + N[(0.5 * N[(N[(N[(x * x), $MachinePrecision] * t$95$1), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision] + N[(eps * N[(x * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 300.0], N[(N[(1.0 + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 7.6e+228], N[(N[(N[(1.0 + N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 7e+253], N[(N[(t$95$2 + N[(x + N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(N[(eps * x), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\varepsilon \cdot x}\\
t_1 := 1 + \frac{1}{\varepsilon}\\
t_2 := e^{-x}\\
\mathbf{if}\;x \leq -250000000:\\
\;\;\;\;\frac{1 + t_2}{2}\\
\mathbf{elif}\;x \leq -1.55 \cdot 10^{-162}:\\
\;\;\;\;\frac{2 + \mathsf{fma}\left(0.5, \left(\left(x \cdot x\right) \cdot t_1\right) \cdot \left(\varepsilon \cdot \varepsilon\right), \varepsilon \cdot \left(x \cdot t_1\right)\right)}{2}\\
\mathbf{elif}\;x \leq 300:\\
\;\;\;\;\frac{1 + t_0}{2}\\
\mathbf{elif}\;x \leq 7.6 \cdot 10^{+228}:\\
\;\;\;\;\frac{\left(1 + t_1 \cdot t_0\right) + \frac{-1}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq 7 \cdot 10^{+253}:\\
\;\;\;\;\frac{t_2 + \left(x + \left(1 - x\right)\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{\varepsilon \cdot x - x} + 1}{2}\\
\end{array}
\end{array}
if x < -2.5e8Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in x around 0 52.9%
Taylor expanded in eps around 0 100.0%
if -2.5e8 < x < -1.5499999999999999e-162Initial program 56.3%
Simplified56.3%
Taylor expanded in x around 0 34.9%
Taylor expanded in eps around inf 32.5%
*-commutative32.5%
Simplified32.5%
Taylor expanded in x around 0 88.3%
fma-def88.3%
*-commutative88.3%
unpow288.3%
unpow288.3%
Simplified88.3%
if -1.5499999999999999e-162 < x < 300Initial program 53.4%
Simplified53.4%
Taylor expanded in x around 0 41.1%
Taylor expanded in eps around inf 41.2%
*-commutative41.2%
Simplified41.2%
Taylor expanded in eps around inf 87.0%
*-commutative87.0%
Simplified87.0%
if 300 < x < 7.6000000000000004e228Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 36.3%
Taylor expanded in eps around inf 57.5%
*-commutative57.5%
Simplified57.5%
Taylor expanded in x around inf 57.5%
if 7.6000000000000004e228 < x < 6.99999999999999955e253Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 1.6%
associate-*r*1.6%
mul-1-neg1.6%
distribute-lft-out1.6%
*-rgt-identity1.6%
cancel-sign-sub-inv1.6%
Simplified1.6%
Taylor expanded in eps around inf 2.6%
Taylor expanded in eps around 0 100.0%
mul-1-neg100.0%
distribute-lft-in100.0%
*-lft-identity100.0%
cancel-sign-sub-inv100.0%
metadata-eval100.0%
*-lft-identity100.0%
*-lft-identity100.0%
Simplified100.0%
if 6.99999999999999955e253 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in x around 0 41.9%
Final simplification80.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= x -250000000.0)
(/ (+ 1.0 t_0) 2.0)
(if (<= x 300.0)
(/ (- (+ 1.0 (exp (* x (+ eps -1.0)))) (* eps x)) 2.0)
(if (<= x 2.8e+227)
(/
(+ (+ 1.0 (* (+ 1.0 (/ 1.0 eps)) (exp (* eps x)))) (/ -1.0 eps))
2.0)
(if (<= x 7e+253)
(/ (+ t_0 (+ x (- 1.0 x))) 2.0)
(/ (+ (exp (- (* eps x) x)) 1.0) 2.0)))))))
double code(double x, double eps) {
double t_0 = exp(-x);
double tmp;
if (x <= -250000000.0) {
tmp = (1.0 + t_0) / 2.0;
} else if (x <= 300.0) {
tmp = ((1.0 + exp((x * (eps + -1.0)))) - (eps * x)) / 2.0;
} else if (x <= 2.8e+227) {
tmp = ((1.0 + ((1.0 + (1.0 / eps)) * exp((eps * x)))) + (-1.0 / eps)) / 2.0;
} else if (x <= 7e+253) {
tmp = (t_0 + (x + (1.0 - x))) / 2.0;
} else {
tmp = (exp(((eps * x) - x)) + 1.0) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = exp(-x)
if (x <= (-250000000.0d0)) then
tmp = (1.0d0 + t_0) / 2.0d0
else if (x <= 300.0d0) then
tmp = ((1.0d0 + exp((x * (eps + (-1.0d0))))) - (eps * x)) / 2.0d0
else if (x <= 2.8d+227) then
tmp = ((1.0d0 + ((1.0d0 + (1.0d0 / eps)) * exp((eps * x)))) + ((-1.0d0) / eps)) / 2.0d0
else if (x <= 7d+253) then
tmp = (t_0 + (x + (1.0d0 - x))) / 2.0d0
else
tmp = (exp(((eps * x) - x)) + 1.0d0) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.exp(-x);
double tmp;
if (x <= -250000000.0) {
tmp = (1.0 + t_0) / 2.0;
} else if (x <= 300.0) {
tmp = ((1.0 + Math.exp((x * (eps + -1.0)))) - (eps * x)) / 2.0;
} else if (x <= 2.8e+227) {
tmp = ((1.0 + ((1.0 + (1.0 / eps)) * Math.exp((eps * x)))) + (-1.0 / eps)) / 2.0;
} else if (x <= 7e+253) {
tmp = (t_0 + (x + (1.0 - x))) / 2.0;
} else {
tmp = (Math.exp(((eps * x) - x)) + 1.0) / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = math.exp(-x) tmp = 0 if x <= -250000000.0: tmp = (1.0 + t_0) / 2.0 elif x <= 300.0: tmp = ((1.0 + math.exp((x * (eps + -1.0)))) - (eps * x)) / 2.0 elif x <= 2.8e+227: tmp = ((1.0 + ((1.0 + (1.0 / eps)) * math.exp((eps * x)))) + (-1.0 / eps)) / 2.0 elif x <= 7e+253: tmp = (t_0 + (x + (1.0 - x))) / 2.0 else: tmp = (math.exp(((eps * x) - x)) + 1.0) / 2.0 return tmp
function code(x, eps) t_0 = exp(Float64(-x)) tmp = 0.0 if (x <= -250000000.0) tmp = Float64(Float64(1.0 + t_0) / 2.0); elseif (x <= 300.0) tmp = Float64(Float64(Float64(1.0 + exp(Float64(x * Float64(eps + -1.0)))) - Float64(eps * x)) / 2.0); elseif (x <= 2.8e+227) tmp = Float64(Float64(Float64(1.0 + Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(eps * x)))) + Float64(-1.0 / eps)) / 2.0); elseif (x <= 7e+253) tmp = Float64(Float64(t_0 + Float64(x + Float64(1.0 - x))) / 2.0); else tmp = Float64(Float64(exp(Float64(Float64(eps * x) - x)) + 1.0) / 2.0); end return tmp end
function tmp_2 = code(x, eps) t_0 = exp(-x); tmp = 0.0; if (x <= -250000000.0) tmp = (1.0 + t_0) / 2.0; elseif (x <= 300.0) tmp = ((1.0 + exp((x * (eps + -1.0)))) - (eps * x)) / 2.0; elseif (x <= 2.8e+227) tmp = ((1.0 + ((1.0 + (1.0 / eps)) * exp((eps * x)))) + (-1.0 / eps)) / 2.0; elseif (x <= 7e+253) tmp = (t_0 + (x + (1.0 - x))) / 2.0; else tmp = (exp(((eps * x) - x)) + 1.0) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[x, -250000000.0], N[(N[(1.0 + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 300.0], N[(N[(N[(1.0 + N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(eps * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 2.8e+227], N[(N[(N[(1.0 + N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(eps * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 7e+253], N[(N[(t$95$0 + N[(x + N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(N[(eps * x), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;x \leq -250000000:\\
\;\;\;\;\frac{1 + t_0}{2}\\
\mathbf{elif}\;x \leq 300:\\
\;\;\;\;\frac{\left(1 + e^{x \cdot \left(\varepsilon + -1\right)}\right) - \varepsilon \cdot x}{2}\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{+227}:\\
\;\;\;\;\frac{\left(1 + \left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\varepsilon \cdot x}\right) + \frac{-1}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq 7 \cdot 10^{+253}:\\
\;\;\;\;\frac{t_0 + \left(x + \left(1 - x\right)\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{\varepsilon \cdot x - x} + 1}{2}\\
\end{array}
\end{array}
if x < -2.5e8Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in x around 0 52.9%
Taylor expanded in eps around 0 100.0%
if -2.5e8 < x < 300Initial program 54.3%
Simplified54.3%
Taylor expanded in x around 0 40.2%
associate-*r*40.2%
mul-1-neg40.2%
distribute-lft-out40.2%
*-rgt-identity40.2%
cancel-sign-sub-inv40.2%
Simplified40.2%
Taylor expanded in eps around inf 84.0%
Taylor expanded in x around inf 84.0%
mul-1-neg84.0%
distribute-lft-neg-in84.0%
*-commutative84.0%
associate-+r+84.0%
associate-*r*84.0%
sub-neg84.0%
mul-1-neg84.0%
associate-*r*84.0%
mul-1-neg84.0%
*-commutative84.0%
mul-1-neg84.0%
sub-neg84.0%
distribute-rgt-neg-in84.0%
*-commutative84.0%
distribute-lft-neg-in84.0%
distribute-rgt-neg-in84.0%
Simplified84.0%
if 300 < x < 2.79999999999999984e227Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 36.3%
Taylor expanded in eps around inf 57.5%
*-commutative57.5%
Simplified57.5%
Taylor expanded in x around inf 57.5%
if 2.79999999999999984e227 < x < 6.99999999999999955e253Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 1.6%
associate-*r*1.6%
mul-1-neg1.6%
distribute-lft-out1.6%
*-rgt-identity1.6%
cancel-sign-sub-inv1.6%
Simplified1.6%
Taylor expanded in eps around inf 2.6%
Taylor expanded in eps around 0 100.0%
mul-1-neg100.0%
distribute-lft-in100.0%
*-lft-identity100.0%
cancel-sign-sub-inv100.0%
metadata-eval100.0%
*-lft-identity100.0%
*-lft-identity100.0%
Simplified100.0%
if 6.99999999999999955e253 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in x around 0 41.9%
Final simplification78.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ x (- 1.0 x))) (t_1 (exp (- x))))
(if (<= x -2.0)
(/ (+ t_0 (- t_1 (* eps x))) 2.0)
(if (<= x 300.0)
(/ (- (+ 1.0 (exp (* x (+ eps -1.0)))) (* eps x)) 2.0)
(if (<= x 1.15e+229)
(/
(+ (+ 1.0 (* (+ 1.0 (/ 1.0 eps)) (exp (* eps x)))) (/ -1.0 eps))
2.0)
(if (<= x 7e+253)
(/ (+ t_1 t_0) 2.0)
(/ (+ (exp (- (* eps x) x)) 1.0) 2.0)))))))
double code(double x, double eps) {
double t_0 = x + (1.0 - x);
double t_1 = exp(-x);
double tmp;
if (x <= -2.0) {
tmp = (t_0 + (t_1 - (eps * x))) / 2.0;
} else if (x <= 300.0) {
tmp = ((1.0 + exp((x * (eps + -1.0)))) - (eps * x)) / 2.0;
} else if (x <= 1.15e+229) {
tmp = ((1.0 + ((1.0 + (1.0 / eps)) * exp((eps * x)))) + (-1.0 / eps)) / 2.0;
} else if (x <= 7e+253) {
tmp = (t_1 + t_0) / 2.0;
} else {
tmp = (exp(((eps * x) - x)) + 1.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 = x + (1.0d0 - x)
t_1 = exp(-x)
if (x <= (-2.0d0)) then
tmp = (t_0 + (t_1 - (eps * x))) / 2.0d0
else if (x <= 300.0d0) then
tmp = ((1.0d0 + exp((x * (eps + (-1.0d0))))) - (eps * x)) / 2.0d0
else if (x <= 1.15d+229) then
tmp = ((1.0d0 + ((1.0d0 + (1.0d0 / eps)) * exp((eps * x)))) + ((-1.0d0) / eps)) / 2.0d0
else if (x <= 7d+253) then
tmp = (t_1 + t_0) / 2.0d0
else
tmp = (exp(((eps * x) - x)) + 1.0d0) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = x + (1.0 - x);
double t_1 = Math.exp(-x);
double tmp;
if (x <= -2.0) {
tmp = (t_0 + (t_1 - (eps * x))) / 2.0;
} else if (x <= 300.0) {
tmp = ((1.0 + Math.exp((x * (eps + -1.0)))) - (eps * x)) / 2.0;
} else if (x <= 1.15e+229) {
tmp = ((1.0 + ((1.0 + (1.0 / eps)) * Math.exp((eps * x)))) + (-1.0 / eps)) / 2.0;
} else if (x <= 7e+253) {
tmp = (t_1 + t_0) / 2.0;
} else {
tmp = (Math.exp(((eps * x) - x)) + 1.0) / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = x + (1.0 - x) t_1 = math.exp(-x) tmp = 0 if x <= -2.0: tmp = (t_0 + (t_1 - (eps * x))) / 2.0 elif x <= 300.0: tmp = ((1.0 + math.exp((x * (eps + -1.0)))) - (eps * x)) / 2.0 elif x <= 1.15e+229: tmp = ((1.0 + ((1.0 + (1.0 / eps)) * math.exp((eps * x)))) + (-1.0 / eps)) / 2.0 elif x <= 7e+253: tmp = (t_1 + t_0) / 2.0 else: tmp = (math.exp(((eps * x) - x)) + 1.0) / 2.0 return tmp
function code(x, eps) t_0 = Float64(x + Float64(1.0 - x)) t_1 = exp(Float64(-x)) tmp = 0.0 if (x <= -2.0) tmp = Float64(Float64(t_0 + Float64(t_1 - Float64(eps * x))) / 2.0); elseif (x <= 300.0) tmp = Float64(Float64(Float64(1.0 + exp(Float64(x * Float64(eps + -1.0)))) - Float64(eps * x)) / 2.0); elseif (x <= 1.15e+229) tmp = Float64(Float64(Float64(1.0 + Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(eps * x)))) + Float64(-1.0 / eps)) / 2.0); elseif (x <= 7e+253) tmp = Float64(Float64(t_1 + t_0) / 2.0); else tmp = Float64(Float64(exp(Float64(Float64(eps * x) - x)) + 1.0) / 2.0); end return tmp end
function tmp_2 = code(x, eps) t_0 = x + (1.0 - x); t_1 = exp(-x); tmp = 0.0; if (x <= -2.0) tmp = (t_0 + (t_1 - (eps * x))) / 2.0; elseif (x <= 300.0) tmp = ((1.0 + exp((x * (eps + -1.0)))) - (eps * x)) / 2.0; elseif (x <= 1.15e+229) tmp = ((1.0 + ((1.0 + (1.0 / eps)) * exp((eps * x)))) + (-1.0 / eps)) / 2.0; elseif (x <= 7e+253) tmp = (t_1 + t_0) / 2.0; else tmp = (exp(((eps * x) - x)) + 1.0) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(x + N[(1.0 - x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[x, -2.0], N[(N[(t$95$0 + N[(t$95$1 - N[(eps * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 300.0], N[(N[(N[(1.0 + N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(eps * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.15e+229], N[(N[(N[(1.0 + N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(eps * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 7e+253], N[(N[(t$95$1 + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(N[(eps * x), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \left(1 - x\right)\\
t_1 := e^{-x}\\
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\frac{t_0 + \left(t_1 - \varepsilon \cdot x\right)}{2}\\
\mathbf{elif}\;x \leq 300:\\
\;\;\;\;\frac{\left(1 + e^{x \cdot \left(\varepsilon + -1\right)}\right) - \varepsilon \cdot x}{2}\\
\mathbf{elif}\;x \leq 1.15 \cdot 10^{+229}:\\
\;\;\;\;\frac{\left(1 + \left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\varepsilon \cdot x}\right) + \frac{-1}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq 7 \cdot 10^{+253}:\\
\;\;\;\;\frac{t_1 + t_0}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{\varepsilon \cdot x - x} + 1}{2}\\
\end{array}
\end{array}
if x < -2Initial program 97.4%
Simplified97.4%
Taylor expanded in x around 0 50.6%
associate-*r*50.6%
mul-1-neg50.6%
distribute-lft-out50.6%
*-rgt-identity50.6%
cancel-sign-sub-inv50.6%
Simplified50.6%
Taylor expanded in eps around inf 48.0%
Taylor expanded in eps around 0 69.6%
if -2 < x < 300Initial program 54.3%
Simplified54.3%
Taylor expanded in x around 0 40.0%
associate-*r*40.0%
mul-1-neg40.0%
distribute-lft-out40.0%
*-rgt-identity40.0%
cancel-sign-sub-inv40.0%
Simplified40.0%
Taylor expanded in eps around inf 85.1%
Taylor expanded in x around inf 85.1%
mul-1-neg85.1%
distribute-lft-neg-in85.1%
*-commutative85.1%
associate-+r+85.1%
associate-*r*85.1%
sub-neg85.1%
mul-1-neg85.1%
associate-*r*85.1%
mul-1-neg85.1%
*-commutative85.1%
mul-1-neg85.1%
sub-neg85.1%
distribute-rgt-neg-in85.1%
*-commutative85.1%
distribute-lft-neg-in85.1%
distribute-rgt-neg-in85.1%
Simplified85.1%
if 300 < x < 1.15e229Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 36.3%
Taylor expanded in eps around inf 57.5%
*-commutative57.5%
Simplified57.5%
Taylor expanded in x around inf 57.5%
if 1.15e229 < x < 6.99999999999999955e253Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 1.6%
associate-*r*1.6%
mul-1-neg1.6%
distribute-lft-out1.6%
*-rgt-identity1.6%
cancel-sign-sub-inv1.6%
Simplified1.6%
Taylor expanded in eps around inf 2.6%
Taylor expanded in eps around 0 100.0%
mul-1-neg100.0%
distribute-lft-in100.0%
*-lft-identity100.0%
cancel-sign-sub-inv100.0%
metadata-eval100.0%
*-lft-identity100.0%
*-lft-identity100.0%
Simplified100.0%
if 6.99999999999999955e253 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in x around 0 41.9%
Final simplification74.7%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= x -7e-227)
(/ (+ 1.0 t_0) 2.0)
(if (or (<= x 1.65e+229) (not (<= x 7e+253)))
(/ (+ (exp (- (* eps x) x)) 1.0) 2.0)
(/ (+ t_0 (+ x (- 1.0 x))) 2.0)))))
double code(double x, double eps) {
double t_0 = exp(-x);
double tmp;
if (x <= -7e-227) {
tmp = (1.0 + t_0) / 2.0;
} else if ((x <= 1.65e+229) || !(x <= 7e+253)) {
tmp = (exp(((eps * x) - x)) + 1.0) / 2.0;
} else {
tmp = (t_0 + (x + (1.0 - x))) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = exp(-x)
if (x <= (-7d-227)) then
tmp = (1.0d0 + t_0) / 2.0d0
else if ((x <= 1.65d+229) .or. (.not. (x <= 7d+253))) then
tmp = (exp(((eps * x) - x)) + 1.0d0) / 2.0d0
else
tmp = (t_0 + (x + (1.0d0 - x))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.exp(-x);
double tmp;
if (x <= -7e-227) {
tmp = (1.0 + t_0) / 2.0;
} else if ((x <= 1.65e+229) || !(x <= 7e+253)) {
tmp = (Math.exp(((eps * x) - x)) + 1.0) / 2.0;
} else {
tmp = (t_0 + (x + (1.0 - x))) / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = math.exp(-x) tmp = 0 if x <= -7e-227: tmp = (1.0 + t_0) / 2.0 elif (x <= 1.65e+229) or not (x <= 7e+253): tmp = (math.exp(((eps * x) - x)) + 1.0) / 2.0 else: tmp = (t_0 + (x + (1.0 - x))) / 2.0 return tmp
function code(x, eps) t_0 = exp(Float64(-x)) tmp = 0.0 if (x <= -7e-227) tmp = Float64(Float64(1.0 + t_0) / 2.0); elseif ((x <= 1.65e+229) || !(x <= 7e+253)) tmp = Float64(Float64(exp(Float64(Float64(eps * x) - x)) + 1.0) / 2.0); else tmp = Float64(Float64(t_0 + Float64(x + Float64(1.0 - x))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) t_0 = exp(-x); tmp = 0.0; if (x <= -7e-227) tmp = (1.0 + t_0) / 2.0; elseif ((x <= 1.65e+229) || ~((x <= 7e+253))) tmp = (exp(((eps * x) - x)) + 1.0) / 2.0; else tmp = (t_0 + (x + (1.0 - x))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[x, -7e-227], N[(N[(1.0 + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 1.65e+229], N[Not[LessEqual[x, 7e+253]], $MachinePrecision]], N[(N[(N[Exp[N[(N[(eps * x), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(t$95$0 + N[(x + N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;x \leq -7 \cdot 10^{-227}:\\
\;\;\;\;\frac{1 + t_0}{2}\\
\mathbf{elif}\;x \leq 1.65 \cdot 10^{+229} \lor \neg \left(x \leq 7 \cdot 10^{+253}\right):\\
\;\;\;\;\frac{e^{\varepsilon \cdot x - x} + 1}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0 + \left(x + \left(1 - x\right)\right)}{2}\\
\end{array}
\end{array}
if x < -7.0000000000000002e-227Initial program 77.3%
Simplified77.4%
Taylor expanded in eps around inf 98.9%
Taylor expanded in x around 0 65.8%
Taylor expanded in eps around 0 82.8%
if -7.0000000000000002e-227 < x < 1.65e229 or 6.99999999999999955e253 < x Initial program 72.0%
Simplified72.0%
Taylor expanded in eps around inf 99.5%
Taylor expanded in x around 0 65.9%
if 1.65e229 < x < 6.99999999999999955e253Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 1.6%
associate-*r*1.6%
mul-1-neg1.6%
distribute-lft-out1.6%
*-rgt-identity1.6%
cancel-sign-sub-inv1.6%
Simplified1.6%
Taylor expanded in eps around inf 2.6%
Taylor expanded in eps around 0 100.0%
mul-1-neg100.0%
distribute-lft-in100.0%
*-lft-identity100.0%
cancel-sign-sub-inv100.0%
metadata-eval100.0%
*-lft-identity100.0%
*-lft-identity100.0%
Simplified100.0%
Final simplification72.8%
(FPCore (x eps) :precision binary64 (if (<= x -7e-227) (/ (+ 1.0 (exp (- x))) 2.0) (/ (+ (exp (- (* eps x) x)) 1.0) 2.0)))
double code(double x, double eps) {
double tmp;
if (x <= -7e-227) {
tmp = (1.0 + exp(-x)) / 2.0;
} else {
tmp = (exp(((eps * x) - x)) + 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 <= (-7d-227)) then
tmp = (1.0d0 + exp(-x)) / 2.0d0
else
tmp = (exp(((eps * x) - x)) + 1.0d0) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -7e-227) {
tmp = (1.0 + Math.exp(-x)) / 2.0;
} else {
tmp = (Math.exp(((eps * x) - x)) + 1.0) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -7e-227: tmp = (1.0 + math.exp(-x)) / 2.0 else: tmp = (math.exp(((eps * x) - x)) + 1.0) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -7e-227) tmp = Float64(Float64(1.0 + exp(Float64(-x))) / 2.0); else tmp = Float64(Float64(exp(Float64(Float64(eps * x) - x)) + 1.0) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -7e-227) tmp = (1.0 + exp(-x)) / 2.0; else tmp = (exp(((eps * x) - x)) + 1.0) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -7e-227], N[(N[(1.0 + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(N[(eps * x), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7 \cdot 10^{-227}:\\
\;\;\;\;\frac{1 + e^{-x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{\varepsilon \cdot x - x} + 1}{2}\\
\end{array}
\end{array}
if x < -7.0000000000000002e-227Initial program 77.3%
Simplified77.4%
Taylor expanded in eps around inf 98.9%
Taylor expanded in x around 0 65.8%
Taylor expanded in eps around 0 82.8%
if -7.0000000000000002e-227 < x Initial program 73.2%
Simplified73.2%
Taylor expanded in eps around inf 99.5%
Taylor expanded in x around 0 63.3%
Final simplification70.1%
(FPCore (x eps) :precision binary64 (if (<= x -5e-226) (/ (+ 1.0 (exp (- x))) 2.0) (/ (+ 1.0 (exp (* eps x))) 2.0)))
double code(double x, double eps) {
double tmp;
if (x <= -5e-226) {
tmp = (1.0 + exp(-x)) / 2.0;
} else {
tmp = (1.0 + exp((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 <= (-5d-226)) then
tmp = (1.0d0 + exp(-x)) / 2.0d0
else
tmp = (1.0d0 + exp((eps * x))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -5e-226) {
tmp = (1.0 + Math.exp(-x)) / 2.0;
} else {
tmp = (1.0 + Math.exp((eps * x))) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -5e-226: tmp = (1.0 + math.exp(-x)) / 2.0 else: tmp = (1.0 + math.exp((eps * x))) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -5e-226) tmp = Float64(Float64(1.0 + exp(Float64(-x))) / 2.0); else tmp = Float64(Float64(1.0 + exp(Float64(eps * x))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -5e-226) tmp = (1.0 + exp(-x)) / 2.0; else tmp = (1.0 + exp((eps * x))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -5e-226], N[(N[(1.0 + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(1.0 + N[Exp[N[(eps * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-226}:\\
\;\;\;\;\frac{1 + e^{-x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + e^{\varepsilon \cdot x}}{2}\\
\end{array}
\end{array}
if x < -4.9999999999999998e-226Initial program 77.3%
Simplified77.4%
Taylor expanded in eps around inf 98.9%
Taylor expanded in x around 0 65.8%
Taylor expanded in eps around 0 82.8%
if -4.9999999999999998e-226 < x Initial program 73.2%
Simplified73.2%
Taylor expanded in x around 0 36.8%
Taylor expanded in eps around inf 43.8%
*-commutative43.8%
Simplified43.8%
Taylor expanded in eps around inf 63.2%
*-commutative63.2%
Simplified63.2%
Final simplification70.1%
(FPCore (x eps)
:precision binary64
(if (<= x 2.6e-15)
(/ (+ 1.0 (exp (- x))) 2.0)
(/
(+ 2.0 (/ (* (* x (+ 1.0 (/ 1.0 eps))) (+ -1.0 (* eps eps))) (+ eps 1.0)))
2.0)))
double code(double x, double eps) {
double tmp;
if (x <= 2.6e-15) {
tmp = (1.0 + exp(-x)) / 2.0;
} else {
tmp = (2.0 + (((x * (1.0 + (1.0 / eps))) * (-1.0 + (eps * eps))) / (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 <= 2.6d-15) then
tmp = (1.0d0 + exp(-x)) / 2.0d0
else
tmp = (2.0d0 + (((x * (1.0d0 + (1.0d0 / eps))) * ((-1.0d0) + (eps * eps))) / (eps + 1.0d0))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 2.6e-15) {
tmp = (1.0 + Math.exp(-x)) / 2.0;
} else {
tmp = (2.0 + (((x * (1.0 + (1.0 / eps))) * (-1.0 + (eps * eps))) / (eps + 1.0))) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 2.6e-15: tmp = (1.0 + math.exp(-x)) / 2.0 else: tmp = (2.0 + (((x * (1.0 + (1.0 / eps))) * (-1.0 + (eps * eps))) / (eps + 1.0))) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 2.6e-15) tmp = Float64(Float64(1.0 + exp(Float64(-x))) / 2.0); else tmp = Float64(Float64(2.0 + Float64(Float64(Float64(x * Float64(1.0 + Float64(1.0 / eps))) * Float64(-1.0 + Float64(eps * eps))) / Float64(eps + 1.0))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 2.6e-15) tmp = (1.0 + exp(-x)) / 2.0; else tmp = (2.0 + (((x * (1.0 + (1.0 / eps))) * (-1.0 + (eps * eps))) / (eps + 1.0))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 2.6e-15], N[(N[(1.0 + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(2.0 + N[(N[(N[(x * N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 + N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(eps + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.6 \cdot 10^{-15}:\\
\;\;\;\;\frac{1 + e^{-x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + \frac{\left(x \cdot \left(1 + \frac{1}{\varepsilon}\right)\right) \cdot \left(-1 + \varepsilon \cdot \varepsilon\right)}{\varepsilon + 1}}{2}\\
\end{array}
\end{array}
if x < 2.60000000000000004e-15Initial program 63.2%
Simplified63.2%
Taylor expanded in eps around inf 99.4%
Taylor expanded in x around 0 77.8%
Taylor expanded in eps around 0 82.1%
if 2.60000000000000004e-15 < x Initial program 98.8%
Simplified98.8%
Taylor expanded in x around 0 34.7%
Taylor expanded in x around 0 16.7%
associate-*r*16.7%
mul-1-neg16.7%
*-commutative16.7%
Simplified16.7%
*-commutative16.7%
flip--20.0%
metadata-eval20.0%
metadata-eval20.0%
associate-*r/20.0%
metadata-eval20.0%
+-commutative20.0%
Applied egg-rr20.0%
associate-/l*20.0%
+-commutative20.0%
Simplified20.0%
Taylor expanded in x around 0 26.8%
mul-1-neg26.8%
associate-*r*26.8%
unpow226.8%
Simplified26.8%
Final simplification64.4%
(FPCore (x eps) :precision binary64 (if (<= x -2e-18) (/ (* (* x (+ eps 1.0)) (+ -1.0 (/ 1.0 eps))) 2.0) (/ (+ (* eps x) 2.0) 2.0)))
double code(double x, double eps) {
double tmp;
if (x <= -2e-18) {
tmp = ((x * (eps + 1.0)) * (-1.0 + (1.0 / eps))) / 2.0;
} else {
tmp = ((eps * x) + 2.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 <= (-2d-18)) then
tmp = ((x * (eps + 1.0d0)) * ((-1.0d0) + (1.0d0 / eps))) / 2.0d0
else
tmp = ((eps * x) + 2.0d0) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -2e-18) {
tmp = ((x * (eps + 1.0)) * (-1.0 + (1.0 / eps))) / 2.0;
} else {
tmp = ((eps * x) + 2.0) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -2e-18: tmp = ((x * (eps + 1.0)) * (-1.0 + (1.0 / eps))) / 2.0 else: tmp = ((eps * x) + 2.0) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -2e-18) tmp = Float64(Float64(Float64(x * Float64(eps + 1.0)) * Float64(-1.0 + Float64(1.0 / eps))) / 2.0); else tmp = Float64(Float64(Float64(eps * x) + 2.0) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -2e-18) tmp = ((x * (eps + 1.0)) * (-1.0 + (1.0 / eps))) / 2.0; else tmp = ((eps * x) + 2.0) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -2e-18], N[(N[(N[(x * N[(eps + 1.0), $MachinePrecision]), $MachinePrecision] * N[(-1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(eps * x), $MachinePrecision] + 2.0), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-18}:\\
\;\;\;\;\frac{\left(x \cdot \left(\varepsilon + 1\right)\right) \cdot \left(-1 + \frac{1}{\varepsilon}\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\varepsilon \cdot x + 2}{2}\\
\end{array}
\end{array}
if x < -2.0000000000000001e-18Initial program 97.5%
Simplified97.5%
Taylor expanded in x around 0 49.4%
associate-*r*49.4%
mul-1-neg49.4%
distribute-lft-out49.4%
*-rgt-identity49.4%
cancel-sign-sub-inv49.4%
Simplified49.4%
Taylor expanded in x around inf 24.5%
sub-neg24.5%
metadata-eval24.5%
associate-*r*24.5%
+-commutative24.5%
Simplified24.5%
if -2.0000000000000001e-18 < x Initial program 70.4%
Simplified70.4%
Taylor expanded in x around 0 37.6%
Taylor expanded in x around 0 40.0%
associate-*r*40.0%
mul-1-neg40.0%
*-commutative40.0%
Simplified40.0%
Taylor expanded in eps around inf 55.1%
*-commutative55.1%
Simplified55.1%
Final simplification50.3%
(FPCore (x eps) :precision binary64 (/ (+ 2.0 (+ x (* eps (+ x (* 0.5 (* x x)))))) 2.0))
double code(double x, double eps) {
return (2.0 + (x + (eps * (x + (0.5 * (x * x)))))) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (2.0d0 + (x + (eps * (x + (0.5d0 * (x * x)))))) / 2.0d0
end function
public static double code(double x, double eps) {
return (2.0 + (x + (eps * (x + (0.5 * (x * x)))))) / 2.0;
}
def code(x, eps): return (2.0 + (x + (eps * (x + (0.5 * (x * x)))))) / 2.0
function code(x, eps) return Float64(Float64(2.0 + Float64(x + Float64(eps * Float64(x + Float64(0.5 * Float64(x * x)))))) / 2.0) end
function tmp = code(x, eps) tmp = (2.0 + (x + (eps * (x + (0.5 * (x * x)))))) / 2.0; end
code[x_, eps_] := N[(N[(2.0 + N[(x + N[(eps * N[(x + N[(0.5 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{2 + \left(x + \varepsilon \cdot \left(x + 0.5 \cdot \left(x \cdot x\right)\right)\right)}{2}
\end{array}
Initial program 74.6%
Simplified74.6%
Taylor expanded in x around 0 39.8%
Taylor expanded in eps around inf 43.9%
*-commutative43.9%
Simplified43.9%
Taylor expanded in eps around 0 54.5%
unpow254.5%
Simplified54.5%
Final simplification54.5%
(FPCore (x eps) :precision binary64 (if (<= x -2e-18) (/ (* eps (- x)) 2.0) (/ (+ (* eps x) 2.0) 2.0)))
double code(double x, double eps) {
double tmp;
if (x <= -2e-18) {
tmp = (eps * -x) / 2.0;
} else {
tmp = ((eps * x) + 2.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 <= (-2d-18)) then
tmp = (eps * -x) / 2.0d0
else
tmp = ((eps * x) + 2.0d0) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -2e-18) {
tmp = (eps * -x) / 2.0;
} else {
tmp = ((eps * x) + 2.0) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -2e-18: tmp = (eps * -x) / 2.0 else: tmp = ((eps * x) + 2.0) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -2e-18) tmp = Float64(Float64(eps * Float64(-x)) / 2.0); else tmp = Float64(Float64(Float64(eps * x) + 2.0) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -2e-18) tmp = (eps * -x) / 2.0; else tmp = ((eps * x) + 2.0) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -2e-18], N[(N[(eps * (-x)), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(eps * x), $MachinePrecision] + 2.0), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-18}:\\
\;\;\;\;\frac{\varepsilon \cdot \left(-x\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\varepsilon \cdot x + 2}{2}\\
\end{array}
\end{array}
if x < -2.0000000000000001e-18Initial program 97.5%
Simplified97.5%
Taylor expanded in x around 0 49.4%
associate-*r*49.4%
mul-1-neg49.4%
distribute-lft-out49.4%
*-rgt-identity49.4%
cancel-sign-sub-inv49.4%
Simplified49.4%
Taylor expanded in eps around inf 24.5%
mul-1-neg24.5%
*-commutative24.5%
Simplified24.5%
if -2.0000000000000001e-18 < x Initial program 70.4%
Simplified70.4%
Taylor expanded in x around 0 37.6%
Taylor expanded in x around 0 40.0%
associate-*r*40.0%
mul-1-neg40.0%
*-commutative40.0%
Simplified40.0%
Taylor expanded in eps around inf 55.1%
*-commutative55.1%
Simplified55.1%
Final simplification50.3%
(FPCore (x eps) :precision binary64 (if (<= x -2e-18) (/ (* eps (- x)) 2.0) (/ (+ x 2.0) 2.0)))
double code(double x, double eps) {
double tmp;
if (x <= -2e-18) {
tmp = (eps * -x) / 2.0;
} else {
tmp = (x + 2.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 <= (-2d-18)) then
tmp = (eps * -x) / 2.0d0
else
tmp = (x + 2.0d0) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -2e-18) {
tmp = (eps * -x) / 2.0;
} else {
tmp = (x + 2.0) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -2e-18: tmp = (eps * -x) / 2.0 else: tmp = (x + 2.0) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -2e-18) tmp = Float64(Float64(eps * Float64(-x)) / 2.0); else tmp = Float64(Float64(x + 2.0) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -2e-18) tmp = (eps * -x) / 2.0; else tmp = (x + 2.0) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -2e-18], N[(N[(eps * (-x)), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(x + 2.0), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-18}:\\
\;\;\;\;\frac{\varepsilon \cdot \left(-x\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x + 2}{2}\\
\end{array}
\end{array}
if x < -2.0000000000000001e-18Initial program 97.5%
Simplified97.5%
Taylor expanded in x around 0 49.4%
associate-*r*49.4%
mul-1-neg49.4%
distribute-lft-out49.4%
*-rgt-identity49.4%
cancel-sign-sub-inv49.4%
Simplified49.4%
Taylor expanded in eps around inf 24.5%
mul-1-neg24.5%
*-commutative24.5%
Simplified24.5%
if -2.0000000000000001e-18 < x Initial program 70.4%
Simplified70.4%
Taylor expanded in x around 0 37.6%
Taylor expanded in eps around inf 43.0%
*-commutative43.0%
Simplified43.0%
Taylor expanded in eps around 0 50.6%
+-commutative50.6%
Simplified50.6%
Final simplification46.5%
(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 74.6%
Simplified74.6%
Taylor expanded in x around 0 43.0%
Final simplification43.0%
herbie shell --seed 2023297
(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))