
(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 12 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}
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= eps 53.0)
(/ (+ (* t_0 (- (+ x 1.0) -1.0)) (* x t_0)) 2.0)
(/ (+ (exp (* x (+ eps -1.0))) (exp (* x (- eps)))) 2.0))))eps = abs(eps);
double code(double x, double eps) {
double t_0 = exp(-x);
double tmp;
if (eps <= 53.0) {
tmp = ((t_0 * ((x + 1.0) - -1.0)) + (x * t_0)) / 2.0;
} else {
tmp = (exp((x * (eps + -1.0))) + exp((x * -eps))) / 2.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = exp(-x)
if (eps <= 53.0d0) then
tmp = ((t_0 * ((x + 1.0d0) - (-1.0d0))) + (x * t_0)) / 2.0d0
else
tmp = (exp((x * (eps + (-1.0d0)))) + exp((x * -eps))) / 2.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double t_0 = Math.exp(-x);
double tmp;
if (eps <= 53.0) {
tmp = ((t_0 * ((x + 1.0) - -1.0)) + (x * t_0)) / 2.0;
} else {
tmp = (Math.exp((x * (eps + -1.0))) + Math.exp((x * -eps))) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): t_0 = math.exp(-x) tmp = 0 if eps <= 53.0: tmp = ((t_0 * ((x + 1.0) - -1.0)) + (x * t_0)) / 2.0 else: tmp = (math.exp((x * (eps + -1.0))) + math.exp((x * -eps))) / 2.0 return tmp
eps = abs(eps) function code(x, eps) t_0 = exp(Float64(-x)) tmp = 0.0 if (eps <= 53.0) tmp = Float64(Float64(Float64(t_0 * Float64(Float64(x + 1.0) - -1.0)) + Float64(x * t_0)) / 2.0); else tmp = Float64(Float64(exp(Float64(x * Float64(eps + -1.0))) + exp(Float64(x * Float64(-eps)))) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) t_0 = exp(-x); tmp = 0.0; if (eps <= 53.0) tmp = ((t_0 * ((x + 1.0) - -1.0)) + (x * t_0)) / 2.0; else tmp = (exp((x * (eps + -1.0))) + exp((x * -eps))) / 2.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function
code[x_, eps_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[eps, 53.0], N[(N[(N[(t$95$0 * N[(N[(x + 1.0), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] + N[(x * t$95$0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * (-eps)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;\varepsilon \leq 53:\\
\;\;\;\;\frac{t_0 \cdot \left(\left(x + 1\right) - -1\right) + x \cdot t_0}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \left(\varepsilon + -1\right)} + e^{x \cdot \left(-\varepsilon\right)}}{2}\\
\end{array}
\end{array}
if eps < 53Initial program 61.4%
Simplified61.4%
Taylor expanded in eps around 0 65.3%
associate--r+65.3%
associate-*r*65.3%
mul-1-neg65.3%
cancel-sign-sub65.3%
distribute-rgt1-in65.3%
distribute-rgt-out--65.3%
mul-1-neg65.3%
mul-1-neg65.3%
Simplified65.3%
if 53 < eps Initial program 99.9%
Simplified99.9%
Taylor expanded in eps around inf 99.9%
*-commutative99.9%
sub-neg99.9%
mul-1-neg99.9%
*-commutative99.9%
associate-*r*99.9%
mul-1-neg99.9%
mul-1-neg99.9%
sub-neg99.9%
mul-1-neg99.9%
exp-prod99.9%
*-lft-identity99.9%
metadata-eval99.9%
cancel-sign-sub-inv99.9%
exp-prod99.9%
Simplified99.9%
Taylor expanded in eps around inf 99.9%
associate-*r*99.9%
neg-mul-199.9%
Simplified99.9%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
mul-1-neg99.9%
distribute-rgt-neg-in99.9%
sub-neg99.9%
mul-1-neg99.9%
distribute-neg-in99.9%
metadata-eval99.9%
mul-1-neg99.9%
remove-double-neg99.9%
Simplified99.9%
Final simplification74.5%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (/ (+ (exp (* x (+ eps -1.0))) (exp (* x (- -1.0 eps)))) 2.0))
eps = abs(eps);
double code(double x, double eps) {
return (exp((x * (eps + -1.0))) + exp((x * (-1.0 - eps)))) / 2.0;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (exp((x * (eps + (-1.0d0)))) + exp((x * ((-1.0d0) - eps)))) / 2.0d0
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
return (Math.exp((x * (eps + -1.0))) + Math.exp((x * (-1.0 - eps)))) / 2.0;
}
eps = abs(eps) def code(x, eps): return (math.exp((x * (eps + -1.0))) + math.exp((x * (-1.0 - eps)))) / 2.0
eps = abs(eps) function code(x, eps) return Float64(Float64(exp(Float64(x * Float64(eps + -1.0))) + exp(Float64(x * Float64(-1.0 - eps)))) / 2.0) end
eps = abs(eps) function tmp = code(x, eps) tmp = (exp((x * (eps + -1.0))) + exp((x * (-1.0 - eps)))) / 2.0; end
NOTE: eps should be positive before calling this function code[x_, eps_] := N[(N[(N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
eps = |eps|\\
\\
\frac{e^{x \cdot \left(\varepsilon + -1\right)} + e^{x \cdot \left(-1 - \varepsilon\right)}}{2}
\end{array}
Initial program 71.6%
Simplified71.6%
Taylor expanded in eps around inf 99.0%
*-commutative99.0%
sub-neg99.0%
mul-1-neg99.0%
*-commutative99.0%
associate-*r*99.0%
mul-1-neg99.0%
mul-1-neg99.0%
sub-neg99.0%
mul-1-neg99.0%
exp-prod99.0%
*-lft-identity99.0%
metadata-eval99.0%
cancel-sign-sub-inv99.0%
exp-prod99.0%
Simplified99.0%
Final simplification99.0%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (/ (+ (exp (* x (+ eps -1.0))) (exp (* x (- eps)))) 2.0))
eps = abs(eps);
double code(double x, double eps) {
return (exp((x * (eps + -1.0))) + exp((x * -eps))) / 2.0;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (exp((x * (eps + (-1.0d0)))) + exp((x * -eps))) / 2.0d0
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
return (Math.exp((x * (eps + -1.0))) + Math.exp((x * -eps))) / 2.0;
}
eps = abs(eps) def code(x, eps): return (math.exp((x * (eps + -1.0))) + math.exp((x * -eps))) / 2.0
eps = abs(eps) function code(x, eps) return Float64(Float64(exp(Float64(x * Float64(eps + -1.0))) + exp(Float64(x * Float64(-eps)))) / 2.0) end
eps = abs(eps) function tmp = code(x, eps) tmp = (exp((x * (eps + -1.0))) + exp((x * -eps))) / 2.0; end
NOTE: eps should be positive before calling this function code[x_, eps_] := N[(N[(N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * (-eps)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
eps = |eps|\\
\\
\frac{e^{x \cdot \left(\varepsilon + -1\right)} + e^{x \cdot \left(-\varepsilon\right)}}{2}
\end{array}
Initial program 71.6%
Simplified71.6%
Taylor expanded in eps around inf 99.0%
*-commutative99.0%
sub-neg99.0%
mul-1-neg99.0%
*-commutative99.0%
associate-*r*99.0%
mul-1-neg99.0%
mul-1-neg99.0%
sub-neg99.0%
mul-1-neg99.0%
exp-prod99.0%
*-lft-identity99.0%
metadata-eval99.0%
cancel-sign-sub-inv99.0%
exp-prod99.0%
Simplified99.0%
Taylor expanded in eps around inf 93.0%
associate-*r*93.0%
neg-mul-193.0%
Simplified93.0%
Taylor expanded in x around inf 93.0%
mul-1-neg93.0%
*-commutative93.0%
distribute-rgt-neg-in93.0%
mul-1-neg93.0%
distribute-rgt-neg-in93.0%
sub-neg93.0%
mul-1-neg93.0%
distribute-neg-in93.0%
metadata-eval93.0%
mul-1-neg93.0%
remove-double-neg93.0%
Simplified93.0%
Final simplification93.0%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x -1.2e-260) (/ (+ 1.0 (exp (* x (- eps)))) 2.0) (/ (+ 1.0 (pow E (* x (+ eps -1.0)))) 2.0)))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= -1.2e-260) {
tmp = (1.0 + exp((x * -eps))) / 2.0;
} else {
tmp = (1.0 + pow(((double) M_E), (x * (eps + -1.0)))) / 2.0;
}
return tmp;
}
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= -1.2e-260) {
tmp = (1.0 + Math.exp((x * -eps))) / 2.0;
} else {
tmp = (1.0 + Math.pow(Math.E, (x * (eps + -1.0)))) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= -1.2e-260: tmp = (1.0 + math.exp((x * -eps))) / 2.0 else: tmp = (1.0 + math.pow(math.e, (x * (eps + -1.0)))) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= -1.2e-260) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-eps)))) / 2.0); else tmp = Float64(Float64(1.0 + (exp(1) ^ Float64(x * Float64(eps + -1.0)))) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -1.2e-260) tmp = (1.0 + exp((x * -eps))) / 2.0; else tmp = (1.0 + (2.71828182845904523536 ^ (x * (eps + -1.0)))) / 2.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, -1.2e-260], N[(N[(1.0 + N[Exp[N[(x * (-eps)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(1.0 + N[Power[E, N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2 \cdot 10^{-260}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-\varepsilon\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + {e}^{\left(x \cdot \left(\varepsilon + -1\right)\right)}}{2}\\
\end{array}
\end{array}
if x < -1.2e-260Initial program 71.9%
Simplified71.9%
Taylor expanded in eps around inf 97.6%
*-commutative97.6%
sub-neg97.6%
mul-1-neg97.6%
*-commutative97.6%
associate-*r*97.6%
mul-1-neg97.6%
mul-1-neg97.6%
sub-neg97.6%
mul-1-neg97.6%
exp-prod97.6%
*-lft-identity97.6%
metadata-eval97.6%
cancel-sign-sub-inv97.6%
exp-prod97.6%
Simplified97.6%
Taylor expanded in eps around inf 97.7%
associate-*r*97.7%
neg-mul-197.7%
Simplified97.7%
Taylor expanded in x around inf 97.7%
mul-1-neg97.7%
*-commutative97.7%
distribute-rgt-neg-in97.7%
mul-1-neg97.7%
distribute-rgt-neg-in97.7%
sub-neg97.7%
mul-1-neg97.7%
distribute-neg-in97.7%
metadata-eval97.7%
mul-1-neg97.7%
remove-double-neg97.7%
Simplified97.7%
Taylor expanded in x around 0 68.1%
if -1.2e-260 < x Initial program 71.4%
Simplified71.4%
Taylor expanded in x around 0 36.5%
Taylor expanded in eps around inf 65.2%
mul-1-neg65.2%
distribute-rgt-neg-in65.2%
sub-neg65.2%
neg-mul-165.2%
distribute-neg-in65.2%
metadata-eval65.2%
neg-mul-165.2%
remove-double-neg65.2%
Simplified65.2%
*-un-lft-identity65.2%
exp-prod65.2%
Applied egg-rr65.2%
exp-1-e65.2%
+-commutative65.2%
Simplified65.2%
Final simplification66.3%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x -1.2e-260) (/ (+ 1.0 (exp (* x (- eps)))) 2.0) (/ (+ 1.0 (exp (* x (+ eps -1.0)))) 2.0)))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= -1.2e-260) {
tmp = (1.0 + exp((x * -eps))) / 2.0;
} else {
tmp = (1.0 + exp((x * (eps + -1.0)))) / 2.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-1.2d-260)) then
tmp = (1.0d0 + exp((x * -eps))) / 2.0d0
else
tmp = (1.0d0 + exp((x * (eps + (-1.0d0))))) / 2.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= -1.2e-260) {
tmp = (1.0 + Math.exp((x * -eps))) / 2.0;
} else {
tmp = (1.0 + Math.exp((x * (eps + -1.0)))) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= -1.2e-260: tmp = (1.0 + math.exp((x * -eps))) / 2.0 else: tmp = (1.0 + math.exp((x * (eps + -1.0)))) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= -1.2e-260) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-eps)))) / 2.0); else tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(eps + -1.0)))) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -1.2e-260) tmp = (1.0 + exp((x * -eps))) / 2.0; else tmp = (1.0 + exp((x * (eps + -1.0)))) / 2.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, -1.2e-260], N[(N[(1.0 + N[Exp[N[(x * (-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}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2 \cdot 10^{-260}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-\varepsilon\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(\varepsilon + -1\right)}}{2}\\
\end{array}
\end{array}
if x < -1.2e-260Initial program 71.9%
Simplified71.9%
Taylor expanded in eps around inf 97.6%
*-commutative97.6%
sub-neg97.6%
mul-1-neg97.6%
*-commutative97.6%
associate-*r*97.6%
mul-1-neg97.6%
mul-1-neg97.6%
sub-neg97.6%
mul-1-neg97.6%
exp-prod97.6%
*-lft-identity97.6%
metadata-eval97.6%
cancel-sign-sub-inv97.6%
exp-prod97.6%
Simplified97.6%
Taylor expanded in eps around inf 97.7%
associate-*r*97.7%
neg-mul-197.7%
Simplified97.7%
Taylor expanded in x around inf 97.7%
mul-1-neg97.7%
*-commutative97.7%
distribute-rgt-neg-in97.7%
mul-1-neg97.7%
distribute-rgt-neg-in97.7%
sub-neg97.7%
mul-1-neg97.7%
distribute-neg-in97.7%
metadata-eval97.7%
mul-1-neg97.7%
remove-double-neg97.7%
Simplified97.7%
Taylor expanded in x around 0 68.1%
if -1.2e-260 < x Initial program 71.4%
Simplified71.4%
Taylor expanded in x around 0 36.5%
Taylor expanded in eps around inf 65.2%
mul-1-neg65.2%
distribute-rgt-neg-in65.2%
sub-neg65.2%
neg-mul-165.2%
distribute-neg-in65.2%
metadata-eval65.2%
neg-mul-165.2%
remove-double-neg65.2%
Simplified65.2%
Final simplification66.3%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x 350.0) (/ (+ 1.0 (exp (* x (- eps)))) 2.0) (/ (/ (expm1 x) eps) 2.0)))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 350.0) {
tmp = (1.0 + exp((x * -eps))) / 2.0;
} else {
tmp = (expm1(x) / eps) / 2.0;
}
return tmp;
}
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= 350.0) {
tmp = (1.0 + Math.exp((x * -eps))) / 2.0;
} else {
tmp = (Math.expm1(x) / eps) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 350.0: tmp = (1.0 + math.exp((x * -eps))) / 2.0 else: tmp = (math.expm1(x) / eps) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 350.0) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-eps)))) / 2.0); else tmp = Float64(Float64(expm1(x) / eps) / 2.0); end return tmp end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, 350.0], N[(N[(1.0 + N[Exp[N[(x * (-eps)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(Exp[x] - 1), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 350:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-\varepsilon\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(x\right)}{\varepsilon}}{2}\\
\end{array}
\end{array}
if x < 350Initial program 61.9%
Simplified61.9%
Taylor expanded in eps around inf 98.7%
*-commutative98.7%
sub-neg98.7%
mul-1-neg98.7%
*-commutative98.7%
associate-*r*98.7%
mul-1-neg98.7%
mul-1-neg98.7%
sub-neg98.7%
mul-1-neg98.7%
exp-prod98.7%
*-lft-identity98.7%
metadata-eval98.7%
cancel-sign-sub-inv98.7%
exp-prod98.7%
Simplified98.7%
Taylor expanded in eps around inf 98.7%
associate-*r*98.7%
neg-mul-198.7%
Simplified98.7%
Taylor expanded in x around inf 98.7%
mul-1-neg98.7%
*-commutative98.7%
distribute-rgt-neg-in98.7%
mul-1-neg98.7%
distribute-rgt-neg-in98.7%
sub-neg98.7%
mul-1-neg98.7%
distribute-neg-in98.7%
metadata-eval98.7%
mul-1-neg98.7%
remove-double-neg98.7%
Simplified98.7%
Taylor expanded in x around 0 78.7%
if 350 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 31.2%
Taylor expanded in eps around 0 1.9%
expm1-def1.9%
neg-mul-11.9%
Simplified1.9%
expm1-log1p-u1.5%
expm1-udef1.4%
expm1-udef1.4%
expm1-udef1.4%
add-sqr-sqrt0.0%
sqrt-unprod29.5%
sqr-neg29.5%
sqrt-unprod29.5%
add-sqr-sqrt29.5%
Applied egg-rr29.5%
expm1-def29.5%
expm1-log1p29.7%
Simplified29.7%
Final simplification66.2%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x -510.0) (/ (/ (expm1 (- x)) eps) 2.0) (if (<= x 350.0) 1.0 (/ (/ (expm1 x) eps) 2.0))))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= -510.0) {
tmp = (expm1(-x) / eps) / 2.0;
} else if (x <= 350.0) {
tmp = 1.0;
} else {
tmp = (expm1(x) / eps) / 2.0;
}
return tmp;
}
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= -510.0) {
tmp = (Math.expm1(-x) / eps) / 2.0;
} else if (x <= 350.0) {
tmp = 1.0;
} else {
tmp = (Math.expm1(x) / eps) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= -510.0: tmp = (math.expm1(-x) / eps) / 2.0 elif x <= 350.0: tmp = 1.0 else: tmp = (math.expm1(x) / eps) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= -510.0) tmp = Float64(Float64(expm1(Float64(-x)) / eps) / 2.0); elseif (x <= 350.0) tmp = 1.0; else tmp = Float64(Float64(expm1(x) / eps) / 2.0); end return tmp end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, -510.0], N[(N[(N[(Exp[(-x)] - 1), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 350.0], 1.0, N[(N[(N[(Exp[x] - 1), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -510:\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(-x\right)}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq 350:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(x\right)}{\varepsilon}}{2}\\
\end{array}
\end{array}
if x < -510Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 64.8%
Taylor expanded in eps around 0 36.4%
expm1-def36.4%
neg-mul-136.4%
Simplified36.4%
if -510 < x < 350Initial program 54.0%
Simplified54.0%
Taylor expanded in x around 0 73.9%
if 350 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 31.2%
Taylor expanded in eps around 0 1.9%
expm1-def1.9%
neg-mul-11.9%
Simplified1.9%
expm1-log1p-u1.5%
expm1-udef1.4%
expm1-udef1.4%
expm1-udef1.4%
add-sqr-sqrt0.0%
sqrt-unprod29.5%
sqr-neg29.5%
sqrt-unprod29.5%
add-sqr-sqrt29.5%
Applied egg-rr29.5%
expm1-def29.5%
expm1-log1p29.7%
Simplified29.7%
Final simplification57.9%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x 2.0) (/ (+ 2.0 (* x (- -1.0 eps))) 2.0) (/ (/ (expm1 x) eps) 2.0)))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 2.0) {
tmp = (2.0 + (x * (-1.0 - eps))) / 2.0;
} else {
tmp = (expm1(x) / eps) / 2.0;
}
return tmp;
}
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= 2.0) {
tmp = (2.0 + (x * (-1.0 - eps))) / 2.0;
} else {
tmp = (Math.expm1(x) / eps) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 2.0: tmp = (2.0 + (x * (-1.0 - eps))) / 2.0 else: tmp = (math.expm1(x) / eps) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 2.0) tmp = Float64(Float64(2.0 + Float64(x * Float64(-1.0 - eps))) / 2.0); else tmp = Float64(Float64(expm1(x) / eps) / 2.0); end return tmp end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, 2.0], N[(N[(2.0 + N[(x * 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}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2:\\
\;\;\;\;\frac{2 + x \cdot \left(-1 - \varepsilon\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(x\right)}{\varepsilon}}{2}\\
\end{array}
\end{array}
if x < 2Initial program 61.9%
Simplified61.9%
Taylor expanded in eps around inf 98.7%
*-commutative98.7%
sub-neg98.7%
mul-1-neg98.7%
*-commutative98.7%
associate-*r*98.7%
mul-1-neg98.7%
mul-1-neg98.7%
sub-neg98.7%
mul-1-neg98.7%
exp-prod98.7%
*-lft-identity98.7%
metadata-eval98.7%
cancel-sign-sub-inv98.7%
exp-prod98.7%
Simplified98.7%
Taylor expanded in x around 0 78.5%
Taylor expanded in x around 0 64.9%
associate-*r*64.9%
neg-mul-164.9%
Simplified64.9%
if 2 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 31.2%
Taylor expanded in eps around 0 1.9%
expm1-def1.9%
neg-mul-11.9%
Simplified1.9%
expm1-log1p-u1.5%
expm1-udef1.4%
expm1-udef1.4%
expm1-udef1.4%
add-sqr-sqrt0.0%
sqrt-unprod29.5%
sqr-neg29.5%
sqrt-unprod29.5%
add-sqr-sqrt29.5%
Applied egg-rr29.5%
expm1-def29.5%
expm1-log1p29.7%
Simplified29.7%
Final simplification55.9%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x 2.0) (/ (+ 2.0 (* x (- -1.0 eps))) 2.0) (if (<= x 1.6e+128) 0.0 (/ (* x eps) 2.0))))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 2.0) {
tmp = (2.0 + (x * (-1.0 - eps))) / 2.0;
} else if (x <= 1.6e+128) {
tmp = 0.0;
} else {
tmp = (x * eps) / 2.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 2.0d0) then
tmp = (2.0d0 + (x * ((-1.0d0) - eps))) / 2.0d0
else if (x <= 1.6d+128) then
tmp = 0.0d0
else
tmp = (x * eps) / 2.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= 2.0) {
tmp = (2.0 + (x * (-1.0 - eps))) / 2.0;
} else if (x <= 1.6e+128) {
tmp = 0.0;
} else {
tmp = (x * eps) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 2.0: tmp = (2.0 + (x * (-1.0 - eps))) / 2.0 elif x <= 1.6e+128: tmp = 0.0 else: tmp = (x * eps) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 2.0) tmp = Float64(Float64(2.0 + Float64(x * Float64(-1.0 - eps))) / 2.0); elseif (x <= 1.6e+128) tmp = 0.0; else tmp = Float64(Float64(x * eps) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 2.0) tmp = (2.0 + (x * (-1.0 - eps))) / 2.0; elseif (x <= 1.6e+128) tmp = 0.0; else tmp = (x * eps) / 2.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, 2.0], N[(N[(2.0 + N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.6e+128], 0.0, N[(N[(x * eps), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2:\\
\;\;\;\;\frac{2 + x \cdot \left(-1 - \varepsilon\right)}{2}\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{+128}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \varepsilon}{2}\\
\end{array}
\end{array}
if x < 2Initial program 61.9%
Simplified61.9%
Taylor expanded in eps around inf 98.7%
*-commutative98.7%
sub-neg98.7%
mul-1-neg98.7%
*-commutative98.7%
associate-*r*98.7%
mul-1-neg98.7%
mul-1-neg98.7%
sub-neg98.7%
mul-1-neg98.7%
exp-prod98.7%
*-lft-identity98.7%
metadata-eval98.7%
cancel-sign-sub-inv98.7%
exp-prod98.7%
Simplified98.7%
Taylor expanded in x around 0 78.5%
Taylor expanded in x around 0 64.9%
associate-*r*64.9%
neg-mul-164.9%
Simplified64.9%
if 2 < x < 1.59999999999999993e128Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 39.7%
div-sub39.7%
rec-exp39.7%
mul-1-neg39.7%
+-inverses39.7%
Simplified39.7%
if 1.59999999999999993e128 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 28.2%
+-commutative28.2%
+-commutative28.2%
associate-+l+28.2%
mul-1-neg28.2%
distribute-rgt-neg-in28.2%
*-commutative28.2%
distribute-rgt-neg-in28.2%
mul-1-neg28.2%
distribute-lft-in28.2%
metadata-eval28.2%
neg-mul-128.2%
distribute-neg-frac28.2%
metadata-eval28.2%
Simplified28.2%
Taylor expanded in eps around inf 19.7%
*-commutative19.7%
Simplified19.7%
Final simplification55.8%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x 5.1e+14) 1.0 (if (<= x 3.2e+130) 0.0 (/ (* x eps) 2.0))))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 5.1e+14) {
tmp = 1.0;
} else if (x <= 3.2e+130) {
tmp = 0.0;
} else {
tmp = (x * eps) / 2.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 5.1d+14) then
tmp = 1.0d0
else if (x <= 3.2d+130) then
tmp = 0.0d0
else
tmp = (x * eps) / 2.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= 5.1e+14) {
tmp = 1.0;
} else if (x <= 3.2e+130) {
tmp = 0.0;
} else {
tmp = (x * eps) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 5.1e+14: tmp = 1.0 elif x <= 3.2e+130: tmp = 0.0 else: tmp = (x * eps) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 5.1e+14) tmp = 1.0; elseif (x <= 3.2e+130) tmp = 0.0; else tmp = Float64(Float64(x * eps) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 5.1e+14) tmp = 1.0; elseif (x <= 3.2e+130) tmp = 0.0; else tmp = (x * eps) / 2.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, 5.1e+14], 1.0, If[LessEqual[x, 3.2e+130], 0.0, N[(N[(x * eps), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.1 \cdot 10^{+14}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{+130}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \varepsilon}{2}\\
\end{array}
\end{array}
if x < 5.1e14Initial program 62.5%
Simplified62.5%
Taylor expanded in x around 0 60.8%
if 5.1e14 < x < 3.2e130Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 43.8%
div-sub43.8%
rec-exp43.8%
mul-1-neg43.8%
+-inverses43.8%
Simplified43.8%
if 3.2e130 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 28.2%
+-commutative28.2%
+-commutative28.2%
associate-+l+28.2%
mul-1-neg28.2%
distribute-rgt-neg-in28.2%
*-commutative28.2%
distribute-rgt-neg-in28.2%
mul-1-neg28.2%
distribute-lft-in28.2%
metadata-eval28.2%
neg-mul-128.2%
distribute-neg-frac28.2%
metadata-eval28.2%
Simplified28.2%
Taylor expanded in eps around inf 19.7%
*-commutative19.7%
Simplified19.7%
Final simplification53.5%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x 5.1e+14) 1.0 0.0))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 5.1e+14) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 5.1d+14) then
tmp = 1.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= 5.1e+14) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 5.1e+14: tmp = 1.0 else: tmp = 0.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 5.1e+14) tmp = 1.0; else tmp = 0.0; end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 5.1e+14) tmp = 1.0; else tmp = 0.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, 5.1e+14], 1.0, 0.0]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.1 \cdot 10^{+14}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 5.1e14Initial program 62.5%
Simplified62.5%
Taylor expanded in x around 0 60.8%
if 5.1e14 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 33.3%
div-sub33.3%
rec-exp33.3%
mul-1-neg33.3%
+-inverses33.3%
Simplified33.3%
Final simplification54.1%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 0.0)
eps = abs(eps);
double code(double x, double eps) {
return 0.0;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 0.0d0
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
return 0.0;
}
eps = abs(eps) def code(x, eps): return 0.0
eps = abs(eps) function code(x, eps) return 0.0 end
eps = abs(eps) function tmp = code(x, eps) tmp = 0.0; end
NOTE: eps should be positive before calling this function code[x_, eps_] := 0.0
\begin{array}{l}
eps = |eps|\\
\\
0
\end{array}
Initial program 71.6%
Simplified64.8%
Taylor expanded in eps around 0 9.8%
div-sub9.8%
rec-exp9.8%
mul-1-neg9.8%
+-inverses10.0%
Simplified10.0%
Final simplification10.0%
herbie shell --seed 2023320
(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))