
(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 8 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))))
(t_1
(-
(* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x))))
(* (- (/ 1.0 eps) 1.0) t_0))))
(if (<= t_1 0.0) t_0 (/ t_1 2.0))))
double code(double x, double eps) {
double t_0 = exp(-((1.0 + eps) * x));
double t_1 = ((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * t_0);
double tmp;
if (t_1 <= 0.0) {
tmp = t_0;
} else {
tmp = t_1 / 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) :: t_1
real(8) :: tmp
t_0 = exp(-((1.0d0 + eps) * x))
t_1 = ((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * t_0)
if (t_1 <= 0.0d0) then
tmp = t_0
else
tmp = t_1 / 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));
double t_1 = ((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * t_0);
double tmp;
if (t_1 <= 0.0) {
tmp = t_0;
} else {
tmp = t_1 / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = math.exp(-((1.0 + eps) * x)) t_1 = ((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * t_0) tmp = 0 if t_1 <= 0.0: tmp = t_0 else: tmp = t_1 / 2.0 return tmp
function code(x, eps) t_0 = exp(Float64(-Float64(Float64(1.0 + eps) * x))) t_1 = 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) * t_0)) tmp = 0.0 if (t_1 <= 0.0) tmp = t_0; else tmp = Float64(t_1 / 2.0); end return tmp end
function tmp_2 = code(x, eps) t_0 = exp(-((1.0 + eps) * x)); t_1 = ((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * t_0); tmp = 0.0; if (t_1 <= 0.0) tmp = t_0; else tmp = t_1 / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]}, Block[{t$95$1 = 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] * t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], t$95$0, N[(t$95$1 / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-\left(1 + \varepsilon\right) \cdot x}\\
t_1 := \left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot t\_0\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{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 41.4%
Taylor expanded in x around 0
Applied rewrites41.3%
Taylor expanded in x around 0
Applied rewrites41.3%
Taylor expanded in x around 0
Applied rewrites19.8%
Taylor expanded in x around inf
Applied rewrites97.1%
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%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (+ 1.0 eps) x))
(t_1 (+ 1.0 (/ 1.0 eps)))
(t_2
(-
(* t_1 (exp (- (* (- 1.0 eps) x))))
(* (- (/ 1.0 eps) 1.0) (exp (- t_0))))))
(if (<= t_2 0.0) (+ 1.0 eps) (if (<= t_2 4.0) t_1 t_0))))
double code(double x, double eps) {
double t_0 = (1.0 + eps) * x;
double t_1 = 1.0 + (1.0 / eps);
double t_2 = (t_1 * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-t_0));
double tmp;
if (t_2 <= 0.0) {
tmp = 1.0 + eps;
} else if (t_2 <= 4.0) {
tmp = t_1;
} 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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = (1.0d0 + eps) * x
t_1 = 1.0d0 + (1.0d0 / eps)
t_2 = (t_1 * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-t_0))
if (t_2 <= 0.0d0) then
tmp = 1.0d0 + eps
else if (t_2 <= 4.0d0) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = (1.0 + eps) * x;
double t_1 = 1.0 + (1.0 / eps);
double t_2 = (t_1 * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-t_0));
double tmp;
if (t_2 <= 0.0) {
tmp = 1.0 + eps;
} else if (t_2 <= 4.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = (1.0 + eps) * x t_1 = 1.0 + (1.0 / eps) t_2 = (t_1 * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-t_0)) tmp = 0 if t_2 <= 0.0: tmp = 1.0 + eps elif t_2 <= 4.0: tmp = t_1 else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(Float64(1.0 + eps) * x) t_1 = Float64(1.0 + Float64(1.0 / eps)) t_2 = Float64(Float64(t_1 * exp(Float64(-Float64(Float64(1.0 - eps) * x)))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * exp(Float64(-t_0)))) tmp = 0.0 if (t_2 <= 0.0) tmp = Float64(1.0 + eps); elseif (t_2 <= 4.0) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, eps) t_0 = (1.0 + eps) * x; t_1 = 1.0 + (1.0 / eps); t_2 = (t_1 * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-t_0)); tmp = 0.0; if (t_2 <= 0.0) tmp = 1.0 + eps; elseif (t_2 <= 4.0) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$1 * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[(-t$95$0)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, 0.0], N[(1.0 + eps), $MachinePrecision], If[LessEqual[t$95$2, 4.0], t$95$1, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 + \varepsilon\right) \cdot x\\
t_1 := 1 + \frac{1}{\varepsilon}\\
t_2 := t\_1 \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-t\_0}\\
\mathbf{if}\;t\_2 \leq 0:\\
\;\;\;\;1 + \varepsilon\\
\mathbf{elif}\;t\_2 \leq 4:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\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 41.4%
Taylor expanded in x around 0
Applied rewrites41.3%
Taylor expanded in x around 0
Applied rewrites59.7%
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))))) < 4Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites83.8%
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
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites17.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (exp (- (* (+ 1.0 eps) x))))
(t_1
(-
(* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x))))
(* (- (/ 1.0 eps) 1.0) t_0))))
(if (<= t_1 4.0) t_0 t_1)))
double code(double x, double eps) {
double t_0 = exp(-((1.0 + eps) * x));
double t_1 = ((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * t_0);
double tmp;
if (t_1 <= 4.0) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = exp(-((1.0d0 + eps) * x))
t_1 = ((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * t_0)
if (t_1 <= 4.0d0) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.exp(-((1.0 + eps) * x));
double t_1 = ((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * t_0);
double tmp;
if (t_1 <= 4.0) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, eps): t_0 = math.exp(-((1.0 + eps) * x)) t_1 = ((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * t_0) tmp = 0 if t_1 <= 4.0: tmp = t_0 else: tmp = t_1 return tmp
function code(x, eps) t_0 = exp(Float64(-Float64(Float64(1.0 + eps) * x))) t_1 = 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) * t_0)) tmp = 0.0 if (t_1 <= 4.0) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, eps) t_0 = exp(-((1.0 + eps) * x)); t_1 = ((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * t_0); tmp = 0.0; if (t_1 <= 4.0) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]}, Block[{t$95$1 = 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] * t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 4.0], t$95$0, t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-\left(1 + \varepsilon\right) \cdot x}\\
t_1 := \left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot t\_0\\
\mathbf{if}\;t\_1 \leq 4:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\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 56.2%
Taylor expanded in x around 0
Applied rewrites51.7%
Taylor expanded in x around 0
Applied rewrites51.7%
Taylor expanded in x around 0
Applied rewrites36.8%
Taylor expanded in x around inf
Applied rewrites97.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
Applied rewrites100.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (+ 1.0 eps) x)))
(if (<=
(-
(* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x))))
(* (- (/ 1.0 eps) 1.0) (exp (- t_0))))
2.000002)
(+ 1.0 eps)
t_0)))
double code(double x, double eps) {
double t_0 = (1.0 + eps) * x;
double tmp;
if ((((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-t_0))) <= 2.000002) {
tmp = 1.0 + eps;
} 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 = (1.0d0 + eps) * x
if ((((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-t_0))) <= 2.000002d0) then
tmp = 1.0d0 + eps
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = (1.0 + eps) * x;
double tmp;
if ((((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-t_0))) <= 2.000002) {
tmp = 1.0 + eps;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = (1.0 + eps) * x tmp = 0 if (((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-t_0))) <= 2.000002: tmp = 1.0 + eps else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(Float64(1.0 + eps) * x) tmp = 0.0 if (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(-t_0)))) <= 2.000002) tmp = Float64(1.0 + eps); else tmp = t_0; end return tmp end
function tmp_2 = code(x, eps) t_0 = (1.0 + eps) * x; tmp = 0.0; if ((((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-t_0))) <= 2.000002) tmp = 1.0 + eps; else tmp = t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[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[(-t$95$0)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.000002], N[(1.0 + eps), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 + \varepsilon\right) \cdot x\\
\mathbf{if}\;\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-t\_0} \leq 2.000002:\\
\;\;\;\;1 + \varepsilon\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\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))))) < 2.00000199999999984Initial program 55.9%
Taylor expanded in x around 0
Applied rewrites51.8%
Taylor expanded in x around 0
Applied rewrites47.1%
if 2.00000199999999984 < (-.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
Applied rewrites99.3%
Taylor expanded in x around 0
Applied rewrites17.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (* (- 1.0 eps) x))))
(if (<= eps 3300000.0)
(exp (- (* (+ 1.0 eps) x)))
(- (* (+ 1.0 (/ 1.0 eps)) (exp t_0)) t_0))))
double code(double x, double eps) {
double t_0 = -((1.0 - eps) * x);
double tmp;
if (eps <= 3300000.0) {
tmp = exp(-((1.0 + eps) * x));
} else {
tmp = ((1.0 + (1.0 / eps)) * exp(t_0)) - 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 = -((1.0d0 - eps) * x)
if (eps <= 3300000.0d0) then
tmp = exp(-((1.0d0 + eps) * x))
else
tmp = ((1.0d0 + (1.0d0 / eps)) * exp(t_0)) - t_0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = -((1.0 - eps) * x);
double tmp;
if (eps <= 3300000.0) {
tmp = Math.exp(-((1.0 + eps) * x));
} else {
tmp = ((1.0 + (1.0 / eps)) * Math.exp(t_0)) - t_0;
}
return tmp;
}
def code(x, eps): t_0 = -((1.0 - eps) * x) tmp = 0 if eps <= 3300000.0: tmp = math.exp(-((1.0 + eps) * x)) else: tmp = ((1.0 + (1.0 / eps)) * math.exp(t_0)) - t_0 return tmp
function code(x, eps) t_0 = Float64(-Float64(Float64(1.0 - eps) * x)) tmp = 0.0 if (eps <= 3300000.0) tmp = exp(Float64(-Float64(Float64(1.0 + eps) * x))); else tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(t_0)) - t_0); end return tmp end
function tmp_2 = code(x, eps) t_0 = -((1.0 - eps) * x); tmp = 0.0; if (eps <= 3300000.0) tmp = exp(-((1.0 + eps) * x)); else tmp = ((1.0 + (1.0 / eps)) * exp(t_0)) - t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = (-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])}, If[LessEqual[eps, 3300000.0], N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[t$95$0], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\left(1 - \varepsilon\right) \cdot x\\
\mathbf{if}\;\varepsilon \leq 3300000:\\
\;\;\;\;e^{-\left(1 + \varepsilon\right) \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{t\_0} - t\_0\\
\end{array}
\end{array}
if eps < 3.3e6Initial program 65.8%
Taylor expanded in x around 0
Applied rewrites44.3%
Taylor expanded in x around 0
Applied rewrites49.1%
Taylor expanded in x around 0
Applied rewrites19.1%
Taylor expanded in x around inf
Applied rewrites84.3%
if 3.3e6 < eps Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites76.4%
Taylor expanded in x around 0
Applied rewrites74.1%
(FPCore (x eps) :precision binary64 (if (<= eps 2.8e+44) (exp (- (* (+ 1.0 eps) x))) (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x))))))
double code(double x, double eps) {
double tmp;
if (eps <= 2.8e+44) {
tmp = exp(-((1.0 + eps) * x));
} else {
tmp = (1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (eps <= 2.8d+44) then
tmp = exp(-((1.0d0 + eps) * x))
else
tmp = (1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= 2.8e+44) {
tmp = Math.exp(-((1.0 + eps) * x));
} else {
tmp = (1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x));
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= 2.8e+44: tmp = math.exp(-((1.0 + eps) * x)) else: tmp = (1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x)) return tmp
function code(x, eps) tmp = 0.0 if (eps <= 2.8e+44) tmp = exp(Float64(-Float64(Float64(1.0 + eps) * x))); else tmp = Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(-Float64(Float64(1.0 - eps) * x)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= 2.8e+44) tmp = exp(-((1.0 + eps) * x)); else tmp = (1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x)); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, 2.8e+44], N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision], N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 2.8 \cdot 10^{+44}:\\
\;\;\;\;e^{-\left(1 + \varepsilon\right) \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x}\\
\end{array}
\end{array}
if eps < 2.8000000000000001e44Initial program 67.5%
Taylor expanded in x around 0
Applied rewrites45.4%
Taylor expanded in x around 0
Applied rewrites49.9%
Taylor expanded in x around 0
Applied rewrites20.3%
Taylor expanded in x around inf
Applied rewrites83.6%
if 2.8000000000000001e44 < eps Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites67.5%
(FPCore (x eps) :precision binary64 (exp (- (* (+ 1.0 eps) x))))
double code(double x, double eps) {
return exp(-((1.0 + eps) * x));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = exp(-((1.0d0 + eps) * x))
end function
public static double code(double x, double eps) {
return Math.exp(-((1.0 + eps) * x));
}
def code(x, eps): return math.exp(-((1.0 + eps) * x))
function code(x, eps) return exp(Float64(-Float64(Float64(1.0 + eps) * x))) end
function tmp = code(x, eps) tmp = exp(-((1.0 + eps) * x)); end
code[x_, eps_] := N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]
\begin{array}{l}
\\
e^{-\left(1 + \varepsilon\right) \cdot x}
\end{array}
Initial program 75.0%
Taylor expanded in x around 0
Applied rewrites50.5%
Taylor expanded in x around 0
Applied rewrites52.1%
Taylor expanded in x around 0
Applied rewrites22.3%
Taylor expanded in x around inf
Applied rewrites77.9%
(FPCore (x eps) :precision binary64 (+ 1.0 eps))
double code(double x, double eps) {
return 1.0 + eps;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 1.0d0 + eps
end function
public static double code(double x, double eps) {
return 1.0 + eps;
}
def code(x, eps): return 1.0 + eps
function code(x, eps) return Float64(1.0 + eps) end
function tmp = code(x, eps) tmp = 1.0 + eps; end
code[x_, eps_] := N[(1.0 + eps), $MachinePrecision]
\begin{array}{l}
\\
1 + \varepsilon
\end{array}
Initial program 75.0%
Taylor expanded in x around 0
Applied rewrites50.5%
Taylor expanded in x around 0
Applied rewrites27.8%
herbie shell --seed 2024321
(FPCore (x eps)
:name "NMSE Section 6.1 mentioned, A"
:precision binary64
:pre (TRUE)
(/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))