
(FPCore (x eps) :precision binary64 (- (pow (+ x eps) 5.0) (pow x 5.0)))
double code(double x, double eps) {
return pow((x + eps), 5.0) - pow(x, 5.0);
}
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
public static double code(double x, double eps) {
return Math.pow((x + eps), 5.0) - Math.pow(x, 5.0);
}
def code(x, eps): return math.pow((x + eps), 5.0) - math.pow(x, 5.0)
function code(x, eps) return Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0)) end
function tmp = code(x, eps) tmp = ((x + eps) ^ 5.0) - (x ^ 5.0); end
code[x_, eps_] := N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + \varepsilon\right)}^{5} - {x}^{5}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (- (pow (+ x eps) 5.0) (pow x 5.0)))
double code(double x, double eps) {
return pow((x + eps), 5.0) - pow(x, 5.0);
}
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
public static double code(double x, double eps) {
return Math.pow((x + eps), 5.0) - Math.pow(x, 5.0);
}
def code(x, eps): return math.pow((x + eps), 5.0) - math.pow(x, 5.0)
function code(x, eps) return Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0)) end
function tmp = code(x, eps) tmp = ((x + eps) ^ 5.0) - (x ^ 5.0); end
code[x_, eps_] := N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + \varepsilon\right)}^{5} - {x}^{5}
\end{array}
(FPCore (x eps)
:precision binary64
(if (<= x -1e-48)
(* (pow x 4.0) (* eps (+ 5.0 (* 10.0 (/ eps x)))))
(if (<= x 1.45e-39)
(- (pow (+ x eps) 5.0) (pow x 5.0))
(* (pow x 4.0) (- (* eps 5.0) (/ (* (pow eps 2.0) -10.0) x))))))
double code(double x, double eps) {
double tmp;
if (x <= -1e-48) {
tmp = pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x))));
} else if (x <= 1.45e-39) {
tmp = pow((x + eps), 5.0) - pow(x, 5.0);
} else {
tmp = pow(x, 4.0) * ((eps * 5.0) - ((pow(eps, 2.0) * -10.0) / x));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-1d-48)) then
tmp = (x ** 4.0d0) * (eps * (5.0d0 + (10.0d0 * (eps / x))))
else if (x <= 1.45d-39) then
tmp = ((x + eps) ** 5.0d0) - (x ** 5.0d0)
else
tmp = (x ** 4.0d0) * ((eps * 5.0d0) - (((eps ** 2.0d0) * (-10.0d0)) / x))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -1e-48) {
tmp = Math.pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x))));
} else if (x <= 1.45e-39) {
tmp = Math.pow((x + eps), 5.0) - Math.pow(x, 5.0);
} else {
tmp = Math.pow(x, 4.0) * ((eps * 5.0) - ((Math.pow(eps, 2.0) * -10.0) / x));
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -1e-48: tmp = math.pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x)))) elif x <= 1.45e-39: tmp = math.pow((x + eps), 5.0) - math.pow(x, 5.0) else: tmp = math.pow(x, 4.0) * ((eps * 5.0) - ((math.pow(eps, 2.0) * -10.0) / x)) return tmp
function code(x, eps) tmp = 0.0 if (x <= -1e-48) tmp = Float64((x ^ 4.0) * Float64(eps * Float64(5.0 + Float64(10.0 * Float64(eps / x))))); elseif (x <= 1.45e-39) tmp = Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0)); else tmp = Float64((x ^ 4.0) * Float64(Float64(eps * 5.0) - Float64(Float64((eps ^ 2.0) * -10.0) / x))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -1e-48) tmp = (x ^ 4.0) * (eps * (5.0 + (10.0 * (eps / x)))); elseif (x <= 1.45e-39) tmp = ((x + eps) ^ 5.0) - (x ^ 5.0); else tmp = (x ^ 4.0) * ((eps * 5.0) - (((eps ^ 2.0) * -10.0) / x)); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -1e-48], N[(N[Power[x, 4.0], $MachinePrecision] * N[(eps * N[(5.0 + N[(10.0 * N[(eps / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.45e-39], N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision], N[(N[Power[x, 4.0], $MachinePrecision] * N[(N[(eps * 5.0), $MachinePrecision] - N[(N[(N[Power[eps, 2.0], $MachinePrecision] * -10.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-48}:\\
\;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot \left(5 + 10 \cdot \frac{\varepsilon}{x}\right)\right)\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-39}:\\
\;\;\;\;{\left(x + \varepsilon\right)}^{5} - {x}^{5}\\
\mathbf{else}:\\
\;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot 5 - \frac{{\varepsilon}^{2} \cdot -10}{x}\right)\\
\end{array}
\end{array}
if x < -9.9999999999999997e-49Initial program 24.9%
Taylor expanded in x around -inf 97.6%
+-commutative97.6%
associate-+r+97.6%
mul-1-neg97.6%
unsub-neg97.6%
distribute-rgt1-in97.6%
metadata-eval97.6%
*-commutative97.6%
Simplified97.6%
Taylor expanded in eps around 0 97.7%
if -9.9999999999999997e-49 < x < 1.44999999999999994e-39Initial program 100.0%
if 1.44999999999999994e-39 < x Initial program 48.1%
Taylor expanded in x around -inf 99.8%
+-commutative99.8%
associate-+r+99.8%
mul-1-neg99.8%
unsub-neg99.8%
distribute-rgt1-in99.8%
metadata-eval99.8%
*-commutative99.8%
Simplified99.8%
(FPCore (x eps) :precision binary64 (if (or (<= x -8.2e-47) (not (<= x 1.1e-41))) (* (pow x 4.0) (* eps (+ 5.0 (* 10.0 (/ eps x))))) (- (pow (+ x eps) 5.0) (pow x 5.0))))
double code(double x, double eps) {
double tmp;
if ((x <= -8.2e-47) || !(x <= 1.1e-41)) {
tmp = pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x))));
} else {
tmp = pow((x + eps), 5.0) - pow(x, 5.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.2d-47)) .or. (.not. (x <= 1.1d-41))) then
tmp = (x ** 4.0d0) * (eps * (5.0d0 + (10.0d0 * (eps / x))))
else
tmp = ((x + eps) ** 5.0d0) - (x ** 5.0d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -8.2e-47) || !(x <= 1.1e-41)) {
tmp = Math.pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x))));
} else {
tmp = Math.pow((x + eps), 5.0) - Math.pow(x, 5.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -8.2e-47) or not (x <= 1.1e-41): tmp = math.pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x)))) else: tmp = math.pow((x + eps), 5.0) - math.pow(x, 5.0) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -8.2e-47) || !(x <= 1.1e-41)) tmp = Float64((x ^ 4.0) * Float64(eps * Float64(5.0 + Float64(10.0 * Float64(eps / x))))); else tmp = Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -8.2e-47) || ~((x <= 1.1e-41))) tmp = (x ^ 4.0) * (eps * (5.0 + (10.0 * (eps / x)))); else tmp = ((x + eps) ^ 5.0) - (x ^ 5.0); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -8.2e-47], N[Not[LessEqual[x, 1.1e-41]], $MachinePrecision]], N[(N[Power[x, 4.0], $MachinePrecision] * N[(eps * N[(5.0 + N[(10.0 * N[(eps / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.2 \cdot 10^{-47} \lor \neg \left(x \leq 1.1 \cdot 10^{-41}\right):\\
\;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot \left(5 + 10 \cdot \frac{\varepsilon}{x}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(x + \varepsilon\right)}^{5} - {x}^{5}\\
\end{array}
\end{array}
if x < -8.20000000000000003e-47 or 1.1e-41 < x Initial program 34.5%
Taylor expanded in x around -inf 98.5%
+-commutative98.5%
associate-+r+98.5%
mul-1-neg98.5%
unsub-neg98.5%
distribute-rgt1-in98.5%
metadata-eval98.5%
*-commutative98.5%
Simplified98.5%
Taylor expanded in eps around 0 98.5%
if -8.20000000000000003e-47 < x < 1.1e-41Initial program 100.0%
Final simplification99.7%
(FPCore (x eps) :precision binary64 (if (or (<= x -2e-47) (not (<= x 2.4e-46))) (* (pow x 4.0) (* eps (+ 5.0 (* 10.0 (/ eps x))))) (* (pow eps 5.0) (+ 1.0 (* 5.0 (/ x eps))))))
double code(double x, double eps) {
double tmp;
if ((x <= -2e-47) || !(x <= 2.4e-46)) {
tmp = pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x))));
} else {
tmp = pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((x <= (-2d-47)) .or. (.not. (x <= 2.4d-46))) then
tmp = (x ** 4.0d0) * (eps * (5.0d0 + (10.0d0 * (eps / x))))
else
tmp = (eps ** 5.0d0) * (1.0d0 + (5.0d0 * (x / eps)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -2e-47) || !(x <= 2.4e-46)) {
tmp = Math.pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x))));
} else {
tmp = Math.pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -2e-47) or not (x <= 2.4e-46): tmp = math.pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x)))) else: tmp = math.pow(eps, 5.0) * (1.0 + (5.0 * (x / eps))) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -2e-47) || !(x <= 2.4e-46)) tmp = Float64((x ^ 4.0) * Float64(eps * Float64(5.0 + Float64(10.0 * Float64(eps / x))))); else tmp = Float64((eps ^ 5.0) * Float64(1.0 + Float64(5.0 * Float64(x / eps)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -2e-47) || ~((x <= 2.4e-46))) tmp = (x ^ 4.0) * (eps * (5.0 + (10.0 * (eps / x)))); else tmp = (eps ^ 5.0) * (1.0 + (5.0 * (x / eps))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -2e-47], N[Not[LessEqual[x, 2.4e-46]], $MachinePrecision]], N[(N[Power[x, 4.0], $MachinePrecision] * N[(eps * N[(5.0 + N[(10.0 * N[(eps / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[eps, 5.0], $MachinePrecision] * N[(1.0 + N[(5.0 * N[(x / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-47} \lor \neg \left(x \leq 2.4 \cdot 10^{-46}\right):\\
\;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot \left(5 + 10 \cdot \frac{\varepsilon}{x}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5} \cdot \left(1 + 5 \cdot \frac{x}{\varepsilon}\right)\\
\end{array}
\end{array}
if x < -1.9999999999999999e-47 or 2.40000000000000013e-46 < x Initial program 37.2%
Taylor expanded in x around -inf 97.3%
+-commutative97.3%
associate-+r+97.3%
mul-1-neg97.3%
unsub-neg97.3%
distribute-rgt1-in97.3%
metadata-eval97.3%
*-commutative97.3%
Simplified97.3%
Taylor expanded in eps around 0 97.3%
if -1.9999999999999999e-47 < x < 2.40000000000000013e-46Initial program 100.0%
Taylor expanded in eps around inf 100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification99.5%
(FPCore (x eps) :precision binary64 (if (or (<= x -8e-48) (not (<= x 6.2e-47))) (* (pow x 4.0) (* eps 5.0)) (* (pow eps 5.0) (+ 1.0 (* 5.0 (/ x eps))))))
double code(double x, double eps) {
double tmp;
if ((x <= -8e-48) || !(x <= 6.2e-47)) {
tmp = pow(x, 4.0) * (eps * 5.0);
} else {
tmp = pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((x <= (-8d-48)) .or. (.not. (x <= 6.2d-47))) then
tmp = (x ** 4.0d0) * (eps * 5.0d0)
else
tmp = (eps ** 5.0d0) * (1.0d0 + (5.0d0 * (x / eps)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -8e-48) || !(x <= 6.2e-47)) {
tmp = Math.pow(x, 4.0) * (eps * 5.0);
} else {
tmp = Math.pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -8e-48) or not (x <= 6.2e-47): tmp = math.pow(x, 4.0) * (eps * 5.0) else: tmp = math.pow(eps, 5.0) * (1.0 + (5.0 * (x / eps))) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -8e-48) || !(x <= 6.2e-47)) tmp = Float64((x ^ 4.0) * Float64(eps * 5.0)); else tmp = Float64((eps ^ 5.0) * Float64(1.0 + Float64(5.0 * Float64(x / eps)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -8e-48) || ~((x <= 6.2e-47))) tmp = (x ^ 4.0) * (eps * 5.0); else tmp = (eps ^ 5.0) * (1.0 + (5.0 * (x / eps))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -8e-48], N[Not[LessEqual[x, 6.2e-47]], $MachinePrecision]], N[(N[Power[x, 4.0], $MachinePrecision] * N[(eps * 5.0), $MachinePrecision]), $MachinePrecision], N[(N[Power[eps, 5.0], $MachinePrecision] * N[(1.0 + N[(5.0 * N[(x / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8 \cdot 10^{-48} \lor \neg \left(x \leq 6.2 \cdot 10^{-47}\right):\\
\;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot 5\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5} \cdot \left(1 + 5 \cdot \frac{x}{\varepsilon}\right)\\
\end{array}
\end{array}
if x < -7.9999999999999998e-48 or 6.1999999999999996e-47 < x Initial program 37.2%
Taylor expanded in x around inf 95.8%
distribute-rgt1-in95.8%
metadata-eval95.8%
Simplified95.8%
if -7.9999999999999998e-48 < x < 6.1999999999999996e-47Initial program 100.0%
Taylor expanded in eps around inf 100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification99.2%
(FPCore (x eps) :precision binary64 (if (or (<= x -6.5e-49) (not (<= x 4.5e-47))) (* (pow x 4.0) (* eps 5.0)) (* (pow eps 4.0) (+ eps (* x 5.0)))))
double code(double x, double eps) {
double tmp;
if ((x <= -6.5e-49) || !(x <= 4.5e-47)) {
tmp = pow(x, 4.0) * (eps * 5.0);
} else {
tmp = pow(eps, 4.0) * (eps + (x * 5.0));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((x <= (-6.5d-49)) .or. (.not. (x <= 4.5d-47))) then
tmp = (x ** 4.0d0) * (eps * 5.0d0)
else
tmp = (eps ** 4.0d0) * (eps + (x * 5.0d0))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -6.5e-49) || !(x <= 4.5e-47)) {
tmp = Math.pow(x, 4.0) * (eps * 5.0);
} else {
tmp = Math.pow(eps, 4.0) * (eps + (x * 5.0));
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -6.5e-49) or not (x <= 4.5e-47): tmp = math.pow(x, 4.0) * (eps * 5.0) else: tmp = math.pow(eps, 4.0) * (eps + (x * 5.0)) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -6.5e-49) || !(x <= 4.5e-47)) tmp = Float64((x ^ 4.0) * Float64(eps * 5.0)); else tmp = Float64((eps ^ 4.0) * Float64(eps + Float64(x * 5.0))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -6.5e-49) || ~((x <= 4.5e-47))) tmp = (x ^ 4.0) * (eps * 5.0); else tmp = (eps ^ 4.0) * (eps + (x * 5.0)); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -6.5e-49], N[Not[LessEqual[x, 4.5e-47]], $MachinePrecision]], N[(N[Power[x, 4.0], $MachinePrecision] * N[(eps * 5.0), $MachinePrecision]), $MachinePrecision], N[(N[Power[eps, 4.0], $MachinePrecision] * N[(eps + N[(x * 5.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.5 \cdot 10^{-49} \lor \neg \left(x \leq 4.5 \cdot 10^{-47}\right):\\
\;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot 5\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\
\end{array}
\end{array}
if x < -6.49999999999999968e-49 or 4.5e-47 < x Initial program 37.2%
Taylor expanded in x around inf 95.8%
distribute-rgt1-in95.8%
metadata-eval95.8%
Simplified95.8%
if -6.49999999999999968e-49 < x < 4.5e-47Initial program 100.0%
Taylor expanded in eps around inf 100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in eps around 0 100.0%
Final simplification99.2%
(FPCore (x eps) :precision binary64 (if (or (<= x -1.9e-48) (not (<= x 5e-47))) (* (pow x 4.0) (* eps 5.0)) (pow eps 5.0)))
double code(double x, double eps) {
double tmp;
if ((x <= -1.9e-48) || !(x <= 5e-47)) {
tmp = pow(x, 4.0) * (eps * 5.0);
} else {
tmp = pow(eps, 5.0);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((x <= (-1.9d-48)) .or. (.not. (x <= 5d-47))) then
tmp = (x ** 4.0d0) * (eps * 5.0d0)
else
tmp = eps ** 5.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -1.9e-48) || !(x <= 5e-47)) {
tmp = Math.pow(x, 4.0) * (eps * 5.0);
} else {
tmp = Math.pow(eps, 5.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -1.9e-48) or not (x <= 5e-47): tmp = math.pow(x, 4.0) * (eps * 5.0) else: tmp = math.pow(eps, 5.0) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -1.9e-48) || !(x <= 5e-47)) tmp = Float64((x ^ 4.0) * Float64(eps * 5.0)); else tmp = eps ^ 5.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -1.9e-48) || ~((x <= 5e-47))) tmp = (x ^ 4.0) * (eps * 5.0); else tmp = eps ^ 5.0; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -1.9e-48], N[Not[LessEqual[x, 5e-47]], $MachinePrecision]], N[(N[Power[x, 4.0], $MachinePrecision] * N[(eps * 5.0), $MachinePrecision]), $MachinePrecision], N[Power[eps, 5.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.9 \cdot 10^{-48} \lor \neg \left(x \leq 5 \cdot 10^{-47}\right):\\
\;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot 5\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\
\end{array}
\end{array}
if x < -1.90000000000000001e-48 or 5.00000000000000011e-47 < x Initial program 37.2%
Taylor expanded in x around inf 95.8%
distribute-rgt1-in95.8%
metadata-eval95.8%
Simplified95.8%
if -1.90000000000000001e-48 < x < 5.00000000000000011e-47Initial program 100.0%
Taylor expanded in x around 0 99.8%
Final simplification99.1%
(FPCore (x eps) :precision binary64 (if (or (<= x -6e-49) (not (<= x 3.8e-47))) (* eps (* (pow x 4.0) 5.0)) (pow eps 5.0)))
double code(double x, double eps) {
double tmp;
if ((x <= -6e-49) || !(x <= 3.8e-47)) {
tmp = eps * (pow(x, 4.0) * 5.0);
} else {
tmp = pow(eps, 5.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-49)) .or. (.not. (x <= 3.8d-47))) then
tmp = eps * ((x ** 4.0d0) * 5.0d0)
else
tmp = eps ** 5.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -6e-49) || !(x <= 3.8e-47)) {
tmp = eps * (Math.pow(x, 4.0) * 5.0);
} else {
tmp = Math.pow(eps, 5.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -6e-49) or not (x <= 3.8e-47): tmp = eps * (math.pow(x, 4.0) * 5.0) else: tmp = math.pow(eps, 5.0) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -6e-49) || !(x <= 3.8e-47)) tmp = Float64(eps * Float64((x ^ 4.0) * 5.0)); else tmp = eps ^ 5.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -6e-49) || ~((x <= 3.8e-47))) tmp = eps * ((x ^ 4.0) * 5.0); else tmp = eps ^ 5.0; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -6e-49], N[Not[LessEqual[x, 3.8e-47]], $MachinePrecision]], N[(eps * N[(N[Power[x, 4.0], $MachinePrecision] * 5.0), $MachinePrecision]), $MachinePrecision], N[Power[eps, 5.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6 \cdot 10^{-49} \lor \neg \left(x \leq 3.8 \cdot 10^{-47}\right):\\
\;\;\;\;\varepsilon \cdot \left({x}^{4} \cdot 5\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\
\end{array}
\end{array}
if x < -6e-49 or 3.80000000000000015e-47 < x Initial program 37.2%
Taylor expanded in x around inf 95.8%
*-commutative95.8%
distribute-rgt1-in95.8%
metadata-eval95.8%
*-commutative95.8%
associate-*r*95.6%
Simplified95.6%
if -6e-49 < x < 3.80000000000000015e-47Initial program 100.0%
Taylor expanded in x around 0 99.8%
Final simplification99.0%
(FPCore (x eps) :precision binary64 (if (or (<= x -9.2e-48) (not (<= x 1.3e-46))) (* 5.0 (* (pow x 4.0) eps)) (pow eps 5.0)))
double code(double x, double eps) {
double tmp;
if ((x <= -9.2e-48) || !(x <= 1.3e-46)) {
tmp = 5.0 * (pow(x, 4.0) * eps);
} else {
tmp = pow(eps, 5.0);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((x <= (-9.2d-48)) .or. (.not. (x <= 1.3d-46))) then
tmp = 5.0d0 * ((x ** 4.0d0) * eps)
else
tmp = eps ** 5.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -9.2e-48) || !(x <= 1.3e-46)) {
tmp = 5.0 * (Math.pow(x, 4.0) * eps);
} else {
tmp = Math.pow(eps, 5.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -9.2e-48) or not (x <= 1.3e-46): tmp = 5.0 * (math.pow(x, 4.0) * eps) else: tmp = math.pow(eps, 5.0) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -9.2e-48) || !(x <= 1.3e-46)) tmp = Float64(5.0 * Float64((x ^ 4.0) * eps)); else tmp = eps ^ 5.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -9.2e-48) || ~((x <= 1.3e-46))) tmp = 5.0 * ((x ^ 4.0) * eps); else tmp = eps ^ 5.0; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -9.2e-48], N[Not[LessEqual[x, 1.3e-46]], $MachinePrecision]], N[(5.0 * N[(N[Power[x, 4.0], $MachinePrecision] * eps), $MachinePrecision]), $MachinePrecision], N[Power[eps, 5.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.2 \cdot 10^{-48} \lor \neg \left(x \leq 1.3 \cdot 10^{-46}\right):\\
\;\;\;\;5 \cdot \left({x}^{4} \cdot \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\
\end{array}
\end{array}
if x < -9.2000000000000003e-48 or 1.3000000000000001e-46 < x Initial program 37.2%
add-cube-cbrt37.2%
pow337.2%
Applied egg-rr37.2%
Taylor expanded in x around inf 95.8%
distribute-rgt1-in95.8%
metadata-eval95.8%
*-commutative95.8%
associate-*r*95.3%
*-commutative95.3%
*-commutative95.3%
Simplified95.3%
if -9.2000000000000003e-48 < x < 1.3000000000000001e-46Initial program 100.0%
Taylor expanded in x around 0 99.8%
Final simplification99.0%
(FPCore (x eps) :precision binary64 (pow eps 5.0))
double code(double x, double eps) {
return pow(eps, 5.0);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps ** 5.0d0
end function
public static double code(double x, double eps) {
return Math.pow(eps, 5.0);
}
def code(x, eps): return math.pow(eps, 5.0)
function code(x, eps) return eps ^ 5.0 end
function tmp = code(x, eps) tmp = eps ^ 5.0; end
code[x_, eps_] := N[Power[eps, 5.0], $MachinePrecision]
\begin{array}{l}
\\
{\varepsilon}^{5}
\end{array}
Initial program 88.2%
Taylor expanded in x around 0 87.1%
herbie shell --seed 2024106
(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)))