
(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 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))
double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0
end function
public static double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-((1.0 + eps) * x)))) / 2.0;
}
def code(x, eps): return (((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-((1.0 + eps) * x)))) / 2.0
function code(x, eps) return Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(-Float64(Float64(1.0 - eps) * x)))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * exp(Float64(-Float64(Float64(1.0 + eps) * x))))) / 2.0) end
function tmp = code(x, eps) tmp = (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0; end
code[x_, eps_] := N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ 1.0 (/ 1.0 eps))))
(if (<=
(-
(* t_0 (exp (* x (+ eps -1.0))))
(* (+ (/ 1.0 eps) -1.0) (exp (* x (- -1.0 eps)))))
4.0)
(/ (+ 1.0 x) (exp x))
(pow
(cbrt
(*
(fma
t_0
(exp (fma eps x x))
(exp (- (log1p (/ 1.0 eps)) (fma eps x x))))
0.5))
3.0))))
double code(double x, double eps) {
double t_0 = 1.0 + (1.0 / eps);
double tmp;
if (((t_0 * exp((x * (eps + -1.0)))) - (((1.0 / eps) + -1.0) * exp((x * (-1.0 - eps))))) <= 4.0) {
tmp = (1.0 + x) / exp(x);
} else {
tmp = pow(cbrt((fma(t_0, exp(fma(eps, x, x)), exp((log1p((1.0 / eps)) - fma(eps, x, x)))) * 0.5)), 3.0);
}
return tmp;
}
function code(x, eps) t_0 = Float64(1.0 + Float64(1.0 / eps)) tmp = 0.0 if (Float64(Float64(t_0 * exp(Float64(x * Float64(eps + -1.0)))) - Float64(Float64(Float64(1.0 / eps) + -1.0) * exp(Float64(x * Float64(-1.0 - eps))))) <= 4.0) tmp = Float64(Float64(1.0 + x) / exp(x)); else tmp = cbrt(Float64(fma(t_0, exp(fma(eps, x, x)), exp(Float64(log1p(Float64(1.0 / eps)) - fma(eps, x, x)))) * 0.5)) ^ 3.0; end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(t$95$0 * N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] + -1.0), $MachinePrecision] * N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4.0], N[(N[(1.0 + x), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[Power[N[Power[N[(N[(t$95$0 * N[Exp[N[(eps * x + x), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(N[Log[1 + N[(1.0 / eps), $MachinePrecision]], $MachinePrecision] - N[(eps * x + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{1}{\varepsilon}\\
\mathbf{if}\;t\_0 \cdot e^{x \cdot \left(\varepsilon + -1\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{x \cdot \left(-1 - \varepsilon\right)} \leq 4:\\
\;\;\;\;\frac{1 + x}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt[3]{\mathsf{fma}\left(t\_0, e^{\mathsf{fma}\left(\varepsilon, x, x\right)}, e^{\mathsf{log1p}\left(\frac{1}{\varepsilon}\right) - \mathsf{fma}\left(\varepsilon, x, x\right)}\right) \cdot 0.5}\right)}^{3}\\
\end{array}
\end{array}
if (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) < 4Initial program 57.7%
Simplified33.9%
Taylor expanded in eps around 0 56.4%
associate-+r+100.0%
mul-1-neg100.0%
sub-neg100.0%
+-inverses100.0%
distribute-lft-out100.0%
distribute-rgt1-in100.0%
mul-1-neg100.0%
Simplified100.0%
Taylor expanded in eps around 0 100.0%
+-commutative100.0%
Simplified100.0%
*-commutative100.0%
exp-neg100.0%
un-div-inv100.0%
Applied egg-rr100.0%
if 4 < (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) Initial program 100.0%
Simplified84.9%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0
(-
(* (+ 1.0 (/ 1.0 eps)) (exp (* x (+ eps -1.0))))
(* (+ (/ 1.0 eps) -1.0) (exp (* x (- -1.0 eps)))))))
(if (<= t_0 4.0) (/ (+ 1.0 x) (exp x)) (/ t_0 2.0))))
double code(double x, double eps) {
double t_0 = ((1.0 + (1.0 / eps)) * exp((x * (eps + -1.0)))) - (((1.0 / eps) + -1.0) * exp((x * (-1.0 - eps))));
double tmp;
if (t_0 <= 4.0) {
tmp = (1.0 + x) / exp(x);
} else {
tmp = t_0 / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = ((1.0d0 + (1.0d0 / eps)) * exp((x * (eps + (-1.0d0))))) - (((1.0d0 / eps) + (-1.0d0)) * exp((x * ((-1.0d0) - eps))))
if (t_0 <= 4.0d0) then
tmp = (1.0d0 + x) / exp(x)
else
tmp = t_0 / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = ((1.0 + (1.0 / eps)) * Math.exp((x * (eps + -1.0)))) - (((1.0 / eps) + -1.0) * Math.exp((x * (-1.0 - eps))));
double tmp;
if (t_0 <= 4.0) {
tmp = (1.0 + x) / Math.exp(x);
} else {
tmp = t_0 / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = ((1.0 + (1.0 / eps)) * math.exp((x * (eps + -1.0)))) - (((1.0 / eps) + -1.0) * math.exp((x * (-1.0 - eps)))) tmp = 0 if t_0 <= 4.0: tmp = (1.0 + x) / math.exp(x) else: tmp = t_0 / 2.0 return tmp
function code(x, eps) t_0 = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(x * Float64(eps + -1.0)))) - Float64(Float64(Float64(1.0 / eps) + -1.0) * exp(Float64(x * Float64(-1.0 - eps))))) tmp = 0.0 if (t_0 <= 4.0) tmp = Float64(Float64(1.0 + x) / exp(x)); else tmp = Float64(t_0 / 2.0); end return tmp end
function tmp_2 = code(x, eps) t_0 = ((1.0 + (1.0 / eps)) * exp((x * (eps + -1.0)))) - (((1.0 / eps) + -1.0) * exp((x * (-1.0 - eps)))); tmp = 0.0; if (t_0 <= 4.0) tmp = (1.0 + x) / exp(x); else tmp = t_0 / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] + -1.0), $MachinePrecision] * N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 4.0], N[(N[(1.0 + x), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(t$95$0 / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 + \frac{1}{\varepsilon}\right) \cdot e^{x \cdot \left(\varepsilon + -1\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{x \cdot \left(-1 - \varepsilon\right)}\\
\mathbf{if}\;t\_0 \leq 4:\\
\;\;\;\;\frac{1 + x}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{2}\\
\end{array}
\end{array}
if (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) < 4Initial program 57.7%
Simplified33.9%
Taylor expanded in eps around 0 56.4%
associate-+r+100.0%
mul-1-neg100.0%
sub-neg100.0%
+-inverses100.0%
distribute-lft-out100.0%
distribute-rgt1-in100.0%
mul-1-neg100.0%
Simplified100.0%
Taylor expanded in eps around 0 100.0%
+-commutative100.0%
Simplified100.0%
*-commutative100.0%
exp-neg100.0%
un-div-inv100.0%
Applied egg-rr100.0%
if 4 < (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) Initial program 100.0%
Final simplification100.0%
(FPCore (x eps)
:precision binary64
(if (<= x -1.02e+73)
(/
(/ (* x (+ (* x (+ 0.5 (* x (* x 0.041666666666666664)))) -1.0)) eps)
2.0)
(if (<= x 0.335)
(/ (+ 2.0 (* x (- (+ (/ 1.0 eps) (/ -1.0 eps)) eps))) 2.0)
(if (<= x 2e+157)
(* x (exp (- x)))
(/
(/ (* eps (* 2.0 (* (+ 1.0 x) (+ 1.0 (* x (+ (* x 0.5) -1.0)))))) eps)
2.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -1.02e+73) {
tmp = ((x * ((x * (0.5 + (x * (x * 0.041666666666666664)))) + -1.0)) / eps) / 2.0;
} else if (x <= 0.335) {
tmp = (2.0 + (x * (((1.0 / eps) + (-1.0 / eps)) - eps))) / 2.0;
} else if (x <= 2e+157) {
tmp = x * exp(-x);
} else {
tmp = ((eps * (2.0 * ((1.0 + x) * (1.0 + (x * ((x * 0.5) + -1.0)))))) / eps) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-1.02d+73)) then
tmp = ((x * ((x * (0.5d0 + (x * (x * 0.041666666666666664d0)))) + (-1.0d0))) / eps) / 2.0d0
else if (x <= 0.335d0) then
tmp = (2.0d0 + (x * (((1.0d0 / eps) + ((-1.0d0) / eps)) - eps))) / 2.0d0
else if (x <= 2d+157) then
tmp = x * exp(-x)
else
tmp = ((eps * (2.0d0 * ((1.0d0 + x) * (1.0d0 + (x * ((x * 0.5d0) + (-1.0d0))))))) / eps) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -1.02e+73) {
tmp = ((x * ((x * (0.5 + (x * (x * 0.041666666666666664)))) + -1.0)) / eps) / 2.0;
} else if (x <= 0.335) {
tmp = (2.0 + (x * (((1.0 / eps) + (-1.0 / eps)) - eps))) / 2.0;
} else if (x <= 2e+157) {
tmp = x * Math.exp(-x);
} else {
tmp = ((eps * (2.0 * ((1.0 + x) * (1.0 + (x * ((x * 0.5) + -1.0)))))) / eps) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -1.02e+73: tmp = ((x * ((x * (0.5 + (x * (x * 0.041666666666666664)))) + -1.0)) / eps) / 2.0 elif x <= 0.335: tmp = (2.0 + (x * (((1.0 / eps) + (-1.0 / eps)) - eps))) / 2.0 elif x <= 2e+157: tmp = x * math.exp(-x) else: tmp = ((eps * (2.0 * ((1.0 + x) * (1.0 + (x * ((x * 0.5) + -1.0)))))) / eps) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -1.02e+73) tmp = Float64(Float64(Float64(x * Float64(Float64(x * Float64(0.5 + Float64(x * Float64(x * 0.041666666666666664)))) + -1.0)) / eps) / 2.0); elseif (x <= 0.335) tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(Float64(1.0 / eps) + Float64(-1.0 / eps)) - eps))) / 2.0); elseif (x <= 2e+157) tmp = Float64(x * exp(Float64(-x))); else tmp = Float64(Float64(Float64(eps * Float64(2.0 * Float64(Float64(1.0 + x) * Float64(1.0 + Float64(x * Float64(Float64(x * 0.5) + -1.0)))))) / eps) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -1.02e+73) tmp = ((x * ((x * (0.5 + (x * (x * 0.041666666666666664)))) + -1.0)) / eps) / 2.0; elseif (x <= 0.335) tmp = (2.0 + (x * (((1.0 / eps) + (-1.0 / eps)) - eps))) / 2.0; elseif (x <= 2e+157) tmp = x * exp(-x); else tmp = ((eps * (2.0 * ((1.0 + x) * (1.0 + (x * ((x * 0.5) + -1.0)))))) / eps) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -1.02e+73], N[(N[(N[(x * N[(N[(x * N[(0.5 + N[(x * N[(x * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 0.335], N[(N[(2.0 + N[(x * N[(N[(N[(1.0 / eps), $MachinePrecision] + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] - eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 2e+157], N[(x * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision], N[(N[(N[(eps * N[(2.0 * N[(N[(1.0 + x), $MachinePrecision] * N[(1.0 + N[(x * N[(N[(x * 0.5), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.02 \cdot 10^{+73}:\\
\;\;\;\;\frac{\frac{x \cdot \left(x \cdot \left(0.5 + x \cdot \left(x \cdot 0.041666666666666664\right)\right) + -1\right)}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq 0.335:\\
\;\;\;\;\frac{2 + x \cdot \left(\left(\frac{1}{\varepsilon} + \frac{-1}{\varepsilon}\right) - \varepsilon\right)}{2}\\
\mathbf{elif}\;x \leq 2 \cdot 10^{+157}:\\
\;\;\;\;x \cdot e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\varepsilon \cdot \left(2 \cdot \left(\left(1 + x\right) \cdot \left(1 + x \cdot \left(x \cdot 0.5 + -1\right)\right)\right)\right)}{\varepsilon}}{2}\\
\end{array}
\end{array}
if x < -1.01999999999999995e73Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 53.4%
Taylor expanded in eps around 0 48.1%
expm1-define48.1%
neg-mul-148.1%
Simplified48.1%
Taylor expanded in x around 0 44.7%
Taylor expanded in x around inf 44.7%
*-commutative44.7%
Simplified44.7%
if -1.01999999999999995e73 < x < 0.33500000000000002Initial program 61.2%
Simplified48.8%
Taylor expanded in x around 0 69.0%
Taylor expanded in eps around 0 69.7%
if 0.33500000000000002 < x < 1.99999999999999997e157Initial program 94.1%
Simplified93.9%
Taylor expanded in eps around 0 51.9%
associate-+r+57.8%
mul-1-neg57.8%
sub-neg57.8%
+-inverses57.8%
distribute-lft-out57.8%
distribute-rgt1-in57.8%
mul-1-neg57.8%
Simplified57.8%
Taylor expanded in x around inf 53.1%
if 1.99999999999999997e157 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 36.3%
associate-+r+36.3%
mul-1-neg36.3%
sub-neg36.3%
+-inverses36.3%
distribute-lft-out36.3%
distribute-rgt1-in36.3%
mul-1-neg36.3%
Simplified36.3%
Taylor expanded in x around 0 65.3%
Final simplification63.3%
(FPCore (x eps)
:precision binary64
(if (<= x -50000.0)
(/ (/ (expm1 (- x)) eps) 2.0)
(if (<= x 2e+157)
(/ (+ 1.0 x) (exp x))
(/
(/ (* eps (* 2.0 (* (+ 1.0 x) (+ 1.0 (* x (+ (* x 0.5) -1.0)))))) eps)
2.0))))
double code(double x, double eps) {
double tmp;
if (x <= -50000.0) {
tmp = (expm1(-x) / eps) / 2.0;
} else if (x <= 2e+157) {
tmp = (1.0 + x) / exp(x);
} else {
tmp = ((eps * (2.0 * ((1.0 + x) * (1.0 + (x * ((x * 0.5) + -1.0)))))) / eps) / 2.0;
}
return tmp;
}
public static double code(double x, double eps) {
double tmp;
if (x <= -50000.0) {
tmp = (Math.expm1(-x) / eps) / 2.0;
} else if (x <= 2e+157) {
tmp = (1.0 + x) / Math.exp(x);
} else {
tmp = ((eps * (2.0 * ((1.0 + x) * (1.0 + (x * ((x * 0.5) + -1.0)))))) / eps) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -50000.0: tmp = (math.expm1(-x) / eps) / 2.0 elif x <= 2e+157: tmp = (1.0 + x) / math.exp(x) else: tmp = ((eps * (2.0 * ((1.0 + x) * (1.0 + (x * ((x * 0.5) + -1.0)))))) / eps) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -50000.0) tmp = Float64(Float64(expm1(Float64(-x)) / eps) / 2.0); elseif (x <= 2e+157) tmp = Float64(Float64(1.0 + x) / exp(x)); else tmp = Float64(Float64(Float64(eps * Float64(2.0 * Float64(Float64(1.0 + x) * Float64(1.0 + Float64(x * Float64(Float64(x * 0.5) + -1.0)))))) / eps) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -50000.0], N[(N[(N[(Exp[(-x)] - 1), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 2e+157], N[(N[(1.0 + x), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(N[(N[(eps * N[(2.0 * N[(N[(1.0 + x), $MachinePrecision] * N[(1.0 + N[(x * N[(N[(x * 0.5), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -50000:\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(-x\right)}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq 2 \cdot 10^{+157}:\\
\;\;\;\;\frac{1 + x}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\varepsilon \cdot \left(2 \cdot \left(\left(1 + x\right) \cdot \left(1 + x \cdot \left(x \cdot 0.5 + -1\right)\right)\right)\right)}{\varepsilon}}{2}\\
\end{array}
\end{array}
if x < -5e4Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 47.6%
Taylor expanded in eps around 0 54.1%
expm1-define54.1%
neg-mul-154.1%
Simplified54.1%
if -5e4 < x < 1.99999999999999997e157Initial program 67.8%
Simplified49.6%
Taylor expanded in eps around 0 37.3%
associate-+r+70.5%
mul-1-neg70.5%
sub-neg70.5%
+-inverses70.5%
distribute-lft-out70.5%
distribute-rgt1-in70.5%
mul-1-neg70.5%
Simplified70.5%
Taylor expanded in eps around 0 70.5%
+-commutative70.5%
Simplified70.5%
*-commutative70.5%
exp-neg70.5%
un-div-inv70.5%
Applied egg-rr70.5%
if 1.99999999999999997e157 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 36.3%
associate-+r+36.3%
mul-1-neg36.3%
sub-neg36.3%
+-inverses36.3%
distribute-lft-out36.3%
distribute-rgt1-in36.3%
mul-1-neg36.3%
Simplified36.3%
Taylor expanded in x around 0 65.3%
Final simplification67.4%
(FPCore (x eps) :precision binary64 (if (<= x -3.5e-236) (/ (+ 1.0 (exp (* (- 1.0 eps) x))) 2.0) (/ (+ 1.0 (exp (* x (+ eps -1.0)))) 2.0)))
double code(double x, double eps) {
double tmp;
if (x <= -3.5e-236) {
tmp = (1.0 + exp(((1.0 - eps) * x))) / 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 <= (-3.5d-236)) then
tmp = (1.0d0 + exp(((1.0d0 - eps) * x))) / 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 <= -3.5e-236) {
tmp = (1.0 + Math.exp(((1.0 - eps) * x))) / 2.0;
} else {
tmp = (1.0 + Math.exp((x * (eps + -1.0)))) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -3.5e-236: tmp = (1.0 + math.exp(((1.0 - eps) * x))) / 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 <= -3.5e-236) tmp = Float64(Float64(1.0 + exp(Float64(Float64(1.0 - eps) * x))) / 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 <= -3.5e-236) tmp = (1.0 + exp(((1.0 - eps) * x))) / 2.0; else tmp = (1.0 + exp((x * (eps + -1.0)))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -3.5e-236], N[(N[(1.0 + N[Exp[N[(N[(1.0 - eps), $MachinePrecision] * x), $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 -3.5 \cdot 10^{-236}:\\
\;\;\;\;\frac{1 + e^{\left(1 - \varepsilon\right) \cdot x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(\varepsilon + -1\right)}}{2}\\
\end{array}
\end{array}
if x < -3.49999999999999994e-236Initial program 75.5%
Simplified75.5%
Taylor expanded in x around 0 42.2%
Taylor expanded in eps around inf 64.8%
associate-*r*64.8%
neg-mul-164.8%
Simplified64.8%
add-sqr-sqrt64.8%
sqrt-unprod63.7%
sqr-neg63.7%
sqrt-unprod0.0%
add-sqr-sqrt71.3%
sub-neg71.3%
distribute-lft-in71.3%
*-rgt-identity71.3%
Applied egg-rr71.3%
*-rgt-identity71.3%
distribute-lft-in71.3%
sub-neg71.3%
Simplified71.3%
if -3.49999999999999994e-236 < x Initial program 77.4%
Simplified77.4%
Taylor expanded in x around 0 39.3%
Taylor expanded in eps around inf 60.1%
associate-*r*60.1%
neg-mul-160.1%
Simplified60.1%
Final simplification64.0%
(FPCore (x eps) :precision binary64 (if (<= x -3.5e-236) (/ (+ 1.0 (exp (* (- 1.0 eps) x))) 2.0) (/ (+ 1.0 (exp (* eps x))) 2.0)))
double code(double x, double eps) {
double tmp;
if (x <= -3.5e-236) {
tmp = (1.0 + exp(((1.0 - eps) * x))) / 2.0;
} else {
tmp = (1.0 + exp((eps * x))) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-3.5d-236)) then
tmp = (1.0d0 + exp(((1.0d0 - eps) * x))) / 2.0d0
else
tmp = (1.0d0 + exp((eps * x))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -3.5e-236) {
tmp = (1.0 + Math.exp(((1.0 - eps) * x))) / 2.0;
} else {
tmp = (1.0 + Math.exp((eps * x))) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -3.5e-236: tmp = (1.0 + math.exp(((1.0 - eps) * x))) / 2.0 else: tmp = (1.0 + math.exp((eps * x))) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -3.5e-236) tmp = Float64(Float64(1.0 + exp(Float64(Float64(1.0 - eps) * x))) / 2.0); else tmp = Float64(Float64(1.0 + exp(Float64(eps * x))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -3.5e-236) tmp = (1.0 + exp(((1.0 - eps) * x))) / 2.0; else tmp = (1.0 + exp((eps * x))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -3.5e-236], N[(N[(1.0 + N[Exp[N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(1.0 + N[Exp[N[(eps * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.5 \cdot 10^{-236}:\\
\;\;\;\;\frac{1 + e^{\left(1 - \varepsilon\right) \cdot x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + e^{\varepsilon \cdot x}}{2}\\
\end{array}
\end{array}
if x < -3.49999999999999994e-236Initial program 75.5%
Simplified75.5%
Taylor expanded in x around 0 42.2%
Taylor expanded in eps around inf 64.8%
associate-*r*64.8%
neg-mul-164.8%
Simplified64.8%
add-sqr-sqrt64.8%
sqrt-unprod63.7%
sqr-neg63.7%
sqrt-unprod0.0%
add-sqr-sqrt71.3%
sub-neg71.3%
distribute-lft-in71.3%
*-rgt-identity71.3%
Applied egg-rr71.3%
*-rgt-identity71.3%
distribute-lft-in71.3%
sub-neg71.3%
Simplified71.3%
if -3.49999999999999994e-236 < x Initial program 77.4%
Simplified77.4%
Taylor expanded in x around 0 39.3%
Taylor expanded in eps around inf 60.1%
associate-*r*60.1%
neg-mul-160.1%
Simplified60.1%
Taylor expanded in eps around inf 60.1%
*-commutative60.1%
Simplified60.1%
Final simplification64.0%
(FPCore (x eps) :precision binary64 (if (<= eps 0.005) (/ (+ 1.0 x) (exp x)) (/ (+ 1.0 (exp (* eps x))) 2.0)))
double code(double x, double eps) {
double tmp;
if (eps <= 0.005) {
tmp = (1.0 + x) / exp(x);
} else {
tmp = (1.0 + exp((eps * x))) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (eps <= 0.005d0) then
tmp = (1.0d0 + x) / exp(x)
else
tmp = (1.0d0 + exp((eps * x))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= 0.005) {
tmp = (1.0 + x) / Math.exp(x);
} else {
tmp = (1.0 + Math.exp((eps * x))) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= 0.005: tmp = (1.0 + x) / math.exp(x) else: tmp = (1.0 + math.exp((eps * x))) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (eps <= 0.005) tmp = Float64(Float64(1.0 + x) / exp(x)); else tmp = Float64(Float64(1.0 + exp(Float64(eps * x))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= 0.005) tmp = (1.0 + x) / exp(x); else tmp = (1.0 + exp((eps * x))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, 0.005], N[(N[(1.0 + x), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[Exp[N[(eps * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 0.005:\\
\;\;\;\;\frac{1 + x}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + e^{\varepsilon \cdot x}}{2}\\
\end{array}
\end{array}
if eps < 0.0050000000000000001Initial program 65.6%
Simplified55.6%
Taylor expanded in eps around 0 34.9%
associate-+r+70.3%
mul-1-neg70.3%
sub-neg70.3%
+-inverses70.3%
distribute-lft-out70.3%
distribute-rgt1-in70.3%
mul-1-neg70.3%
Simplified70.3%
Taylor expanded in eps around 0 70.3%
+-commutative70.3%
Simplified70.3%
*-commutative70.3%
exp-neg70.3%
un-div-inv70.4%
Applied egg-rr70.4%
if 0.0050000000000000001 < eps Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 64.4%
Taylor expanded in eps around inf 64.4%
associate-*r*64.4%
neg-mul-164.4%
Simplified64.4%
Taylor expanded in eps around inf 64.4%
*-commutative64.4%
Simplified64.4%
Final simplification68.4%
(FPCore (x eps)
:precision binary64
(if (<= eps 0.005)
(/ (+ 1.0 x) (exp x))
(if (<= eps 1.8e+249)
(/
(/ (* eps (* 2.0 (* (+ 1.0 x) (+ 1.0 (* x (+ (* x 0.5) -1.0)))))) eps)
2.0)
(/ (+ 2.0 (* x (- (+ (/ 1.0 eps) (/ -1.0 eps)) eps))) 2.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 0.005) {
tmp = (1.0 + x) / exp(x);
} else if (eps <= 1.8e+249) {
tmp = ((eps * (2.0 * ((1.0 + x) * (1.0 + (x * ((x * 0.5) + -1.0)))))) / eps) / 2.0;
} else {
tmp = (2.0 + (x * (((1.0 / eps) + (-1.0 / eps)) - 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 (eps <= 0.005d0) then
tmp = (1.0d0 + x) / exp(x)
else if (eps <= 1.8d+249) then
tmp = ((eps * (2.0d0 * ((1.0d0 + x) * (1.0d0 + (x * ((x * 0.5d0) + (-1.0d0))))))) / eps) / 2.0d0
else
tmp = (2.0d0 + (x * (((1.0d0 / eps) + ((-1.0d0) / eps)) - eps))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= 0.005) {
tmp = (1.0 + x) / Math.exp(x);
} else if (eps <= 1.8e+249) {
tmp = ((eps * (2.0 * ((1.0 + x) * (1.0 + (x * ((x * 0.5) + -1.0)))))) / eps) / 2.0;
} else {
tmp = (2.0 + (x * (((1.0 / eps) + (-1.0 / eps)) - eps))) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= 0.005: tmp = (1.0 + x) / math.exp(x) elif eps <= 1.8e+249: tmp = ((eps * (2.0 * ((1.0 + x) * (1.0 + (x * ((x * 0.5) + -1.0)))))) / eps) / 2.0 else: tmp = (2.0 + (x * (((1.0 / eps) + (-1.0 / eps)) - eps))) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (eps <= 0.005) tmp = Float64(Float64(1.0 + x) / exp(x)); elseif (eps <= 1.8e+249) tmp = Float64(Float64(Float64(eps * Float64(2.0 * Float64(Float64(1.0 + x) * Float64(1.0 + Float64(x * Float64(Float64(x * 0.5) + -1.0)))))) / eps) / 2.0); else tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(Float64(1.0 / eps) + Float64(-1.0 / eps)) - eps))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= 0.005) tmp = (1.0 + x) / exp(x); elseif (eps <= 1.8e+249) tmp = ((eps * (2.0 * ((1.0 + x) * (1.0 + (x * ((x * 0.5) + -1.0)))))) / eps) / 2.0; else tmp = (2.0 + (x * (((1.0 / eps) + (-1.0 / eps)) - eps))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, 0.005], N[(N[(1.0 + x), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 1.8e+249], N[(N[(N[(eps * N[(2.0 * N[(N[(1.0 + x), $MachinePrecision] * N[(1.0 + N[(x * N[(N[(x * 0.5), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(2.0 + N[(x * N[(N[(N[(1.0 / eps), $MachinePrecision] + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] - eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 0.005:\\
\;\;\;\;\frac{1 + x}{e^{x}}\\
\mathbf{elif}\;\varepsilon \leq 1.8 \cdot 10^{+249}:\\
\;\;\;\;\frac{\frac{\varepsilon \cdot \left(2 \cdot \left(\left(1 + x\right) \cdot \left(1 + x \cdot \left(x \cdot 0.5 + -1\right)\right)\right)\right)}{\varepsilon}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + x \cdot \left(\left(\frac{1}{\varepsilon} + \frac{-1}{\varepsilon}\right) - \varepsilon\right)}{2}\\
\end{array}
\end{array}
if eps < 0.0050000000000000001Initial program 65.6%
Simplified55.6%
Taylor expanded in eps around 0 34.9%
associate-+r+70.3%
mul-1-neg70.3%
sub-neg70.3%
+-inverses70.3%
distribute-lft-out70.3%
distribute-rgt1-in70.3%
mul-1-neg70.3%
Simplified70.3%
Taylor expanded in eps around 0 70.3%
+-commutative70.3%
Simplified70.3%
*-commutative70.3%
exp-neg70.3%
un-div-inv70.4%
Applied egg-rr70.4%
if 0.0050000000000000001 < eps < 1.7999999999999999e249Initial program 100.0%
Simplified76.6%
Taylor expanded in eps around 0 29.6%
associate-+r+29.7%
mul-1-neg29.7%
sub-neg29.7%
+-inverses29.7%
distribute-lft-out29.7%
distribute-rgt1-in29.7%
mul-1-neg29.7%
Simplified29.7%
Taylor expanded in x around 0 50.2%
if 1.7999999999999999e249 < eps Initial program 99.9%
Simplified89.0%
Taylor expanded in x around 0 13.0%
Taylor expanded in eps around 0 39.9%
Final simplification63.0%
(FPCore (x eps)
:precision binary64
(if (<= x -350000.0)
(/
(/
(*
x
(+
(* x (+ 0.5 (* x (- (* x 0.041666666666666664) 0.16666666666666666))))
-1.0))
eps)
2.0)
(if (or (<= x 1.55e+59) (not (<= x 1.5e+157)))
(/
(/ (* eps (* 2.0 (* (+ 1.0 x) (+ 1.0 (* x (+ (* x 0.5) -1.0)))))) eps)
2.0)
0.0)))
double code(double x, double eps) {
double tmp;
if (x <= -350000.0) {
tmp = ((x * ((x * (0.5 + (x * ((x * 0.041666666666666664) - 0.16666666666666666)))) + -1.0)) / eps) / 2.0;
} else if ((x <= 1.55e+59) || !(x <= 1.5e+157)) {
tmp = ((eps * (2.0 * ((1.0 + x) * (1.0 + (x * ((x * 0.5) + -1.0)))))) / eps) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-350000.0d0)) then
tmp = ((x * ((x * (0.5d0 + (x * ((x * 0.041666666666666664d0) - 0.16666666666666666d0)))) + (-1.0d0))) / eps) / 2.0d0
else if ((x <= 1.55d+59) .or. (.not. (x <= 1.5d+157))) then
tmp = ((eps * (2.0d0 * ((1.0d0 + x) * (1.0d0 + (x * ((x * 0.5d0) + (-1.0d0))))))) / eps) / 2.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -350000.0) {
tmp = ((x * ((x * (0.5 + (x * ((x * 0.041666666666666664) - 0.16666666666666666)))) + -1.0)) / eps) / 2.0;
} else if ((x <= 1.55e+59) || !(x <= 1.5e+157)) {
tmp = ((eps * (2.0 * ((1.0 + x) * (1.0 + (x * ((x * 0.5) + -1.0)))))) / eps) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -350000.0: tmp = ((x * ((x * (0.5 + (x * ((x * 0.041666666666666664) - 0.16666666666666666)))) + -1.0)) / eps) / 2.0 elif (x <= 1.55e+59) or not (x <= 1.5e+157): tmp = ((eps * (2.0 * ((1.0 + x) * (1.0 + (x * ((x * 0.5) + -1.0)))))) / eps) / 2.0 else: tmp = 0.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -350000.0) tmp = Float64(Float64(Float64(x * Float64(Float64(x * Float64(0.5 + Float64(x * Float64(Float64(x * 0.041666666666666664) - 0.16666666666666666)))) + -1.0)) / eps) / 2.0); elseif ((x <= 1.55e+59) || !(x <= 1.5e+157)) tmp = Float64(Float64(Float64(eps * Float64(2.0 * Float64(Float64(1.0 + x) * Float64(1.0 + Float64(x * Float64(Float64(x * 0.5) + -1.0)))))) / eps) / 2.0); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -350000.0) tmp = ((x * ((x * (0.5 + (x * ((x * 0.041666666666666664) - 0.16666666666666666)))) + -1.0)) / eps) / 2.0; elseif ((x <= 1.55e+59) || ~((x <= 1.5e+157))) tmp = ((eps * (2.0 * ((1.0 + x) * (1.0 + (x * ((x * 0.5) + -1.0)))))) / eps) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -350000.0], N[(N[(N[(x * N[(N[(x * N[(0.5 + N[(x * N[(N[(x * 0.041666666666666664), $MachinePrecision] - 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 1.55e+59], N[Not[LessEqual[x, 1.5e+157]], $MachinePrecision]], N[(N[(N[(eps * N[(2.0 * N[(N[(1.0 + x), $MachinePrecision] * N[(1.0 + N[(x * N[(N[(x * 0.5), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -350000:\\
\;\;\;\;\frac{\frac{x \cdot \left(x \cdot \left(0.5 + x \cdot \left(x \cdot 0.041666666666666664 - 0.16666666666666666\right)\right) + -1\right)}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{+59} \lor \neg \left(x \leq 1.5 \cdot 10^{+157}\right):\\
\;\;\;\;\frac{\frac{\varepsilon \cdot \left(2 \cdot \left(\left(1 + x\right) \cdot \left(1 + x \cdot \left(x \cdot 0.5 + -1\right)\right)\right)\right)}{\varepsilon}}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -3.5e5Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 47.6%
Taylor expanded in eps around 0 54.1%
expm1-define54.1%
neg-mul-154.1%
Simplified54.1%
Taylor expanded in x around 0 33.3%
if -3.5e5 < x < 1.55000000000000007e59 or 1.50000000000000005e157 < x Initial program 68.1%
Simplified50.2%
Taylor expanded in eps around 0 32.7%
associate-+r+65.6%
mul-1-neg65.6%
sub-neg65.6%
+-inverses65.6%
distribute-lft-out65.6%
distribute-rgt1-in65.6%
mul-1-neg65.6%
Simplified65.6%
Taylor expanded in x around 0 69.4%
if 1.55000000000000007e59 < x < 1.50000000000000005e157Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 63.1%
div-sub63.1%
mul-1-neg63.1%
rec-exp63.1%
+-inverses63.1%
metadata-eval63.1%
Simplified63.1%
Final simplification63.4%
(FPCore (x eps)
:precision binary64
(if (<= x -1.02e+73)
(/
(/ (* x (+ (* x (+ 0.5 (* x (* x 0.041666666666666664)))) -1.0)) eps)
2.0)
(if (<= x 240.0)
(/ (+ 2.0 (* x (- (+ (/ 1.0 eps) (/ -1.0 eps)) eps))) 2.0)
(if (<= x 1.5e+157) 0.0 (/ (* x (- (* x 0.25) 0.5)) eps)))))
double code(double x, double eps) {
double tmp;
if (x <= -1.02e+73) {
tmp = ((x * ((x * (0.5 + (x * (x * 0.041666666666666664)))) + -1.0)) / eps) / 2.0;
} else if (x <= 240.0) {
tmp = (2.0 + (x * (((1.0 / eps) + (-1.0 / eps)) - eps))) / 2.0;
} else if (x <= 1.5e+157) {
tmp = 0.0;
} else {
tmp = (x * ((x * 0.25) - 0.5)) / eps;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-1.02d+73)) then
tmp = ((x * ((x * (0.5d0 + (x * (x * 0.041666666666666664d0)))) + (-1.0d0))) / eps) / 2.0d0
else if (x <= 240.0d0) then
tmp = (2.0d0 + (x * (((1.0d0 / eps) + ((-1.0d0) / eps)) - eps))) / 2.0d0
else if (x <= 1.5d+157) then
tmp = 0.0d0
else
tmp = (x * ((x * 0.25d0) - 0.5d0)) / eps
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -1.02e+73) {
tmp = ((x * ((x * (0.5 + (x * (x * 0.041666666666666664)))) + -1.0)) / eps) / 2.0;
} else if (x <= 240.0) {
tmp = (2.0 + (x * (((1.0 / eps) + (-1.0 / eps)) - eps))) / 2.0;
} else if (x <= 1.5e+157) {
tmp = 0.0;
} else {
tmp = (x * ((x * 0.25) - 0.5)) / eps;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -1.02e+73: tmp = ((x * ((x * (0.5 + (x * (x * 0.041666666666666664)))) + -1.0)) / eps) / 2.0 elif x <= 240.0: tmp = (2.0 + (x * (((1.0 / eps) + (-1.0 / eps)) - eps))) / 2.0 elif x <= 1.5e+157: tmp = 0.0 else: tmp = (x * ((x * 0.25) - 0.5)) / eps return tmp
function code(x, eps) tmp = 0.0 if (x <= -1.02e+73) tmp = Float64(Float64(Float64(x * Float64(Float64(x * Float64(0.5 + Float64(x * Float64(x * 0.041666666666666664)))) + -1.0)) / eps) / 2.0); elseif (x <= 240.0) tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(Float64(1.0 / eps) + Float64(-1.0 / eps)) - eps))) / 2.0); elseif (x <= 1.5e+157) tmp = 0.0; else tmp = Float64(Float64(x * Float64(Float64(x * 0.25) - 0.5)) / eps); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -1.02e+73) tmp = ((x * ((x * (0.5 + (x * (x * 0.041666666666666664)))) + -1.0)) / eps) / 2.0; elseif (x <= 240.0) tmp = (2.0 + (x * (((1.0 / eps) + (-1.0 / eps)) - eps))) / 2.0; elseif (x <= 1.5e+157) tmp = 0.0; else tmp = (x * ((x * 0.25) - 0.5)) / eps; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -1.02e+73], N[(N[(N[(x * N[(N[(x * N[(0.5 + N[(x * N[(x * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 240.0], N[(N[(2.0 + N[(x * N[(N[(N[(1.0 / eps), $MachinePrecision] + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] - eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.5e+157], 0.0, N[(N[(x * N[(N[(x * 0.25), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.02 \cdot 10^{+73}:\\
\;\;\;\;\frac{\frac{x \cdot \left(x \cdot \left(0.5 + x \cdot \left(x \cdot 0.041666666666666664\right)\right) + -1\right)}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq 240:\\
\;\;\;\;\frac{2 + x \cdot \left(\left(\frac{1}{\varepsilon} + \frac{-1}{\varepsilon}\right) - \varepsilon\right)}{2}\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{+157}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(x \cdot 0.25 - 0.5\right)}{\varepsilon}\\
\end{array}
\end{array}
if x < -1.01999999999999995e73Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 53.4%
Taylor expanded in eps around 0 48.1%
expm1-define48.1%
neg-mul-148.1%
Simplified48.1%
Taylor expanded in x around 0 44.7%
Taylor expanded in x around inf 44.7%
*-commutative44.7%
Simplified44.7%
if -1.01999999999999995e73 < x < 240Initial program 60.3%
Simplified48.2%
Taylor expanded in x around 0 67.4%
Taylor expanded in eps around 0 68.1%
if 240 < x < 1.50000000000000005e157Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 56.3%
div-sub56.3%
mul-1-neg56.3%
rec-exp56.3%
+-inverses56.3%
metadata-eval56.3%
Simplified56.3%
if 1.50000000000000005e157 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 28.4%
Taylor expanded in eps around 0 1.9%
expm1-define1.9%
neg-mul-11.9%
Simplified1.9%
Taylor expanded in x around 0 15.9%
*-commutative15.9%
associate-*r/15.9%
metadata-eval15.9%
Simplified15.9%
Taylor expanded in eps around 0 27.0%
Final simplification58.1%
(FPCore (x eps)
:precision binary64
(if (<= x -2.4e+120)
(/ (/ (* x (+ (* x (+ 0.5 (* x -0.16666666666666666))) -1.0)) eps) 2.0)
(if (<= x 195.0)
(/ (+ 2.0 (* x (- (+ (/ 1.0 eps) (/ -1.0 eps)) eps))) 2.0)
(if (<= x 5e+157) 0.0 (/ (* x (- (* x 0.25) 0.5)) eps)))))
double code(double x, double eps) {
double tmp;
if (x <= -2.4e+120) {
tmp = ((x * ((x * (0.5 + (x * -0.16666666666666666))) + -1.0)) / eps) / 2.0;
} else if (x <= 195.0) {
tmp = (2.0 + (x * (((1.0 / eps) + (-1.0 / eps)) - eps))) / 2.0;
} else if (x <= 5e+157) {
tmp = 0.0;
} else {
tmp = (x * ((x * 0.25) - 0.5)) / eps;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-2.4d+120)) then
tmp = ((x * ((x * (0.5d0 + (x * (-0.16666666666666666d0)))) + (-1.0d0))) / eps) / 2.0d0
else if (x <= 195.0d0) then
tmp = (2.0d0 + (x * (((1.0d0 / eps) + ((-1.0d0) / eps)) - eps))) / 2.0d0
else if (x <= 5d+157) then
tmp = 0.0d0
else
tmp = (x * ((x * 0.25d0) - 0.5d0)) / eps
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -2.4e+120) {
tmp = ((x * ((x * (0.5 + (x * -0.16666666666666666))) + -1.0)) / eps) / 2.0;
} else if (x <= 195.0) {
tmp = (2.0 + (x * (((1.0 / eps) + (-1.0 / eps)) - eps))) / 2.0;
} else if (x <= 5e+157) {
tmp = 0.0;
} else {
tmp = (x * ((x * 0.25) - 0.5)) / eps;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -2.4e+120: tmp = ((x * ((x * (0.5 + (x * -0.16666666666666666))) + -1.0)) / eps) / 2.0 elif x <= 195.0: tmp = (2.0 + (x * (((1.0 / eps) + (-1.0 / eps)) - eps))) / 2.0 elif x <= 5e+157: tmp = 0.0 else: tmp = (x * ((x * 0.25) - 0.5)) / eps return tmp
function code(x, eps) tmp = 0.0 if (x <= -2.4e+120) tmp = Float64(Float64(Float64(x * Float64(Float64(x * Float64(0.5 + Float64(x * -0.16666666666666666))) + -1.0)) / eps) / 2.0); elseif (x <= 195.0) tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(Float64(1.0 / eps) + Float64(-1.0 / eps)) - eps))) / 2.0); elseif (x <= 5e+157) tmp = 0.0; else tmp = Float64(Float64(x * Float64(Float64(x * 0.25) - 0.5)) / eps); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -2.4e+120) tmp = ((x * ((x * (0.5 + (x * -0.16666666666666666))) + -1.0)) / eps) / 2.0; elseif (x <= 195.0) tmp = (2.0 + (x * (((1.0 / eps) + (-1.0 / eps)) - eps))) / 2.0; elseif (x <= 5e+157) tmp = 0.0; else tmp = (x * ((x * 0.25) - 0.5)) / eps; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -2.4e+120], N[(N[(N[(x * N[(N[(x * N[(0.5 + N[(x * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 195.0], N[(N[(2.0 + N[(x * N[(N[(N[(1.0 / eps), $MachinePrecision] + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] - eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 5e+157], 0.0, N[(N[(x * N[(N[(x * 0.25), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.4 \cdot 10^{+120}:\\
\;\;\;\;\frac{\frac{x \cdot \left(x \cdot \left(0.5 + x \cdot -0.16666666666666666\right) + -1\right)}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq 195:\\
\;\;\;\;\frac{2 + x \cdot \left(\left(\frac{1}{\varepsilon} + \frac{-1}{\varepsilon}\right) - \varepsilon\right)}{2}\\
\mathbf{elif}\;x \leq 5 \cdot 10^{+157}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(x \cdot 0.25 - 0.5\right)}{\varepsilon}\\
\end{array}
\end{array}
if x < -2.40000000000000001e120Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 63.1%
Taylor expanded in eps around 0 38.1%
expm1-define38.1%
neg-mul-138.1%
Simplified38.1%
Taylor expanded in x around 0 38.1%
if -2.40000000000000001e120 < x < 195Initial program 61.8%
Simplified50.2%
Taylor expanded in x around 0 65.0%
Taylor expanded in eps around 0 68.1%
if 195 < x < 4.99999999999999976e157Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 56.3%
div-sub56.3%
mul-1-neg56.3%
rec-exp56.3%
+-inverses56.3%
metadata-eval56.3%
Simplified56.3%
if 4.99999999999999976e157 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 28.4%
Taylor expanded in eps around 0 1.9%
expm1-define1.9%
neg-mul-11.9%
Simplified1.9%
Taylor expanded in x around 0 15.9%
*-commutative15.9%
associate-*r/15.9%
metadata-eval15.9%
Simplified15.9%
Taylor expanded in eps around 0 27.0%
Final simplification58.1%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (/ (* x (- (* x 0.25) 0.5)) eps)))
(if (<= x -190.0)
t_0
(if (<= x 7.4e+19)
(* (+ 1.0 x) (+ 1.0 (* x (+ (* x 0.5) -1.0))))
(if (<= x 1.15e+157) 0.0 t_0)))))
double code(double x, double eps) {
double t_0 = (x * ((x * 0.25) - 0.5)) / eps;
double tmp;
if (x <= -190.0) {
tmp = t_0;
} else if (x <= 7.4e+19) {
tmp = (1.0 + x) * (1.0 + (x * ((x * 0.5) + -1.0)));
} else if (x <= 1.15e+157) {
tmp = 0.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 * 0.25d0) - 0.5d0)) / eps
if (x <= (-190.0d0)) then
tmp = t_0
else if (x <= 7.4d+19) then
tmp = (1.0d0 + x) * (1.0d0 + (x * ((x * 0.5d0) + (-1.0d0))))
else if (x <= 1.15d+157) then
tmp = 0.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = (x * ((x * 0.25) - 0.5)) / eps;
double tmp;
if (x <= -190.0) {
tmp = t_0;
} else if (x <= 7.4e+19) {
tmp = (1.0 + x) * (1.0 + (x * ((x * 0.5) + -1.0)));
} else if (x <= 1.15e+157) {
tmp = 0.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = (x * ((x * 0.25) - 0.5)) / eps tmp = 0 if x <= -190.0: tmp = t_0 elif x <= 7.4e+19: tmp = (1.0 + x) * (1.0 + (x * ((x * 0.5) + -1.0))) elif x <= 1.15e+157: tmp = 0.0 else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(Float64(x * Float64(Float64(x * 0.25) - 0.5)) / eps) tmp = 0.0 if (x <= -190.0) tmp = t_0; elseif (x <= 7.4e+19) tmp = Float64(Float64(1.0 + x) * Float64(1.0 + Float64(x * Float64(Float64(x * 0.5) + -1.0)))); elseif (x <= 1.15e+157) tmp = 0.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, eps) t_0 = (x * ((x * 0.25) - 0.5)) / eps; tmp = 0.0; if (x <= -190.0) tmp = t_0; elseif (x <= 7.4e+19) tmp = (1.0 + x) * (1.0 + (x * ((x * 0.5) + -1.0))); elseif (x <= 1.15e+157) tmp = 0.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[(x * N[(N[(x * 0.25), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]}, If[LessEqual[x, -190.0], t$95$0, If[LessEqual[x, 7.4e+19], N[(N[(1.0 + x), $MachinePrecision] * N[(1.0 + N[(x * N[(N[(x * 0.5), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.15e+157], 0.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(x \cdot 0.25 - 0.5\right)}{\varepsilon}\\
\mathbf{if}\;x \leq -190:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 7.4 \cdot 10^{+19}:\\
\;\;\;\;\left(1 + x\right) \cdot \left(1 + x \cdot \left(x \cdot 0.5 + -1\right)\right)\\
\mathbf{elif}\;x \leq 1.15 \cdot 10^{+157}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -190 or 1.15000000000000002e157 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 38.4%
Taylor expanded in eps around 0 29.1%
expm1-define29.1%
neg-mul-129.1%
Simplified29.1%
Taylor expanded in x around 0 14.1%
*-commutative14.1%
associate-*r/14.1%
metadata-eval14.1%
Simplified14.1%
Taylor expanded in eps around 0 19.4%
if -190 < x < 7.4e19Initial program 58.3%
Simplified34.8%
Taylor expanded in eps around 0 30.6%
associate-+r+73.5%
mul-1-neg73.5%
sub-neg73.5%
+-inverses73.5%
distribute-lft-out73.5%
distribute-rgt1-in73.5%
mul-1-neg73.5%
Simplified73.5%
Taylor expanded in eps around 0 73.5%
+-commutative73.5%
Simplified73.5%
Taylor expanded in x around 0 71.0%
if 7.4e19 < x < 1.15000000000000002e157Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 60.2%
div-sub60.2%
mul-1-neg60.2%
rec-exp60.2%
+-inverses60.2%
metadata-eval60.2%
Simplified60.2%
Final simplification54.9%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (/ (* x (- (* x 0.25) 0.5)) eps)))
(if (<= x -0.0074)
t_0
(if (<= x 7.4e+19)
(/ (+ 2.0 (* eps x)) 2.0)
(if (<= x 2e+157) 0.0 t_0)))))
double code(double x, double eps) {
double t_0 = (x * ((x * 0.25) - 0.5)) / eps;
double tmp;
if (x <= -0.0074) {
tmp = t_0;
} else if (x <= 7.4e+19) {
tmp = (2.0 + (eps * x)) / 2.0;
} else if (x <= 2e+157) {
tmp = 0.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 * 0.25d0) - 0.5d0)) / eps
if (x <= (-0.0074d0)) then
tmp = t_0
else if (x <= 7.4d+19) then
tmp = (2.0d0 + (eps * x)) / 2.0d0
else if (x <= 2d+157) then
tmp = 0.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = (x * ((x * 0.25) - 0.5)) / eps;
double tmp;
if (x <= -0.0074) {
tmp = t_0;
} else if (x <= 7.4e+19) {
tmp = (2.0 + (eps * x)) / 2.0;
} else if (x <= 2e+157) {
tmp = 0.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = (x * ((x * 0.25) - 0.5)) / eps tmp = 0 if x <= -0.0074: tmp = t_0 elif x <= 7.4e+19: tmp = (2.0 + (eps * x)) / 2.0 elif x <= 2e+157: tmp = 0.0 else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(Float64(x * Float64(Float64(x * 0.25) - 0.5)) / eps) tmp = 0.0 if (x <= -0.0074) tmp = t_0; elseif (x <= 7.4e+19) tmp = Float64(Float64(2.0 + Float64(eps * x)) / 2.0); elseif (x <= 2e+157) tmp = 0.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, eps) t_0 = (x * ((x * 0.25) - 0.5)) / eps; tmp = 0.0; if (x <= -0.0074) tmp = t_0; elseif (x <= 7.4e+19) tmp = (2.0 + (eps * x)) / 2.0; elseif (x <= 2e+157) tmp = 0.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[(x * N[(N[(x * 0.25), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]}, If[LessEqual[x, -0.0074], t$95$0, If[LessEqual[x, 7.4e+19], N[(N[(2.0 + N[(eps * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 2e+157], 0.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(x \cdot 0.25 - 0.5\right)}{\varepsilon}\\
\mathbf{if}\;x \leq -0.0074:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 7.4 \cdot 10^{+19}:\\
\;\;\;\;\frac{2 + \varepsilon \cdot x}{2}\\
\mathbf{elif}\;x \leq 2 \cdot 10^{+157}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -0.0074000000000000003 or 1.99999999999999997e157 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 39.3%
Taylor expanded in eps around 0 28.7%
expm1-define28.7%
neg-mul-128.7%
Simplified28.7%
Taylor expanded in x around 0 13.9%
*-commutative13.9%
associate-*r/13.9%
metadata-eval13.9%
Simplified13.9%
Taylor expanded in eps around 0 19.1%
if -0.0074000000000000003 < x < 7.4e19Initial program 58.0%
Simplified58.0%
Taylor expanded in x around 0 46.5%
Taylor expanded in eps around inf 84.9%
associate-*r*84.9%
neg-mul-184.9%
Simplified84.9%
Taylor expanded in eps around inf 85.7%
*-commutative85.7%
Simplified85.7%
Taylor expanded in x around 0 70.6%
if 7.4e19 < x < 1.99999999999999997e157Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 60.2%
div-sub60.2%
mul-1-neg60.2%
rec-exp60.2%
+-inverses60.2%
metadata-eval60.2%
Simplified60.2%
Final simplification54.4%
(FPCore (x eps)
:precision binary64
(if (<= x -0.0074)
(* x (/ (- (* x 0.25) 0.5) eps))
(if (or (<= x 7.5e+19) (not (<= x 1.22e+222)))
(/ (+ 2.0 (* eps x)) 2.0)
0.0)))
double code(double x, double eps) {
double tmp;
if (x <= -0.0074) {
tmp = x * (((x * 0.25) - 0.5) / eps);
} else if ((x <= 7.5e+19) || !(x <= 1.22e+222)) {
tmp = (2.0 + (eps * x)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-0.0074d0)) then
tmp = x * (((x * 0.25d0) - 0.5d0) / eps)
else if ((x <= 7.5d+19) .or. (.not. (x <= 1.22d+222))) then
tmp = (2.0d0 + (eps * x)) / 2.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -0.0074) {
tmp = x * (((x * 0.25) - 0.5) / eps);
} else if ((x <= 7.5e+19) || !(x <= 1.22e+222)) {
tmp = (2.0 + (eps * x)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -0.0074: tmp = x * (((x * 0.25) - 0.5) / eps) elif (x <= 7.5e+19) or not (x <= 1.22e+222): tmp = (2.0 + (eps * x)) / 2.0 else: tmp = 0.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -0.0074) tmp = Float64(x * Float64(Float64(Float64(x * 0.25) - 0.5) / eps)); elseif ((x <= 7.5e+19) || !(x <= 1.22e+222)) tmp = Float64(Float64(2.0 + Float64(eps * x)) / 2.0); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -0.0074) tmp = x * (((x * 0.25) - 0.5) / eps); elseif ((x <= 7.5e+19) || ~((x <= 1.22e+222))) tmp = (2.0 + (eps * x)) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -0.0074], N[(x * N[(N[(N[(x * 0.25), $MachinePrecision] - 0.5), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, 7.5e+19], N[Not[LessEqual[x, 1.22e+222]], $MachinePrecision]], N[(N[(2.0 + N[(eps * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.0074:\\
\;\;\;\;x \cdot \frac{x \cdot 0.25 - 0.5}{\varepsilon}\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{+19} \lor \neg \left(x \leq 1.22 \cdot 10^{+222}\right):\\
\;\;\;\;\frac{2 + \varepsilon \cdot x}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -0.0074000000000000003Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 49.0%
Taylor expanded in eps around 0 52.7%
expm1-define52.7%
neg-mul-152.7%
Simplified52.7%
Taylor expanded in x around 0 12.1%
*-commutative12.1%
associate-*r/12.1%
metadata-eval12.1%
Simplified12.1%
associate-*l/12.1%
sub-div12.1%
Applied egg-rr12.1%
if -0.0074000000000000003 < x < 7.5e19 or 1.21999999999999996e222 < x Initial program 63.0%
Simplified63.0%
Taylor expanded in x around 0 44.9%
Taylor expanded in eps around inf 78.9%
associate-*r*78.9%
neg-mul-178.9%
Simplified78.9%
Taylor expanded in eps around inf 79.5%
*-commutative79.5%
Simplified79.5%
Taylor expanded in x around 0 65.5%
if 7.5e19 < x < 1.21999999999999996e222Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 56.8%
div-sub56.8%
mul-1-neg56.8%
rec-exp56.8%
+-inverses56.8%
metadata-eval56.8%
Simplified56.8%
Final simplification55.7%
(FPCore (x eps) :precision binary64 (if (<= x 155.0) (/ (+ 2.0 (* x (- (+ (/ 1.0 eps) (/ -1.0 eps)) eps))) 2.0) (if (<= x 1.5e+157) 0.0 (/ (* x (- (* x 0.25) 0.5)) eps))))
double code(double x, double eps) {
double tmp;
if (x <= 155.0) {
tmp = (2.0 + (x * (((1.0 / eps) + (-1.0 / eps)) - eps))) / 2.0;
} else if (x <= 1.5e+157) {
tmp = 0.0;
} else {
tmp = (x * ((x * 0.25) - 0.5)) / eps;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 155.0d0) then
tmp = (2.0d0 + (x * (((1.0d0 / eps) + ((-1.0d0) / eps)) - eps))) / 2.0d0
else if (x <= 1.5d+157) then
tmp = 0.0d0
else
tmp = (x * ((x * 0.25d0) - 0.5d0)) / eps
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 155.0) {
tmp = (2.0 + (x * (((1.0 / eps) + (-1.0 / eps)) - eps))) / 2.0;
} else if (x <= 1.5e+157) {
tmp = 0.0;
} else {
tmp = (x * ((x * 0.25) - 0.5)) / eps;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 155.0: tmp = (2.0 + (x * (((1.0 / eps) + (-1.0 / eps)) - eps))) / 2.0 elif x <= 1.5e+157: tmp = 0.0 else: tmp = (x * ((x * 0.25) - 0.5)) / eps return tmp
function code(x, eps) tmp = 0.0 if (x <= 155.0) tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(Float64(1.0 / eps) + Float64(-1.0 / eps)) - eps))) / 2.0); elseif (x <= 1.5e+157) tmp = 0.0; else tmp = Float64(Float64(x * Float64(Float64(x * 0.25) - 0.5)) / eps); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 155.0) tmp = (2.0 + (x * (((1.0 / eps) + (-1.0 / eps)) - eps))) / 2.0; elseif (x <= 1.5e+157) tmp = 0.0; else tmp = (x * ((x * 0.25) - 0.5)) / eps; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 155.0], N[(N[(2.0 + N[(x * N[(N[(N[(1.0 / eps), $MachinePrecision] + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] - eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.5e+157], 0.0, N[(N[(x * N[(N[(x * 0.25), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 155:\\
\;\;\;\;\frac{2 + x \cdot \left(\left(\frac{1}{\varepsilon} + \frac{-1}{\varepsilon}\right) - \varepsilon\right)}{2}\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{+157}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(x \cdot 0.25 - 0.5\right)}{\varepsilon}\\
\end{array}
\end{array}
if x < 155Initial program 66.3%
Simplified56.1%
Taylor expanded in x around 0 57.6%
Taylor expanded in eps around 0 63.0%
if 155 < x < 1.50000000000000005e157Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 56.3%
div-sub56.3%
mul-1-neg56.3%
rec-exp56.3%
+-inverses56.3%
metadata-eval56.3%
Simplified56.3%
if 1.50000000000000005e157 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 28.4%
Taylor expanded in eps around 0 1.9%
expm1-define1.9%
neg-mul-11.9%
Simplified1.9%
Taylor expanded in x around 0 15.9%
*-commutative15.9%
associate-*r/15.9%
metadata-eval15.9%
Simplified15.9%
Taylor expanded in eps around 0 27.0%
Final simplification57.0%
(FPCore (x eps) :precision binary64 (if (<= x 7.4e+19) 1.0 (if (<= x 2.3e+224) 0.0 (/ (+ 2.0 (* eps x)) 2.0))))
double code(double x, double eps) {
double tmp;
if (x <= 7.4e+19) {
tmp = 1.0;
} else if (x <= 2.3e+224) {
tmp = 0.0;
} else {
tmp = (2.0 + (eps * x)) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 7.4d+19) then
tmp = 1.0d0
else if (x <= 2.3d+224) then
tmp = 0.0d0
else
tmp = (2.0d0 + (eps * x)) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 7.4e+19) {
tmp = 1.0;
} else if (x <= 2.3e+224) {
tmp = 0.0;
} else {
tmp = (2.0 + (eps * x)) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 7.4e+19: tmp = 1.0 elif x <= 2.3e+224: tmp = 0.0 else: tmp = (2.0 + (eps * x)) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 7.4e+19) tmp = 1.0; elseif (x <= 2.3e+224) tmp = 0.0; else tmp = Float64(Float64(2.0 + Float64(eps * x)) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 7.4e+19) tmp = 1.0; elseif (x <= 2.3e+224) tmp = 0.0; else tmp = (2.0 + (eps * x)) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 7.4e+19], 1.0, If[LessEqual[x, 2.3e+224], 0.0, N[(N[(2.0 + N[(eps * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 7.4 \cdot 10^{+19}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{+224}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + \varepsilon \cdot x}{2}\\
\end{array}
\end{array}
if x < 7.4e19Initial program 66.9%
Simplified56.8%
Taylor expanded in x around 0 56.7%
Taylor expanded in x around 0 56.7%
if 7.4e19 < x < 2.3000000000000002e224Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 56.8%
div-sub56.8%
mul-1-neg56.8%
rec-exp56.8%
+-inverses56.8%
metadata-eval56.8%
Simplified56.8%
if 2.3000000000000002e224 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 33.5%
Taylor expanded in eps around inf 33.7%
associate-*r*33.7%
neg-mul-133.7%
Simplified33.7%
Taylor expanded in eps around inf 33.4%
*-commutative33.4%
Simplified33.4%
Taylor expanded in x around 0 27.7%
(FPCore (x eps) :precision binary64 (if (<= x 7.4e+19) 1.0 0.0))
double code(double x, double eps) {
double tmp;
if (x <= 7.4e+19) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 7.4d+19) then
tmp = 1.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 7.4e+19) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 7.4e+19: tmp = 1.0 else: tmp = 0.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 7.4e+19) tmp = 1.0; else tmp = 0.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 7.4e+19) tmp = 1.0; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 7.4e+19], 1.0, 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 7.4 \cdot 10^{+19}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 7.4e19Initial program 66.9%
Simplified56.8%
Taylor expanded in x around 0 56.7%
Taylor expanded in x around 0 56.7%
if 7.4e19 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 49.5%
div-sub49.5%
mul-1-neg49.5%
rec-exp49.5%
+-inverses49.5%
metadata-eval49.5%
Simplified49.5%
(FPCore (x eps) :precision binary64 0.0)
double code(double x, double eps) {
return 0.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 0.0d0
end function
public static double code(double x, double eps) {
return 0.0;
}
def code(x, eps): return 0.0
function code(x, eps) return 0.0 end
function tmp = code(x, eps) tmp = 0.0; end
code[x_, eps_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 76.7%
Simplified69.6%
Taylor expanded in eps around 0 16.2%
div-sub16.2%
mul-1-neg16.2%
rec-exp16.2%
+-inverses16.4%
metadata-eval16.4%
Simplified16.4%
herbie shell --seed 2024167
(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))