
(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 15 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
(-
(* (exp (* (- eps 1.0) x)) (+ (/ 1.0 eps) 1.0))
(* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0)))))
(if (<= t_0 0.0) (* 0.5 (* (/ (+ x 1.0) (exp x)) 2.0)) (/ t_0 2.0))))
double code(double x, double eps) {
double t_0 = (exp(((eps - 1.0) * x)) * ((1.0 / eps) + 1.0)) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0));
double tmp;
if (t_0 <= 0.0) {
tmp = 0.5 * (((x + 1.0) / exp(x)) * 2.0);
} 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 = (exp(((eps - 1.0d0) * x)) * ((1.0d0 / eps) + 1.0d0)) - (exp((((-1.0d0) - eps) * x)) * ((1.0d0 / eps) - 1.0d0))
if (t_0 <= 0.0d0) then
tmp = 0.5d0 * (((x + 1.0d0) / exp(x)) * 2.0d0)
else
tmp = t_0 / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = (Math.exp(((eps - 1.0) * x)) * ((1.0 / eps) + 1.0)) - (Math.exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0));
double tmp;
if (t_0 <= 0.0) {
tmp = 0.5 * (((x + 1.0) / Math.exp(x)) * 2.0);
} else {
tmp = t_0 / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = (math.exp(((eps - 1.0) * x)) * ((1.0 / eps) + 1.0)) - (math.exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0)) tmp = 0 if t_0 <= 0.0: tmp = 0.5 * (((x + 1.0) / math.exp(x)) * 2.0) else: tmp = t_0 / 2.0 return tmp
function code(x, eps) t_0 = Float64(Float64(exp(Float64(Float64(eps - 1.0) * x)) * Float64(Float64(1.0 / eps) + 1.0)) - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * Float64(Float64(1.0 / eps) - 1.0))) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(0.5 * Float64(Float64(Float64(x + 1.0) / exp(x)) * 2.0)); else tmp = Float64(t_0 / 2.0); end return tmp end
function tmp_2 = code(x, eps) t_0 = (exp(((eps - 1.0) * x)) * ((1.0 / eps) + 1.0)) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0)); tmp = 0.0; if (t_0 <= 0.0) tmp = 0.5 * (((x + 1.0) / exp(x)) * 2.0); else tmp = t_0 / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[(N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(0.5 * N[(N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\left(\varepsilon - 1\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} + 1\right) - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right)\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;0.5 \cdot \left(\frac{x + 1}{e^{x}} \cdot 2\right)\\
\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))))) < 0.0Initial program 38.5%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
if 0.0 < (-.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
(let* ((t_0 (+ (/ 1.0 eps) 1.0)))
(if (<=
(-
(* (exp (* (- eps 1.0) x)) t_0)
(* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0)))
4.0)
(* 0.5 (* (/ (+ x 1.0) (exp x)) 2.0))
(/ (- t_0 (/ -1.0 (exp (fma eps x x)))) 2.0))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double tmp;
if (((exp(((eps - 1.0) * x)) * t_0) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 4.0) {
tmp = 0.5 * (((x + 1.0) / exp(x)) * 2.0);
} else {
tmp = (t_0 - (-1.0 / exp(fma(eps, x, x)))) / 2.0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) tmp = 0.0 if (Float64(Float64(exp(Float64(Float64(eps - 1.0) * x)) * t_0) - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * Float64(Float64(1.0 / eps) - 1.0))) <= 4.0) tmp = Float64(0.5 * Float64(Float64(Float64(x + 1.0) / exp(x)) * 2.0)); else tmp = Float64(Float64(t_0 - Float64(-1.0 / exp(fma(eps, x, x)))) / 2.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[N[(N[(N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] - N[(N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4.0], N[(0.5 * N[(N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - N[(-1.0 / N[Exp[N[(eps * x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
\mathbf{if}\;e^{\left(\varepsilon - 1\right) \cdot x} \cdot t\_0 - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right) \leq 4:\\
\;\;\;\;0.5 \cdot \left(\frac{x + 1}{e^{x}} \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - \frac{-1}{e^{\mathsf{fma}\left(\varepsilon, x, x\right)}}}{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 54.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.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%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6454.5
Applied rewrites54.5%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f6454.5
Applied rewrites54.5%
Final simplification79.2%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0)) (t_1 (- (/ 1.0 eps) 1.0)))
(if (<= eps 0.0056)
(* 0.5 (* (/ (+ x 1.0) (exp x)) 2.0))
(if (<= eps 6.8e+115)
(/ (- t_0 (* (exp (* (- -1.0 eps) x)) t_1)) 2.0)
(if (<= eps 1.75e+211)
(/ (- (* (exp (* (- eps 1.0) x)) t_0) t_1) 2.0)
(/ (- t_0 (/ -1.0 (exp (fma eps x x)))) 2.0))))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double t_1 = (1.0 / eps) - 1.0;
double tmp;
if (eps <= 0.0056) {
tmp = 0.5 * (((x + 1.0) / exp(x)) * 2.0);
} else if (eps <= 6.8e+115) {
tmp = (t_0 - (exp(((-1.0 - eps) * x)) * t_1)) / 2.0;
} else if (eps <= 1.75e+211) {
tmp = ((exp(((eps - 1.0) * x)) * t_0) - t_1) / 2.0;
} else {
tmp = (t_0 - (-1.0 / exp(fma(eps, x, x)))) / 2.0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) t_1 = Float64(Float64(1.0 / eps) - 1.0) tmp = 0.0 if (eps <= 0.0056) tmp = Float64(0.5 * Float64(Float64(Float64(x + 1.0) / exp(x)) * 2.0)); elseif (eps <= 6.8e+115) tmp = Float64(Float64(t_0 - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * t_1)) / 2.0); elseif (eps <= 1.75e+211) tmp = Float64(Float64(Float64(exp(Float64(Float64(eps - 1.0) * x)) * t_0) - t_1) / 2.0); else tmp = Float64(Float64(t_0 - Float64(-1.0 / exp(fma(eps, x, x)))) / 2.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]}, If[LessEqual[eps, 0.0056], N[(0.5 * N[(N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 6.8e+115], N[(N[(t$95$0 - N[(N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[eps, 1.75e+211], N[(N[(N[(N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] - t$95$1), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(t$95$0 - N[(-1.0 / N[Exp[N[(eps * x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
t_1 := \frac{1}{\varepsilon} - 1\\
\mathbf{if}\;\varepsilon \leq 0.0056:\\
\;\;\;\;0.5 \cdot \left(\frac{x + 1}{e^{x}} \cdot 2\right)\\
\mathbf{elif}\;\varepsilon \leq 6.8 \cdot 10^{+115}:\\
\;\;\;\;\frac{t\_0 - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot t\_1}{2}\\
\mathbf{elif}\;\varepsilon \leq 1.75 \cdot 10^{+211}:\\
\;\;\;\;\frac{e^{\left(\varepsilon - 1\right) \cdot x} \cdot t\_0 - t\_1}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - \frac{-1}{e^{\mathsf{fma}\left(\varepsilon, x, x\right)}}}{2}\\
\end{array}
\end{array}
if eps < 0.00559999999999999994Initial program 65.3%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites71.2%
if 0.00559999999999999994 < eps < 6.8000000000000001e115Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6468.6
Applied rewrites68.6%
if 6.8000000000000001e115 < eps < 1.74999999999999998e211Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6482.9
Applied rewrites82.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f6482.9
Applied rewrites82.9%
if 1.74999999999999998e211 < eps Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6467.4
Applied rewrites67.4%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f6467.4
Applied rewrites67.4%
Final simplification71.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0))
(t_1 (/ (- t_0 (/ -1.0 (exp (fma eps x x)))) 2.0)))
(if (<= eps 23000.0)
(* 0.5 (* (/ (+ x 1.0) (exp x)) 2.0))
(if (<= eps 6.8e+115)
t_1
(if (<= eps 1.75e+211)
(/ (- (* (exp (* (- eps 1.0) x)) t_0) (- (/ 1.0 eps) 1.0)) 2.0)
t_1)))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double t_1 = (t_0 - (-1.0 / exp(fma(eps, x, x)))) / 2.0;
double tmp;
if (eps <= 23000.0) {
tmp = 0.5 * (((x + 1.0) / exp(x)) * 2.0);
} else if (eps <= 6.8e+115) {
tmp = t_1;
} else if (eps <= 1.75e+211) {
tmp = ((exp(((eps - 1.0) * x)) * t_0) - ((1.0 / eps) - 1.0)) / 2.0;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) t_1 = Float64(Float64(t_0 - Float64(-1.0 / exp(fma(eps, x, x)))) / 2.0) tmp = 0.0 if (eps <= 23000.0) tmp = Float64(0.5 * Float64(Float64(Float64(x + 1.0) / exp(x)) * 2.0)); elseif (eps <= 6.8e+115) tmp = t_1; elseif (eps <= 1.75e+211) tmp = Float64(Float64(Float64(exp(Float64(Float64(eps - 1.0) * x)) * t_0) - Float64(Float64(1.0 / eps) - 1.0)) / 2.0); else tmp = t_1; end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 - N[(-1.0 / N[Exp[N[(eps * x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[eps, 23000.0], N[(0.5 * N[(N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 6.8e+115], t$95$1, If[LessEqual[eps, 1.75e+211], N[(N[(N[(N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] - N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
t_1 := \frac{t\_0 - \frac{-1}{e^{\mathsf{fma}\left(\varepsilon, x, x\right)}}}{2}\\
\mathbf{if}\;\varepsilon \leq 23000:\\
\;\;\;\;0.5 \cdot \left(\frac{x + 1}{e^{x}} \cdot 2\right)\\
\mathbf{elif}\;\varepsilon \leq 6.8 \cdot 10^{+115}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\varepsilon \leq 1.75 \cdot 10^{+211}:\\
\;\;\;\;\frac{e^{\left(\varepsilon - 1\right) \cdot x} \cdot t\_0 - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if eps < 23000Initial program 65.4%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites71.3%
if 23000 < eps < 6.8000000000000001e115 or 1.74999999999999998e211 < eps Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6467.5
Applied rewrites67.5%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f6466.6
Applied rewrites66.6%
if 6.8000000000000001e115 < eps < 1.74999999999999998e211Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6482.9
Applied rewrites82.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f6482.9
Applied rewrites82.9%
Final simplification71.1%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0)))
(if (<= x -1.0)
(/ (- t_0 (/ (fma (fma (- eps 1.0) x (- x 1.0)) eps (- 1.0 x)) eps)) 2.0)
(if (<= x -5e-258)
(fma (* 0.5 x) (fma (- eps 1.0) t_0 (/ (- 1.0 (* eps eps)) eps)) 1.0)
(if (<= x 2.7e+79)
(* 0.5 (* (/ (+ x 1.0) (exp x)) 2.0))
(/ (* (fma (fma 0.5 x -1.0) x 1.0) (fma x x -1.0)) (- x 1.0)))))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double tmp;
if (x <= -1.0) {
tmp = (t_0 - (fma(fma((eps - 1.0), x, (x - 1.0)), eps, (1.0 - x)) / eps)) / 2.0;
} else if (x <= -5e-258) {
tmp = fma((0.5 * x), fma((eps - 1.0), t_0, ((1.0 - (eps * eps)) / eps)), 1.0);
} else if (x <= 2.7e+79) {
tmp = 0.5 * (((x + 1.0) / exp(x)) * 2.0);
} else {
tmp = (fma(fma(0.5, x, -1.0), x, 1.0) * fma(x, x, -1.0)) / (x - 1.0);
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) tmp = 0.0 if (x <= -1.0) tmp = Float64(Float64(t_0 - Float64(fma(fma(Float64(eps - 1.0), x, Float64(x - 1.0)), eps, Float64(1.0 - x)) / eps)) / 2.0); elseif (x <= -5e-258) tmp = fma(Float64(0.5 * x), fma(Float64(eps - 1.0), t_0, Float64(Float64(1.0 - Float64(eps * eps)) / eps)), 1.0); elseif (x <= 2.7e+79) tmp = Float64(0.5 * Float64(Float64(Float64(x + 1.0) / exp(x)) * 2.0)); else tmp = Float64(Float64(fma(fma(0.5, x, -1.0), x, 1.0) * fma(x, x, -1.0)) / Float64(x - 1.0)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, -1.0], N[(N[(t$95$0 - N[(N[(N[(N[(eps - 1.0), $MachinePrecision] * x + N[(x - 1.0), $MachinePrecision]), $MachinePrecision] * eps + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, -5e-258], N[(N[(0.5 * x), $MachinePrecision] * N[(N[(eps - 1.0), $MachinePrecision] * t$95$0 + N[(N[(1.0 - N[(eps * eps), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[x, 2.7e+79], N[(0.5 * N[(N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(x * x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{t\_0 - \frac{\mathsf{fma}\left(\mathsf{fma}\left(\varepsilon - 1, x, x - 1\right), \varepsilon, 1 - x\right)}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-258}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \mathsf{fma}\left(\varepsilon - 1, t\_0, \frac{1 - \varepsilon \cdot \varepsilon}{\varepsilon}\right), 1\right)\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{+79}:\\
\;\;\;\;0.5 \cdot \left(\frac{x + 1}{e^{x}} \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right) \cdot \mathsf{fma}\left(x, x, -1\right)}{x - 1}\\
\end{array}
\end{array}
if x < -1Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6465.0
Applied rewrites65.0%
Taylor expanded in x around 0
associate--l+N/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-neg-inN/A
distribute-lft1-inN/A
lower-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
lower--.f64N/A
lower-/.f6425.0
Applied rewrites25.0%
Taylor expanded in eps around 0
Applied rewrites40.2%
if -1 < x < -4.9999999999999999e-258Initial program 53.1%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites66.7%
Taylor expanded in eps around 0
Applied rewrites76.7%
if -4.9999999999999999e-258 < x < 2.7e79Initial program 63.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites76.1%
if 2.7e79 < x Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites42.8%
Applied rewrites42.8%
Taylor expanded in x around 0
Applied rewrites51.2%
Applied rewrites58.7%
Final simplification67.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0)))
(if (<= x -1.0)
(/ (- t_0 (/ (fma (fma (- eps 1.0) x (- x 1.0)) eps (- 1.0 x)) eps)) 2.0)
(if (<= x -5e-258)
(fma (* 0.5 x) (fma (- eps 1.0) t_0 (/ (- 1.0 (* eps eps)) eps)) 1.0)
(if (<= x 2.7e+79)
(* (exp (- x)) (+ x 1.0))
(/ (* (fma (fma 0.5 x -1.0) x 1.0) (fma x x -1.0)) (- x 1.0)))))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double tmp;
if (x <= -1.0) {
tmp = (t_0 - (fma(fma((eps - 1.0), x, (x - 1.0)), eps, (1.0 - x)) / eps)) / 2.0;
} else if (x <= -5e-258) {
tmp = fma((0.5 * x), fma((eps - 1.0), t_0, ((1.0 - (eps * eps)) / eps)), 1.0);
} else if (x <= 2.7e+79) {
tmp = exp(-x) * (x + 1.0);
} else {
tmp = (fma(fma(0.5, x, -1.0), x, 1.0) * fma(x, x, -1.0)) / (x - 1.0);
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) tmp = 0.0 if (x <= -1.0) tmp = Float64(Float64(t_0 - Float64(fma(fma(Float64(eps - 1.0), x, Float64(x - 1.0)), eps, Float64(1.0 - x)) / eps)) / 2.0); elseif (x <= -5e-258) tmp = fma(Float64(0.5 * x), fma(Float64(eps - 1.0), t_0, Float64(Float64(1.0 - Float64(eps * eps)) / eps)), 1.0); elseif (x <= 2.7e+79) tmp = Float64(exp(Float64(-x)) * Float64(x + 1.0)); else tmp = Float64(Float64(fma(fma(0.5, x, -1.0), x, 1.0) * fma(x, x, -1.0)) / Float64(x - 1.0)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, -1.0], N[(N[(t$95$0 - N[(N[(N[(N[(eps - 1.0), $MachinePrecision] * x + N[(x - 1.0), $MachinePrecision]), $MachinePrecision] * eps + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, -5e-258], N[(N[(0.5 * x), $MachinePrecision] * N[(N[(eps - 1.0), $MachinePrecision] * t$95$0 + N[(N[(1.0 - N[(eps * eps), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[x, 2.7e+79], N[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(x * x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{t\_0 - \frac{\mathsf{fma}\left(\mathsf{fma}\left(\varepsilon - 1, x, x - 1\right), \varepsilon, 1 - x\right)}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-258}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \mathsf{fma}\left(\varepsilon - 1, t\_0, \frac{1 - \varepsilon \cdot \varepsilon}{\varepsilon}\right), 1\right)\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{+79}:\\
\;\;\;\;e^{-x} \cdot \left(x + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right) \cdot \mathsf{fma}\left(x, x, -1\right)}{x - 1}\\
\end{array}
\end{array}
if x < -1Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6465.0
Applied rewrites65.0%
Taylor expanded in x around 0
associate--l+N/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-neg-inN/A
distribute-lft1-inN/A
lower-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
lower--.f64N/A
lower-/.f6425.0
Applied rewrites25.0%
Taylor expanded in eps around 0
Applied rewrites40.2%
if -1 < x < -4.9999999999999999e-258Initial program 53.1%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites66.7%
Taylor expanded in eps around 0
Applied rewrites76.7%
if -4.9999999999999999e-258 < x < 2.7e79Initial program 63.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites76.1%
Applied rewrites76.1%
if 2.7e79 < x Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites42.8%
Applied rewrites42.8%
Taylor expanded in x around 0
Applied rewrites51.2%
Applied rewrites58.7%
Final simplification67.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0)))
(if (<= x -1.0)
(/ (- t_0 (/ (fma (fma (- eps 1.0) x (- x 1.0)) eps (- 1.0 x)) eps)) 2.0)
(if (<= x -5e-258)
(fma (* 0.5 x) (fma (- eps 1.0) t_0 (/ (- 1.0 (* eps eps)) eps)) 1.0)
(if (<= x 2.1)
(*
(*
(/
(+ x 1.0)
(fma (fma (fma 0.16666666666666666 x 0.5) x 1.0) x 1.0))
2.0)
0.5)
(if (<= x 2.25e+70)
(/
(-
(/ (fma (fma x eps 1.0) eps (- 1.0 x)) eps)
(* (fma (- -1.0 eps) x 1.0) (- (/ 1.0 eps) 1.0)))
2.0)
(/ (* (fma (fma 0.5 x -1.0) x 1.0) (fma x x -1.0)) (- x 1.0))))))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double tmp;
if (x <= -1.0) {
tmp = (t_0 - (fma(fma((eps - 1.0), x, (x - 1.0)), eps, (1.0 - x)) / eps)) / 2.0;
} else if (x <= -5e-258) {
tmp = fma((0.5 * x), fma((eps - 1.0), t_0, ((1.0 - (eps * eps)) / eps)), 1.0);
} else if (x <= 2.1) {
tmp = (((x + 1.0) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0)) * 2.0) * 0.5;
} else if (x <= 2.25e+70) {
tmp = ((fma(fma(x, eps, 1.0), eps, (1.0 - x)) / eps) - (fma((-1.0 - eps), x, 1.0) * ((1.0 / eps) - 1.0))) / 2.0;
} else {
tmp = (fma(fma(0.5, x, -1.0), x, 1.0) * fma(x, x, -1.0)) / (x - 1.0);
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) tmp = 0.0 if (x <= -1.0) tmp = Float64(Float64(t_0 - Float64(fma(fma(Float64(eps - 1.0), x, Float64(x - 1.0)), eps, Float64(1.0 - x)) / eps)) / 2.0); elseif (x <= -5e-258) tmp = fma(Float64(0.5 * x), fma(Float64(eps - 1.0), t_0, Float64(Float64(1.0 - Float64(eps * eps)) / eps)), 1.0); elseif (x <= 2.1) tmp = Float64(Float64(Float64(Float64(x + 1.0) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0)) * 2.0) * 0.5); elseif (x <= 2.25e+70) tmp = Float64(Float64(Float64(fma(fma(x, eps, 1.0), eps, Float64(1.0 - x)) / eps) - Float64(fma(Float64(-1.0 - eps), x, 1.0) * Float64(Float64(1.0 / eps) - 1.0))) / 2.0); else tmp = Float64(Float64(fma(fma(0.5, x, -1.0), x, 1.0) * fma(x, x, -1.0)) / Float64(x - 1.0)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, -1.0], N[(N[(t$95$0 - N[(N[(N[(N[(eps - 1.0), $MachinePrecision] * x + N[(x - 1.0), $MachinePrecision]), $MachinePrecision] * eps + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, -5e-258], N[(N[(0.5 * x), $MachinePrecision] * N[(N[(eps - 1.0), $MachinePrecision] * t$95$0 + N[(N[(1.0 - N[(eps * eps), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[x, 2.1], N[(N[(N[(N[(x + 1.0), $MachinePrecision] / N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 2.25e+70], N[(N[(N[(N[(N[(x * eps + 1.0), $MachinePrecision] * eps + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision] - N[(N[(N[(-1.0 - eps), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(x * x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{t\_0 - \frac{\mathsf{fma}\left(\mathsf{fma}\left(\varepsilon - 1, x, x - 1\right), \varepsilon, 1 - x\right)}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-258}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \mathsf{fma}\left(\varepsilon - 1, t\_0, \frac{1 - \varepsilon \cdot \varepsilon}{\varepsilon}\right), 1\right)\\
\mathbf{elif}\;x \leq 2.1:\\
\;\;\;\;\left(\frac{x + 1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right), x, 1\right)} \cdot 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 2.25 \cdot 10^{+70}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left(x, \varepsilon, 1\right), \varepsilon, 1 - x\right)}{\varepsilon} - \mathsf{fma}\left(-1 - \varepsilon, x, 1\right) \cdot \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right) \cdot \mathsf{fma}\left(x, x, -1\right)}{x - 1}\\
\end{array}
\end{array}
if x < -1Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6465.0
Applied rewrites65.0%
Taylor expanded in x around 0
associate--l+N/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-neg-inN/A
distribute-lft1-inN/A
lower-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
lower--.f64N/A
lower-/.f6425.0
Applied rewrites25.0%
Taylor expanded in eps around 0
Applied rewrites40.2%
if -1 < x < -4.9999999999999999e-258Initial program 53.1%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites66.7%
Taylor expanded in eps around 0
Applied rewrites76.7%
if -4.9999999999999999e-258 < x < 2.10000000000000009Initial program 51.6%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites84.8%
Taylor expanded in x around 0
Applied rewrites83.7%
if 2.10000000000000009 < x < 2.25e70Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6433.5
Applied rewrites33.5%
Taylor expanded in x around 0
associate--l+N/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-neg-inN/A
distribute-lft1-inN/A
lower-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
lower--.f64N/A
lower-/.f642.7
Applied rewrites2.7%
Taylor expanded in x around 0
+-commutativeN/A
associate-+r+N/A
*-commutativeN/A
associate-*r*N/A
sub-negN/A
metadata-evalN/A
distribute-rgt-outN/A
+-commutativeN/A
distribute-rgt-outN/A
metadata-evalN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
distribute-rgt-neg-inN/A
distribute-rgt1-inN/A
lower-*.f64N/A
Applied rewrites37.4%
Taylor expanded in eps around 0
Applied rewrites46.0%
if 2.25e70 < x Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites44.6%
Applied rewrites44.6%
Taylor expanded in x around 0
Applied rewrites49.7%
Applied rewrites56.9%
Final simplification65.9%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0)))
(if (<= x -1.0)
(/ (- t_0 (/ (fma (fma (- eps 1.0) x (- x 1.0)) eps (- 1.0 x)) eps)) 2.0)
(if (<= x -5e-258)
(fma (* 0.5 x) (fma (- eps 1.0) t_0 (/ (- 1.0 (* eps eps)) eps)) 1.0)
(if (<= x 980.0)
(*
(*
(/
(+ x 1.0)
(fma (fma (fma 0.16666666666666666 x 0.5) x 1.0) x 1.0))
2.0)
0.5)
(if (<= x 2.7e+79)
(/ (- t_0 (- (/ 1.0 eps) 1.0)) 2.0)
(/ (* (fma (fma 0.5 x -1.0) x 1.0) (fma x x -1.0)) (- x 1.0))))))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double tmp;
if (x <= -1.0) {
tmp = (t_0 - (fma(fma((eps - 1.0), x, (x - 1.0)), eps, (1.0 - x)) / eps)) / 2.0;
} else if (x <= -5e-258) {
tmp = fma((0.5 * x), fma((eps - 1.0), t_0, ((1.0 - (eps * eps)) / eps)), 1.0);
} else if (x <= 980.0) {
tmp = (((x + 1.0) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0)) * 2.0) * 0.5;
} else if (x <= 2.7e+79) {
tmp = (t_0 - ((1.0 / eps) - 1.0)) / 2.0;
} else {
tmp = (fma(fma(0.5, x, -1.0), x, 1.0) * fma(x, x, -1.0)) / (x - 1.0);
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) tmp = 0.0 if (x <= -1.0) tmp = Float64(Float64(t_0 - Float64(fma(fma(Float64(eps - 1.0), x, Float64(x - 1.0)), eps, Float64(1.0 - x)) / eps)) / 2.0); elseif (x <= -5e-258) tmp = fma(Float64(0.5 * x), fma(Float64(eps - 1.0), t_0, Float64(Float64(1.0 - Float64(eps * eps)) / eps)), 1.0); elseif (x <= 980.0) tmp = Float64(Float64(Float64(Float64(x + 1.0) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0)) * 2.0) * 0.5); elseif (x <= 2.7e+79) tmp = Float64(Float64(t_0 - Float64(Float64(1.0 / eps) - 1.0)) / 2.0); else tmp = Float64(Float64(fma(fma(0.5, x, -1.0), x, 1.0) * fma(x, x, -1.0)) / Float64(x - 1.0)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, -1.0], N[(N[(t$95$0 - N[(N[(N[(N[(eps - 1.0), $MachinePrecision] * x + N[(x - 1.0), $MachinePrecision]), $MachinePrecision] * eps + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, -5e-258], N[(N[(0.5 * x), $MachinePrecision] * N[(N[(eps - 1.0), $MachinePrecision] * t$95$0 + N[(N[(1.0 - N[(eps * eps), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[x, 980.0], N[(N[(N[(N[(x + 1.0), $MachinePrecision] / N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 2.7e+79], N[(N[(t$95$0 - N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(x * x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{t\_0 - \frac{\mathsf{fma}\left(\mathsf{fma}\left(\varepsilon - 1, x, x - 1\right), \varepsilon, 1 - x\right)}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-258}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \mathsf{fma}\left(\varepsilon - 1, t\_0, \frac{1 - \varepsilon \cdot \varepsilon}{\varepsilon}\right), 1\right)\\
\mathbf{elif}\;x \leq 980:\\
\;\;\;\;\left(\frac{x + 1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right), x, 1\right)} \cdot 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{+79}:\\
\;\;\;\;\frac{t\_0 - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right) \cdot \mathsf{fma}\left(x, x, -1\right)}{x - 1}\\
\end{array}
\end{array}
if x < -1Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6465.0
Applied rewrites65.0%
Taylor expanded in x around 0
associate--l+N/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-neg-inN/A
distribute-lft1-inN/A
lower-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
lower--.f64N/A
lower-/.f6425.0
Applied rewrites25.0%
Taylor expanded in eps around 0
Applied rewrites40.2%
if -1 < x < -4.9999999999999999e-258Initial program 53.1%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites66.7%
Taylor expanded in eps around 0
Applied rewrites76.7%
if -4.9999999999999999e-258 < x < 980Initial program 52.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites83.8%
Taylor expanded in x around 0
Applied rewrites81.4%
if 980 < x < 2.7e79Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6433.4
Applied rewrites33.4%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6447.2
Applied rewrites47.2%
if 2.7e79 < x Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites42.8%
Applied rewrites42.8%
Taylor expanded in x around 0
Applied rewrites51.2%
Applied rewrites58.7%
Final simplification66.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0)))
(if (<= x -5e-258)
(fma (* 0.5 x) (fma (- eps 1.0) t_0 (/ (- 1.0 (* eps eps)) eps)) 1.0)
(if (<= x 980.0)
(*
(*
(/ (+ x 1.0) (fma (fma (fma 0.16666666666666666 x 0.5) x 1.0) x 1.0))
2.0)
0.5)
(if (<= x 2.7e+79)
(/ (- t_0 (- (/ 1.0 eps) 1.0)) 2.0)
(/ (* (fma (fma 0.5 x -1.0) x 1.0) (fma x x -1.0)) (- x 1.0)))))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double tmp;
if (x <= -5e-258) {
tmp = fma((0.5 * x), fma((eps - 1.0), t_0, ((1.0 - (eps * eps)) / eps)), 1.0);
} else if (x <= 980.0) {
tmp = (((x + 1.0) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0)) * 2.0) * 0.5;
} else if (x <= 2.7e+79) {
tmp = (t_0 - ((1.0 / eps) - 1.0)) / 2.0;
} else {
tmp = (fma(fma(0.5, x, -1.0), x, 1.0) * fma(x, x, -1.0)) / (x - 1.0);
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) tmp = 0.0 if (x <= -5e-258) tmp = fma(Float64(0.5 * x), fma(Float64(eps - 1.0), t_0, Float64(Float64(1.0 - Float64(eps * eps)) / eps)), 1.0); elseif (x <= 980.0) tmp = Float64(Float64(Float64(Float64(x + 1.0) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0)) * 2.0) * 0.5); elseif (x <= 2.7e+79) tmp = Float64(Float64(t_0 - Float64(Float64(1.0 / eps) - 1.0)) / 2.0); else tmp = Float64(Float64(fma(fma(0.5, x, -1.0), x, 1.0) * fma(x, x, -1.0)) / Float64(x - 1.0)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, -5e-258], N[(N[(0.5 * x), $MachinePrecision] * N[(N[(eps - 1.0), $MachinePrecision] * t$95$0 + N[(N[(1.0 - N[(eps * eps), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[x, 980.0], N[(N[(N[(N[(x + 1.0), $MachinePrecision] / N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 2.7e+79], N[(N[(t$95$0 - N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(x * x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
\mathbf{if}\;x \leq -5 \cdot 10^{-258}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \mathsf{fma}\left(\varepsilon - 1, t\_0, \frac{1 - \varepsilon \cdot \varepsilon}{\varepsilon}\right), 1\right)\\
\mathbf{elif}\;x \leq 980:\\
\;\;\;\;\left(\frac{x + 1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right), x, 1\right)} \cdot 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{+79}:\\
\;\;\;\;\frac{t\_0 - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right) \cdot \mathsf{fma}\left(x, x, -1\right)}{x - 1}\\
\end{array}
\end{array}
if x < -4.9999999999999999e-258Initial program 70.0%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites43.9%
Taylor expanded in eps around 0
Applied rewrites57.8%
if -4.9999999999999999e-258 < x < 980Initial program 52.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites83.8%
Taylor expanded in x around 0
Applied rewrites81.4%
if 980 < x < 2.7e79Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6433.4
Applied rewrites33.4%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6447.2
Applied rewrites47.2%
if 2.7e79 < x Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites42.8%
Applied rewrites42.8%
Taylor expanded in x around 0
Applied rewrites51.2%
Applied rewrites58.7%
Final simplification63.7%
(FPCore (x eps)
:precision binary64
(if (<= eps 115000000000.0)
(*
(*
(/ (+ x 1.0) (fma (fma (fma 0.16666666666666666 x 0.5) x 1.0) x 1.0))
2.0)
0.5)
(/ (* (fma (fma 0.5 x -1.0) x 1.0) (fma x x -1.0)) (- x 1.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 115000000000.0) {
tmp = (((x + 1.0) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0)) * 2.0) * 0.5;
} else {
tmp = (fma(fma(0.5, x, -1.0), x, 1.0) * fma(x, x, -1.0)) / (x - 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 115000000000.0) tmp = Float64(Float64(Float64(Float64(x + 1.0) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0)) * 2.0) * 0.5); else tmp = Float64(Float64(fma(fma(0.5, x, -1.0), x, 1.0) * fma(x, x, -1.0)) / Float64(x - 1.0)); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 115000000000.0], N[(N[(N[(N[(x + 1.0), $MachinePrecision] / N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(x * x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 115000000000:\\
\;\;\;\;\left(\frac{x + 1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right), x, 1\right)} \cdot 2\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right) \cdot \mathsf{fma}\left(x, x, -1\right)}{x - 1}\\
\end{array}
\end{array}
if eps < 1.15e11Initial program 66.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.7%
Taylor expanded in x around 0
Applied rewrites63.9%
if 1.15e11 < eps Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites11.5%
Applied rewrites11.5%
Taylor expanded in x around 0
Applied rewrites39.6%
Applied rewrites45.0%
Final simplification58.9%
(FPCore (x eps) :precision binary64 (if (<= eps 2400000.0) (/ (+ x 1.0) (fma (fma 0.5 x 1.0) x 1.0)) (/ (* (fma (fma 0.5 x -1.0) x 1.0) (fma x x -1.0)) (- x 1.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 2400000.0) {
tmp = (x + 1.0) / fma(fma(0.5, x, 1.0), x, 1.0);
} else {
tmp = (fma(fma(0.5, x, -1.0), x, 1.0) * fma(x, x, -1.0)) / (x - 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 2400000.0) tmp = Float64(Float64(x + 1.0) / fma(fma(0.5, x, 1.0), x, 1.0)); else tmp = Float64(Float64(fma(fma(0.5, x, -1.0), x, 1.0) * fma(x, x, -1.0)) / Float64(x - 1.0)); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 2400000.0], N[(N[(x + 1.0), $MachinePrecision] / N[(N[(0.5 * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(x * x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 2400000:\\
\;\;\;\;\frac{x + 1}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, 1\right), x, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right) \cdot \mathsf{fma}\left(x, x, -1\right)}{x - 1}\\
\end{array}
\end{array}
if eps < 2.4e6Initial program 65.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites71.1%
Taylor expanded in x around 0
Applied rewrites62.5%
Applied rewrites62.5%
if 2.4e6 < eps Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites11.3%
Applied rewrites11.3%
Taylor expanded in x around 0
Applied rewrites39.0%
Applied rewrites44.4%
Final simplification57.6%
(FPCore (x eps) :precision binary64 (if (<= eps 2400000.0) (/ (+ x 1.0) (fma (fma 0.5 x 1.0) x 1.0)) (* (+ x 1.0) (fma (fma 0.5 x -1.0) x 1.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 2400000.0) {
tmp = (x + 1.0) / fma(fma(0.5, x, 1.0), x, 1.0);
} else {
tmp = (x + 1.0) * fma(fma(0.5, x, -1.0), x, 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 2400000.0) tmp = Float64(Float64(x + 1.0) / fma(fma(0.5, x, 1.0), x, 1.0)); else tmp = Float64(Float64(x + 1.0) * fma(fma(0.5, x, -1.0), x, 1.0)); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 2400000.0], N[(N[(x + 1.0), $MachinePrecision] / N[(N[(0.5 * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x + 1.0), $MachinePrecision] * N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 2400000:\\
\;\;\;\;\frac{x + 1}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, 1\right), x, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(x + 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right)\\
\end{array}
\end{array}
if eps < 2.4e6Initial program 65.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites71.1%
Taylor expanded in x around 0
Applied rewrites62.5%
Applied rewrites62.5%
if 2.4e6 < eps Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites11.3%
Applied rewrites11.3%
Taylor expanded in x around 0
Applied rewrites39.0%
(FPCore (x eps) :precision binary64 (fma (* (fma 0.3333333333333333 x -0.5) x) x 1.0))
double code(double x, double eps) {
return fma((fma(0.3333333333333333, x, -0.5) * x), x, 1.0);
}
function code(x, eps) return fma(Float64(fma(0.3333333333333333, x, -0.5) * x), x, 1.0) end
code[x_, eps_] := N[(N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * x), $MachinePrecision] * x + 1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right) \cdot x, x, 1\right)
\end{array}
Initial program 75.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites55.0%
Taylor expanded in x around 0
Applied rewrites52.3%
Applied rewrites52.3%
(FPCore (x eps) :precision binary64 (fma (* 0.3333333333333333 x) (* x x) 1.0))
double code(double x, double eps) {
return fma((0.3333333333333333 * x), (x * x), 1.0);
}
function code(x, eps) return fma(Float64(0.3333333333333333 * x), Float64(x * x), 1.0) end
code[x_, eps_] := N[(N[(0.3333333333333333 * x), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(0.3333333333333333 \cdot x, x \cdot x, 1\right)
\end{array}
Initial program 75.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites55.0%
Taylor expanded in x around 0
Applied rewrites52.3%
Taylor expanded in x around inf
Applied rewrites52.0%
(FPCore (x eps) :precision binary64 1.0)
double code(double x, double eps) {
return 1.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 1.0d0
end function
public static double code(double x, double eps) {
return 1.0;
}
def code(x, eps): return 1.0
function code(x, eps) return 1.0 end
function tmp = code(x, eps) tmp = 1.0; end
code[x_, eps_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 75.0%
Taylor expanded in x around 0
Applied rewrites40.8%
herbie shell --seed 2024304
(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))