
(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 (/ (- (* (pow (exp -1.0) (* x (- 1.0 eps))) 1.0) (/ -1.0 (exp (fma eps x x)))) 2.0))
double code(double x, double eps) {
return ((pow(exp(-1.0), (x * (1.0 - eps))) * 1.0) - (-1.0 / exp(fma(eps, x, x)))) / 2.0;
}
function code(x, eps) return Float64(Float64(Float64((exp(-1.0) ^ Float64(x * Float64(1.0 - eps))) * 1.0) - Float64(-1.0 / exp(fma(eps, x, x)))) / 2.0) end
code[x_, eps_] := N[(N[(N[(N[Power[N[Exp[-1.0], $MachinePrecision], N[(x * N[(1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] - N[(-1.0 / N[Exp[N[(eps * x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(e^{-1}\right)}^{\left(x \cdot \left(1 - \varepsilon\right)\right)} \cdot 1 - \frac{-1}{e^{\mathsf{fma}\left(\varepsilon, x, x\right)}}}{2}
\end{array}
Initial program 73.5%
lift-exp.f64N/A
lift-neg.f64N/A
neg-mul-1N/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f6473.5
Applied rewrites73.5%
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
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6471.7
Applied rewrites71.7%
Taylor expanded in eps around inf
Applied rewrites99.7%
Final simplification99.7%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (exp (* (+ -1.0 eps) x))))
(if (<=
(-
(* (+ (/ 1.0 eps) 1.0) t_0)
(* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0)))
4.0)
(* (* (/ (+ x 1.0) (exp x)) 2.0) 0.5)
(/ (- (* t_0 1.0) (* x eps)) 2.0))))
double code(double x, double eps) {
double t_0 = exp(((-1.0 + eps) * x));
double tmp;
if (((((1.0 / eps) + 1.0) * t_0) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 4.0) {
tmp = (((x + 1.0) / exp(x)) * 2.0) * 0.5;
} else {
tmp = ((t_0 * 1.0) - (x * eps)) / 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))
if (((((1.0d0 / eps) + 1.0d0) * t_0) - (exp((((-1.0d0) - eps) * x)) * ((1.0d0 / eps) - 1.0d0))) <= 4.0d0) then
tmp = (((x + 1.0d0) / exp(x)) * 2.0d0) * 0.5d0
else
tmp = ((t_0 * 1.0d0) - (x * eps)) / 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 tmp;
if (((((1.0 / eps) + 1.0) * t_0) - (Math.exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 4.0) {
tmp = (((x + 1.0) / Math.exp(x)) * 2.0) * 0.5;
} else {
tmp = ((t_0 * 1.0) - (x * eps)) / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = math.exp(((-1.0 + eps) * x)) tmp = 0 if ((((1.0 / eps) + 1.0) * t_0) - (math.exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 4.0: tmp = (((x + 1.0) / math.exp(x)) * 2.0) * 0.5 else: tmp = ((t_0 * 1.0) - (x * eps)) / 2.0 return tmp
function code(x, eps) t_0 = exp(Float64(Float64(-1.0 + eps) * x)) tmp = 0.0 if (Float64(Float64(Float64(Float64(1.0 / eps) + 1.0) * t_0) - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * Float64(Float64(1.0 / eps) - 1.0))) <= 4.0) tmp = Float64(Float64(Float64(Float64(x + 1.0) / exp(x)) * 2.0) * 0.5); else tmp = Float64(Float64(Float64(t_0 * 1.0) - Float64(x * eps)) / 2.0); end return tmp end
function tmp_2 = code(x, eps) t_0 = exp(((-1.0 + eps) * x)); tmp = 0.0; if (((((1.0 / eps) + 1.0) * t_0) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 4.0) tmp = (((x + 1.0) / exp(x)) * 2.0) * 0.5; else tmp = ((t_0 * 1.0) - (x * eps)) / 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]}, If[LessEqual[N[(N[(N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $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[(N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(t$95$0 * 1.0), $MachinePrecision] - N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\left(-1 + \varepsilon\right) \cdot x}\\
\mathbf{if}\;\left(\frac{1}{\varepsilon} + 1\right) \cdot t\_0 - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right) \leq 4:\\
\;\;\;\;\left(\frac{x + 1}{e^{x}} \cdot 2\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 \cdot 1 - x \cdot \varepsilon}{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 49.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.2%
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
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-/.f6459.0
Applied rewrites59.0%
Taylor expanded in eps around inf
Applied rewrites59.0%
Taylor expanded in eps around inf
Applied rewrites59.0%
Final simplification80.2%
(FPCore (x eps)
:precision binary64
(if (<=
(-
(* (+ (/ 1.0 eps) 1.0) (exp (* (+ -1.0 eps) x)))
(* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0)))
4.0)
(* (* (/ (+ x 1.0) (exp x)) 2.0) 0.5)
(/ (- (* (exp (* x eps)) 1.0) (* x eps)) 2.0)))
double code(double x, double eps) {
double tmp;
if (((((1.0 / eps) + 1.0) * exp(((-1.0 + eps) * x))) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 4.0) {
tmp = (((x + 1.0) / exp(x)) * 2.0) * 0.5;
} else {
tmp = ((exp((x * eps)) * 1.0) - (x * eps)) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (((((1.0d0 / eps) + 1.0d0) * exp((((-1.0d0) + eps) * x))) - (exp((((-1.0d0) - eps) * x)) * ((1.0d0 / eps) - 1.0d0))) <= 4.0d0) then
tmp = (((x + 1.0d0) / exp(x)) * 2.0d0) * 0.5d0
else
tmp = ((exp((x * eps)) * 1.0d0) - (x * eps)) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (((((1.0 / eps) + 1.0) * Math.exp(((-1.0 + eps) * x))) - (Math.exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 4.0) {
tmp = (((x + 1.0) / Math.exp(x)) * 2.0) * 0.5;
} else {
tmp = ((Math.exp((x * eps)) * 1.0) - (x * eps)) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if ((((1.0 / eps) + 1.0) * math.exp(((-1.0 + eps) * x))) - (math.exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 4.0: tmp = (((x + 1.0) / math.exp(x)) * 2.0) * 0.5 else: tmp = ((math.exp((x * eps)) * 1.0) - (x * eps)) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (Float64(Float64(Float64(Float64(1.0 / eps) + 1.0) * exp(Float64(Float64(-1.0 + eps) * x))) - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * Float64(Float64(1.0 / eps) - 1.0))) <= 4.0) tmp = Float64(Float64(Float64(Float64(x + 1.0) / exp(x)) * 2.0) * 0.5); else tmp = Float64(Float64(Float64(exp(Float64(x * eps)) * 1.0) - Float64(x * eps)) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (((((1.0 / eps) + 1.0) * exp(((-1.0 + eps) * x))) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 4.0) tmp = (((x + 1.0) / exp(x)) * 2.0) * 0.5; else tmp = ((exp((x * eps)) * 1.0) - (x * eps)) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[(N[(N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] * N[Exp[N[(N[(-1.0 + eps), $MachinePrecision] * x), $MachinePrecision]], $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], 4.0], N[(N[(N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] - N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\frac{1}{\varepsilon} + 1\right) \cdot e^{\left(-1 + \varepsilon\right) \cdot x} - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right) \leq 4:\\
\;\;\;\;\left(\frac{x + 1}{e^{x}} \cdot 2\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \varepsilon} \cdot 1 - x \cdot \varepsilon}{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 49.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.2%
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
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-/.f6459.0
Applied rewrites59.0%
Taylor expanded in eps around inf
Applied rewrites59.0%
Taylor expanded in eps around inf
Applied rewrites59.0%
Taylor expanded in eps around inf
lower-*.f6459.0
Applied rewrites59.0%
Final simplification80.2%
(FPCore (x eps) :precision binary64 (/ (- (* (exp (* (+ -1.0 eps) x)) 1.0) (/ -1.0 (exp (fma eps x x)))) 2.0))
double code(double x, double eps) {
return ((exp(((-1.0 + eps) * x)) * 1.0) - (-1.0 / exp(fma(eps, x, x)))) / 2.0;
}
function code(x, eps) return Float64(Float64(Float64(exp(Float64(Float64(-1.0 + eps) * x)) * 1.0) - Float64(-1.0 / exp(fma(eps, x, x)))) / 2.0) end
code[x_, eps_] := N[(N[(N[(N[Exp[N[(N[(-1.0 + eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] - N[(-1.0 / N[Exp[N[(eps * x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{\left(-1 + \varepsilon\right) \cdot x} \cdot 1 - \frac{-1}{e^{\mathsf{fma}\left(\varepsilon, x, x\right)}}}{2}
\end{array}
Initial program 73.5%
lift-exp.f64N/A
lift-neg.f64N/A
neg-mul-1N/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f6473.5
Applied rewrites73.5%
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
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6471.7
Applied rewrites71.7%
Taylor expanded in eps around inf
Applied rewrites99.7%
lift-pow.f64N/A
lift-exp.f64N/A
pow-expN/A
neg-mul-1N/A
lift-neg.f64N/A
lift-exp.f6499.7
lift-neg.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lift--.f64N/A
flip--N/A
distribute-neg-frac2N/A
metadata-evalN/A
metadata-evalN/A
distribute-neg-inN/A
metadata-evalN/A
sub-negN/A
flip-+N/A
lower-+.f6499.7
Applied rewrites99.7%
Final simplification99.7%
(FPCore (x eps)
:precision binary64
(if (<= x -5e-289)
(/ (- (* 1.0 1.0) (/ -1.0 (exp (fma eps x x)))) 2.0)
(if (<= x 0.0032)
(/
(-
(* (exp (* (+ -1.0 eps) x)) 1.0)
(* (- x (/ (- x (- x 1.0)) eps)) eps))
2.0)
(/ (- (* (exp (* x eps)) (+ (/ 1.0 eps) 1.0)) (- (/ 1.0 eps) 1.0)) 2.0))))
double code(double x, double eps) {
double tmp;
if (x <= -5e-289) {
tmp = ((1.0 * 1.0) - (-1.0 / exp(fma(eps, x, x)))) / 2.0;
} else if (x <= 0.0032) {
tmp = ((exp(((-1.0 + eps) * x)) * 1.0) - ((x - ((x - (x - 1.0)) / eps)) * eps)) / 2.0;
} else {
tmp = ((exp((x * eps)) * ((1.0 / eps) + 1.0)) - ((1.0 / eps) - 1.0)) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -5e-289) tmp = Float64(Float64(Float64(1.0 * 1.0) - Float64(-1.0 / exp(fma(eps, x, x)))) / 2.0); elseif (x <= 0.0032) tmp = Float64(Float64(Float64(exp(Float64(Float64(-1.0 + eps) * x)) * 1.0) - Float64(Float64(x - Float64(Float64(x - Float64(x - 1.0)) / eps)) * eps)) / 2.0); else tmp = Float64(Float64(Float64(exp(Float64(x * eps)) * Float64(Float64(1.0 / eps) + 1.0)) - Float64(Float64(1.0 / eps) - 1.0)) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -5e-289], N[(N[(N[(1.0 * 1.0), $MachinePrecision] - N[(-1.0 / N[Exp[N[(eps * x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 0.0032], N[(N[(N[(N[Exp[N[(N[(-1.0 + eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] - N[(N[(x - N[(N[(x - N[(x - 1.0), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 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]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-289}:\\
\;\;\;\;\frac{1 \cdot 1 - \frac{-1}{e^{\mathsf{fma}\left(\varepsilon, x, x\right)}}}{2}\\
\mathbf{elif}\;x \leq 0.0032:\\
\;\;\;\;\frac{e^{\left(-1 + \varepsilon\right) \cdot x} \cdot 1 - \left(x - \frac{x - \left(x - 1\right)}{\varepsilon}\right) \cdot \varepsilon}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \varepsilon} \cdot \left(\frac{1}{\varepsilon} + 1\right) - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\end{array}
\end{array}
if x < -5.00000000000000029e-289Initial program 70.4%
lift-exp.f64N/A
lift-neg.f64N/A
neg-mul-1N/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f6470.4
Applied rewrites70.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
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6469.4
Applied rewrites69.4%
Taylor expanded in eps around inf
Applied rewrites99.6%
Taylor expanded in x around 0
Applied rewrites72.7%
if -5.00000000000000029e-289 < x < 0.00320000000000000015Initial program 51.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
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-/.f6442.4
Applied rewrites42.4%
Taylor expanded in eps around inf
Applied rewrites20.6%
Taylor expanded in eps around inf
Applied rewrites28.8%
Taylor expanded in eps around inf
Applied rewrites90.3%
if 0.00320000000000000015 < x Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6432.9
Applied rewrites32.9%
Taylor expanded in eps around inf
lower-*.f6448.7
Applied rewrites48.7%
Final simplification70.8%
(FPCore (x eps) :precision binary64 (if (<= x 2.15e-9) (/ (- (* 1.0 1.0) (/ -1.0 (exp (fma eps x x)))) 2.0) (/ (- (* (exp (* x eps)) (+ (/ 1.0 eps) 1.0)) (- (/ 1.0 eps) 1.0)) 2.0)))
double code(double x, double eps) {
double tmp;
if (x <= 2.15e-9) {
tmp = ((1.0 * 1.0) - (-1.0 / exp(fma(eps, x, x)))) / 2.0;
} else {
tmp = ((exp((x * eps)) * ((1.0 / eps) + 1.0)) - ((1.0 / eps) - 1.0)) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 2.15e-9) tmp = Float64(Float64(Float64(1.0 * 1.0) - Float64(-1.0 / exp(fma(eps, x, x)))) / 2.0); else tmp = Float64(Float64(Float64(exp(Float64(x * eps)) * Float64(Float64(1.0 / eps) + 1.0)) - Float64(Float64(1.0 / eps) - 1.0)) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, 2.15e-9], N[(N[(N[(1.0 * 1.0), $MachinePrecision] - N[(-1.0 / N[Exp[N[(eps * x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 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]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.15 \cdot 10^{-9}:\\
\;\;\;\;\frac{1 \cdot 1 - \frac{-1}{e^{\mathsf{fma}\left(\varepsilon, x, x\right)}}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \varepsilon} \cdot \left(\frac{1}{\varepsilon} + 1\right) - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\end{array}
\end{array}
if x < 2.14999999999999981e-9Initial program 62.7%
lift-exp.f64N/A
lift-neg.f64N/A
neg-mul-1N/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f6462.7
Applied rewrites62.7%
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
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6460.1
Applied rewrites60.1%
Taylor expanded in eps around inf
Applied rewrites99.6%
Taylor expanded in x around 0
Applied rewrites77.4%
if 2.14999999999999981e-9 < x Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6432.9
Applied rewrites32.9%
Taylor expanded in eps around inf
lower-*.f6448.7
Applied rewrites48.7%
Final simplification69.1%
(FPCore (x eps) :precision binary64 (if (<= x 2.15e-9) (/ (- (* 1.0 1.0) (/ -1.0 (exp (fma eps x x)))) 2.0) (/ (- (* (exp (* (+ -1.0 eps) x)) 1.0) (/ (- 1.0 x) eps)) 2.0)))
double code(double x, double eps) {
double tmp;
if (x <= 2.15e-9) {
tmp = ((1.0 * 1.0) - (-1.0 / exp(fma(eps, x, x)))) / 2.0;
} else {
tmp = ((exp(((-1.0 + eps) * x)) * 1.0) - ((1.0 - x) / eps)) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 2.15e-9) tmp = Float64(Float64(Float64(1.0 * 1.0) - Float64(-1.0 / exp(fma(eps, x, x)))) / 2.0); else tmp = Float64(Float64(Float64(exp(Float64(Float64(-1.0 + eps) * x)) * 1.0) - Float64(Float64(1.0 - x) / eps)) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, 2.15e-9], N[(N[(N[(1.0 * 1.0), $MachinePrecision] - N[(-1.0 / N[Exp[N[(eps * x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(N[Exp[N[(N[(-1.0 + eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] - N[(N[(1.0 - x), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.15 \cdot 10^{-9}:\\
\;\;\;\;\frac{1 \cdot 1 - \frac{-1}{e^{\mathsf{fma}\left(\varepsilon, x, x\right)}}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{\left(-1 + \varepsilon\right) \cdot x} \cdot 1 - \frac{1 - x}{\varepsilon}}{2}\\
\end{array}
\end{array}
if x < 2.14999999999999981e-9Initial program 62.7%
lift-exp.f64N/A
lift-neg.f64N/A
neg-mul-1N/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f6462.7
Applied rewrites62.7%
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
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6460.1
Applied rewrites60.1%
Taylor expanded in eps around inf
Applied rewrites99.6%
Taylor expanded in x around 0
Applied rewrites77.4%
if 2.14999999999999981e-9 < x Initial program 100.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
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-/.f6435.7
Applied rewrites35.7%
Taylor expanded in eps around 0
Applied rewrites31.9%
Taylor expanded in eps around inf
Applied rewrites31.9%
Final simplification64.3%
(FPCore (x eps)
:precision binary64
(if (<= x 2.15e-9)
(/ (- (* 1.0 1.0) (/ -1.0 (exp (fma eps x x)))) 2.0)
(if (<= x 8.4e+102)
(/ (- (* (exp (* (+ -1.0 eps) x)) 1.0) (* x eps)) 2.0)
(fma (* 0.3333333333333333 x) (* x x) 1.0))))
double code(double x, double eps) {
double tmp;
if (x <= 2.15e-9) {
tmp = ((1.0 * 1.0) - (-1.0 / exp(fma(eps, x, x)))) / 2.0;
} else if (x <= 8.4e+102) {
tmp = ((exp(((-1.0 + eps) * x)) * 1.0) - (x * eps)) / 2.0;
} else {
tmp = fma((0.3333333333333333 * x), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 2.15e-9) tmp = Float64(Float64(Float64(1.0 * 1.0) - Float64(-1.0 / exp(fma(eps, x, x)))) / 2.0); elseif (x <= 8.4e+102) tmp = Float64(Float64(Float64(exp(Float64(Float64(-1.0 + eps) * x)) * 1.0) - Float64(x * eps)) / 2.0); else tmp = fma(Float64(0.3333333333333333 * x), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, 2.15e-9], N[(N[(N[(1.0 * 1.0), $MachinePrecision] - N[(-1.0 / N[Exp[N[(eps * x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 8.4e+102], N[(N[(N[(N[Exp[N[(N[(-1.0 + eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] - N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(0.3333333333333333 * x), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.15 \cdot 10^{-9}:\\
\;\;\;\;\frac{1 \cdot 1 - \frac{-1}{e^{\mathsf{fma}\left(\varepsilon, x, x\right)}}}{2}\\
\mathbf{elif}\;x \leq 8.4 \cdot 10^{+102}:\\
\;\;\;\;\frac{e^{\left(-1 + \varepsilon\right) \cdot x} \cdot 1 - x \cdot \varepsilon}{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333 \cdot x, x \cdot x, 1\right)\\
\end{array}
\end{array}
if x < 2.14999999999999981e-9Initial program 62.7%
lift-exp.f64N/A
lift-neg.f64N/A
neg-mul-1N/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f6462.7
Applied rewrites62.7%
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
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6460.1
Applied rewrites60.1%
Taylor expanded in eps around inf
Applied rewrites99.6%
Taylor expanded in x around 0
Applied rewrites77.4%
if 2.14999999999999981e-9 < x < 8.40000000000000006e102Initial program 100.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
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-/.f6437.6
Applied rewrites37.6%
Taylor expanded in eps around inf
Applied rewrites38.5%
Taylor expanded in eps around inf
Applied rewrites38.5%
if 8.40000000000000006e102 < x Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites39.6%
Taylor expanded in x around 0
Applied rewrites62.0%
Taylor expanded in x around inf
Applied rewrites62.0%
Final simplification71.4%
(FPCore (x eps)
:precision binary64
(if (<= x -900.0)
(/ (- (* (exp (- x)) 1.0) (* x eps)) 2.0)
(if (<= x 5e+102)
(* (* (/ (+ x 1.0) (exp x)) 2.0) 0.5)
(fma (* 0.3333333333333333 x) (* x x) 1.0))))
double code(double x, double eps) {
double tmp;
if (x <= -900.0) {
tmp = ((exp(-x) * 1.0) - (x * eps)) / 2.0;
} else if (x <= 5e+102) {
tmp = (((x + 1.0) / exp(x)) * 2.0) * 0.5;
} else {
tmp = fma((0.3333333333333333 * x), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -900.0) tmp = Float64(Float64(Float64(exp(Float64(-x)) * 1.0) - Float64(x * eps)) / 2.0); elseif (x <= 5e+102) tmp = Float64(Float64(Float64(Float64(x + 1.0) / exp(x)) * 2.0) * 0.5); else tmp = fma(Float64(0.3333333333333333 * x), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -900.0], N[(N[(N[(N[Exp[(-x)], $MachinePrecision] * 1.0), $MachinePrecision] - N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 5e+102], N[(N[(N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(0.3333333333333333 * x), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -900:\\
\;\;\;\;\frac{e^{-x} \cdot 1 - x \cdot \varepsilon}{2}\\
\mathbf{elif}\;x \leq 5 \cdot 10^{+102}:\\
\;\;\;\;\left(\frac{x + 1}{e^{x}} \cdot 2\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333 \cdot x, x \cdot x, 1\right)\\
\end{array}
\end{array}
if x < -900Initial program 100.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
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-/.f6471.1
Applied rewrites71.1%
Taylor expanded in eps around inf
Applied rewrites71.1%
Taylor expanded in eps around inf
Applied rewrites71.1%
Taylor expanded in eps around 0
neg-mul-1N/A
lower-neg.f6485.0
Applied rewrites85.0%
if -900 < x < 5e102Initial program 57.3%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites71.2%
if 5e102 < x Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites39.6%
Taylor expanded in x around 0
Applied rewrites62.0%
Taylor expanded in x around inf
Applied rewrites62.0%
Final simplification71.3%
(FPCore (x eps)
:precision binary64
(if (<= eps 44.0)
(* (* (/ (+ x 1.0) (exp x)) 2.0) 0.5)
(if (<= eps 2.5e+68)
(fma (* 0.3333333333333333 x) (* x 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 <= 44.0) {
tmp = (((x + 1.0) / exp(x)) * 2.0) * 0.5;
} else if (eps <= 2.5e+68) {
tmp = fma((0.3333333333333333 * x), (x * 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 <= 44.0) tmp = Float64(Float64(Float64(Float64(x + 1.0) / exp(x)) * 2.0) * 0.5); elseif (eps <= 2.5e+68) tmp = fma(Float64(0.3333333333333333 * x), Float64(x * 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, 44.0], N[(N[(N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[eps, 2.5e+68], N[(N[(0.3333333333333333 * x), $MachinePrecision] * N[(x * x), $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 44:\\
\;\;\;\;\left(\frac{x + 1}{e^{x}} \cdot 2\right) \cdot 0.5\\
\mathbf{elif}\;\varepsilon \leq 2.5 \cdot 10^{+68}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333 \cdot x, x \cdot 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 < 44Initial program 60.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.2%
if 44 < eps < 2.5000000000000002e68Initial program 99.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites58.3%
Taylor expanded in x around 0
Applied rewrites86.5%
Taylor expanded in x around inf
Applied rewrites86.5%
if 2.5000000000000002e68 < eps Initial program 100.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
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-/.f6457.8
Applied rewrites57.8%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6432.1
Applied rewrites32.1%
Taylor expanded in eps around 0
Applied rewrites47.3%
Final simplification63.3%
(FPCore (x eps)
:precision binary64
(if (<= x -1.9e-5)
(/
(-
(+ (/ 1.0 eps) 1.0)
(/ (fma (fma eps x (- (- x 1.0) x)) eps (- 1.0 x)) eps))
2.0)
(fma (* 0.3333333333333333 x) (* x x) 1.0)))
double code(double x, double eps) {
double tmp;
if (x <= -1.9e-5) {
tmp = (((1.0 / eps) + 1.0) - (fma(fma(eps, x, ((x - 1.0) - x)), eps, (1.0 - x)) / eps)) / 2.0;
} else {
tmp = fma((0.3333333333333333 * x), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -1.9e-5) 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); else tmp = fma(Float64(0.3333333333333333 * x), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -1.9e-5], 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], N[(N[(0.3333333333333333 * x), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.9 \cdot 10^{-5}:\\
\;\;\;\;\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}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333 \cdot x, x \cdot x, 1\right)\\
\end{array}
\end{array}
if x < -1.9000000000000001e-5Initial program 100.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
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-/.f6471.1
Applied rewrites71.1%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6428.7
Applied rewrites28.7%
Taylor expanded in eps around 0
Applied rewrites35.5%
if -1.9000000000000001e-5 < x Initial program 68.6%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites62.9%
Taylor expanded in x around 0
Applied rewrites65.8%
Taylor expanded in x around inf
Applied rewrites65.8%
(FPCore (x eps) :precision binary64 (if (<= x -118.0) (/ (- (+ (/ 1.0 eps) 1.0) (* x eps)) 2.0) (fma (* 0.3333333333333333 x) (* x x) 1.0)))
double code(double x, double eps) {
double tmp;
if (x <= -118.0) {
tmp = (((1.0 / eps) + 1.0) - (x * eps)) / 2.0;
} else {
tmp = fma((0.3333333333333333 * x), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -118.0) tmp = Float64(Float64(Float64(Float64(1.0 / eps) + 1.0) - Float64(x * eps)) / 2.0); else tmp = fma(Float64(0.3333333333333333 * x), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -118.0], N[(N[(N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] - N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(0.3333333333333333 * x), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -118:\\
\;\;\;\;\frac{\left(\frac{1}{\varepsilon} + 1\right) - x \cdot \varepsilon}{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333 \cdot x, x \cdot x, 1\right)\\
\end{array}
\end{array}
if x < -118Initial program 100.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
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-/.f6471.1
Applied rewrites71.1%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6428.7
Applied rewrites28.7%
Taylor expanded in eps around inf
Applied rewrites28.7%
if -118 < x Initial program 68.6%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites62.9%
Taylor expanded in x around 0
Applied rewrites65.8%
Taylor expanded in x around inf
Applied rewrites65.8%
Final simplification60.0%
(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 73.5%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites53.1%
Taylor expanded in x around 0
Applied rewrites55.5%
Taylor expanded in x around inf
Applied rewrites55.5%
(FPCore (x eps) :precision binary64 (if (<= x 490.0) 1.0 0.0))
double code(double x, double eps) {
double tmp;
if (x <= 490.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 490.0d0) then
tmp = 1.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 490.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 490.0: tmp = 1.0 else: tmp = 0.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 490.0) tmp = 1.0; else tmp = 0.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 490.0) tmp = 1.0; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 490.0], 1.0, 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 490:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 490Initial program 63.1%
Taylor expanded in x around 0
Applied rewrites58.4%
if 490 < x Initial program 100.0%
lift-exp.f64N/A
lift-neg.f64N/A
neg-mul-1N/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around 0
div-subN/A
neg-mul-1N/A
+-inversesN/A
metadata-eval41.2
Applied rewrites41.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 73.5%
Taylor expanded in x around 0
Applied rewrites42.8%
herbie shell --seed 2024273
(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))