
(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 (* (+ -1.0 eps) x)) (+ (/ 1.0 eps) 1.0))
(* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0)))))
(if (<= t_0 0.0) (* (exp (- x)) (+ x 1.0)) (/ t_0 2.0))))
double code(double x, double eps) {
double t_0 = (exp(((-1.0 + eps) * x)) * ((1.0 / eps) + 1.0)) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0));
double tmp;
if (t_0 <= 0.0) {
tmp = exp(-x) * (x + 1.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((((-1.0d0) + eps) * x)) * ((1.0d0 / eps) + 1.0d0)) - (exp((((-1.0d0) - eps) * x)) * ((1.0d0 / eps) - 1.0d0))
if (t_0 <= 0.0d0) then
tmp = exp(-x) * (x + 1.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(((-1.0 + eps) * 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 = Math.exp(-x) * (x + 1.0);
} else {
tmp = t_0 / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = (math.exp(((-1.0 + eps) * 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 = math.exp(-x) * (x + 1.0) else: tmp = t_0 / 2.0 return tmp
function code(x, eps) t_0 = Float64(Float64(exp(Float64(Float64(-1.0 + eps) * 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(exp(Float64(-x)) * Float64(x + 1.0)); else tmp = Float64(t_0 / 2.0); end return tmp end
function tmp_2 = code(x, eps) t_0 = (exp(((-1.0 + eps) * 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 = exp(-x) * (x + 1.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[(-1.0 + eps), $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[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\left(-1 + \varepsilon\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:\\
\;\;\;\;e^{-x} \cdot \left(x + 1\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 33.3%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
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 (* (+ -1.0 eps) x)) t_0)
(* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0)))
4.0)
(* (exp (- x)) (+ x 1.0))
(/ (- (* (exp (* x eps)) 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(((-1.0 + eps) * x)) * t_0) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 4.0) {
tmp = exp(-x) * (x + 1.0);
} else {
tmp = ((exp((x * eps)) * 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(-1.0 + eps) * x)) * t_0) - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * Float64(Float64(1.0 / eps) - 1.0))) <= 4.0) tmp = Float64(exp(Float64(-x)) * Float64(x + 1.0)); else tmp = Float64(Float64(Float64(exp(Float64(x * eps)) * 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[(-1.0 + eps), $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[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] - 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(-1 + \varepsilon\right) \cdot x} \cdot t\_0 - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right) \leq 4:\\
\;\;\;\;e^{-x} \cdot \left(x + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \varepsilon} \cdot 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 51.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
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 eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
*-commutativeN/A
+-commutativeN/A
distribute-lft1-inN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around inf
lower-*.f64100.0
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0
(/
(- (* (exp (* x eps)) (+ (/ 1.0 eps) 1.0)) (- (/ 1.0 eps) 1.0))
2.0)))
(if (<= x -1e-252)
(/ (- 1.0 (/ -1.0 (exp (fma eps x x)))) 2.0)
(if (<= x 370.0)
(/
(- (* 1.0 (exp (* (+ -1.0 eps) x))) (/ -1.0 (fma (- eps -1.0) x 1.0)))
2.0)
(if (<= x 1.3e+166)
t_0
(if (<= x 1.2e+267)
(* (* (/ (+ x 1.0) (fma (fma x 0.5 1.0) x 1.0)) 2.0) 0.5)
t_0))))))
double code(double x, double eps) {
double t_0 = ((exp((x * eps)) * ((1.0 / eps) + 1.0)) - ((1.0 / eps) - 1.0)) / 2.0;
double tmp;
if (x <= -1e-252) {
tmp = (1.0 - (-1.0 / exp(fma(eps, x, x)))) / 2.0;
} else if (x <= 370.0) {
tmp = ((1.0 * exp(((-1.0 + eps) * x))) - (-1.0 / fma((eps - -1.0), x, 1.0))) / 2.0;
} else if (x <= 1.3e+166) {
tmp = t_0;
} else if (x <= 1.2e+267) {
tmp = (((x + 1.0) / fma(fma(x, 0.5, 1.0), x, 1.0)) * 2.0) * 0.5;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(Float64(exp(Float64(x * eps)) * Float64(Float64(1.0 / eps) + 1.0)) - Float64(Float64(1.0 / eps) - 1.0)) / 2.0) tmp = 0.0 if (x <= -1e-252) tmp = Float64(Float64(1.0 - Float64(-1.0 / exp(fma(eps, x, x)))) / 2.0); elseif (x <= 370.0) tmp = Float64(Float64(Float64(1.0 * exp(Float64(Float64(-1.0 + eps) * x))) - Float64(-1.0 / fma(Float64(eps - -1.0), x, 1.0))) / 2.0); elseif (x <= 1.3e+166) tmp = t_0; elseif (x <= 1.2e+267) tmp = Float64(Float64(Float64(Float64(x + 1.0) / fma(fma(x, 0.5, 1.0), x, 1.0)) * 2.0) * 0.5); else tmp = t_0; end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[x, -1e-252], N[(N[(1.0 - N[(-1.0 / N[Exp[N[(eps * x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 370.0], N[(N[(N[(1.0 * N[Exp[N[(N[(-1.0 + eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(-1.0 / N[(N[(eps - -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.3e+166], t$95$0, If[LessEqual[x, 1.2e+267], N[(N[(N[(N[(x + 1.0), $MachinePrecision] / N[(N[(x * 0.5 + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision] * 0.5), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{e^{x \cdot \varepsilon} \cdot \left(\frac{1}{\varepsilon} + 1\right) - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\mathbf{if}\;x \leq -1 \cdot 10^{-252}:\\
\;\;\;\;\frac{1 - \frac{-1}{e^{\mathsf{fma}\left(\varepsilon, x, x\right)}}}{2}\\
\mathbf{elif}\;x \leq 370:\\
\;\;\;\;\frac{1 \cdot e^{\left(-1 + \varepsilon\right) \cdot x} - \frac{-1}{\mathsf{fma}\left(\varepsilon - -1, x, 1\right)}}{2}\\
\mathbf{elif}\;x \leq 1.3 \cdot 10^{+166}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{+267}:\\
\;\;\;\;\left(\frac{x + 1}{\mathsf{fma}\left(\mathsf{fma}\left(x, 0.5, 1\right), x, 1\right)} \cdot 2\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -9.99999999999999943e-253Initial program 68.4%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6453.1
Applied rewrites53.1%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
*-commutativeN/A
+-commutativeN/A
distribute-lft1-inN/A
lower-fma.f6450.8
Applied rewrites50.8%
Taylor expanded in eps around inf
Applied rewrites82.4%
if -9.99999999999999943e-253 < x < 370Initial program 50.4%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
*-commutativeN/A
+-commutativeN/A
distribute-lft1-inN/A
lower-fma.f6443.8
Applied rewrites43.8%
Taylor expanded in x around 0
Applied rewrites40.4%
Taylor expanded in eps around inf
Applied rewrites95.3%
if 370 < x < 1.3e166 or 1.19999999999999992e267 < x Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6434.5
Applied rewrites34.5%
Taylor expanded in eps around inf
lower-*.f6461.2
Applied rewrites61.2%
if 1.3e166 < x < 1.19999999999999992e267Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.5%
Taylor expanded in x around 0
Applied rewrites70.5%
Final simplification81.2%
(FPCore (x eps)
:precision binary64
(if (<= x -1e-252)
(/ (- 1.0 (/ -1.0 (exp (fma eps x x)))) 2.0)
(if (<= x 1.75e+129)
(/
(- (* 1.0 (exp (* (+ -1.0 eps) x))) (/ -1.0 (fma (- eps -1.0) x 1.0)))
2.0)
(if (<= x 1e+270)
(* 1.0 (exp (- x)))
(fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -1e-252) {
tmp = (1.0 - (-1.0 / exp(fma(eps, x, x)))) / 2.0;
} else if (x <= 1.75e+129) {
tmp = ((1.0 * exp(((-1.0 + eps) * x))) - (-1.0 / fma((eps - -1.0), x, 1.0))) / 2.0;
} else if (x <= 1e+270) {
tmp = 1.0 * exp(-x);
} else {
tmp = fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -1e-252) tmp = Float64(Float64(1.0 - Float64(-1.0 / exp(fma(eps, x, x)))) / 2.0); elseif (x <= 1.75e+129) tmp = Float64(Float64(Float64(1.0 * exp(Float64(Float64(-1.0 + eps) * x))) - Float64(-1.0 / fma(Float64(eps - -1.0), x, 1.0))) / 2.0); elseif (x <= 1e+270) tmp = Float64(1.0 * exp(Float64(-x))); else tmp = fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -1e-252], N[(N[(1.0 - N[(-1.0 / N[Exp[N[(eps * x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.75e+129], N[(N[(N[(1.0 * N[Exp[N[(N[(-1.0 + eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(-1.0 / N[(N[(eps - -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1e+270], N[(1.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision], N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-252}:\\
\;\;\;\;\frac{1 - \frac{-1}{e^{\mathsf{fma}\left(\varepsilon, x, x\right)}}}{2}\\
\mathbf{elif}\;x \leq 1.75 \cdot 10^{+129}:\\
\;\;\;\;\frac{1 \cdot e^{\left(-1 + \varepsilon\right) \cdot x} - \frac{-1}{\mathsf{fma}\left(\varepsilon - -1, x, 1\right)}}{2}\\
\mathbf{elif}\;x \leq 10^{+270}:\\
\;\;\;\;1 \cdot e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)\\
\end{array}
\end{array}
if x < -9.99999999999999943e-253Initial program 68.4%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6453.1
Applied rewrites53.1%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
*-commutativeN/A
+-commutativeN/A
distribute-lft1-inN/A
lower-fma.f6450.8
Applied rewrites50.8%
Taylor expanded in eps around inf
Applied rewrites82.4%
if -9.99999999999999943e-253 < x < 1.7499999999999999e129Initial program 64.1%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
*-commutativeN/A
+-commutativeN/A
distribute-lft1-inN/A
lower-fma.f6459.4
Applied rewrites59.4%
Taylor expanded in x around 0
Applied rewrites38.9%
Taylor expanded in eps around inf
Applied rewrites78.6%
if 1.7499999999999999e129 < x < 1e270Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites67.2%
Applied rewrites67.2%
Taylor expanded in x around 0
Applied rewrites67.2%
if 1e270 < x Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites1.6%
Taylor expanded in x around 0
Applied rewrites100.0%
Final simplification79.3%
(FPCore (x eps)
:precision binary64
(if (<= x -1e-252)
(/ (- 1.0 (/ -1.0 (exp (fma eps x x)))) 2.0)
(if (<= x 1e+270)
(* (exp (- x)) (+ x 1.0))
(fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0))))
double code(double x, double eps) {
double tmp;
if (x <= -1e-252) {
tmp = (1.0 - (-1.0 / exp(fma(eps, x, x)))) / 2.0;
} else if (x <= 1e+270) {
tmp = exp(-x) * (x + 1.0);
} else {
tmp = fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -1e-252) tmp = Float64(Float64(1.0 - Float64(-1.0 / exp(fma(eps, x, x)))) / 2.0); elseif (x <= 1e+270) tmp = Float64(exp(Float64(-x)) * Float64(x + 1.0)); else tmp = fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -1e-252], N[(N[(1.0 - N[(-1.0 / N[Exp[N[(eps * x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1e+270], N[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-252}:\\
\;\;\;\;\frac{1 - \frac{-1}{e^{\mathsf{fma}\left(\varepsilon, x, x\right)}}}{2}\\
\mathbf{elif}\;x \leq 10^{+270}:\\
\;\;\;\;e^{-x} \cdot \left(x + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)\\
\end{array}
\end{array}
if x < -9.99999999999999943e-253Initial program 68.4%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6453.1
Applied rewrites53.1%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
*-commutativeN/A
+-commutativeN/A
distribute-lft1-inN/A
lower-fma.f6450.8
Applied rewrites50.8%
Taylor expanded in eps around inf
Applied rewrites82.4%
if -9.99999999999999943e-253 < x < 1e270Initial program 71.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites69.8%
Applied rewrites69.9%
if 1e270 < x Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites1.6%
Taylor expanded in x around 0
Applied rewrites100.0%
Final simplification75.6%
(FPCore (x eps)
:precision binary64
(if (<= eps 0.031)
(* (exp (- x)) (+ x 1.0))
(if (<= eps 1.8e+258)
(* (fma (fma x 0.5 -1.0) x 1.0) 1.0)
(/
(-
(+ (/ 1.0 eps) 1.0)
(/ (fma (fma eps x (- (- x 1.0) x)) eps (- 1.0 x)) eps))
2.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 0.031) {
tmp = exp(-x) * (x + 1.0);
} else if (eps <= 1.8e+258) {
tmp = fma(fma(x, 0.5, -1.0), x, 1.0) * 1.0;
} else {
tmp = (((1.0 / eps) + 1.0) - (fma(fma(eps, x, ((x - 1.0) - x)), eps, (1.0 - x)) / eps)) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 0.031) tmp = Float64(exp(Float64(-x)) * Float64(x + 1.0)); elseif (eps <= 1.8e+258) tmp = Float64(fma(fma(x, 0.5, -1.0), x, 1.0) * 1.0); else tmp = Float64(Float64(Float64(Float64(1.0 / eps) + 1.0) - Float64(fma(fma(eps, x, Float64(Float64(x - 1.0) - x)), eps, Float64(1.0 - x)) / eps)) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 0.031], N[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 1.8e+258], N[(N[(N[(x * 0.5 + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] - N[(N[(N[(eps * x + N[(N[(x - 1.0), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision] * eps + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 0.031:\\
\;\;\;\;e^{-x} \cdot \left(x + 1\right)\\
\mathbf{elif}\;\varepsilon \leq 1.8 \cdot 10^{+258}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x, 0.5, -1\right), x, 1\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{1}{\varepsilon} + 1\right) - \frac{\mathsf{fma}\left(\mathsf{fma}\left(\varepsilon, x, \left(x - 1\right) - x\right), \varepsilon, 1 - x\right)}{\varepsilon}}{2}\\
\end{array}
\end{array}
if eps < 0.031Initial program 55.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites78.7%
Applied rewrites78.7%
if 0.031 < eps < 1.8e258Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites30.8%
Applied rewrites30.8%
Taylor expanded in x around 0
Applied rewrites62.3%
Taylor expanded in x around 0
Applied rewrites63.3%
if 1.8e258 < eps Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6448.2
Applied rewrites48.2%
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
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-fma.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
lower--.f64N/A
lower-/.f6433.1
Applied rewrites33.1%
Taylor expanded in eps around 0
Applied rewrites42.0%
Final simplification71.5%
(FPCore (x eps)
:precision binary64
(if (<= eps 2.15e+92)
(* 1.0 (exp (- x)))
(if (<= eps 4.3e+188)
(* (fma (fma x 0.5 -1.0) x 1.0) (+ x 1.0))
(/
(-
(+ (/ 1.0 eps) 1.0)
(/ (fma (fma eps x (- (- x 1.0) x)) eps (- 1.0 x)) eps))
2.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 2.15e+92) {
tmp = 1.0 * exp(-x);
} else if (eps <= 4.3e+188) {
tmp = fma(fma(x, 0.5, -1.0), x, 1.0) * (x + 1.0);
} else {
tmp = (((1.0 / eps) + 1.0) - (fma(fma(eps, x, ((x - 1.0) - x)), eps, (1.0 - x)) / eps)) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 2.15e+92) tmp = Float64(1.0 * exp(Float64(-x))); elseif (eps <= 4.3e+188) tmp = Float64(fma(fma(x, 0.5, -1.0), x, 1.0) * Float64(x + 1.0)); else tmp = Float64(Float64(Float64(Float64(1.0 / eps) + 1.0) - Float64(fma(fma(eps, x, Float64(Float64(x - 1.0) - x)), eps, Float64(1.0 - x)) / eps)) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 2.15e+92], N[(1.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 4.3e+188], N[(N[(N[(x * 0.5 + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] - N[(N[(N[(eps * x + N[(N[(x - 1.0), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision] * eps + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 2.15 \cdot 10^{+92}:\\
\;\;\;\;1 \cdot e^{-x}\\
\mathbf{elif}\;\varepsilon \leq 4.3 \cdot 10^{+188}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x, 0.5, -1\right), x, 1\right) \cdot \left(x + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{1}{\varepsilon} + 1\right) - \frac{\mathsf{fma}\left(\mathsf{fma}\left(\varepsilon, x, \left(x - 1\right) - x\right), \varepsilon, 1 - x\right)}{\varepsilon}}{2}\\
\end{array}
\end{array}
if eps < 2.1499999999999999e92Initial program 62.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites71.9%
Applied rewrites71.9%
Taylor expanded in x around 0
Applied rewrites79.0%
if 2.1499999999999999e92 < eps < 4.29999999999999985e188Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites32.8%
Applied rewrites32.8%
Taylor expanded in x around 0
Applied rewrites60.7%
if 4.29999999999999985e188 < eps Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6459.7
Applied rewrites59.7%
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
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-fma.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
lower--.f64N/A
lower-/.f6446.2
Applied rewrites46.2%
Taylor expanded in eps around 0
Applied rewrites51.0%
Final simplification73.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0)))
(if (<= x -0.135)
(/ (- t_0 (/ (fma (fma eps x (- (- x 1.0) x)) eps (- 1.0 x)) eps)) 2.0)
(if (<= x 1.8)
(fma (fma (fma -0.125 x 0.3333333333333333) x -0.5) (* x x) 1.0)
(if (<= x 4.4e+271)
(/ (- t_0 (- (/ 1.0 eps) 1.0)) 2.0)
(fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0))))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double tmp;
if (x <= -0.135) {
tmp = (t_0 - (fma(fma(eps, x, ((x - 1.0) - x)), eps, (1.0 - x)) / eps)) / 2.0;
} else if (x <= 1.8) {
tmp = fma(fma(fma(-0.125, x, 0.3333333333333333), x, -0.5), (x * x), 1.0);
} else if (x <= 4.4e+271) {
tmp = (t_0 - ((1.0 / eps) - 1.0)) / 2.0;
} else {
tmp = fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) tmp = 0.0 if (x <= -0.135) tmp = Float64(Float64(t_0 - Float64(fma(fma(eps, x, Float64(Float64(x - 1.0) - x)), eps, Float64(1.0 - x)) / eps)) / 2.0); elseif (x <= 1.8) tmp = fma(fma(fma(-0.125, x, 0.3333333333333333), x, -0.5), Float64(x * x), 1.0); elseif (x <= 4.4e+271) tmp = Float64(Float64(t_0 - Float64(Float64(1.0 / eps) - 1.0)) / 2.0); else tmp = fma(fma(0.3333333333333333, x, -0.5), Float64(x * 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, -0.135], N[(N[(t$95$0 - N[(N[(N[(eps * x + N[(N[(x - 1.0), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision] * eps + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.8], N[(N[(N[(-0.125 * x + 0.3333333333333333), $MachinePrecision] * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[x, 4.4e+271], N[(N[(t$95$0 - N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
\mathbf{if}\;x \leq -0.135:\\
\;\;\;\;\frac{t\_0 - \frac{\mathsf{fma}\left(\mathsf{fma}\left(\varepsilon, x, \left(x - 1\right) - x\right), \varepsilon, 1 - x\right)}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq 1.8:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.125, x, 0.3333333333333333\right), x, -0.5\right), x \cdot x, 1\right)\\
\mathbf{elif}\;x \leq 4.4 \cdot 10^{+271}:\\
\;\;\;\;\frac{t\_0 - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)\\
\end{array}
\end{array}
if x < -0.13500000000000001Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6480.6
Applied rewrites80.6%
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
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-fma.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
lower--.f64N/A
lower-/.f6450.5
Applied rewrites50.5%
Taylor expanded in eps around 0
Applied rewrites66.4%
if -0.13500000000000001 < x < 1.80000000000000004Initial program 50.2%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites80.9%
Taylor expanded in x around 0
Applied rewrites80.6%
if 1.80000000000000004 < x < 4.40000000000000002e271Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6432.0
Applied rewrites32.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6450.1
Applied rewrites50.1%
if 4.40000000000000002e271 < x Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites1.6%
Taylor expanded in x around 0
Applied rewrites100.0%
(FPCore (x eps)
:precision binary64
(if (<= x 1.6)
(* (fma (fma (fma -0.16666666666666666 x 0.5) x -1.0) x 1.0) 1.0)
(if (<= x 4.4e+271)
(/ (- (+ (/ 1.0 eps) 1.0) (- (/ 1.0 eps) 1.0)) 2.0)
(fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0))))
double code(double x, double eps) {
double tmp;
if (x <= 1.6) {
tmp = fma(fma(fma(-0.16666666666666666, x, 0.5), x, -1.0), x, 1.0) * 1.0;
} else if (x <= 4.4e+271) {
tmp = (((1.0 / eps) + 1.0) - ((1.0 / eps) - 1.0)) / 2.0;
} else {
tmp = fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 1.6) tmp = Float64(fma(fma(fma(-0.16666666666666666, x, 0.5), x, -1.0), x, 1.0) * 1.0); elseif (x <= 4.4e+271) tmp = Float64(Float64(Float64(Float64(1.0 / eps) + 1.0) - Float64(Float64(1.0 / eps) - 1.0)) / 2.0); else tmp = fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, 1.6], N[(N[(N[(N[(-0.16666666666666666 * x + 0.5), $MachinePrecision] * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[x, 4.4e+271], N[(N[(N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] - N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.6:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, x, 0.5\right), x, -1\right), x, 1\right) \cdot 1\\
\mathbf{elif}\;x \leq 4.4 \cdot 10^{+271}:\\
\;\;\;\;\frac{\left(\frac{1}{\varepsilon} + 1\right) - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)\\
\end{array}
\end{array}
if x < 1.6000000000000001Initial program 59.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites65.2%
Applied rewrites65.2%
Taylor expanded in x around 0
Applied rewrites82.8%
Taylor expanded in x around 0
Applied rewrites77.0%
if 1.6000000000000001 < x < 4.40000000000000002e271Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6432.0
Applied rewrites32.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6450.1
Applied rewrites50.1%
if 4.40000000000000002e271 < x Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites1.6%
Taylor expanded in x around 0
Applied rewrites100.0%
Final simplification70.9%
(FPCore (x eps) :precision binary64 (if (<= eps 0.031) (* (* (/ (+ x 1.0) (fma (fma x 0.5 1.0) x 1.0)) 2.0) 0.5) (* (fma (fma x 0.5 -1.0) x 1.0) 1.0)))
double code(double x, double eps) {
double tmp;
if (eps <= 0.031) {
tmp = (((x + 1.0) / fma(fma(x, 0.5, 1.0), x, 1.0)) * 2.0) * 0.5;
} else {
tmp = fma(fma(x, 0.5, -1.0), x, 1.0) * 1.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 0.031) tmp = Float64(Float64(Float64(Float64(x + 1.0) / fma(fma(x, 0.5, 1.0), x, 1.0)) * 2.0) * 0.5); else tmp = Float64(fma(fma(x, 0.5, -1.0), x, 1.0) * 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 0.031], N[(N[(N[(N[(x + 1.0), $MachinePrecision] / N[(N[(x * 0.5 + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(x * 0.5 + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 0.031:\\
\;\;\;\;\left(\frac{x + 1}{\mathsf{fma}\left(\mathsf{fma}\left(x, 0.5, 1\right), x, 1\right)} \cdot 2\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x, 0.5, -1\right), x, 1\right) \cdot 1\\
\end{array}
\end{array}
if eps < 0.031Initial program 55.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites78.7%
Taylor expanded in x around 0
Applied rewrites67.6%
if 0.031 < eps Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites25.2%
Applied rewrites25.2%
Taylor expanded in x around 0
Applied rewrites56.0%
Taylor expanded in x around 0
Applied rewrites53.9%
Final simplification62.7%
(FPCore (x eps) :precision binary64 (if (<= x -5500.0) (* (fma (fma (fma -0.16666666666666666 x 0.5) x -1.0) x 1.0) 1.0) (fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0)))
double code(double x, double eps) {
double tmp;
if (x <= -5500.0) {
tmp = fma(fma(fma(-0.16666666666666666, x, 0.5), x, -1.0), x, 1.0) * 1.0;
} else {
tmp = fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -5500.0) tmp = Float64(fma(fma(fma(-0.16666666666666666, x, 0.5), x, -1.0), x, 1.0) * 1.0); else tmp = fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -5500.0], N[(N[(N[(N[(-0.16666666666666666 * x + 0.5), $MachinePrecision] * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5500:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, x, 0.5\right), x, -1\right), x, 1\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)\\
\end{array}
\end{array}
if x < -5500Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites0.0%
Applied rewrites0.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites70.4%
if -5500 < x Initial program 67.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites69.1%
Taylor expanded in x around 0
Applied rewrites65.1%
Final simplification65.8%
(FPCore (x eps) :precision binary64 (if (<= x -68.0) (/ (- 1.0 (* x eps)) 2.0) (fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0)))
double code(double x, double eps) {
double tmp;
if (x <= -68.0) {
tmp = (1.0 - (x * eps)) / 2.0;
} else {
tmp = fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -68.0) tmp = Float64(Float64(1.0 - Float64(x * eps)) / 2.0); else tmp = fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -68.0], N[(N[(1.0 - N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -68:\\
\;\;\;\;\frac{1 - x \cdot \varepsilon}{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)\\
\end{array}
\end{array}
if x < -68Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6480.6
Applied rewrites80.6%
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
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-fma.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
lower--.f64N/A
lower-/.f6450.5
Applied rewrites50.5%
Taylor expanded in eps around inf
Applied rewrites50.5%
Taylor expanded in eps around inf
Applied rewrites50.5%
if -68 < x Initial program 67.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites69.1%
Taylor expanded in x around 0
Applied rewrites65.1%
Final simplification63.1%
(FPCore (x eps) :precision binary64 (if (<= x -5500.0) (* (fma (fma x 0.5 -1.0) x 1.0) 1.0) (fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0)))
double code(double x, double eps) {
double tmp;
if (x <= -5500.0) {
tmp = fma(fma(x, 0.5, -1.0), x, 1.0) * 1.0;
} else {
tmp = fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -5500.0) tmp = Float64(fma(fma(x, 0.5, -1.0), x, 1.0) * 1.0); else tmp = fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -5500.0], N[(N[(N[(x * 0.5 + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5500:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x, 0.5, -1\right), x, 1\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)\\
\end{array}
\end{array}
if x < -5500Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites0.0%
Applied rewrites0.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites62.2%
if -5500 < x Initial program 67.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites69.1%
Taylor expanded in x around 0
Applied rewrites65.1%
Final simplification64.7%
(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(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0) end
code[x_, eps_] := N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)
\end{array}
Initial program 71.6%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites59.7%
Taylor expanded in x around 0
Applied rewrites56.2%
(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 71.6%
Taylor expanded in x around 0
Applied rewrites46.8%
herbie shell --seed 2024259
(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))