
(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 14 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}
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= eps_m 1.0) (/ (+ x 1.0) (exp x)) (/ (+ (/ 1.0 (exp (+ x (* x eps_m)))) (exp (* x eps_m))) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 1.0) {
tmp = (x + 1.0) / exp(x);
} else {
tmp = ((1.0 / exp((x + (x * eps_m)))) + exp((x * eps_m))) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (eps_m <= 1.0d0) then
tmp = (x + 1.0d0) / exp(x)
else
tmp = ((1.0d0 / exp((x + (x * eps_m)))) + exp((x * eps_m))) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (eps_m <= 1.0) {
tmp = (x + 1.0) / Math.exp(x);
} else {
tmp = ((1.0 / Math.exp((x + (x * eps_m)))) + Math.exp((x * eps_m))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 1.0: tmp = (x + 1.0) / math.exp(x) else: tmp = ((1.0 / math.exp((x + (x * eps_m)))) + math.exp((x * eps_m))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 1.0) tmp = Float64(Float64(x + 1.0) / exp(x)); else tmp = Float64(Float64(Float64(1.0 / exp(Float64(x + Float64(x * eps_m)))) + exp(Float64(x * eps_m))) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (eps_m <= 1.0) tmp = (x + 1.0) / exp(x); else tmp = ((1.0 / exp((x + (x * eps_m)))) + exp((x * eps_m))) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 1.0], N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / N[Exp[N[(x + N[(x * eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 1:\\
\;\;\;\;\frac{x + 1}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{e^{x + x \cdot eps\_m}} + e^{x \cdot eps\_m}}{2}\\
\end{array}
\end{array}
if eps < 1Initial program 59.3%
Simplified51.7%
Taylor expanded in eps around 0 30.1%
associate-+r+71.6%
mul-1-neg71.6%
sub-neg71.6%
+-inverses71.6%
distribute-lft-out71.6%
distribute-rgt1-in71.6%
mul-1-neg71.6%
Simplified71.6%
Taylor expanded in eps around 0 71.6%
rec-exp71.6%
+-commutative71.6%
associate-*l/71.6%
*-lft-identity71.6%
Simplified71.6%
if 1 < eps Initial program 100.0%
Simplified85.3%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around inf 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification79.9%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (/ (+ (exp (* x (+ eps_m -1.0))) (/ 1.0 (exp (+ x (* x eps_m))))) 2.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return (exp((x * (eps_m + -1.0))) + (1.0 / exp((x + (x * eps_m))))) / 2.0;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
code = (exp((x * (eps_m + (-1.0d0)))) + (1.0d0 / exp((x + (x * eps_m))))) / 2.0d0
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
return (Math.exp((x * (eps_m + -1.0))) + (1.0 / Math.exp((x + (x * eps_m))))) / 2.0;
}
eps_m = math.fabs(eps) def code(x, eps_m): return (math.exp((x * (eps_m + -1.0))) + (1.0 / math.exp((x + (x * eps_m))))) / 2.0
eps_m = abs(eps) function code(x, eps_m) return Float64(Float64(exp(Float64(x * Float64(eps_m + -1.0))) + Float64(1.0 / exp(Float64(x + Float64(x * eps_m))))) / 2.0) end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = (exp((x * (eps_m + -1.0))) + (1.0 / exp((x + (x * eps_m))))) / 2.0; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(N[(N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(1.0 / N[Exp[N[(x + N[(x * eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\frac{e^{x \cdot \left(eps\_m + -1\right)} + \frac{1}{e^{x + x \cdot eps\_m}}}{2}
\end{array}
Initial program 71.2%
Simplified62.0%
Taylor expanded in eps around inf 99.4%
Final simplification99.4%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -1e-277)
(/ (+ 1.0 (exp (* x (- -1.0 eps_m)))) 2.0)
(if (<= x 27000.0)
(/ (+ (exp (* x eps_m)) (/ 1.0 (+ 1.0 (* x (+ eps_m 1.0))))) 2.0)
0.0)))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -1e-277) {
tmp = (1.0 + exp((x * (-1.0 - eps_m)))) / 2.0;
} else if (x <= 27000.0) {
tmp = (exp((x * eps_m)) + (1.0 / (1.0 + (x * (eps_m + 1.0))))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= (-1d-277)) then
tmp = (1.0d0 + exp((x * ((-1.0d0) - eps_m)))) / 2.0d0
else if (x <= 27000.0d0) then
tmp = (exp((x * eps_m)) + (1.0d0 / (1.0d0 + (x * (eps_m + 1.0d0))))) / 2.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= -1e-277) {
tmp = (1.0 + Math.exp((x * (-1.0 - eps_m)))) / 2.0;
} else if (x <= 27000.0) {
tmp = (Math.exp((x * eps_m)) + (1.0 / (1.0 + (x * (eps_m + 1.0))))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -1e-277: tmp = (1.0 + math.exp((x * (-1.0 - eps_m)))) / 2.0 elif x <= 27000.0: tmp = (math.exp((x * eps_m)) + (1.0 / (1.0 + (x * (eps_m + 1.0))))) / 2.0 else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -1e-277) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps_m)))) / 2.0); elseif (x <= 27000.0) tmp = Float64(Float64(exp(Float64(x * eps_m)) + Float64(1.0 / Float64(1.0 + Float64(x * Float64(eps_m + 1.0))))) / 2.0); else tmp = 0.0; end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -1e-277) tmp = (1.0 + exp((x * (-1.0 - eps_m)))) / 2.0; elseif (x <= 27000.0) tmp = (exp((x * eps_m)) + (1.0 / (1.0 + (x * (eps_m + 1.0))))) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -1e-277], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 27000.0], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] + N[(1.0 / N[(1.0 + N[(x * N[(eps$95$m + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-277}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - eps\_m\right)}}{2}\\
\mathbf{elif}\;x \leq 27000:\\
\;\;\;\;\frac{e^{x \cdot eps\_m} + \frac{1}{1 + x \cdot \left(eps\_m + 1\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -9.99999999999999969e-278Initial program 72.1%
Simplified60.9%
Taylor expanded in eps around inf 98.8%
Taylor expanded in x around 0 69.0%
Taylor expanded in x around -inf 69.0%
Simplified69.0%
if -9.99999999999999969e-278 < x < 27000Initial program 52.6%
Simplified39.9%
Taylor expanded in eps around inf 99.7%
Taylor expanded in eps around inf 99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in x around 0 87.9%
if 27000 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 59.3%
div-sub59.3%
mul-1-neg59.3%
rec-exp59.3%
+-inverses59.3%
metadata-eval59.3%
Simplified59.3%
Final simplification73.7%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -2e-276) (/ (+ 1.0 (exp (* x (- -1.0 eps_m)))) 2.0) (if (<= x 40000000.0) (/ (+ 1.0 (exp (* x eps_m))) 2.0) 0.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -2e-276) {
tmp = (1.0 + exp((x * (-1.0 - eps_m)))) / 2.0;
} else if (x <= 40000000.0) {
tmp = (1.0 + exp((x * eps_m))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= (-2d-276)) then
tmp = (1.0d0 + exp((x * ((-1.0d0) - eps_m)))) / 2.0d0
else if (x <= 40000000.0d0) then
tmp = (1.0d0 + exp((x * eps_m))) / 2.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= -2e-276) {
tmp = (1.0 + Math.exp((x * (-1.0 - eps_m)))) / 2.0;
} else if (x <= 40000000.0) {
tmp = (1.0 + Math.exp((x * eps_m))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -2e-276: tmp = (1.0 + math.exp((x * (-1.0 - eps_m)))) / 2.0 elif x <= 40000000.0: tmp = (1.0 + math.exp((x * eps_m))) / 2.0 else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -2e-276) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps_m)))) / 2.0); elseif (x <= 40000000.0) tmp = Float64(Float64(1.0 + exp(Float64(x * eps_m))) / 2.0); else tmp = 0.0; end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -2e-276) tmp = (1.0 + exp((x * (-1.0 - eps_m)))) / 2.0; elseif (x <= 40000000.0) tmp = (1.0 + exp((x * eps_m))) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -2e-276], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 40000000.0], N[(N[(1.0 + N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-276}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - eps\_m\right)}}{2}\\
\mathbf{elif}\;x \leq 40000000:\\
\;\;\;\;\frac{1 + e^{x \cdot eps\_m}}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -2e-276Initial program 72.1%
Simplified60.9%
Taylor expanded in eps around inf 98.8%
Taylor expanded in x around 0 69.0%
Taylor expanded in x around -inf 69.0%
Simplified69.0%
if -2e-276 < x < 4e7Initial program 52.6%
Simplified39.9%
Taylor expanded in eps around inf 99.7%
Taylor expanded in eps around inf 99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in x around 0 87.3%
if 4e7 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 59.3%
div-sub59.3%
mul-1-neg59.3%
rec-exp59.3%
+-inverses59.3%
metadata-eval59.3%
Simplified59.3%
Final simplification73.5%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= eps_m 1.0)
(/ (+ x 1.0) (exp x))
(if (<= eps_m 2.35e+204)
(+ 0.5 (/ 0.5 (exp x)))
(if (<= eps_m 2.2e+263)
(/
(+ 2.0 (* x (- (/ (+ 1.0 (* eps_m (+ eps_m 1.0))) eps_m) eps_m)))
2.0)
(/
(+
2.0
(*
x
(/
(* (+ eps_m 1.0) (+ 1.0 (+ (/ 1.0 eps_m) (- (/ 1.0 eps_m) eps_m))))
(+ eps_m 1.0))))
2.0)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 1.0) {
tmp = (x + 1.0) / exp(x);
} else if (eps_m <= 2.35e+204) {
tmp = 0.5 + (0.5 / exp(x));
} else if (eps_m <= 2.2e+263) {
tmp = (2.0 + (x * (((1.0 + (eps_m * (eps_m + 1.0))) / eps_m) - eps_m))) / 2.0;
} else {
tmp = (2.0 + (x * (((eps_m + 1.0) * (1.0 + ((1.0 / eps_m) + ((1.0 / eps_m) - eps_m)))) / (eps_m + 1.0)))) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (eps_m <= 1.0d0) then
tmp = (x + 1.0d0) / exp(x)
else if (eps_m <= 2.35d+204) then
tmp = 0.5d0 + (0.5d0 / exp(x))
else if (eps_m <= 2.2d+263) then
tmp = (2.0d0 + (x * (((1.0d0 + (eps_m * (eps_m + 1.0d0))) / eps_m) - eps_m))) / 2.0d0
else
tmp = (2.0d0 + (x * (((eps_m + 1.0d0) * (1.0d0 + ((1.0d0 / eps_m) + ((1.0d0 / eps_m) - eps_m)))) / (eps_m + 1.0d0)))) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (eps_m <= 1.0) {
tmp = (x + 1.0) / Math.exp(x);
} else if (eps_m <= 2.35e+204) {
tmp = 0.5 + (0.5 / Math.exp(x));
} else if (eps_m <= 2.2e+263) {
tmp = (2.0 + (x * (((1.0 + (eps_m * (eps_m + 1.0))) / eps_m) - eps_m))) / 2.0;
} else {
tmp = (2.0 + (x * (((eps_m + 1.0) * (1.0 + ((1.0 / eps_m) + ((1.0 / eps_m) - eps_m)))) / (eps_m + 1.0)))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 1.0: tmp = (x + 1.0) / math.exp(x) elif eps_m <= 2.35e+204: tmp = 0.5 + (0.5 / math.exp(x)) elif eps_m <= 2.2e+263: tmp = (2.0 + (x * (((1.0 + (eps_m * (eps_m + 1.0))) / eps_m) - eps_m))) / 2.0 else: tmp = (2.0 + (x * (((eps_m + 1.0) * (1.0 + ((1.0 / eps_m) + ((1.0 / eps_m) - eps_m)))) / (eps_m + 1.0)))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 1.0) tmp = Float64(Float64(x + 1.0) / exp(x)); elseif (eps_m <= 2.35e+204) tmp = Float64(0.5 + Float64(0.5 / exp(x))); elseif (eps_m <= 2.2e+263) tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(Float64(1.0 + Float64(eps_m * Float64(eps_m + 1.0))) / eps_m) - eps_m))) / 2.0); else tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(Float64(eps_m + 1.0) * Float64(1.0 + Float64(Float64(1.0 / eps_m) + Float64(Float64(1.0 / eps_m) - eps_m)))) / Float64(eps_m + 1.0)))) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (eps_m <= 1.0) tmp = (x + 1.0) / exp(x); elseif (eps_m <= 2.35e+204) tmp = 0.5 + (0.5 / exp(x)); elseif (eps_m <= 2.2e+263) tmp = (2.0 + (x * (((1.0 + (eps_m * (eps_m + 1.0))) / eps_m) - eps_m))) / 2.0; else tmp = (2.0 + (x * (((eps_m + 1.0) * (1.0 + ((1.0 / eps_m) + ((1.0 / eps_m) - eps_m)))) / (eps_m + 1.0)))) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 1.0], N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps$95$m, 2.35e+204], N[(0.5 + N[(0.5 / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps$95$m, 2.2e+263], N[(N[(2.0 + N[(x * N[(N[(N[(1.0 + N[(eps$95$m * N[(eps$95$m + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / eps$95$m), $MachinePrecision] - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(2.0 + N[(x * N[(N[(N[(eps$95$m + 1.0), $MachinePrecision] * N[(1.0 + N[(N[(1.0 / eps$95$m), $MachinePrecision] + N[(N[(1.0 / eps$95$m), $MachinePrecision] - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(eps$95$m + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 1:\\
\;\;\;\;\frac{x + 1}{e^{x}}\\
\mathbf{elif}\;eps\_m \leq 2.35 \cdot 10^{+204}:\\
\;\;\;\;0.5 + \frac{0.5}{e^{x}}\\
\mathbf{elif}\;eps\_m \leq 2.2 \cdot 10^{+263}:\\
\;\;\;\;\frac{2 + x \cdot \left(\frac{1 + eps\_m \cdot \left(eps\_m + 1\right)}{eps\_m} - eps\_m\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + x \cdot \frac{\left(eps\_m + 1\right) \cdot \left(1 + \left(\frac{1}{eps\_m} + \left(\frac{1}{eps\_m} - eps\_m\right)\right)\right)}{eps\_m + 1}}{2}\\
\end{array}
\end{array}
if eps < 1Initial program 59.3%
Simplified51.7%
Taylor expanded in eps around 0 30.1%
associate-+r+71.6%
mul-1-neg71.6%
sub-neg71.6%
+-inverses71.6%
distribute-lft-out71.6%
distribute-rgt1-in71.6%
mul-1-neg71.6%
Simplified71.6%
Taylor expanded in eps around 0 71.6%
rec-exp71.6%
+-commutative71.6%
associate-*l/71.6%
*-lft-identity71.6%
Simplified71.6%
if 1 < eps < 2.3500000000000001e204Initial program 100.0%
Simplified89.9%
Taylor expanded in eps around inf 100.0%
Taylor expanded in x around 0 77.4%
Taylor expanded in eps around 0 68.6%
distribute-lft-in68.6%
metadata-eval68.6%
associate-*r/68.6%
metadata-eval68.6%
Simplified68.6%
if 2.3500000000000001e204 < eps < 2.2e263Initial program 100.0%
Simplified70.2%
Taylor expanded in x around 0 10.6%
Taylor expanded in eps around inf 10.6%
Taylor expanded in eps around 0 69.5%
if 2.2e263 < eps Initial program 100.0%
Simplified78.9%
Taylor expanded in x around 0 7.6%
Taylor expanded in eps around 0 42.0%
associate--l+42.0%
flip-+62.6%
*-commutative62.6%
*-commutative62.6%
swap-sqr62.6%
metadata-eval62.6%
*-un-lft-identity62.6%
pow262.6%
Applied egg-rr62.6%
unpow262.6%
difference-of-squares62.6%
associate-+l+62.6%
associate--l+62.6%
associate--r-62.6%
+-inverses62.6%
associate-+l+62.6%
metadata-eval62.6%
associate--l+62.6%
associate--r-62.6%
+-inverses62.6%
associate-+l+62.6%
metadata-eval62.6%
Simplified62.6%
Final simplification70.6%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= eps_m 2.15) (/ (+ x 1.0) (exp x)) (/ (+ 1.0 (exp (* x (- -1.0 eps_m)))) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 2.15) {
tmp = (x + 1.0) / exp(x);
} else {
tmp = (1.0 + exp((x * (-1.0 - eps_m)))) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (eps_m <= 2.15d0) then
tmp = (x + 1.0d0) / exp(x)
else
tmp = (1.0d0 + exp((x * ((-1.0d0) - eps_m)))) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (eps_m <= 2.15) {
tmp = (x + 1.0) / Math.exp(x);
} else {
tmp = (1.0 + Math.exp((x * (-1.0 - eps_m)))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 2.15: tmp = (x + 1.0) / math.exp(x) else: tmp = (1.0 + math.exp((x * (-1.0 - eps_m)))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 2.15) tmp = Float64(Float64(x + 1.0) / exp(x)); else tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps_m)))) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (eps_m <= 2.15) tmp = (x + 1.0) / exp(x); else tmp = (1.0 + exp((x * (-1.0 - eps_m)))) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 2.15], N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 2.15:\\
\;\;\;\;\frac{x + 1}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - eps\_m\right)}}{2}\\
\end{array}
\end{array}
if eps < 2.14999999999999991Initial program 59.3%
Simplified51.7%
Taylor expanded in eps around 0 30.1%
associate-+r+71.6%
mul-1-neg71.6%
sub-neg71.6%
+-inverses71.6%
distribute-lft-out71.6%
distribute-rgt1-in71.6%
mul-1-neg71.6%
Simplified71.6%
Taylor expanded in eps around 0 71.6%
rec-exp71.6%
+-commutative71.6%
associate-*l/71.6%
*-lft-identity71.6%
Simplified71.6%
if 2.14999999999999991 < eps Initial program 100.0%
Simplified85.3%
Taylor expanded in eps around inf 100.0%
Taylor expanded in x around 0 68.5%
Taylor expanded in x around -inf 68.5%
Simplified68.5%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -6.0)
(/
(+
2.0
(*
x
(/
(* (+ eps_m 1.0) (+ 1.0 (+ (/ 1.0 eps_m) (- (/ 1.0 eps_m) eps_m))))
(+ eps_m 1.0))))
2.0)
(if (<= x 1.35)
(/
(/
(*
eps_m
(*
2.0
(*
(+ x 1.0)
(+ 1.0 (* x (+ -1.0 (* x (+ 0.5 (* x -0.16666666666666666)))))))))
eps_m)
2.0)
(/ x (exp x)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -6.0) {
tmp = (2.0 + (x * (((eps_m + 1.0) * (1.0 + ((1.0 / eps_m) + ((1.0 / eps_m) - eps_m)))) / (eps_m + 1.0)))) / 2.0;
} else if (x <= 1.35) {
tmp = ((eps_m * (2.0 * ((x + 1.0) * (1.0 + (x * (-1.0 + (x * (0.5 + (x * -0.16666666666666666))))))))) / eps_m) / 2.0;
} else {
tmp = x / exp(x);
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= (-6.0d0)) then
tmp = (2.0d0 + (x * (((eps_m + 1.0d0) * (1.0d0 + ((1.0d0 / eps_m) + ((1.0d0 / eps_m) - eps_m)))) / (eps_m + 1.0d0)))) / 2.0d0
else if (x <= 1.35d0) then
tmp = ((eps_m * (2.0d0 * ((x + 1.0d0) * (1.0d0 + (x * ((-1.0d0) + (x * (0.5d0 + (x * (-0.16666666666666666d0)))))))))) / eps_m) / 2.0d0
else
tmp = x / exp(x)
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= -6.0) {
tmp = (2.0 + (x * (((eps_m + 1.0) * (1.0 + ((1.0 / eps_m) + ((1.0 / eps_m) - eps_m)))) / (eps_m + 1.0)))) / 2.0;
} else if (x <= 1.35) {
tmp = ((eps_m * (2.0 * ((x + 1.0) * (1.0 + (x * (-1.0 + (x * (0.5 + (x * -0.16666666666666666))))))))) / eps_m) / 2.0;
} else {
tmp = x / Math.exp(x);
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -6.0: tmp = (2.0 + (x * (((eps_m + 1.0) * (1.0 + ((1.0 / eps_m) + ((1.0 / eps_m) - eps_m)))) / (eps_m + 1.0)))) / 2.0 elif x <= 1.35: tmp = ((eps_m * (2.0 * ((x + 1.0) * (1.0 + (x * (-1.0 + (x * (0.5 + (x * -0.16666666666666666))))))))) / eps_m) / 2.0 else: tmp = x / math.exp(x) return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -6.0) tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(Float64(eps_m + 1.0) * Float64(1.0 + Float64(Float64(1.0 / eps_m) + Float64(Float64(1.0 / eps_m) - eps_m)))) / Float64(eps_m + 1.0)))) / 2.0); elseif (x <= 1.35) tmp = Float64(Float64(Float64(eps_m * Float64(2.0 * Float64(Float64(x + 1.0) * Float64(1.0 + Float64(x * Float64(-1.0 + Float64(x * Float64(0.5 + Float64(x * -0.16666666666666666))))))))) / eps_m) / 2.0); else tmp = Float64(x / exp(x)); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -6.0) tmp = (2.0 + (x * (((eps_m + 1.0) * (1.0 + ((1.0 / eps_m) + ((1.0 / eps_m) - eps_m)))) / (eps_m + 1.0)))) / 2.0; elseif (x <= 1.35) tmp = ((eps_m * (2.0 * ((x + 1.0) * (1.0 + (x * (-1.0 + (x * (0.5 + (x * -0.16666666666666666))))))))) / eps_m) / 2.0; else tmp = x / exp(x); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -6.0], N[(N[(2.0 + N[(x * N[(N[(N[(eps$95$m + 1.0), $MachinePrecision] * N[(1.0 + N[(N[(1.0 / eps$95$m), $MachinePrecision] + N[(N[(1.0 / eps$95$m), $MachinePrecision] - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(eps$95$m + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.35], N[(N[(N[(eps$95$m * N[(2.0 * N[(N[(x + 1.0), $MachinePrecision] * N[(1.0 + N[(x * N[(-1.0 + N[(x * N[(0.5 + N[(x * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / eps$95$m), $MachinePrecision] / 2.0), $MachinePrecision], N[(x / N[Exp[x], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6:\\
\;\;\;\;\frac{2 + x \cdot \frac{\left(eps\_m + 1\right) \cdot \left(1 + \left(\frac{1}{eps\_m} + \left(\frac{1}{eps\_m} - eps\_m\right)\right)\right)}{eps\_m + 1}}{2}\\
\mathbf{elif}\;x \leq 1.35:\\
\;\;\;\;\frac{\frac{eps\_m \cdot \left(2 \cdot \left(\left(x + 1\right) \cdot \left(1 + x \cdot \left(-1 + x \cdot \left(0.5 + x \cdot -0.16666666666666666\right)\right)\right)\right)\right)}{eps\_m}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{e^{x}}\\
\end{array}
\end{array}
if x < -6Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 3.2%
Taylor expanded in eps around 0 30.1%
associate--l+30.1%
flip-+35.3%
*-commutative35.3%
*-commutative35.3%
swap-sqr35.3%
metadata-eval35.3%
*-un-lft-identity35.3%
pow235.3%
Applied egg-rr35.3%
unpow235.3%
difference-of-squares35.3%
associate-+l+35.3%
associate--l+35.3%
associate--r-35.3%
+-inverses35.3%
associate-+l+35.3%
metadata-eval35.3%
associate--l+35.3%
associate--r-35.3%
+-inverses35.3%
associate-+l+35.3%
metadata-eval35.3%
Simplified35.3%
if -6 < x < 1.3500000000000001Initial program 54.6%
Simplified33.2%
Taylor expanded in eps around 0 27.6%
associate-+r+74.0%
mul-1-neg74.0%
sub-neg74.0%
+-inverses74.0%
distribute-lft-out74.0%
distribute-rgt1-in74.0%
mul-1-neg74.0%
Simplified74.0%
Taylor expanded in x around 0 73.5%
if 1.3500000000000001 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 58.3%
associate-+r+58.3%
mul-1-neg58.3%
sub-neg58.3%
+-inverses58.3%
distribute-lft-out58.3%
distribute-rgt1-in58.3%
mul-1-neg58.3%
Simplified58.3%
Taylor expanded in x around inf 58.3%
rec-exp58.3%
associate-*r/58.3%
*-rgt-identity58.3%
Simplified58.3%
Final simplification64.8%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 520.0) (+ 0.5 (/ 0.5 (exp x))) 0.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 520.0) {
tmp = 0.5 + (0.5 / exp(x));
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= 520.0d0) then
tmp = 0.5d0 + (0.5d0 / exp(x))
else
tmp = 0.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= 520.0) {
tmp = 0.5 + (0.5 / Math.exp(x));
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 520.0: tmp = 0.5 + (0.5 / math.exp(x)) else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 520.0) tmp = Float64(0.5 + Float64(0.5 / exp(x))); else tmp = 0.0; end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 520.0) tmp = 0.5 + (0.5 / exp(x)); else tmp = 0.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 520.0], N[(0.5 + N[(0.5 / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 520:\\
\;\;\;\;0.5 + \frac{0.5}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 520Initial program 62.8%
Simplified50.9%
Taylor expanded in eps around inf 99.3%
Taylor expanded in x around 0 77.6%
Taylor expanded in eps around 0 77.5%
distribute-lft-in77.5%
metadata-eval77.5%
associate-*r/77.5%
metadata-eval77.5%
Simplified77.5%
if 520 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 59.3%
div-sub59.3%
mul-1-neg59.3%
rec-exp59.3%
+-inverses59.3%
metadata-eval59.3%
Simplified59.3%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -6.0)
(/
(+
2.0
(*
x
(/
(* (+ eps_m 1.0) (+ 1.0 (+ (/ 1.0 eps_m) (- (/ 1.0 eps_m) eps_m))))
(+ eps_m 1.0))))
2.0)
(if (<= x 520.0)
(/
(/
(* eps_m (* 2.0 (* (+ x 1.0) (+ 1.0 (* x (+ -1.0 (* x 0.5)))))))
eps_m)
2.0)
0.0)))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -6.0) {
tmp = (2.0 + (x * (((eps_m + 1.0) * (1.0 + ((1.0 / eps_m) + ((1.0 / eps_m) - eps_m)))) / (eps_m + 1.0)))) / 2.0;
} else if (x <= 520.0) {
tmp = ((eps_m * (2.0 * ((x + 1.0) * (1.0 + (x * (-1.0 + (x * 0.5))))))) / eps_m) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= (-6.0d0)) then
tmp = (2.0d0 + (x * (((eps_m + 1.0d0) * (1.0d0 + ((1.0d0 / eps_m) + ((1.0d0 / eps_m) - eps_m)))) / (eps_m + 1.0d0)))) / 2.0d0
else if (x <= 520.0d0) then
tmp = ((eps_m * (2.0d0 * ((x + 1.0d0) * (1.0d0 + (x * ((-1.0d0) + (x * 0.5d0))))))) / eps_m) / 2.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= -6.0) {
tmp = (2.0 + (x * (((eps_m + 1.0) * (1.0 + ((1.0 / eps_m) + ((1.0 / eps_m) - eps_m)))) / (eps_m + 1.0)))) / 2.0;
} else if (x <= 520.0) {
tmp = ((eps_m * (2.0 * ((x + 1.0) * (1.0 + (x * (-1.0 + (x * 0.5))))))) / eps_m) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -6.0: tmp = (2.0 + (x * (((eps_m + 1.0) * (1.0 + ((1.0 / eps_m) + ((1.0 / eps_m) - eps_m)))) / (eps_m + 1.0)))) / 2.0 elif x <= 520.0: tmp = ((eps_m * (2.0 * ((x + 1.0) * (1.0 + (x * (-1.0 + (x * 0.5))))))) / eps_m) / 2.0 else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -6.0) tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(Float64(eps_m + 1.0) * Float64(1.0 + Float64(Float64(1.0 / eps_m) + Float64(Float64(1.0 / eps_m) - eps_m)))) / Float64(eps_m + 1.0)))) / 2.0); elseif (x <= 520.0) tmp = Float64(Float64(Float64(eps_m * Float64(2.0 * Float64(Float64(x + 1.0) * Float64(1.0 + Float64(x * Float64(-1.0 + Float64(x * 0.5))))))) / eps_m) / 2.0); else tmp = 0.0; end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -6.0) tmp = (2.0 + (x * (((eps_m + 1.0) * (1.0 + ((1.0 / eps_m) + ((1.0 / eps_m) - eps_m)))) / (eps_m + 1.0)))) / 2.0; elseif (x <= 520.0) tmp = ((eps_m * (2.0 * ((x + 1.0) * (1.0 + (x * (-1.0 + (x * 0.5))))))) / eps_m) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -6.0], N[(N[(2.0 + N[(x * N[(N[(N[(eps$95$m + 1.0), $MachinePrecision] * N[(1.0 + N[(N[(1.0 / eps$95$m), $MachinePrecision] + N[(N[(1.0 / eps$95$m), $MachinePrecision] - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(eps$95$m + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 520.0], N[(N[(N[(eps$95$m * N[(2.0 * N[(N[(x + 1.0), $MachinePrecision] * N[(1.0 + N[(x * N[(-1.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / eps$95$m), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6:\\
\;\;\;\;\frac{2 + x \cdot \frac{\left(eps\_m + 1\right) \cdot \left(1 + \left(\frac{1}{eps\_m} + \left(\frac{1}{eps\_m} - eps\_m\right)\right)\right)}{eps\_m + 1}}{2}\\
\mathbf{elif}\;x \leq 520:\\
\;\;\;\;\frac{\frac{eps\_m \cdot \left(2 \cdot \left(\left(x + 1\right) \cdot \left(1 + x \cdot \left(-1 + x \cdot 0.5\right)\right)\right)\right)}{eps\_m}}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -6Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 3.2%
Taylor expanded in eps around 0 30.1%
associate--l+30.1%
flip-+35.3%
*-commutative35.3%
*-commutative35.3%
swap-sqr35.3%
metadata-eval35.3%
*-un-lft-identity35.3%
pow235.3%
Applied egg-rr35.3%
unpow235.3%
difference-of-squares35.3%
associate-+l+35.3%
associate--l+35.3%
associate--r-35.3%
+-inverses35.3%
associate-+l+35.3%
metadata-eval35.3%
associate--l+35.3%
associate--r-35.3%
+-inverses35.3%
associate-+l+35.3%
metadata-eval35.3%
Simplified35.3%
if -6 < x < 520Initial program 54.8%
Simplified33.6%
Taylor expanded in eps around 0 27.5%
associate-+r+73.6%
mul-1-neg73.6%
sub-neg73.6%
+-inverses73.6%
distribute-lft-out73.6%
distribute-rgt1-in73.6%
mul-1-neg73.6%
Simplified73.6%
Taylor expanded in x around 0 73.1%
if 520 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 59.3%
div-sub59.3%
mul-1-neg59.3%
rec-exp59.3%
+-inverses59.3%
metadata-eval59.3%
Simplified59.3%
Final simplification64.8%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 13.5) (/ (+ 2.0 (* x (- (+ (/ 1.0 eps_m) (- -1.0 (/ 1.0 eps_m))) eps_m))) 2.0) 0.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 13.5) {
tmp = (2.0 + (x * (((1.0 / eps_m) + (-1.0 - (1.0 / eps_m))) - eps_m))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= 13.5d0) then
tmp = (2.0d0 + (x * (((1.0d0 / eps_m) + ((-1.0d0) - (1.0d0 / eps_m))) - eps_m))) / 2.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= 13.5) {
tmp = (2.0 + (x * (((1.0 / eps_m) + (-1.0 - (1.0 / eps_m))) - eps_m))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 13.5: tmp = (2.0 + (x * (((1.0 / eps_m) + (-1.0 - (1.0 / eps_m))) - eps_m))) / 2.0 else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 13.5) tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(Float64(1.0 / eps_m) + Float64(-1.0 - Float64(1.0 / eps_m))) - eps_m))) / 2.0); else tmp = 0.0; end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 13.5) tmp = (2.0 + (x * (((1.0 / eps_m) + (-1.0 - (1.0 / eps_m))) - eps_m))) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 13.5], N[(N[(2.0 + N[(x * N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] + N[(-1.0 - N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 13.5:\\
\;\;\;\;\frac{2 + x \cdot \left(\left(\frac{1}{eps\_m} + \left(-1 - \frac{1}{eps\_m}\right)\right) - eps\_m\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 13.5Initial program 62.6%
Simplified50.6%
Taylor expanded in x around 0 60.9%
Taylor expanded in eps around 0 65.0%
if 13.5 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 58.3%
div-sub58.3%
mul-1-neg58.3%
rec-exp58.3%
+-inverses58.3%
metadata-eval58.3%
Simplified58.3%
Final simplification63.5%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 13.5) (/ (- 2.0 (* x eps_m)) 2.0) 0.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 13.5) {
tmp = (2.0 - (x * eps_m)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= 13.5d0) then
tmp = (2.0d0 - (x * eps_m)) / 2.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= 13.5) {
tmp = (2.0 - (x * eps_m)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 13.5: tmp = (2.0 - (x * eps_m)) / 2.0 else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 13.5) tmp = Float64(Float64(2.0 - Float64(x * eps_m)) / 2.0); else tmp = 0.0; end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 13.5) tmp = (2.0 - (x * eps_m)) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 13.5], N[(N[(2.0 - N[(x * eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 13.5:\\
\;\;\;\;\frac{2 - x \cdot eps\_m}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 13.5Initial program 62.6%
Simplified50.6%
Taylor expanded in x around 0 60.9%
Taylor expanded in eps around 0 65.0%
Taylor expanded in x around 0 65.0%
associate-*r*65.0%
neg-mul-165.0%
Simplified65.0%
if 13.5 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 58.3%
div-sub58.3%
mul-1-neg58.3%
rec-exp58.3%
+-inverses58.3%
metadata-eval58.3%
Simplified58.3%
Final simplification63.5%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 2.0) (/ (- 2.0 x) 2.0) 0.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 2.0) {
tmp = (2.0 - x) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= 2.0d0) then
tmp = (2.0d0 - x) / 2.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= 2.0) {
tmp = (2.0 - x) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 2.0: tmp = (2.0 - x) / 2.0 else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 2.0) tmp = Float64(Float64(2.0 - x) / 2.0); else tmp = 0.0; end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 2.0) tmp = (2.0 - x) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 2.0], N[(N[(2.0 - x), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2:\\
\;\;\;\;\frac{2 - x}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 2Initial program 62.6%
Simplified50.6%
Taylor expanded in eps around inf 99.3%
Taylor expanded in eps around inf 99.3%
*-commutative99.3%
Simplified99.3%
Taylor expanded in x around 0 61.1%
neg-mul-161.1%
unsub-neg61.1%
Simplified61.1%
if 2 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 58.3%
div-sub58.3%
mul-1-neg58.3%
rec-exp58.3%
+-inverses58.3%
metadata-eval58.3%
Simplified58.3%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 490.0) 1.0 0.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 490.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= 490.0d0) then
tmp = 1.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= 490.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 490.0: tmp = 1.0 else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 490.0) tmp = 1.0; else tmp = 0.0; end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 490.0) tmp = 1.0; else tmp = 0.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 490.0], 1.0, 0.0]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 490:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 490Initial program 62.8%
Simplified50.9%
Taylor expanded in eps around inf 99.3%
Taylor expanded in x around 0 77.6%
Taylor expanded in x around 0 60.6%
if 490 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 59.3%
div-sub59.3%
mul-1-neg59.3%
rec-exp59.3%
+-inverses59.3%
metadata-eval59.3%
Simplified59.3%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 0.0)
eps_m = fabs(eps);
double code(double x, double eps_m) {
return 0.0;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
code = 0.0d0
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
return 0.0;
}
eps_m = math.fabs(eps) def code(x, eps_m): return 0.0
eps_m = abs(eps) function code(x, eps_m) return 0.0 end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = 0.0; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := 0.0
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
0
\end{array}
Initial program 71.2%
Simplified62.0%
Taylor expanded in eps around 0 15.2%
div-sub15.2%
mul-1-neg15.2%
rec-exp15.2%
+-inverses15.4%
metadata-eval15.4%
Simplified15.4%
herbie shell --seed 2024180
(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))