(FPCore (x eps) :precision binary64 (- (pow (+ x eps) 5.0) (pow x 5.0)))
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (* eps (* 10.0 eps)) (* x (+ x eps)))))
(if (<= x -7.6e-54)
(*
x
(+ (* 10.0 (* (pow eps 2.0) (pow x 2.0))) (* eps (* 5.0 (pow x 3.0)))))
(if (<= x 4e-47)
(+ (pow eps 5.0) (* x (+ (* 5.0 (pow eps 4.0)) t_0)))
(* x (+ t_0 (* (pow x 3.0) (* eps 5.0))))))))double code(double x, double eps) {
return pow((x + eps), 5.0) - pow(x, 5.0);
}
double code(double x, double eps) {
double t_0 = (eps * (10.0 * eps)) * (x * (x + eps));
double tmp;
if (x <= -7.6e-54) {
tmp = x * ((10.0 * (pow(eps, 2.0) * pow(x, 2.0))) + (eps * (5.0 * pow(x, 3.0))));
} else if (x <= 4e-47) {
tmp = pow(eps, 5.0) + (x * ((5.0 * pow(eps, 4.0)) + t_0));
} else {
tmp = x * (t_0 + (pow(x, 3.0) * (eps * 5.0)));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = ((x + eps) ** 5.0d0) - (x ** 5.0d0)
end function
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 = (eps * (10.0d0 * eps)) * (x * (x + eps))
if (x <= (-7.6d-54)) then
tmp = x * ((10.0d0 * ((eps ** 2.0d0) * (x ** 2.0d0))) + (eps * (5.0d0 * (x ** 3.0d0))))
else if (x <= 4d-47) then
tmp = (eps ** 5.0d0) + (x * ((5.0d0 * (eps ** 4.0d0)) + t_0))
else
tmp = x * (t_0 + ((x ** 3.0d0) * (eps * 5.0d0)))
end if
code = tmp
end function
public static double code(double x, double eps) {
return Math.pow((x + eps), 5.0) - Math.pow(x, 5.0);
}
public static double code(double x, double eps) {
double t_0 = (eps * (10.0 * eps)) * (x * (x + eps));
double tmp;
if (x <= -7.6e-54) {
tmp = x * ((10.0 * (Math.pow(eps, 2.0) * Math.pow(x, 2.0))) + (eps * (5.0 * Math.pow(x, 3.0))));
} else if (x <= 4e-47) {
tmp = Math.pow(eps, 5.0) + (x * ((5.0 * Math.pow(eps, 4.0)) + t_0));
} else {
tmp = x * (t_0 + (Math.pow(x, 3.0) * (eps * 5.0)));
}
return tmp;
}
def code(x, eps): return math.pow((x + eps), 5.0) - math.pow(x, 5.0)
def code(x, eps): t_0 = (eps * (10.0 * eps)) * (x * (x + eps)) tmp = 0 if x <= -7.6e-54: tmp = x * ((10.0 * (math.pow(eps, 2.0) * math.pow(x, 2.0))) + (eps * (5.0 * math.pow(x, 3.0)))) elif x <= 4e-47: tmp = math.pow(eps, 5.0) + (x * ((5.0 * math.pow(eps, 4.0)) + t_0)) else: tmp = x * (t_0 + (math.pow(x, 3.0) * (eps * 5.0))) return tmp
function code(x, eps) return Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0)) end
function code(x, eps) t_0 = Float64(Float64(eps * Float64(10.0 * eps)) * Float64(x * Float64(x + eps))) tmp = 0.0 if (x <= -7.6e-54) tmp = Float64(x * Float64(Float64(10.0 * Float64((eps ^ 2.0) * (x ^ 2.0))) + Float64(eps * Float64(5.0 * (x ^ 3.0))))); elseif (x <= 4e-47) tmp = Float64((eps ^ 5.0) + Float64(x * Float64(Float64(5.0 * (eps ^ 4.0)) + t_0))); else tmp = Float64(x * Float64(t_0 + Float64((x ^ 3.0) * Float64(eps * 5.0)))); end return tmp end
function tmp = code(x, eps) tmp = ((x + eps) ^ 5.0) - (x ^ 5.0); end
function tmp_2 = code(x, eps) t_0 = (eps * (10.0 * eps)) * (x * (x + eps)); tmp = 0.0; if (x <= -7.6e-54) tmp = x * ((10.0 * ((eps ^ 2.0) * (x ^ 2.0))) + (eps * (5.0 * (x ^ 3.0)))); elseif (x <= 4e-47) tmp = (eps ^ 5.0) + (x * ((5.0 * (eps ^ 4.0)) + t_0)); else tmp = x * (t_0 + ((x ^ 3.0) * (eps * 5.0))); end tmp_2 = tmp; end
code[x_, eps_] := N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]
code[x_, eps_] := Block[{t$95$0 = N[(N[(eps * N[(10.0 * eps), $MachinePrecision]), $MachinePrecision] * N[(x * N[(x + eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -7.6e-54], N[(x * N[(N[(10.0 * N[(N[Power[eps, 2.0], $MachinePrecision] * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(eps * N[(5.0 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4e-47], N[(N[Power[eps, 5.0], $MachinePrecision] + N[(x * N[(N[(5.0 * N[Power[eps, 4.0], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(t$95$0 + N[(N[Power[x, 3.0], $MachinePrecision] * N[(eps * 5.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
{\left(x + \varepsilon\right)}^{5} - {x}^{5}
\begin{array}{l}
t_0 := \left(\varepsilon \cdot \left(10 \cdot \varepsilon\right)\right) \cdot \left(x \cdot \left(x + \varepsilon\right)\right)\\
\mathbf{if}\;x \leq -7.6 \cdot 10^{-54}:\\
\;\;\;\;x \cdot \left(10 \cdot \left({\varepsilon}^{2} \cdot {x}^{2}\right) + \varepsilon \cdot \left(5 \cdot {x}^{3}\right)\right)\\
\mathbf{elif}\;x \leq 4 \cdot 10^{-47}:\\
\;\;\;\;{\varepsilon}^{5} + x \cdot \left(5 \cdot {\varepsilon}^{4} + t_0\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(t_0 + {x}^{3} \cdot \left(\varepsilon \cdot 5\right)\right)\\
\end{array}



Bits error versus x



Bits error versus eps
Results
if x < -7.6000000000000005e-54Initial program 37.3
Taylor expanded in x around inf 4.5
Simplified4.4
Taylor expanded in eps around 0 4.5
Simplified4.5
Taylor expanded in eps around 0 4.9
if -7.6000000000000005e-54 < x < 3.9999999999999999e-47Initial program 0.2
Taylor expanded in x around 0 0.3
Simplified0.3
if 3.9999999999999999e-47 < x Initial program 40.0
Taylor expanded in x around inf 5.1
Simplified5.1
Taylor expanded in eps around 0 5.1
Simplified5.2
Taylor expanded in eps around 0 5.1
Simplified5.1
Final simplification1.2
herbie shell --seed 2022166
(FPCore (x eps)
:name "ENA, Section 1.4, Exercise 4b, n=5"
:precision binary64
:pre (and (and (<= -1000000000.0 x) (<= x 1000000000.0)) (and (<= -1.0 eps) (<= eps 1.0)))
(- (pow (+ x eps) 5.0) (pow x 5.0)))