
(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}
(FPCore (x eps) :precision binary64 (/ (+ (exp (* x (- -1.0 eps))) (exp (* x (- eps 1.0)))) 2.0))
double code(double x, double eps) {
return (exp((x * (-1.0 - eps))) + exp((x * (eps - 1.0)))) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (exp((x * ((-1.0d0) - eps))) + exp((x * (eps - 1.0d0)))) / 2.0d0
end function
public static double code(double x, double eps) {
return (Math.exp((x * (-1.0 - eps))) + Math.exp((x * (eps - 1.0)))) / 2.0;
}
def code(x, eps): return (math.exp((x * (-1.0 - eps))) + math.exp((x * (eps - 1.0)))) / 2.0
function code(x, eps) return Float64(Float64(exp(Float64(x * Float64(-1.0 - eps))) + exp(Float64(x * Float64(eps - 1.0)))) / 2.0) end
function tmp = code(x, eps) tmp = (exp((x * (-1.0 - eps))) + exp((x * (eps - 1.0)))) / 2.0; end
code[x_, eps_] := N[(N[(N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * N[(eps - 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{x \cdot \left(-1 - \varepsilon\right)} + e^{x \cdot \left(\varepsilon - 1\right)}}{2}
\end{array}
Initial program 72.4%
Simplified57.3%
Taylor expanded in eps around inf 99.6%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(if (<= x 108000000000.0)
(/ (+ (exp (* x (- -1.0 eps))) (exp (* x eps))) 2.0)
(if (<= x 6.4e+59)
(/ (+ (+ 1.0 (/ 1.0 eps)) (+ 1.0 (/ -1.0 eps))) 2.0)
(/ (+ 1.0 (exp (* x (- eps 1.0)))) 2.0))))
double code(double x, double eps) {
double tmp;
if (x <= 108000000000.0) {
tmp = (exp((x * (-1.0 - eps))) + exp((x * eps))) / 2.0;
} else if (x <= 6.4e+59) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
} else {
tmp = (1.0 + exp((x * (eps - 1.0)))) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 108000000000.0d0) then
tmp = (exp((x * ((-1.0d0) - eps))) + exp((x * eps))) / 2.0d0
else if (x <= 6.4d+59) then
tmp = ((1.0d0 + (1.0d0 / eps)) + (1.0d0 + ((-1.0d0) / eps))) / 2.0d0
else
tmp = (1.0d0 + exp((x * (eps - 1.0d0)))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 108000000000.0) {
tmp = (Math.exp((x * (-1.0 - eps))) + Math.exp((x * eps))) / 2.0;
} else if (x <= 6.4e+59) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
} else {
tmp = (1.0 + Math.exp((x * (eps - 1.0)))) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 108000000000.0: tmp = (math.exp((x * (-1.0 - eps))) + math.exp((x * eps))) / 2.0 elif x <= 6.4e+59: tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0 else: tmp = (1.0 + math.exp((x * (eps - 1.0)))) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 108000000000.0) tmp = Float64(Float64(exp(Float64(x * Float64(-1.0 - eps))) + exp(Float64(x * eps))) / 2.0); elseif (x <= 6.4e+59) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) + Float64(1.0 + Float64(-1.0 / eps))) / 2.0); else tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(eps - 1.0)))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 108000000000.0) tmp = (exp((x * (-1.0 - eps))) + exp((x * eps))) / 2.0; elseif (x <= 6.4e+59) tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0; else tmp = (1.0 + exp((x * (eps - 1.0)))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 108000000000.0], N[(N[(N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 6.4e+59], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(1.0 + N[Exp[N[(x * N[(eps - 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 108000000000:\\
\;\;\;\;\frac{e^{x \cdot \left(-1 - \varepsilon\right)} + e^{x \cdot \varepsilon}}{2}\\
\mathbf{elif}\;x \leq 6.4 \cdot 10^{+59}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) + \left(1 + \frac{-1}{\varepsilon}\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(\varepsilon - 1\right)}}{2}\\
\end{array}
\end{array}
if x < 1.08e11Initial program 62.6%
Simplified42.2%
Taylor expanded in eps around inf 99.5%
Taylor expanded in eps around inf 99.5%
*-commutative99.5%
Simplified99.5%
if 1.08e11 < x < 6.39999999999999964e59Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 9.9%
Taylor expanded in x around 0 77.6%
if 6.39999999999999964e59 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 35.1%
Taylor expanded in eps around inf 35.4%
mul-1-neg35.4%
distribute-rgt-neg-out35.4%
Simplified35.4%
Final simplification84.8%
(FPCore (x eps)
:precision binary64
(if (<= x -1e-281)
(/ (* eps (+ x (/ (+ 1.0 (exp (* x (- -1.0 eps)))) eps))) 2.0)
(if (or (<= x 180000000000.0) (not (<= x 9e+58)))
(/ (+ 1.0 (exp (* x (- eps 1.0)))) 2.0)
(/ (+ (+ 1.0 (/ 1.0 eps)) (+ 1.0 (/ -1.0 eps))) 2.0))))
double code(double x, double eps) {
double tmp;
if (x <= -1e-281) {
tmp = (eps * (x + ((1.0 + exp((x * (-1.0 - eps)))) / eps))) / 2.0;
} else if ((x <= 180000000000.0) || !(x <= 9e+58)) {
tmp = (1.0 + exp((x * (eps - 1.0)))) / 2.0;
} else {
tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-1d-281)) then
tmp = (eps * (x + ((1.0d0 + exp((x * ((-1.0d0) - eps)))) / eps))) / 2.0d0
else if ((x <= 180000000000.0d0) .or. (.not. (x <= 9d+58))) then
tmp = (1.0d0 + exp((x * (eps - 1.0d0)))) / 2.0d0
else
tmp = ((1.0d0 + (1.0d0 / eps)) + (1.0d0 + ((-1.0d0) / eps))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -1e-281) {
tmp = (eps * (x + ((1.0 + Math.exp((x * (-1.0 - eps)))) / eps))) / 2.0;
} else if ((x <= 180000000000.0) || !(x <= 9e+58)) {
tmp = (1.0 + Math.exp((x * (eps - 1.0)))) / 2.0;
} else {
tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -1e-281: tmp = (eps * (x + ((1.0 + math.exp((x * (-1.0 - eps)))) / eps))) / 2.0 elif (x <= 180000000000.0) or not (x <= 9e+58): tmp = (1.0 + math.exp((x * (eps - 1.0)))) / 2.0 else: tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -1e-281) tmp = Float64(Float64(eps * Float64(x + Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps)))) / eps))) / 2.0); elseif ((x <= 180000000000.0) || !(x <= 9e+58)) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(eps - 1.0)))) / 2.0); else tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) + Float64(1.0 + Float64(-1.0 / eps))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -1e-281) tmp = (eps * (x + ((1.0 + exp((x * (-1.0 - eps)))) / eps))) / 2.0; elseif ((x <= 180000000000.0) || ~((x <= 9e+58))) tmp = (1.0 + exp((x * (eps - 1.0)))) / 2.0; else tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -1e-281], N[(N[(eps * N[(x + N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 180000000000.0], N[Not[LessEqual[x, 9e+58]], $MachinePrecision]], N[(N[(1.0 + N[Exp[N[(x * N[(eps - 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-281}:\\
\;\;\;\;\frac{\varepsilon \cdot \left(x + \frac{1 + e^{x \cdot \left(-1 - \varepsilon\right)}}{\varepsilon}\right)}{2}\\
\mathbf{elif}\;x \leq 180000000000 \lor \neg \left(x \leq 9 \cdot 10^{+58}\right):\\
\;\;\;\;\frac{1 + e^{x \cdot \left(\varepsilon - 1\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) + \left(1 + \frac{-1}{\varepsilon}\right)}{2}\\
\end{array}
\end{array}
if x < -1e-281Initial program 73.7%
Simplified73.7%
Taylor expanded in x around 0 46.2%
Taylor expanded in eps around inf 80.0%
Taylor expanded in eps around -inf 80.0%
associate-*r*80.0%
neg-mul-180.0%
distribute-lft-out80.0%
Simplified80.0%
if -1e-281 < x < 1.8e11 or 8.9999999999999996e58 < x Initial program 69.2%
Simplified69.2%
Taylor expanded in x around 0 38.4%
Taylor expanded in eps around inf 69.3%
mul-1-neg69.3%
distribute-rgt-neg-out69.3%
Simplified69.3%
if 1.8e11 < x < 8.9999999999999996e58Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 9.9%
Taylor expanded in x around 0 77.6%
Final simplification73.6%
(FPCore (x eps)
:precision binary64
(if (<= x -1e-281)
(/ (+ 1.0 (exp (* x (- -1.0 eps)))) 2.0)
(if (or (<= x 16200000000.0) (not (<= x 9e+58)))
(/ (+ 1.0 (exp (* x (- eps 1.0)))) 2.0)
(/ (+ (+ 1.0 (/ 1.0 eps)) (+ 1.0 (/ -1.0 eps))) 2.0))))
double code(double x, double eps) {
double tmp;
if (x <= -1e-281) {
tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0;
} else if ((x <= 16200000000.0) || !(x <= 9e+58)) {
tmp = (1.0 + exp((x * (eps - 1.0)))) / 2.0;
} else {
tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-1d-281)) then
tmp = (1.0d0 + exp((x * ((-1.0d0) - eps)))) / 2.0d0
else if ((x <= 16200000000.0d0) .or. (.not. (x <= 9d+58))) then
tmp = (1.0d0 + exp((x * (eps - 1.0d0)))) / 2.0d0
else
tmp = ((1.0d0 + (1.0d0 / eps)) + (1.0d0 + ((-1.0d0) / eps))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -1e-281) {
tmp = (1.0 + Math.exp((x * (-1.0 - eps)))) / 2.0;
} else if ((x <= 16200000000.0) || !(x <= 9e+58)) {
tmp = (1.0 + Math.exp((x * (eps - 1.0)))) / 2.0;
} else {
tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -1e-281: tmp = (1.0 + math.exp((x * (-1.0 - eps)))) / 2.0 elif (x <= 16200000000.0) or not (x <= 9e+58): tmp = (1.0 + math.exp((x * (eps - 1.0)))) / 2.0 else: tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -1e-281) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps)))) / 2.0); elseif ((x <= 16200000000.0) || !(x <= 9e+58)) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(eps - 1.0)))) / 2.0); else tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) + Float64(1.0 + Float64(-1.0 / eps))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -1e-281) tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0; elseif ((x <= 16200000000.0) || ~((x <= 9e+58))) tmp = (1.0 + exp((x * (eps - 1.0)))) / 2.0; else tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -1e-281], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 16200000000.0], N[Not[LessEqual[x, 9e+58]], $MachinePrecision]], N[(N[(1.0 + N[Exp[N[(x * N[(eps - 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-281}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - \varepsilon\right)}}{2}\\
\mathbf{elif}\;x \leq 16200000000 \lor \neg \left(x \leq 9 \cdot 10^{+58}\right):\\
\;\;\;\;\frac{1 + e^{x \cdot \left(\varepsilon - 1\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) + \left(1 + \frac{-1}{\varepsilon}\right)}{2}\\
\end{array}
\end{array}
if x < -1e-281Initial program 73.7%
Simplified73.7%
Taylor expanded in x around 0 47.0%
Taylor expanded in eps around inf 72.3%
Taylor expanded in eps around -inf 72.3%
sub-neg72.3%
mul-1-neg72.3%
remove-double-neg72.3%
mul-1-neg72.3%
distribute-rgt-neg-in72.3%
sub-neg72.3%
neg-mul-172.3%
remove-double-neg72.3%
distribute-neg-in72.3%
metadata-eval72.3%
unsub-neg72.3%
Simplified72.3%
if -1e-281 < x < 1.62e10 or 8.9999999999999996e58 < x Initial program 69.2%
Simplified69.2%
Taylor expanded in x around 0 38.4%
Taylor expanded in eps around inf 69.3%
mul-1-neg69.3%
distribute-rgt-neg-out69.3%
Simplified69.3%
if 1.62e10 < x < 8.9999999999999996e58Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 9.9%
Taylor expanded in x around 0 77.6%
Final simplification70.8%
(FPCore (x eps)
:precision binary64
(if (<= x -410.0)
(/ (/ (expm1 (- x)) eps) 2.0)
(if (<= x 6.1e-9)
1.0
(if (<= x 5.4e+59)
(/ (+ (+ 1.0 (/ 1.0 eps)) (+ 1.0 (/ -1.0 eps))) 2.0)
(/ (/ (expm1 x) eps) 2.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -410.0) {
tmp = (expm1(-x) / eps) / 2.0;
} else if (x <= 6.1e-9) {
tmp = 1.0;
} else if (x <= 5.4e+59) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
} else {
tmp = (expm1(x) / eps) / 2.0;
}
return tmp;
}
public static double code(double x, double eps) {
double tmp;
if (x <= -410.0) {
tmp = (Math.expm1(-x) / eps) / 2.0;
} else if (x <= 6.1e-9) {
tmp = 1.0;
} else if (x <= 5.4e+59) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
} else {
tmp = (Math.expm1(x) / eps) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -410.0: tmp = (math.expm1(-x) / eps) / 2.0 elif x <= 6.1e-9: tmp = 1.0 elif x <= 5.4e+59: tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0 else: tmp = (math.expm1(x) / eps) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -410.0) tmp = Float64(Float64(expm1(Float64(-x)) / eps) / 2.0); elseif (x <= 6.1e-9) tmp = 1.0; elseif (x <= 5.4e+59) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) + Float64(1.0 + Float64(-1.0 / eps))) / 2.0); else tmp = Float64(Float64(expm1(x) / eps) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -410.0], N[(N[(N[(Exp[(-x)] - 1), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 6.1e-9], 1.0, If[LessEqual[x, 5.4e+59], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(Exp[x] - 1), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -410:\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(-x\right)}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq 6.1 \cdot 10^{-9}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 5.4 \cdot 10^{+59}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) + \left(1 + \frac{-1}{\varepsilon}\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(x\right)}{\varepsilon}}{2}\\
\end{array}
\end{array}
if x < -410Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 39.5%
Taylor expanded in eps around 0 62.5%
expm1-define62.5%
mul-1-neg62.5%
Simplified62.5%
if -410 < x < 6.1e-9Initial program 54.4%
Simplified54.4%
Taylor expanded in x around 0 75.5%
if 6.1e-9 < x < 5.4000000000000002e59Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 9.0%
Taylor expanded in x around 0 67.7%
if 5.4000000000000002e59 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 35.1%
Taylor expanded in eps around 0 1.8%
expm1-define1.8%
mul-1-neg1.8%
Simplified1.8%
expm1-undefine1.8%
div-sub1.8%
add-sqr-sqrt0.0%
sqrt-unprod33.9%
sqr-neg33.9%
sqrt-unprod33.9%
add-sqr-sqrt33.9%
Applied egg-rr33.9%
div-sub33.9%
expm1-undefine33.9%
Simplified33.9%
Final simplification64.6%
(FPCore (x eps)
:precision binary64
(if (<= x -9.5e+94)
(/
(*
x
(+
(*
x
(+
(*
x
(+
(* 0.041666666666666664 (/ x eps))
(* 0.16666666666666666 (/ -1.0 eps))))
(* (/ 1.0 eps) 0.5)))
(/ -1.0 eps)))
2.0)
(if (<= x 6.1e-9)
(/ (- 2.0 (* x eps)) 2.0)
(if (<= x 2.6e+64)
(/ (+ (+ 1.0 (/ 1.0 eps)) (+ 1.0 (/ -1.0 eps))) 2.0)
(/ (/ (expm1 x) eps) 2.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -9.5e+94) {
tmp = (x * ((x * ((x * ((0.041666666666666664 * (x / eps)) + (0.16666666666666666 * (-1.0 / eps)))) + ((1.0 / eps) * 0.5))) + (-1.0 / eps))) / 2.0;
} else if (x <= 6.1e-9) {
tmp = (2.0 - (x * eps)) / 2.0;
} else if (x <= 2.6e+64) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
} else {
tmp = (expm1(x) / eps) / 2.0;
}
return tmp;
}
public static double code(double x, double eps) {
double tmp;
if (x <= -9.5e+94) {
tmp = (x * ((x * ((x * ((0.041666666666666664 * (x / eps)) + (0.16666666666666666 * (-1.0 / eps)))) + ((1.0 / eps) * 0.5))) + (-1.0 / eps))) / 2.0;
} else if (x <= 6.1e-9) {
tmp = (2.0 - (x * eps)) / 2.0;
} else if (x <= 2.6e+64) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
} else {
tmp = (Math.expm1(x) / eps) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -9.5e+94: tmp = (x * ((x * ((x * ((0.041666666666666664 * (x / eps)) + (0.16666666666666666 * (-1.0 / eps)))) + ((1.0 / eps) * 0.5))) + (-1.0 / eps))) / 2.0 elif x <= 6.1e-9: tmp = (2.0 - (x * eps)) / 2.0 elif x <= 2.6e+64: tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0 else: tmp = (math.expm1(x) / eps) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -9.5e+94) tmp = Float64(Float64(x * Float64(Float64(x * Float64(Float64(x * Float64(Float64(0.041666666666666664 * Float64(x / eps)) + Float64(0.16666666666666666 * Float64(-1.0 / eps)))) + Float64(Float64(1.0 / eps) * 0.5))) + Float64(-1.0 / eps))) / 2.0); elseif (x <= 6.1e-9) tmp = Float64(Float64(2.0 - Float64(x * eps)) / 2.0); elseif (x <= 2.6e+64) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) + Float64(1.0 + Float64(-1.0 / eps))) / 2.0); else tmp = Float64(Float64(expm1(x) / eps) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -9.5e+94], N[(N[(x * N[(N[(x * N[(N[(x * N[(N[(0.041666666666666664 * N[(x / eps), $MachinePrecision]), $MachinePrecision] + N[(0.16666666666666666 * N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / eps), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 6.1e-9], N[(N[(2.0 - N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 2.6e+64], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(Exp[x] - 1), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.5 \cdot 10^{+94}:\\
\;\;\;\;\frac{x \cdot \left(x \cdot \left(x \cdot \left(0.041666666666666664 \cdot \frac{x}{\varepsilon} + 0.16666666666666666 \cdot \frac{-1}{\varepsilon}\right) + \frac{1}{\varepsilon} \cdot 0.5\right) + \frac{-1}{\varepsilon}\right)}{2}\\
\mathbf{elif}\;x \leq 6.1 \cdot 10^{-9}:\\
\;\;\;\;\frac{2 - x \cdot \varepsilon}{2}\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{+64}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) + \left(1 + \frac{-1}{\varepsilon}\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(x\right)}{\varepsilon}}{2}\\
\end{array}
\end{array}
if x < -9.4999999999999998e94Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 35.4%
Taylor expanded in eps around 0 66.7%
expm1-define66.7%
mul-1-neg66.7%
Simplified66.7%
Taylor expanded in x around 0 62.2%
if -9.4999999999999998e94 < x < 6.1e-9Initial program 57.4%
Simplified57.4%
Taylor expanded in x around 0 41.6%
Taylor expanded in x around 0 44.8%
Taylor expanded in eps around inf 70.9%
associate-*r*70.9%
neg-mul-170.9%
Simplified70.9%
if 6.1e-9 < x < 2.59999999999999997e64Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 9.0%
Taylor expanded in x around 0 67.7%
if 2.59999999999999997e64 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 35.1%
Taylor expanded in eps around 0 1.8%
expm1-define1.8%
mul-1-neg1.8%
Simplified1.8%
expm1-undefine1.8%
div-sub1.8%
add-sqr-sqrt0.0%
sqrt-unprod33.9%
sqr-neg33.9%
sqrt-unprod33.9%
add-sqr-sqrt33.9%
Applied egg-rr33.9%
div-sub33.9%
expm1-undefine33.9%
Simplified33.9%
Final simplification62.2%
(FPCore (x eps)
:precision binary64
(if (<= x 6.1e-9)
(/ (+ 1.0 (exp (* x (- -1.0 eps)))) 2.0)
(if (<= x 1.1e+64)
(/ (+ (+ 1.0 (/ 1.0 eps)) (+ 1.0 (/ -1.0 eps))) 2.0)
(/ (/ (expm1 x) eps) 2.0))))
double code(double x, double eps) {
double tmp;
if (x <= 6.1e-9) {
tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0;
} else if (x <= 1.1e+64) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
} else {
tmp = (expm1(x) / eps) / 2.0;
}
return tmp;
}
public static double code(double x, double eps) {
double tmp;
if (x <= 6.1e-9) {
tmp = (1.0 + Math.exp((x * (-1.0 - eps)))) / 2.0;
} else if (x <= 1.1e+64) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
} else {
tmp = (Math.expm1(x) / eps) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 6.1e-9: tmp = (1.0 + math.exp((x * (-1.0 - eps)))) / 2.0 elif x <= 1.1e+64: tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0 else: tmp = (math.expm1(x) / eps) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 6.1e-9) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps)))) / 2.0); elseif (x <= 1.1e+64) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) + Float64(1.0 + Float64(-1.0 / eps))) / 2.0); else tmp = Float64(Float64(expm1(x) / eps) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, 6.1e-9], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.1e+64], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(Exp[x] - 1), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.1 \cdot 10^{-9}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - \varepsilon\right)}}{2}\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{+64}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) + \left(1 + \frac{-1}{\varepsilon}\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(x\right)}{\varepsilon}}{2}\\
\end{array}
\end{array}
if x < 6.1e-9Initial program 62.2%
Simplified62.2%
Taylor expanded in x around 0 44.5%
Taylor expanded in eps around inf 81.8%
Taylor expanded in eps around -inf 81.8%
sub-neg81.8%
mul-1-neg81.8%
remove-double-neg81.8%
mul-1-neg81.8%
distribute-rgt-neg-in81.8%
sub-neg81.8%
neg-mul-181.8%
remove-double-neg81.8%
distribute-neg-in81.8%
metadata-eval81.8%
unsub-neg81.8%
Simplified81.8%
if 6.1e-9 < x < 1.10000000000000001e64Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 9.0%
Taylor expanded in x around 0 67.7%
if 1.10000000000000001e64 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 35.1%
Taylor expanded in eps around 0 1.8%
expm1-define1.8%
mul-1-neg1.8%
Simplified1.8%
expm1-undefine1.8%
div-sub1.8%
add-sqr-sqrt0.0%
sqrt-unprod33.9%
sqr-neg33.9%
sqrt-unprod33.9%
add-sqr-sqrt33.9%
Applied egg-rr33.9%
div-sub33.9%
expm1-undefine33.9%
Simplified33.9%
Final simplification70.9%
(FPCore (x eps)
:precision binary64
(let* ((t_0
(/
(*
x
(+
(*
x
(+
(*
x
(+
(* 0.041666666666666664 (/ x eps))
(* 0.16666666666666666 (/ -1.0 eps))))
(* (/ 1.0 eps) 0.5)))
(/ -1.0 eps)))
2.0)))
(if (<= x -7.9e+93)
t_0
(if (<= x 6.1e-9)
(/ (- 2.0 (* x eps)) 2.0)
(if (<= x 8e+129)
(/ (+ (+ 1.0 (/ 1.0 eps)) (+ 1.0 (/ -1.0 eps))) 2.0)
t_0)))))
double code(double x, double eps) {
double t_0 = (x * ((x * ((x * ((0.041666666666666664 * (x / eps)) + (0.16666666666666666 * (-1.0 / eps)))) + ((1.0 / eps) * 0.5))) + (-1.0 / eps))) / 2.0;
double tmp;
if (x <= -7.9e+93) {
tmp = t_0;
} else if (x <= 6.1e-9) {
tmp = (2.0 - (x * eps)) / 2.0;
} else if (x <= 8e+129) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
} else {
tmp = t_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 = (x * ((x * ((x * ((0.041666666666666664d0 * (x / eps)) + (0.16666666666666666d0 * ((-1.0d0) / eps)))) + ((1.0d0 / eps) * 0.5d0))) + ((-1.0d0) / eps))) / 2.0d0
if (x <= (-7.9d+93)) then
tmp = t_0
else if (x <= 6.1d-9) then
tmp = (2.0d0 - (x * eps)) / 2.0d0
else if (x <= 8d+129) then
tmp = ((1.0d0 + (1.0d0 / eps)) + (1.0d0 + ((-1.0d0) / eps))) / 2.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = (x * ((x * ((x * ((0.041666666666666664 * (x / eps)) + (0.16666666666666666 * (-1.0 / eps)))) + ((1.0 / eps) * 0.5))) + (-1.0 / eps))) / 2.0;
double tmp;
if (x <= -7.9e+93) {
tmp = t_0;
} else if (x <= 6.1e-9) {
tmp = (2.0 - (x * eps)) / 2.0;
} else if (x <= 8e+129) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = (x * ((x * ((x * ((0.041666666666666664 * (x / eps)) + (0.16666666666666666 * (-1.0 / eps)))) + ((1.0 / eps) * 0.5))) + (-1.0 / eps))) / 2.0 tmp = 0 if x <= -7.9e+93: tmp = t_0 elif x <= 6.1e-9: tmp = (2.0 - (x * eps)) / 2.0 elif x <= 8e+129: tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0 else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(Float64(x * Float64(Float64(x * Float64(Float64(x * Float64(Float64(0.041666666666666664 * Float64(x / eps)) + Float64(0.16666666666666666 * Float64(-1.0 / eps)))) + Float64(Float64(1.0 / eps) * 0.5))) + Float64(-1.0 / eps))) / 2.0) tmp = 0.0 if (x <= -7.9e+93) tmp = t_0; elseif (x <= 6.1e-9) tmp = Float64(Float64(2.0 - Float64(x * eps)) / 2.0); elseif (x <= 8e+129) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) + Float64(1.0 + Float64(-1.0 / eps))) / 2.0); else tmp = t_0; end return tmp end
function tmp_2 = code(x, eps) t_0 = (x * ((x * ((x * ((0.041666666666666664 * (x / eps)) + (0.16666666666666666 * (-1.0 / eps)))) + ((1.0 / eps) * 0.5))) + (-1.0 / eps))) / 2.0; tmp = 0.0; if (x <= -7.9e+93) tmp = t_0; elseif (x <= 6.1e-9) tmp = (2.0 - (x * eps)) / 2.0; elseif (x <= 8e+129) tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[(x * N[(N[(x * N[(N[(x * N[(N[(0.041666666666666664 * N[(x / eps), $MachinePrecision]), $MachinePrecision] + N[(0.16666666666666666 * N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / eps), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[x, -7.9e+93], t$95$0, If[LessEqual[x, 6.1e-9], N[(N[(2.0 - N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 8e+129], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(x \cdot \left(x \cdot \left(0.041666666666666664 \cdot \frac{x}{\varepsilon} + 0.16666666666666666 \cdot \frac{-1}{\varepsilon}\right) + \frac{1}{\varepsilon} \cdot 0.5\right) + \frac{-1}{\varepsilon}\right)}{2}\\
\mathbf{if}\;x \leq -7.9 \cdot 10^{+93}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 6.1 \cdot 10^{-9}:\\
\;\;\;\;\frac{2 - x \cdot \varepsilon}{2}\\
\mathbf{elif}\;x \leq 8 \cdot 10^{+129}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) + \left(1 + \frac{-1}{\varepsilon}\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -7.8999999999999999e93 or 8e129 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 35.7%
Taylor expanded in eps around 0 23.8%
expm1-define23.8%
mul-1-neg23.8%
Simplified23.8%
Taylor expanded in x around 0 44.1%
if -7.8999999999999999e93 < x < 6.1e-9Initial program 57.4%
Simplified57.4%
Taylor expanded in x around 0 41.6%
Taylor expanded in x around 0 44.8%
Taylor expanded in eps around inf 70.9%
associate-*r*70.9%
neg-mul-170.9%
Simplified70.9%
if 6.1e-9 < x < 8e129Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 23.4%
Taylor expanded in x around 0 51.6%
Final simplification62.3%
(FPCore (x eps)
:precision binary64
(if (<= x -2.6e+122)
(/
(*
x
(+
(* x (+ (* (/ 1.0 eps) 0.5) (* (/ x eps) -0.16666666666666666)))
(/ -1.0 eps)))
2.0)
(if (<= x 6.1e-9)
(/ (- 2.0 (* x eps)) 2.0)
(if (or (<= x 7e+153) (not (<= x 1.96e+295)))
(/ (+ (+ 1.0 (/ 1.0 eps)) (+ 1.0 (/ -1.0 eps))) 2.0)
(/ (* x eps) 2.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -2.6e+122) {
tmp = (x * ((x * (((1.0 / eps) * 0.5) + ((x / eps) * -0.16666666666666666))) + (-1.0 / eps))) / 2.0;
} else if (x <= 6.1e-9) {
tmp = (2.0 - (x * eps)) / 2.0;
} else if ((x <= 7e+153) || !(x <= 1.96e+295)) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
} else {
tmp = (x * eps) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-2.6d+122)) then
tmp = (x * ((x * (((1.0d0 / eps) * 0.5d0) + ((x / eps) * (-0.16666666666666666d0)))) + ((-1.0d0) / eps))) / 2.0d0
else if (x <= 6.1d-9) then
tmp = (2.0d0 - (x * eps)) / 2.0d0
else if ((x <= 7d+153) .or. (.not. (x <= 1.96d+295))) then
tmp = ((1.0d0 + (1.0d0 / eps)) + (1.0d0 + ((-1.0d0) / eps))) / 2.0d0
else
tmp = (x * eps) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -2.6e+122) {
tmp = (x * ((x * (((1.0 / eps) * 0.5) + ((x / eps) * -0.16666666666666666))) + (-1.0 / eps))) / 2.0;
} else if (x <= 6.1e-9) {
tmp = (2.0 - (x * eps)) / 2.0;
} else if ((x <= 7e+153) || !(x <= 1.96e+295)) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
} else {
tmp = (x * eps) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -2.6e+122: tmp = (x * ((x * (((1.0 / eps) * 0.5) + ((x / eps) * -0.16666666666666666))) + (-1.0 / eps))) / 2.0 elif x <= 6.1e-9: tmp = (2.0 - (x * eps)) / 2.0 elif (x <= 7e+153) or not (x <= 1.96e+295): tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0 else: tmp = (x * eps) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -2.6e+122) tmp = Float64(Float64(x * Float64(Float64(x * Float64(Float64(Float64(1.0 / eps) * 0.5) + Float64(Float64(x / eps) * -0.16666666666666666))) + Float64(-1.0 / eps))) / 2.0); elseif (x <= 6.1e-9) tmp = Float64(Float64(2.0 - Float64(x * eps)) / 2.0); elseif ((x <= 7e+153) || !(x <= 1.96e+295)) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) + Float64(1.0 + Float64(-1.0 / eps))) / 2.0); else tmp = Float64(Float64(x * eps) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -2.6e+122) tmp = (x * ((x * (((1.0 / eps) * 0.5) + ((x / eps) * -0.16666666666666666))) + (-1.0 / eps))) / 2.0; elseif (x <= 6.1e-9) tmp = (2.0 - (x * eps)) / 2.0; elseif ((x <= 7e+153) || ~((x <= 1.96e+295))) tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0; else tmp = (x * eps) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -2.6e+122], N[(N[(x * N[(N[(x * N[(N[(N[(1.0 / eps), $MachinePrecision] * 0.5), $MachinePrecision] + N[(N[(x / eps), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 6.1e-9], N[(N[(2.0 - N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 7e+153], N[Not[LessEqual[x, 1.96e+295]], $MachinePrecision]], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(x * eps), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.6 \cdot 10^{+122}:\\
\;\;\;\;\frac{x \cdot \left(x \cdot \left(\frac{1}{\varepsilon} \cdot 0.5 + \frac{x}{\varepsilon} \cdot -0.16666666666666666\right) + \frac{-1}{\varepsilon}\right)}{2}\\
\mathbf{elif}\;x \leq 6.1 \cdot 10^{-9}:\\
\;\;\;\;\frac{2 - x \cdot \varepsilon}{2}\\
\mathbf{elif}\;x \leq 7 \cdot 10^{+153} \lor \neg \left(x \leq 1.96 \cdot 10^{+295}\right):\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) + \left(1 + \frac{-1}{\varepsilon}\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \varepsilon}{2}\\
\end{array}
\end{array}
if x < -2.60000000000000007e122Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 31.6%
Taylor expanded in eps around 0 70.6%
expm1-define70.6%
mul-1-neg70.6%
Simplified70.6%
Taylor expanded in x around 0 59.8%
if -2.60000000000000007e122 < x < 6.1e-9Initial program 58.4%
Simplified58.4%
Taylor expanded in x around 0 41.8%
Taylor expanded in x around 0 44.3%
Taylor expanded in eps around inf 69.9%
associate-*r*69.9%
neg-mul-169.9%
Simplified69.9%
if 6.1e-9 < x < 6.9999999999999998e153 or 1.9599999999999999e295 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 24.2%
Taylor expanded in x around 0 54.3%
if 6.9999999999999998e153 < x < 1.9599999999999999e295Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 43.3%
Taylor expanded in x around inf 34.2%
neg-mul-134.2%
distribute-rgt-neg-in34.2%
*-commutative34.2%
distribute-rgt-neg-in34.2%
neg-mul-134.2%
distribute-rgt-in34.2%
metadata-eval34.2%
associate-*l/34.2%
metadata-eval34.2%
Simplified34.2%
Taylor expanded in eps around inf 34.6%
*-commutative34.6%
Simplified34.6%
Final simplification62.5%
(FPCore (x eps)
:precision binary64
(if (<= x 6.1e-9)
(/ (- 2.0 (* x eps)) 2.0)
(if (or (<= x 1.32e+154) (not (<= x 9.5e+292)))
(/ (+ (+ 1.0 (/ 1.0 eps)) (+ 1.0 (/ -1.0 eps))) 2.0)
(/ (* x eps) 2.0))))
double code(double x, double eps) {
double tmp;
if (x <= 6.1e-9) {
tmp = (2.0 - (x * eps)) / 2.0;
} else if ((x <= 1.32e+154) || !(x <= 9.5e+292)) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
} else {
tmp = (x * eps) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 6.1d-9) then
tmp = (2.0d0 - (x * eps)) / 2.0d0
else if ((x <= 1.32d+154) .or. (.not. (x <= 9.5d+292))) then
tmp = ((1.0d0 + (1.0d0 / eps)) + (1.0d0 + ((-1.0d0) / eps))) / 2.0d0
else
tmp = (x * eps) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 6.1e-9) {
tmp = (2.0 - (x * eps)) / 2.0;
} else if ((x <= 1.32e+154) || !(x <= 9.5e+292)) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
} else {
tmp = (x * eps) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 6.1e-9: tmp = (2.0 - (x * eps)) / 2.0 elif (x <= 1.32e+154) or not (x <= 9.5e+292): tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0 else: tmp = (x * eps) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 6.1e-9) tmp = Float64(Float64(2.0 - Float64(x * eps)) / 2.0); elseif ((x <= 1.32e+154) || !(x <= 9.5e+292)) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) + Float64(1.0 + Float64(-1.0 / eps))) / 2.0); else tmp = Float64(Float64(x * eps) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 6.1e-9) tmp = (2.0 - (x * eps)) / 2.0; elseif ((x <= 1.32e+154) || ~((x <= 9.5e+292))) tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0; else tmp = (x * eps) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 6.1e-9], N[(N[(2.0 - N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 1.32e+154], N[Not[LessEqual[x, 9.5e+292]], $MachinePrecision]], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(x * eps), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.1 \cdot 10^{-9}:\\
\;\;\;\;\frac{2 - x \cdot \varepsilon}{2}\\
\mathbf{elif}\;x \leq 1.32 \cdot 10^{+154} \lor \neg \left(x \leq 9.5 \cdot 10^{+292}\right):\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) + \left(1 + \frac{-1}{\varepsilon}\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \varepsilon}{2}\\
\end{array}
\end{array}
if x < 6.1e-9Initial program 62.2%
Simplified62.2%
Taylor expanded in x around 0 44.5%
Taylor expanded in x around 0 43.2%
Taylor expanded in eps around inf 66.5%
associate-*r*66.5%
neg-mul-166.5%
Simplified66.5%
if 6.1e-9 < x < 1.31999999999999998e154 or 9.50000000000000035e292 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 24.2%
Taylor expanded in x around 0 54.3%
if 1.31999999999999998e154 < x < 9.50000000000000035e292Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 43.3%
Taylor expanded in x around inf 34.2%
neg-mul-134.2%
distribute-rgt-neg-in34.2%
*-commutative34.2%
distribute-rgt-neg-in34.2%
neg-mul-134.2%
distribute-rgt-in34.2%
metadata-eval34.2%
associate-*l/34.2%
metadata-eval34.2%
Simplified34.2%
Taylor expanded in eps around inf 34.6%
*-commutative34.6%
Simplified34.6%
Final simplification60.6%
(FPCore (x eps) :precision binary64 (if (<= x 6.1e-9) (/ (- 2.0 (* x eps)) 2.0) (/ (* x eps) 2.0)))
double code(double x, double eps) {
double tmp;
if (x <= 6.1e-9) {
tmp = (2.0 - (x * eps)) / 2.0;
} else {
tmp = (x * eps) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 6.1d-9) then
tmp = (2.0d0 - (x * eps)) / 2.0d0
else
tmp = (x * eps) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 6.1e-9) {
tmp = (2.0 - (x * eps)) / 2.0;
} else {
tmp = (x * eps) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 6.1e-9: tmp = (2.0 - (x * eps)) / 2.0 else: tmp = (x * eps) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 6.1e-9) tmp = Float64(Float64(2.0 - Float64(x * eps)) / 2.0); else tmp = Float64(Float64(x * eps) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 6.1e-9) tmp = (2.0 - (x * eps)) / 2.0; else tmp = (x * eps) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 6.1e-9], N[(N[(2.0 - N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(x * eps), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.1 \cdot 10^{-9}:\\
\;\;\;\;\frac{2 - x \cdot \varepsilon}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \varepsilon}{2}\\
\end{array}
\end{array}
if x < 6.1e-9Initial program 62.2%
Simplified62.2%
Taylor expanded in x around 0 44.5%
Taylor expanded in x around 0 43.2%
Taylor expanded in eps around inf 66.5%
associate-*r*66.5%
neg-mul-166.5%
Simplified66.5%
if 6.1e-9 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 31.9%
Taylor expanded in x around inf 20.3%
neg-mul-120.3%
distribute-rgt-neg-in20.3%
*-commutative20.3%
distribute-rgt-neg-in20.3%
neg-mul-120.3%
distribute-rgt-in20.3%
metadata-eval20.3%
associate-*l/20.3%
metadata-eval20.3%
Simplified20.3%
Taylor expanded in eps around inf 21.1%
*-commutative21.1%
Simplified21.1%
Final simplification54.2%
(FPCore (x eps) :precision binary64 (if (<= x 6.1e-9) (/ (- 2.0 x) 2.0) (/ (* x eps) 2.0)))
double code(double x, double eps) {
double tmp;
if (x <= 6.1e-9) {
tmp = (2.0 - x) / 2.0;
} else {
tmp = (x * eps) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 6.1d-9) then
tmp = (2.0d0 - x) / 2.0d0
else
tmp = (x * eps) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 6.1e-9) {
tmp = (2.0 - x) / 2.0;
} else {
tmp = (x * eps) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 6.1e-9: tmp = (2.0 - x) / 2.0 else: tmp = (x * eps) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 6.1e-9) tmp = Float64(Float64(2.0 - x) / 2.0); else tmp = Float64(Float64(x * eps) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 6.1e-9) tmp = (2.0 - x) / 2.0; else tmp = (x * eps) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 6.1e-9], N[(N[(2.0 - x), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(x * eps), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.1 \cdot 10^{-9}:\\
\;\;\;\;\frac{2 - x}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \varepsilon}{2}\\
\end{array}
\end{array}
if x < 6.1e-9Initial program 62.2%
Simplified62.2%
Taylor expanded in x around 0 44.2%
Taylor expanded in eps around inf 85.6%
Taylor expanded in x around 0 63.4%
neg-mul-163.4%
unsub-neg63.4%
Simplified63.4%
if 6.1e-9 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 31.9%
Taylor expanded in x around inf 20.3%
neg-mul-120.3%
distribute-rgt-neg-in20.3%
*-commutative20.3%
distribute-rgt-neg-in20.3%
neg-mul-120.3%
distribute-rgt-in20.3%
metadata-eval20.3%
associate-*l/20.3%
metadata-eval20.3%
Simplified20.3%
Taylor expanded in eps around inf 21.1%
*-commutative21.1%
Simplified21.1%
(FPCore (x eps) :precision binary64 (if (<= x 6.1e-9) 1.0 (/ (* x eps) 2.0)))
double code(double x, double eps) {
double tmp;
if (x <= 6.1e-9) {
tmp = 1.0;
} else {
tmp = (x * eps) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 6.1d-9) then
tmp = 1.0d0
else
tmp = (x * eps) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 6.1e-9) {
tmp = 1.0;
} else {
tmp = (x * eps) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 6.1e-9: tmp = 1.0 else: tmp = (x * eps) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 6.1e-9) tmp = 1.0; else tmp = Float64(Float64(x * eps) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 6.1e-9) tmp = 1.0; else tmp = (x * eps) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 6.1e-9], 1.0, N[(N[(x * eps), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.1 \cdot 10^{-9}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \varepsilon}{2}\\
\end{array}
\end{array}
if x < 6.1e-9Initial program 62.2%
Simplified62.2%
Taylor expanded in x around 0 63.1%
if 6.1e-9 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 31.9%
Taylor expanded in x around inf 20.3%
neg-mul-120.3%
distribute-rgt-neg-in20.3%
*-commutative20.3%
distribute-rgt-neg-in20.3%
neg-mul-120.3%
distribute-rgt-in20.3%
metadata-eval20.3%
associate-*l/20.3%
metadata-eval20.3%
Simplified20.3%
Taylor expanded in eps around inf 21.1%
*-commutative21.1%
Simplified21.1%
Final simplification51.8%
(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 72.4%
Simplified72.4%
Taylor expanded in x around 0 46.9%
Final simplification46.9%
herbie shell --seed 2024101
(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))