
(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 10 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}
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= eps_m 1.9e-7) (/ (+ x 1.0) (exp x)) (* 0.5 (+ (exp (* x (- -1.0 eps_m))) (exp (* x eps_m))))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 1.9e-7) {
tmp = (x + 1.0) / exp(x);
} else {
tmp = 0.5 * (exp((x * (-1.0 - eps_m))) + exp((x * eps_m)));
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (eps_m <= 1.9d-7) then
tmp = (x + 1.0d0) / exp(x)
else
tmp = 0.5d0 * (exp((x * ((-1.0d0) - eps_m))) + exp((x * eps_m)))
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (eps_m <= 1.9e-7) {
tmp = (x + 1.0) / Math.exp(x);
} else {
tmp = 0.5 * (Math.exp((x * (-1.0 - eps_m))) + Math.exp((x * eps_m)));
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 1.9e-7: tmp = (x + 1.0) / math.exp(x) else: tmp = 0.5 * (math.exp((x * (-1.0 - eps_m))) + math.exp((x * eps_m))) return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 1.9e-7) tmp = Float64(Float64(x + 1.0) / exp(x)); else tmp = Float64(0.5 * Float64(exp(Float64(x * Float64(-1.0 - eps_m))) + exp(Float64(x * eps_m)))); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (eps_m <= 1.9e-7) tmp = (x + 1.0) / exp(x); else tmp = 0.5 * (exp((x * (-1.0 - eps_m))) + exp((x * eps_m))); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 1.9e-7], N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Exp[N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 1.9 \cdot 10^{-7}:\\
\;\;\;\;\frac{x + 1}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{x \cdot \left(-1 - eps\_m\right)} + e^{x \cdot eps\_m}\right)\\
\end{array}
\end{array}
if eps < 1.90000000000000007e-7Initial program 63.5%
Simplified63.5%
Taylor expanded in eps around 0
distribute-lft-outN/A
distribute-lft-outN/A
distribute-rgt-out--N/A
metadata-evalN/A
*-rgt-identityN/A
distribute-rgt1-inN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
mul-1-negN/A
neg-sub0N/A
--lowering--.f6468.5%
Simplified68.5%
exp-diffN/A
1-expN/A
un-div-invN/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f6468.5%
Applied egg-rr68.5%
if 1.90000000000000007e-7 < eps Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around inf
cancel-sign-sub-invN/A
metadata-evalN/A
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-lowering-*.f64N/A
distribute-lft-inN/A
metadata-evalN/A
mul-1-negN/A
unsub-negN/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in eps around inf
*-commutativeN/A
*-lowering-*.f64100.0%
Simplified100.0%
Final simplification78.1%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (* 0.5 (+ (exp (* x (+ eps_m -1.0))) (exp (* x (- -1.0 eps_m))))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return 0.5 * (exp((x * (eps_m + -1.0))) + exp((x * (-1.0 - eps_m))));
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
code = 0.5d0 * (exp((x * (eps_m + (-1.0d0)))) + exp((x * ((-1.0d0) - eps_m))))
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
return 0.5 * (Math.exp((x * (eps_m + -1.0))) + Math.exp((x * (-1.0 - eps_m))));
}
eps_m = math.fabs(eps) def code(x, eps_m): return 0.5 * (math.exp((x * (eps_m + -1.0))) + math.exp((x * (-1.0 - eps_m))))
eps_m = abs(eps) function code(x, eps_m) return Float64(0.5 * Float64(exp(Float64(x * Float64(eps_m + -1.0))) + exp(Float64(x * Float64(-1.0 - eps_m))))) end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = 0.5 * (exp((x * (eps_m + -1.0))) + exp((x * (-1.0 - eps_m)))); end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(0.5 * N[(N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
0.5 \cdot \left(e^{x \cdot \left(eps\_m + -1\right)} + e^{x \cdot \left(-1 - eps\_m\right)}\right)
\end{array}
Initial program 74.6%
Simplified74.6%
Taylor expanded in eps around inf
cancel-sign-sub-invN/A
metadata-evalN/A
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-lowering-*.f64N/A
distribute-lft-inN/A
metadata-evalN/A
mul-1-negN/A
unsub-negN/A
--lowering--.f6498.9%
Simplified98.9%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= eps_m 1.9e-7) (/ (+ x 1.0) (exp x)) (+ 1.0 (* x (* eps_m (* eps_m (* 0.5 x)))))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 1.9e-7) {
tmp = (x + 1.0) / exp(x);
} else {
tmp = 1.0 + (x * (eps_m * (eps_m * (0.5 * x))));
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (eps_m <= 1.9d-7) then
tmp = (x + 1.0d0) / exp(x)
else
tmp = 1.0d0 + (x * (eps_m * (eps_m * (0.5d0 * x))))
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (eps_m <= 1.9e-7) {
tmp = (x + 1.0) / Math.exp(x);
} else {
tmp = 1.0 + (x * (eps_m * (eps_m * (0.5 * x))));
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 1.9e-7: tmp = (x + 1.0) / math.exp(x) else: tmp = 1.0 + (x * (eps_m * (eps_m * (0.5 * x)))) return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 1.9e-7) tmp = Float64(Float64(x + 1.0) / exp(x)); else tmp = Float64(1.0 + Float64(x * Float64(eps_m * Float64(eps_m * Float64(0.5 * x))))); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (eps_m <= 1.9e-7) tmp = (x + 1.0) / exp(x); else tmp = 1.0 + (x * (eps_m * (eps_m * (0.5 * x)))); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 1.9e-7], N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(x * N[(eps$95$m * N[(eps$95$m * N[(0.5 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 1.9 \cdot 10^{-7}:\\
\;\;\;\;\frac{x + 1}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;1 + x \cdot \left(eps\_m \cdot \left(eps\_m \cdot \left(0.5 \cdot x\right)\right)\right)\\
\end{array}
\end{array}
if eps < 1.90000000000000007e-7Initial program 63.5%
Simplified63.5%
Taylor expanded in eps around 0
distribute-lft-outN/A
distribute-lft-outN/A
distribute-rgt-out--N/A
metadata-evalN/A
*-rgt-identityN/A
distribute-rgt1-inN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
mul-1-negN/A
neg-sub0N/A
--lowering--.f6468.5%
Simplified68.5%
exp-diffN/A
1-expN/A
un-div-invN/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f6468.5%
Applied egg-rr68.5%
if 1.90000000000000007e-7 < eps Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0
Simplified88.2%
Taylor expanded in eps around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6490.7%
Simplified90.7%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= eps_m 7e+31) (exp (- 0.0 x)) (+ 1.0 (* x (* eps_m (* eps_m (* 0.5 x)))))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 7e+31) {
tmp = exp((0.0 - x));
} else {
tmp = 1.0 + (x * (eps_m * (eps_m * (0.5 * x))));
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (eps_m <= 7d+31) then
tmp = exp((0.0d0 - x))
else
tmp = 1.0d0 + (x * (eps_m * (eps_m * (0.5d0 * x))))
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (eps_m <= 7e+31) {
tmp = Math.exp((0.0 - x));
} else {
tmp = 1.0 + (x * (eps_m * (eps_m * (0.5 * x))));
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 7e+31: tmp = math.exp((0.0 - x)) else: tmp = 1.0 + (x * (eps_m * (eps_m * (0.5 * x)))) return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 7e+31) tmp = exp(Float64(0.0 - x)); else tmp = Float64(1.0 + Float64(x * Float64(eps_m * Float64(eps_m * Float64(0.5 * x))))); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (eps_m <= 7e+31) tmp = exp((0.0 - x)); else tmp = 1.0 + (x * (eps_m * (eps_m * (0.5 * x)))); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 7e+31], N[Exp[N[(0.0 - x), $MachinePrecision]], $MachinePrecision], N[(1.0 + N[(x * N[(eps$95$m * N[(eps$95$m * N[(0.5 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 7 \cdot 10^{+31}:\\
\;\;\;\;e^{0 - x}\\
\mathbf{else}:\\
\;\;\;\;1 + x \cdot \left(eps\_m \cdot \left(eps\_m \cdot \left(0.5 \cdot x\right)\right)\right)\\
\end{array}
\end{array}
if eps < 7e31Initial program 64.9%
Simplified64.9%
Taylor expanded in eps around inf
cancel-sign-sub-invN/A
metadata-evalN/A
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-lowering-*.f64N/A
distribute-lft-inN/A
metadata-evalN/A
mul-1-negN/A
unsub-negN/A
--lowering--.f6498.5%
Simplified98.5%
Taylor expanded in eps around 0
exp-lowering-exp.f64N/A
neg-mul-1N/A
neg-sub0N/A
--lowering--.f6477.5%
Simplified77.5%
if 7e31 < eps Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0
Simplified87.9%
Taylor expanded in eps around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6490.6%
Simplified90.6%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -5e-161)
(+ 1.0 (* x (* x (+ -0.5 (* 0.5 (* eps_m eps_m))))))
(if (<= x 4.5e-14)
(+ 1.0 (* x (* eps_m (* eps_m (* 0.5 x)))))
(* 0.5 (* x (* x (* eps_m eps_m)))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -5e-161) {
tmp = 1.0 + (x * (x * (-0.5 + (0.5 * (eps_m * eps_m)))));
} else if (x <= 4.5e-14) {
tmp = 1.0 + (x * (eps_m * (eps_m * (0.5 * x))));
} else {
tmp = 0.5 * (x * (x * (eps_m * eps_m)));
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= (-5d-161)) then
tmp = 1.0d0 + (x * (x * ((-0.5d0) + (0.5d0 * (eps_m * eps_m)))))
else if (x <= 4.5d-14) then
tmp = 1.0d0 + (x * (eps_m * (eps_m * (0.5d0 * x))))
else
tmp = 0.5d0 * (x * (x * (eps_m * eps_m)))
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= -5e-161) {
tmp = 1.0 + (x * (x * (-0.5 + (0.5 * (eps_m * eps_m)))));
} else if (x <= 4.5e-14) {
tmp = 1.0 + (x * (eps_m * (eps_m * (0.5 * x))));
} else {
tmp = 0.5 * (x * (x * (eps_m * eps_m)));
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -5e-161: tmp = 1.0 + (x * (x * (-0.5 + (0.5 * (eps_m * eps_m))))) elif x <= 4.5e-14: tmp = 1.0 + (x * (eps_m * (eps_m * (0.5 * x)))) else: tmp = 0.5 * (x * (x * (eps_m * eps_m))) return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -5e-161) tmp = Float64(1.0 + Float64(x * Float64(x * Float64(-0.5 + Float64(0.5 * Float64(eps_m * eps_m)))))); elseif (x <= 4.5e-14) tmp = Float64(1.0 + Float64(x * Float64(eps_m * Float64(eps_m * Float64(0.5 * x))))); else tmp = Float64(0.5 * Float64(x * Float64(x * Float64(eps_m * eps_m)))); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -5e-161) tmp = 1.0 + (x * (x * (-0.5 + (0.5 * (eps_m * eps_m))))); elseif (x <= 4.5e-14) tmp = 1.0 + (x * (eps_m * (eps_m * (0.5 * x)))); else tmp = 0.5 * (x * (x * (eps_m * eps_m))); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -5e-161], N[(1.0 + N[(x * N[(x * N[(-0.5 + N[(0.5 * N[(eps$95$m * eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.5e-14], N[(1.0 + N[(x * N[(eps$95$m * N[(eps$95$m * N[(0.5 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(x * N[(x * N[(eps$95$m * eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-161}:\\
\;\;\;\;1 + x \cdot \left(x \cdot \left(-0.5 + 0.5 \cdot \left(eps\_m \cdot eps\_m\right)\right)\right)\\
\mathbf{elif}\;x \leq 4.5 \cdot 10^{-14}:\\
\;\;\;\;1 + x \cdot \left(eps\_m \cdot \left(eps\_m \cdot \left(0.5 \cdot x\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \left(x \cdot \left(eps\_m \cdot eps\_m\right)\right)\right)\\
\end{array}
\end{array}
if x < -4.9999999999999999e-161Initial program 81.0%
Simplified81.0%
Taylor expanded in x around 0
Simplified87.7%
Taylor expanded in eps around 0
associate-*r*N/A
distribute-rgt-outN/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6487.9%
Simplified87.9%
if -4.9999999999999999e-161 < x < 4.4999999999999998e-14Initial program 52.5%
Simplified52.5%
Taylor expanded in x around 0
Simplified92.0%
Taylor expanded in eps around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6496.6%
Simplified96.6%
if 4.4999999999999998e-14 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0
Simplified50.3%
Taylor expanded in eps around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6450.1%
Simplified50.1%
Taylor expanded in x around inf
*-lowering-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6465.4%
Simplified65.4%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (let* ((t_0 (* 0.5 (* x (* x (* eps_m eps_m)))))) (if (<= x -1.2e-33) t_0 (if (<= x 1.35e-14) (+ 1.0 (* x (* x -0.5))) t_0))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = 0.5 * (x * (x * (eps_m * eps_m)));
double tmp;
if (x <= -1.2e-33) {
tmp = t_0;
} else if (x <= 1.35e-14) {
tmp = 1.0 + (x * (x * -0.5));
} else {
tmp = t_0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: t_0
real(8) :: tmp
t_0 = 0.5d0 * (x * (x * (eps_m * eps_m)))
if (x <= (-1.2d-33)) then
tmp = t_0
else if (x <= 1.35d-14) then
tmp = 1.0d0 + (x * (x * (-0.5d0)))
else
tmp = t_0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double t_0 = 0.5 * (x * (x * (eps_m * eps_m)));
double tmp;
if (x <= -1.2e-33) {
tmp = t_0;
} else if (x <= 1.35e-14) {
tmp = 1.0 + (x * (x * -0.5));
} else {
tmp = t_0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = 0.5 * (x * (x * (eps_m * eps_m))) tmp = 0 if x <= -1.2e-33: tmp = t_0 elif x <= 1.35e-14: tmp = 1.0 + (x * (x * -0.5)) else: tmp = t_0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(0.5 * Float64(x * Float64(x * Float64(eps_m * eps_m)))) tmp = 0.0 if (x <= -1.2e-33) tmp = t_0; elseif (x <= 1.35e-14) tmp = Float64(1.0 + Float64(x * Float64(x * -0.5))); else tmp = t_0; end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = 0.5 * (x * (x * (eps_m * eps_m))); tmp = 0.0; if (x <= -1.2e-33) tmp = t_0; elseif (x <= 1.35e-14) tmp = 1.0 + (x * (x * -0.5)); else tmp = t_0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[(0.5 * N[(x * N[(x * N[(eps$95$m * eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.2e-33], t$95$0, If[LessEqual[x, 1.35e-14], N[(1.0 + N[(x * N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(x \cdot \left(x \cdot \left(eps\_m \cdot eps\_m\right)\right)\right)\\
\mathbf{if}\;x \leq -1.2 \cdot 10^{-33}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{-14}:\\
\;\;\;\;1 + x \cdot \left(x \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.2e-33 or 1.3499999999999999e-14 < x Initial program 96.7%
Simplified96.7%
Taylor expanded in x around 0
Simplified65.0%
Taylor expanded in eps around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6464.9%
Simplified64.9%
Taylor expanded in x around inf
*-lowering-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6472.7%
Simplified72.7%
if -1.2e-33 < x < 1.3499999999999999e-14Initial program 55.1%
Simplified55.1%
Taylor expanded in x around 0
Simplified91.7%
Taylor expanded in eps around 0
*-commutativeN/A
*-lowering-*.f6480.6%
Simplified80.6%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 4.5e-14) (+ 1.0 (* x (* eps_m (* eps_m (* 0.5 x))))) (* 0.5 (* x (* x (* eps_m eps_m))))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 4.5e-14) {
tmp = 1.0 + (x * (eps_m * (eps_m * (0.5 * x))));
} else {
tmp = 0.5 * (x * (x * (eps_m * eps_m)));
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= 4.5d-14) then
tmp = 1.0d0 + (x * (eps_m * (eps_m * (0.5d0 * x))))
else
tmp = 0.5d0 * (x * (x * (eps_m * eps_m)))
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= 4.5e-14) {
tmp = 1.0 + (x * (eps_m * (eps_m * (0.5 * x))));
} else {
tmp = 0.5 * (x * (x * (eps_m * eps_m)));
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 4.5e-14: tmp = 1.0 + (x * (eps_m * (eps_m * (0.5 * x)))) else: tmp = 0.5 * (x * (x * (eps_m * eps_m))) return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 4.5e-14) tmp = Float64(1.0 + Float64(x * Float64(eps_m * Float64(eps_m * Float64(0.5 * x))))); else tmp = Float64(0.5 * Float64(x * Float64(x * Float64(eps_m * eps_m)))); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 4.5e-14) tmp = 1.0 + (x * (eps_m * (eps_m * (0.5 * x)))); else tmp = 0.5 * (x * (x * (eps_m * eps_m))); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 4.5e-14], N[(1.0 + N[(x * N[(eps$95$m * N[(eps$95$m * N[(0.5 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(x * N[(x * N[(eps$95$m * eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.5 \cdot 10^{-14}:\\
\;\;\;\;1 + x \cdot \left(eps\_m \cdot \left(eps\_m \cdot \left(0.5 \cdot x\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \left(x \cdot \left(eps\_m \cdot eps\_m\right)\right)\right)\\
\end{array}
\end{array}
if x < 4.4999999999999998e-14Initial program 65.1%
Simplified65.1%
Taylor expanded in x around 0
Simplified90.1%
Taylor expanded in eps around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6490.6%
Simplified90.6%
if 4.4999999999999998e-14 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0
Simplified50.3%
Taylor expanded in eps around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6450.1%
Simplified50.1%
Taylor expanded in x around inf
*-lowering-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6465.4%
Simplified65.4%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -0.0051) (* x (* eps_m -0.5)) (+ x 1.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -0.0051) {
tmp = x * (eps_m * -0.5);
} else {
tmp = x + 1.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= (-0.0051d0)) then
tmp = x * (eps_m * (-0.5d0))
else
tmp = x + 1.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= -0.0051) {
tmp = x * (eps_m * -0.5);
} else {
tmp = x + 1.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -0.0051: tmp = x * (eps_m * -0.5) else: tmp = x + 1.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -0.0051) tmp = Float64(x * Float64(eps_m * -0.5)); else tmp = Float64(x + 1.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -0.0051) tmp = x * (eps_m * -0.5); else tmp = x + 1.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -0.0051], N[(x * N[(eps$95$m * -0.5), $MachinePrecision]), $MachinePrecision], N[(x + 1.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.0051:\\
\;\;\;\;x \cdot \left(eps\_m \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;x + 1\\
\end{array}
\end{array}
if x < -0.0051000000000000004Initial program 95.1%
Simplified95.1%
Taylor expanded in x around 0
+-lowering-+.f64N/A
associate-*r/N/A
metadata-evalN/A
/-lowering-/.f6455.1%
Simplified55.1%
Taylor expanded in x around 0
+-lowering-+.f64N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
associate-*r/N/A
metadata-evalN/A
/-lowering-/.f6423.8%
Simplified23.8%
Taylor expanded in eps around inf
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6423.7%
Simplified23.7%
if -0.0051000000000000004 < x Initial program 70.7%
Simplified70.7%
Taylor expanded in eps around 0
distribute-lft-outN/A
distribute-lft-outN/A
distribute-rgt-out--N/A
metadata-evalN/A
*-rgt-identityN/A
distribute-rgt1-inN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
mul-1-negN/A
neg-sub0N/A
--lowering--.f6467.2%
Simplified67.2%
Taylor expanded in x around 0
Simplified53.0%
*-rgt-identityN/A
+-lowering-+.f6453.0%
Applied egg-rr53.0%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (+ 1.0 (* x (* eps_m -0.5))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return 1.0 + (x * (eps_m * -0.5));
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
code = 1.0d0 + (x * (eps_m * (-0.5d0)))
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
return 1.0 + (x * (eps_m * -0.5));
}
eps_m = math.fabs(eps) def code(x, eps_m): return 1.0 + (x * (eps_m * -0.5))
eps_m = abs(eps) function code(x, eps_m) return Float64(1.0 + Float64(x * Float64(eps_m * -0.5))) end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = 1.0 + (x * (eps_m * -0.5)); end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(1.0 + N[(x * N[(eps$95$m * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
1 + x \cdot \left(eps\_m \cdot -0.5\right)
\end{array}
Initial program 74.6%
Simplified74.6%
Taylor expanded in x around 0
+-lowering-+.f64N/A
associate-*r/N/A
metadata-evalN/A
/-lowering-/.f6444.5%
Simplified44.5%
Taylor expanded in x around 0
+-lowering-+.f64N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
associate-*r/N/A
metadata-evalN/A
/-lowering-/.f6439.7%
Simplified39.7%
Taylor expanded in eps around inf
+-commutativeN/A
distribute-lft-inN/A
rgt-mult-inverseN/A
+-lowering-+.f64N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6452.1%
Simplified52.1%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 1.0)
eps_m = fabs(eps);
double code(double x, double eps_m) {
return 1.0;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
code = 1.0d0
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
return 1.0;
}
eps_m = math.fabs(eps) def code(x, eps_m): return 1.0
eps_m = abs(eps) function code(x, eps_m) return 1.0 end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = 1.0; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := 1.0
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
1
\end{array}
Initial program 74.6%
Simplified74.6%
Taylor expanded in x around 0
Simplified44.8%
herbie shell --seed 2024161
(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))