
(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}
(FPCore (x eps) :precision binary64 (/ (+ (exp (* x (- -1.0 eps))) (exp (* x (+ -1.0 eps)))) 2.0))
double code(double x, double eps) {
return (exp((x * (-1.0 - eps))) + exp((x * (-1.0 + eps)))) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (exp((x * ((-1.0d0) - eps))) + exp((x * ((-1.0d0) + eps)))) / 2.0d0
end function
public static double code(double x, double eps) {
return (Math.exp((x * (-1.0 - eps))) + Math.exp((x * (-1.0 + eps)))) / 2.0;
}
def code(x, eps): return (math.exp((x * (-1.0 - eps))) + math.exp((x * (-1.0 + eps)))) / 2.0
function code(x, eps) return Float64(Float64(exp(Float64(x * Float64(-1.0 - eps))) + exp(Float64(x * Float64(-1.0 + eps)))) / 2.0) end
function tmp = code(x, eps) tmp = (exp((x * (-1.0 - eps))) + exp((x * (-1.0 + eps)))) / 2.0; end
code[x_, eps_] := N[(N[(N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * N[(-1.0 + eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{x \cdot \left(-1 - \varepsilon\right)} + e^{x \cdot \left(-1 + \varepsilon\right)}}{2}
\end{array}
Initial program 76.9%
Simplified64.7%
Taylor expanded in eps around inf 99.1%
Final simplification99.1%
(FPCore (x eps) :precision binary64 (/ (+ (exp (* x (+ -1.0 eps))) (exp (* eps (- x)))) 2.0))
double code(double x, double eps) {
return (exp((x * (-1.0 + eps))) + exp((eps * -x))) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (exp((x * ((-1.0d0) + eps))) + exp((eps * -x))) / 2.0d0
end function
public static double code(double x, double eps) {
return (Math.exp((x * (-1.0 + eps))) + Math.exp((eps * -x))) / 2.0;
}
def code(x, eps): return (math.exp((x * (-1.0 + eps))) + math.exp((eps * -x))) / 2.0
function code(x, eps) return Float64(Float64(exp(Float64(x * Float64(-1.0 + eps))) + exp(Float64(eps * Float64(-x)))) / 2.0) end
function tmp = code(x, eps) tmp = (exp((x * (-1.0 + eps))) + exp((eps * -x))) / 2.0; end
code[x_, eps_] := N[(N[(N[Exp[N[(x * N[(-1.0 + eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(eps * (-x)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{x \cdot \left(-1 + \varepsilon\right)} + e^{\varepsilon \cdot \left(-x\right)}}{2}
\end{array}
Initial program 76.9%
Simplified64.7%
Taylor expanded in eps around inf 99.1%
Taylor expanded in eps around inf 88.9%
mul-1-neg88.9%
*-commutative88.9%
distribute-rgt-neg-in88.9%
Simplified88.9%
Final simplification88.9%
(FPCore (x eps) :precision binary64 (/ (* 2.0 (cosh (* x eps))) 2.0))
double code(double x, double eps) {
return (2.0 * cosh((x * eps))) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (2.0d0 * cosh((x * eps))) / 2.0d0
end function
public static double code(double x, double eps) {
return (2.0 * Math.cosh((x * eps))) / 2.0;
}
def code(x, eps): return (2.0 * math.cosh((x * eps))) / 2.0
function code(x, eps) return Float64(Float64(2.0 * cosh(Float64(x * eps))) / 2.0) end
function tmp = code(x, eps) tmp = (2.0 * cosh((x * eps))) / 2.0; end
code[x_, eps_] := N[(N[(2.0 * N[Cosh[N[(x * eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{2 \cdot \cosh \left(x \cdot \varepsilon\right)}{2}
\end{array}
Initial program 76.9%
Simplified64.7%
Taylor expanded in eps around inf 99.1%
Taylor expanded in eps around inf 88.9%
mul-1-neg88.9%
*-commutative88.9%
distribute-rgt-neg-in88.9%
Simplified88.9%
Taylor expanded in eps around inf 85.5%
*-commutative85.5%
Simplified85.5%
+-commutative85.5%
distribute-rgt-neg-out85.5%
cosh-undef85.5%
Applied egg-rr85.5%
(FPCore (x eps)
:precision binary64
(if (<= x -6e-37)
(/ (/ (- (* eps (- 2.0 (* x eps))) x) eps) 2.0)
(if (<= x 550.0)
1.0
(if (<= x 1e+164)
(/ (/ (+ (- 1.0 x) (+ -1.0 x)) eps) 2.0)
(/ (/ (+ (+ -1.0 x) (+ 1.0 (* x (+ -1.0 (* x 0.5))))) eps) 2.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -6e-37) {
tmp = (((eps * (2.0 - (x * eps))) - x) / eps) / 2.0;
} else if (x <= 550.0) {
tmp = 1.0;
} else if (x <= 1e+164) {
tmp = (((1.0 - x) + (-1.0 + x)) / eps) / 2.0;
} else {
tmp = (((-1.0 + x) + (1.0 + (x * (-1.0 + (x * 0.5))))) / 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 (x <= (-6d-37)) then
tmp = (((eps * (2.0d0 - (x * eps))) - x) / eps) / 2.0d0
else if (x <= 550.0d0) then
tmp = 1.0d0
else if (x <= 1d+164) then
tmp = (((1.0d0 - x) + ((-1.0d0) + x)) / eps) / 2.0d0
else
tmp = ((((-1.0d0) + x) + (1.0d0 + (x * ((-1.0d0) + (x * 0.5d0))))) / eps) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -6e-37) {
tmp = (((eps * (2.0 - (x * eps))) - x) / eps) / 2.0;
} else if (x <= 550.0) {
tmp = 1.0;
} else if (x <= 1e+164) {
tmp = (((1.0 - x) + (-1.0 + x)) / eps) / 2.0;
} else {
tmp = (((-1.0 + x) + (1.0 + (x * (-1.0 + (x * 0.5))))) / eps) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -6e-37: tmp = (((eps * (2.0 - (x * eps))) - x) / eps) / 2.0 elif x <= 550.0: tmp = 1.0 elif x <= 1e+164: tmp = (((1.0 - x) + (-1.0 + x)) / eps) / 2.0 else: tmp = (((-1.0 + x) + (1.0 + (x * (-1.0 + (x * 0.5))))) / eps) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -6e-37) tmp = Float64(Float64(Float64(Float64(eps * Float64(2.0 - Float64(x * eps))) - x) / eps) / 2.0); elseif (x <= 550.0) tmp = 1.0; elseif (x <= 1e+164) tmp = Float64(Float64(Float64(Float64(1.0 - x) + Float64(-1.0 + x)) / eps) / 2.0); else tmp = Float64(Float64(Float64(Float64(-1.0 + x) + Float64(1.0 + Float64(x * Float64(-1.0 + Float64(x * 0.5))))) / eps) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -6e-37) tmp = (((eps * (2.0 - (x * eps))) - x) / eps) / 2.0; elseif (x <= 550.0) tmp = 1.0; elseif (x <= 1e+164) tmp = (((1.0 - x) + (-1.0 + x)) / eps) / 2.0; else tmp = (((-1.0 + x) + (1.0 + (x * (-1.0 + (x * 0.5))))) / eps) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -6e-37], N[(N[(N[(N[(eps * N[(2.0 - N[(x * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 550.0], 1.0, If[LessEqual[x, 1e+164], N[(N[(N[(N[(1.0 - x), $MachinePrecision] + N[(-1.0 + x), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(N[(-1.0 + x), $MachinePrecision] + N[(1.0 + N[(x * N[(-1.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6 \cdot 10^{-37}:\\
\;\;\;\;\frac{\frac{\varepsilon \cdot \left(2 - x \cdot \varepsilon\right) - x}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq 550:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 10^{+164}:\\
\;\;\;\;\frac{\frac{\left(1 - x\right) + \left(-1 + x\right)}{\varepsilon}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(-1 + x\right) + \left(1 + x \cdot \left(-1 + x \cdot 0.5\right)\right)}{\varepsilon}}{2}\\
\end{array}
\end{array}
if x < -6e-37Initial program 95.2%
Simplified95.2%
Taylor expanded in x around 0 5.3%
Taylor expanded in eps around 0 28.0%
Taylor expanded in eps around inf 28.1%
mul-1-neg28.1%
Simplified28.1%
Taylor expanded in eps around 0 45.7%
if -6e-37 < x < 550Initial program 58.9%
Simplified36.4%
Taylor expanded in x around 0 72.6%
add-sqr-sqrt32.6%
sqrt-unprod45.9%
frac-times45.2%
metadata-eval45.2%
metadata-eval45.2%
frac-times45.9%
sqrt-unprod24.7%
add-sqr-sqrt49.2%
div-inv49.2%
mul-1-neg49.2%
Applied egg-rr49.2%
Taylor expanded in eps around 0 49.2%
Taylor expanded in x around 0 72.6%
if 550 < x < 1e164Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 55.3%
Taylor expanded in x around 0 1.7%
Taylor expanded in x around 0 55.3%
neg-mul-155.3%
unsub-neg55.3%
Simplified55.3%
if 1e164 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 43.8%
Taylor expanded in x around 0 2.1%
Taylor expanded in x around 0 29.2%
Final simplification58.9%
(FPCore (x eps) :precision binary64 (if (<= x -5.5e-34) (/ (/ (- (* eps (- 2.0 (* x eps))) x) eps) 2.0) (if (<= x 520.0) 1.0 (/ (/ (+ (- 1.0 x) (+ -1.0 x)) eps) 2.0))))
double code(double x, double eps) {
double tmp;
if (x <= -5.5e-34) {
tmp = (((eps * (2.0 - (x * eps))) - x) / eps) / 2.0;
} else if (x <= 520.0) {
tmp = 1.0;
} else {
tmp = (((1.0 - x) + (-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 (x <= (-5.5d-34)) then
tmp = (((eps * (2.0d0 - (x * eps))) - x) / eps) / 2.0d0
else if (x <= 520.0d0) then
tmp = 1.0d0
else
tmp = (((1.0d0 - x) + ((-1.0d0) + x)) / eps) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -5.5e-34) {
tmp = (((eps * (2.0 - (x * eps))) - x) / eps) / 2.0;
} else if (x <= 520.0) {
tmp = 1.0;
} else {
tmp = (((1.0 - x) + (-1.0 + x)) / eps) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -5.5e-34: tmp = (((eps * (2.0 - (x * eps))) - x) / eps) / 2.0 elif x <= 520.0: tmp = 1.0 else: tmp = (((1.0 - x) + (-1.0 + x)) / eps) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -5.5e-34) tmp = Float64(Float64(Float64(Float64(eps * Float64(2.0 - Float64(x * eps))) - x) / eps) / 2.0); elseif (x <= 520.0) tmp = 1.0; else tmp = Float64(Float64(Float64(Float64(1.0 - x) + Float64(-1.0 + x)) / eps) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -5.5e-34) tmp = (((eps * (2.0 - (x * eps))) - x) / eps) / 2.0; elseif (x <= 520.0) tmp = 1.0; else tmp = (((1.0 - x) + (-1.0 + x)) / eps) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -5.5e-34], N[(N[(N[(N[(eps * N[(2.0 - N[(x * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 520.0], 1.0, N[(N[(N[(N[(1.0 - x), $MachinePrecision] + N[(-1.0 + x), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.5 \cdot 10^{-34}:\\
\;\;\;\;\frac{\frac{\varepsilon \cdot \left(2 - x \cdot \varepsilon\right) - x}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq 520:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(1 - x\right) + \left(-1 + x\right)}{\varepsilon}}{2}\\
\end{array}
\end{array}
if x < -5.50000000000000014e-34Initial program 95.2%
Simplified95.2%
Taylor expanded in x around 0 5.3%
Taylor expanded in eps around 0 28.0%
Taylor expanded in eps around inf 28.1%
mul-1-neg28.1%
Simplified28.1%
Taylor expanded in eps around 0 45.7%
if -5.50000000000000014e-34 < x < 520Initial program 58.9%
Simplified36.4%
Taylor expanded in x around 0 72.6%
add-sqr-sqrt32.6%
sqrt-unprod45.9%
frac-times45.2%
metadata-eval45.2%
metadata-eval45.2%
frac-times45.9%
sqrt-unprod24.7%
add-sqr-sqrt49.2%
div-inv49.2%
mul-1-neg49.2%
Applied egg-rr49.2%
Taylor expanded in eps around 0 49.2%
Taylor expanded in x around 0 72.6%
if 520 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 48.8%
Taylor expanded in x around 0 1.9%
Taylor expanded in x around 0 48.8%
neg-mul-148.8%
unsub-neg48.8%
Simplified48.8%
Final simplification61.2%
(FPCore (x eps) :precision binary64 (if (<= x 8.5e-10) (/ (- 2.0 (* x eps)) 2.0) (/ (/ (+ (- 1.0 x) (+ -1.0 x)) eps) 2.0)))
double code(double x, double eps) {
double tmp;
if (x <= 8.5e-10) {
tmp = (2.0 - (x * eps)) / 2.0;
} else {
tmp = (((1.0 - x) + (-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 (x <= 8.5d-10) then
tmp = (2.0d0 - (x * eps)) / 2.0d0
else
tmp = (((1.0d0 - x) + ((-1.0d0) + x)) / eps) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 8.5e-10) {
tmp = (2.0 - (x * eps)) / 2.0;
} else {
tmp = (((1.0 - x) + (-1.0 + x)) / eps) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 8.5e-10: tmp = (2.0 - (x * eps)) / 2.0 else: tmp = (((1.0 - x) + (-1.0 + x)) / eps) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 8.5e-10) tmp = Float64(Float64(2.0 - Float64(x * eps)) / 2.0); else tmp = Float64(Float64(Float64(Float64(1.0 - x) + Float64(-1.0 + x)) / eps) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 8.5e-10) tmp = (2.0 - (x * eps)) / 2.0; else tmp = (((1.0 - x) + (-1.0 + x)) / eps) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 8.5e-10], N[(N[(2.0 - N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(N[(1.0 - x), $MachinePrecision] + N[(-1.0 + x), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8.5 \cdot 10^{-10}:\\
\;\;\;\;\frac{2 - x \cdot \varepsilon}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(1 - x\right) + \left(-1 + x\right)}{\varepsilon}}{2}\\
\end{array}
\end{array}
if x < 8.4999999999999996e-10Initial program 66.8%
Simplified49.2%
Taylor expanded in x around 0 57.9%
Taylor expanded in eps around 0 62.2%
Taylor expanded in eps around inf 43.6%
mul-1-neg43.6%
Simplified43.6%
Taylor expanded in eps around inf 62.2%
if 8.4999999999999996e-10 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 47.0%
Taylor expanded in x around 0 1.9%
Taylor expanded in x around 0 47.0%
neg-mul-147.0%
unsub-neg47.0%
Simplified47.0%
Final simplification57.6%
(FPCore (x eps) :precision binary64 (if (<= x 8.5e-10) (/ (- 2.0 (* x eps)) 2.0) (/ (+ 2.0 (+ (* x eps) (/ x eps))) 2.0)))
double code(double x, double eps) {
double tmp;
if (x <= 8.5e-10) {
tmp = (2.0 - (x * eps)) / 2.0;
} else {
tmp = (2.0 + ((x * eps) + (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 (x <= 8.5d-10) then
tmp = (2.0d0 - (x * eps)) / 2.0d0
else
tmp = (2.0d0 + ((x * eps) + (x / eps))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 8.5e-10) {
tmp = (2.0 - (x * eps)) / 2.0;
} else {
tmp = (2.0 + ((x * eps) + (x / eps))) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 8.5e-10: tmp = (2.0 - (x * eps)) / 2.0 else: tmp = (2.0 + ((x * eps) + (x / eps))) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 8.5e-10) tmp = Float64(Float64(2.0 - Float64(x * eps)) / 2.0); else tmp = Float64(Float64(2.0 + Float64(Float64(x * eps) + Float64(x / eps))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 8.5e-10) tmp = (2.0 - (x * eps)) / 2.0; else tmp = (2.0 + ((x * eps) + (x / eps))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 8.5e-10], N[(N[(2.0 - N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(2.0 + N[(N[(x * eps), $MachinePrecision] + N[(x / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8.5 \cdot 10^{-10}:\\
\;\;\;\;\frac{2 - x \cdot \varepsilon}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + \left(x \cdot \varepsilon + \frac{x}{\varepsilon}\right)}{2}\\
\end{array}
\end{array}
if x < 8.4999999999999996e-10Initial program 66.8%
Simplified49.2%
Taylor expanded in x around 0 57.9%
Taylor expanded in eps around 0 62.2%
Taylor expanded in eps around inf 43.6%
mul-1-neg43.6%
Simplified43.6%
Taylor expanded in eps around inf 62.2%
if 8.4999999999999996e-10 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 3.1%
Taylor expanded in eps around 0 20.0%
Taylor expanded in eps around inf 19.4%
mul-1-neg19.4%
Simplified19.4%
distribute-lft-in19.4%
add-sqr-sqrt19.0%
sqrt-unprod35.4%
sqr-neg35.4%
sqrt-unprod15.3%
add-sqr-sqrt15.7%
frac-2neg15.7%
metadata-eval15.7%
add-sqr-sqrt0.5%
sqrt-unprod15.7%
sqr-neg15.7%
sqrt-unprod15.3%
add-sqr-sqrt15.7%
div-inv15.7%
Applied egg-rr15.7%
Final simplification48.0%
(FPCore (x eps) :precision binary64 (/ (- 2.0 (* x eps)) 2.0))
double code(double x, double eps) {
return (2.0 - (x * eps)) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (2.0d0 - (x * eps)) / 2.0d0
end function
public static double code(double x, double eps) {
return (2.0 - (x * eps)) / 2.0;
}
def code(x, eps): return (2.0 - (x * eps)) / 2.0
function code(x, eps) return Float64(Float64(2.0 - Float64(x * eps)) / 2.0) end
function tmp = code(x, eps) tmp = (2.0 - (x * eps)) / 2.0; end
code[x_, eps_] := N[(N[(2.0 - N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{2 - x \cdot \varepsilon}{2}
\end{array}
Initial program 76.9%
Simplified64.7%
Taylor expanded in x around 0 41.2%
Taylor expanded in eps around 0 49.3%
Taylor expanded in eps around inf 36.3%
mul-1-neg36.3%
Simplified36.3%
Taylor expanded in eps around inf 49.3%
Final simplification49.3%
(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 76.9%
Simplified64.7%
Taylor expanded in x around 0 41.2%
add-sqr-sqrt18.3%
sqrt-unprod26.5%
frac-times26.2%
metadata-eval26.2%
metadata-eval26.2%
frac-times26.5%
sqrt-unprod14.4%
add-sqr-sqrt28.3%
div-inv28.3%
mul-1-neg28.3%
Applied egg-rr28.3%
Taylor expanded in eps around 0 28.2%
Taylor expanded in x around 0 41.2%
herbie shell --seed 2024163
(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))