
(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 9 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 0.9)
(/ (+ x 1.0) (exp x))
(-
(/
1.0
(/
(+ 0.5 (/ -0.5 eps_m))
(* (- 0.25 (/ 0.25 (* eps_m eps_m))) (exp (* x (+ eps_m -1.0))))))
(* (exp (* x (- -1.0 eps_m))) (+ -0.5 (/ 0.5 eps_m))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 0.9) {
tmp = (x + 1.0) / exp(x);
} else {
tmp = (1.0 / ((0.5 + (-0.5 / eps_m)) / ((0.25 - (0.25 / (eps_m * eps_m))) * exp((x * (eps_m + -1.0)))))) - (exp((x * (-1.0 - eps_m))) * (-0.5 + (0.5 / 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 <= 0.9d0) then
tmp = (x + 1.0d0) / exp(x)
else
tmp = (1.0d0 / ((0.5d0 + ((-0.5d0) / eps_m)) / ((0.25d0 - (0.25d0 / (eps_m * eps_m))) * exp((x * (eps_m + (-1.0d0))))))) - (exp((x * ((-1.0d0) - eps_m))) * ((-0.5d0) + (0.5d0 / 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 <= 0.9) {
tmp = (x + 1.0) / Math.exp(x);
} else {
tmp = (1.0 / ((0.5 + (-0.5 / eps_m)) / ((0.25 - (0.25 / (eps_m * eps_m))) * Math.exp((x * (eps_m + -1.0)))))) - (Math.exp((x * (-1.0 - eps_m))) * (-0.5 + (0.5 / eps_m)));
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 0.9: tmp = (x + 1.0) / math.exp(x) else: tmp = (1.0 / ((0.5 + (-0.5 / eps_m)) / ((0.25 - (0.25 / (eps_m * eps_m))) * math.exp((x * (eps_m + -1.0)))))) - (math.exp((x * (-1.0 - eps_m))) * (-0.5 + (0.5 / eps_m))) return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 0.9) tmp = Float64(Float64(x + 1.0) / exp(x)); else tmp = Float64(Float64(1.0 / Float64(Float64(0.5 + Float64(-0.5 / eps_m)) / Float64(Float64(0.25 - Float64(0.25 / Float64(eps_m * eps_m))) * exp(Float64(x * Float64(eps_m + -1.0)))))) - Float64(exp(Float64(x * Float64(-1.0 - eps_m))) * Float64(-0.5 + Float64(0.5 / eps_m)))); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (eps_m <= 0.9) tmp = (x + 1.0) / exp(x); else tmp = (1.0 / ((0.5 + (-0.5 / eps_m)) / ((0.25 - (0.25 / (eps_m * eps_m))) * exp((x * (eps_m + -1.0)))))) - (exp((x * (-1.0 - eps_m))) * (-0.5 + (0.5 / eps_m))); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 0.9], N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[(0.5 + N[(-0.5 / eps$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(0.25 - N[(0.25 / N[(eps$95$m * eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Exp[N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-0.5 + N[(0.5 / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 0.9:\\
\;\;\;\;\frac{x + 1}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{0.5 + \frac{-0.5}{eps\_m}}{\left(0.25 - \frac{0.25}{eps\_m \cdot eps\_m}\right) \cdot e^{x \cdot \left(eps\_m + -1\right)}}} - e^{x \cdot \left(-1 - eps\_m\right)} \cdot \left(-0.5 + \frac{0.5}{eps\_m}\right)\\
\end{array}
\end{array}
if eps < 0.900000000000000022Initial program 56.4%
Simplified56.4%
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--.f6476.8%
Simplified76.8%
exp-diffN/A
1-expN/A
un-div-invN/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f6476.8%
Applied egg-rr76.8%
if 0.900000000000000022 < eps Initial program 100.0%
Simplified100.0%
*-commutativeN/A
flip--N/A
associate-*l/N/A
clear-numN/A
metadata-evalN/A
/-lowering-/.f64N/A
metadata-evalN/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
Applied egg-rr100.0%
Final simplification82.9%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= eps_m 0.00047) (/ (+ x 1.0) (exp x)) (* 0.5 (+ (exp (* x (- -1.0 eps_m))) (exp (* eps_m x))))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 0.00047) {
tmp = (x + 1.0) / exp(x);
} else {
tmp = 0.5 * (exp((x * (-1.0 - eps_m))) + exp((eps_m * 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 <= 0.00047d0) then
tmp = (x + 1.0d0) / exp(x)
else
tmp = 0.5d0 * (exp((x * ((-1.0d0) - eps_m))) + exp((eps_m * 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 <= 0.00047) {
tmp = (x + 1.0) / Math.exp(x);
} else {
tmp = 0.5 * (Math.exp((x * (-1.0 - eps_m))) + Math.exp((eps_m * x)));
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 0.00047: tmp = (x + 1.0) / math.exp(x) else: tmp = 0.5 * (math.exp((x * (-1.0 - eps_m))) + math.exp((eps_m * x))) return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 0.00047) tmp = Float64(Float64(x + 1.0) / exp(x)); else tmp = Float64(0.5 * Float64(exp(Float64(x * Float64(-1.0 - eps_m))) + exp(Float64(eps_m * x)))); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (eps_m <= 0.00047) tmp = (x + 1.0) / exp(x); else tmp = 0.5 * (exp((x * (-1.0 - eps_m))) + exp((eps_m * x))); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 0.00047], 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[(eps$95$m * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 0.00047:\\
\;\;\;\;\frac{x + 1}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{x \cdot \left(-1 - eps\_m\right)} + e^{eps\_m \cdot x}\right)\\
\end{array}
\end{array}
if eps < 4.69999999999999986e-4Initial program 56.1%
Simplified56.1%
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--.f6476.6%
Simplified76.6%
exp-diffN/A
1-expN/A
un-div-invN/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f6476.7%
Applied egg-rr76.7%
if 4.69999999999999986e-4 < 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 simplification82.9%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= eps_m 0.00047)
(/ (+ x 1.0) (exp x))
(+
1.0
(* (* x 0.5) (* eps_m (* eps_m (+ x (/ (+ x -2.0) (* eps_m eps_m)))))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 0.00047) {
tmp = (x + 1.0) / exp(x);
} else {
tmp = 1.0 + ((x * 0.5) * (eps_m * (eps_m * (x + ((x + -2.0) / (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 (eps_m <= 0.00047d0) then
tmp = (x + 1.0d0) / exp(x)
else
tmp = 1.0d0 + ((x * 0.5d0) * (eps_m * (eps_m * (x + ((x + (-2.0d0)) / (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 (eps_m <= 0.00047) {
tmp = (x + 1.0) / Math.exp(x);
} else {
tmp = 1.0 + ((x * 0.5) * (eps_m * (eps_m * (x + ((x + -2.0) / (eps_m * eps_m))))));
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 0.00047: tmp = (x + 1.0) / math.exp(x) else: tmp = 1.0 + ((x * 0.5) * (eps_m * (eps_m * (x + ((x + -2.0) / (eps_m * eps_m)))))) return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 0.00047) tmp = Float64(Float64(x + 1.0) / exp(x)); else tmp = Float64(1.0 + Float64(Float64(x * 0.5) * Float64(eps_m * Float64(eps_m * Float64(x + Float64(Float64(x + -2.0) / Float64(eps_m * eps_m))))))); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (eps_m <= 0.00047) tmp = (x + 1.0) / exp(x); else tmp = 1.0 + ((x * 0.5) * (eps_m * (eps_m * (x + ((x + -2.0) / (eps_m * eps_m)))))); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 0.00047], N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(x * 0.5), $MachinePrecision] * N[(eps$95$m * N[(eps$95$m * N[(x + N[(N[(x + -2.0), $MachinePrecision] / N[(eps$95$m * eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 0.00047:\\
\;\;\;\;\frac{x + 1}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;1 + \left(x \cdot 0.5\right) \cdot \left(eps\_m \cdot \left(eps\_m \cdot \left(x + \frac{x + -2}{eps\_m \cdot eps\_m}\right)\right)\right)\\
\end{array}
\end{array}
if eps < 4.69999999999999986e-4Initial program 56.1%
Simplified56.1%
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--.f6476.6%
Simplified76.6%
exp-diffN/A
1-expN/A
un-div-invN/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f6476.7%
Applied egg-rr76.7%
if 4.69999999999999986e-4 < 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 x around 0
+-lowering-+.f64N/A
distribute-lft-outN/A
associate-+r-N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
+-commutativeN/A
Simplified90.1%
Taylor expanded in eps around inf
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
associate--l+N/A
associate-*r/N/A
metadata-evalN/A
div-subN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
sub-negN/A
+-lowering-+.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f6484.5%
Simplified84.5%
Final simplification78.7%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= eps_m 0.00047)
(exp (- 0.0 x))
(+
1.0
(* (* x 0.5) (* eps_m (* eps_m (+ x (/ (+ x -2.0) (* eps_m eps_m)))))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 0.00047) {
tmp = exp((0.0 - x));
} else {
tmp = 1.0 + ((x * 0.5) * (eps_m * (eps_m * (x + ((x + -2.0) / (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 (eps_m <= 0.00047d0) then
tmp = exp((0.0d0 - x))
else
tmp = 1.0d0 + ((x * 0.5d0) * (eps_m * (eps_m * (x + ((x + (-2.0d0)) / (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 (eps_m <= 0.00047) {
tmp = Math.exp((0.0 - x));
} else {
tmp = 1.0 + ((x * 0.5) * (eps_m * (eps_m * (x + ((x + -2.0) / (eps_m * eps_m))))));
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 0.00047: tmp = math.exp((0.0 - x)) else: tmp = 1.0 + ((x * 0.5) * (eps_m * (eps_m * (x + ((x + -2.0) / (eps_m * eps_m)))))) return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 0.00047) tmp = exp(Float64(0.0 - x)); else tmp = Float64(1.0 + Float64(Float64(x * 0.5) * Float64(eps_m * Float64(eps_m * Float64(x + Float64(Float64(x + -2.0) / Float64(eps_m * eps_m))))))); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (eps_m <= 0.00047) tmp = exp((0.0 - x)); else tmp = 1.0 + ((x * 0.5) * (eps_m * (eps_m * (x + ((x + -2.0) / (eps_m * eps_m)))))); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 0.00047], N[Exp[N[(0.0 - x), $MachinePrecision]], $MachinePrecision], N[(1.0 + N[(N[(x * 0.5), $MachinePrecision] * N[(eps$95$m * N[(eps$95$m * N[(x + N[(N[(x + -2.0), $MachinePrecision] / N[(eps$95$m * eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 0.00047:\\
\;\;\;\;e^{0 - x}\\
\mathbf{else}:\\
\;\;\;\;1 + \left(x \cdot 0.5\right) \cdot \left(eps\_m \cdot \left(eps\_m \cdot \left(x + \frac{x + -2}{eps\_m \cdot eps\_m}\right)\right)\right)\\
\end{array}
\end{array}
if eps < 4.69999999999999986e-4Initial program 56.1%
Simplified56.1%
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--.f6497.3%
Simplified97.3%
Taylor expanded in eps around 0
exp-lowering-exp.f64N/A
neg-mul-1N/A
neg-sub0N/A
--lowering--.f6482.5%
Simplified82.5%
if 4.69999999999999986e-4 < 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 x around 0
+-lowering-+.f64N/A
distribute-lft-outN/A
associate-+r-N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
+-commutativeN/A
Simplified90.1%
Taylor expanded in eps around inf
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
associate--l+N/A
associate-*r/N/A
metadata-evalN/A
div-subN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
sub-negN/A
+-lowering-+.f64N/A
metadata-evalN/A
unpow2N/A
*-lowering-*.f6484.5%
Simplified84.5%
Final simplification83.1%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (let* ((t_0 (* 0.5 (* x (* x (* eps_m eps_m)))))) (if (<= x -6.7e-12) t_0 (if (<= x 4.4e-11) 1.0 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 <= -6.7e-12) {
tmp = t_0;
} else if (x <= 4.4e-11) {
tmp = 1.0;
} 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 <= (-6.7d-12)) then
tmp = t_0
else if (x <= 4.4d-11) then
tmp = 1.0d0
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 <= -6.7e-12) {
tmp = t_0;
} else if (x <= 4.4e-11) {
tmp = 1.0;
} 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 <= -6.7e-12: tmp = t_0 elif x <= 4.4e-11: tmp = 1.0 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 <= -6.7e-12) tmp = t_0; elseif (x <= 4.4e-11) tmp = 1.0; 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 <= -6.7e-12) tmp = t_0; elseif (x <= 4.4e-11) tmp = 1.0; 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, -6.7e-12], t$95$0, If[LessEqual[x, 4.4e-11], 1.0, 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 -6.7 \cdot 10^{-12}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4.4 \cdot 10^{-11}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -6.7000000000000001e-12 or 4.4000000000000003e-11 < x Initial program 95.1%
Simplified95.1%
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--.f6495.9%
Simplified95.9%
Taylor expanded in x around 0
+-lowering-+.f64N/A
distribute-lft-outN/A
associate-+r-N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
+-commutativeN/A
Simplified60.9%
Taylor expanded in eps 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-*.f6473.4%
Simplified73.4%
if -6.7000000000000001e-12 < x < 4.4000000000000003e-11Initial program 43.7%
Simplified43.7%
Taylor expanded in x around 0
Simplified84.8%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (let* ((t_0 (* x (* eps_m eps_m)))) (if (<= x 310.0) (+ 1.0 (* (* x 0.5) t_0)) (* 0.5 (* x t_0)))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = x * (eps_m * eps_m);
double tmp;
if (x <= 310.0) {
tmp = 1.0 + ((x * 0.5) * t_0);
} else {
tmp = 0.5 * (x * 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 = x * (eps_m * eps_m)
if (x <= 310.0d0) then
tmp = 1.0d0 + ((x * 0.5d0) * t_0)
else
tmp = 0.5d0 * (x * 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 = x * (eps_m * eps_m);
double tmp;
if (x <= 310.0) {
tmp = 1.0 + ((x * 0.5) * t_0);
} else {
tmp = 0.5 * (x * t_0);
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = x * (eps_m * eps_m) tmp = 0 if x <= 310.0: tmp = 1.0 + ((x * 0.5) * t_0) else: tmp = 0.5 * (x * t_0) return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(x * Float64(eps_m * eps_m)) tmp = 0.0 if (x <= 310.0) tmp = Float64(1.0 + Float64(Float64(x * 0.5) * t_0)); else tmp = Float64(0.5 * Float64(x * t_0)); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = x * (eps_m * eps_m); tmp = 0.0; if (x <= 310.0) tmp = 1.0 + ((x * 0.5) * t_0); else tmp = 0.5 * (x * t_0); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[(x * N[(eps$95$m * eps$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 310.0], N[(1.0 + N[(N[(x * 0.5), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(x * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := x \cdot \left(eps\_m \cdot eps\_m\right)\\
\mathbf{if}\;x \leq 310:\\
\;\;\;\;1 + \left(x \cdot 0.5\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x \cdot t\_0\right)\\
\end{array}
\end{array}
if x < 310Initial program 55.4%
Simplified55.4%
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--.f6497.3%
Simplified97.3%
Taylor expanded in x around 0
+-lowering-+.f64N/A
distribute-lft-outN/A
associate-+r-N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
+-commutativeN/A
Simplified89.5%
Taylor expanded in eps around inf
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6489.8%
Simplified89.8%
if 310 < x 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 x around 0
+-lowering-+.f64N/A
distribute-lft-outN/A
associate-+r-N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
+-commutativeN/A
Simplified44.9%
Taylor expanded in eps 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-*.f6467.3%
Simplified67.3%
Final simplification83.5%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 0.75) (- 1.0 x) (* x (* 0.5 (* x x)))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 0.75) {
tmp = 1.0 - x;
} else {
tmp = x * (0.5 * (x * 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 (x <= 0.75d0) then
tmp = 1.0d0 - x
else
tmp = x * (0.5d0 * (x * x))
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.75) {
tmp = 1.0 - x;
} else {
tmp = x * (0.5 * (x * x));
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 0.75: tmp = 1.0 - x else: tmp = x * (0.5 * (x * x)) return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 0.75) tmp = Float64(1.0 - x); else tmp = Float64(x * Float64(0.5 * Float64(x * x))); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 0.75) tmp = 1.0 - x; else tmp = x * (0.5 * (x * x)); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 0.75], N[(1.0 - x), $MachinePrecision], N[(x * N[(0.5 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.75:\\
\;\;\;\;1 - x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(0.5 \cdot \left(x \cdot x\right)\right)\\
\end{array}
\end{array}
if x < 0.75Initial program 55.7%
Simplified55.7%
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--.f6497.8%
Simplified97.8%
Taylor expanded in x around 0
+-lowering-+.f64N/A
distribute-lft-outN/A
associate-+r-N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
+-commutativeN/A
Simplified89.9%
Taylor expanded in x around 0
mul-1-negN/A
unsub-negN/A
--lowering--.f6464.3%
Simplified64.3%
if 0.75 < x Initial program 98.7%
Simplified98.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--.f6456.3%
Simplified56.3%
Taylor expanded in x around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-lowering-+.f64N/A
*-lowering-*.f6436.4%
Simplified36.4%
Taylor expanded in x around inf
*-commutativeN/A
cube-multN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6436.4%
Simplified36.4%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 2.95e-8) (- 1.0 x) (* 0.5 (* eps_m x))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 2.95e-8) {
tmp = 1.0 - x;
} else {
tmp = 0.5 * (eps_m * 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 (x <= 2.95d-8) then
tmp = 1.0d0 - x
else
tmp = 0.5d0 * (eps_m * x)
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= 2.95e-8) {
tmp = 1.0 - x;
} else {
tmp = 0.5 * (eps_m * x);
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 2.95e-8: tmp = 1.0 - x else: tmp = 0.5 * (eps_m * x) return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 2.95e-8) tmp = Float64(1.0 - x); else tmp = Float64(0.5 * Float64(eps_m * x)); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 2.95e-8) tmp = 1.0 - x; else tmp = 0.5 * (eps_m * x); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 2.95e-8], N[(1.0 - x), $MachinePrecision], N[(0.5 * N[(eps$95$m * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.95 \cdot 10^{-8}:\\
\;\;\;\;1 - x\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(eps\_m \cdot x\right)\\
\end{array}
\end{array}
if x < 2.9499999999999999e-8Initial program 55.2%
Simplified55.2%
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--.f6497.7%
Simplified97.7%
Taylor expanded in x around 0
+-lowering-+.f64N/A
distribute-lft-outN/A
associate-+r-N/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
+-commutativeN/A
Simplified89.8%
Taylor expanded in x around 0
mul-1-negN/A
unsub-negN/A
--lowering--.f6465.0%
Simplified65.0%
if 2.9499999999999999e-8 < x Initial program 98.7%
Simplified98.7%
Taylor expanded in x around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-lowering-+.f6422.1%
Simplified22.1%
Taylor expanded in eps around inf
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6413.5%
Simplified13.5%
Final simplification50.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 67.8%
Simplified67.8%
Taylor expanded in x around 0
Simplified47.0%
herbie shell --seed 2024144
(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))