
(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 8 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
(let* ((t_0 (- (pow (+ x eps) 5.0) (pow x 5.0))))
(if (or (<= t_0 -4e-270) (not (<= t_0 1e-308)))
t_0
(fma
(* eps 5.0)
(pow x 4.0)
(* x (* x (* 10.0 (+ (* eps (* x eps)) (pow eps 3.0)))))))))
double code(double x, double eps) {
double t_0 = pow((x + eps), 5.0) - pow(x, 5.0);
double tmp;
if ((t_0 <= -4e-270) || !(t_0 <= 1e-308)) {
tmp = t_0;
} else {
tmp = fma((eps * 5.0), pow(x, 4.0), (x * (x * (10.0 * ((eps * (x * eps)) + pow(eps, 3.0))))));
}
return tmp;
}
function code(x, eps) t_0 = Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0)) tmp = 0.0 if ((t_0 <= -4e-270) || !(t_0 <= 1e-308)) tmp = t_0; else tmp = fma(Float64(eps * 5.0), (x ^ 4.0), Float64(x * Float64(x * Float64(10.0 * Float64(Float64(eps * Float64(x * eps)) + (eps ^ 3.0)))))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -4e-270], N[Not[LessEqual[t$95$0, 1e-308]], $MachinePrecision]], t$95$0, N[(N[(eps * 5.0), $MachinePrecision] * N[Power[x, 4.0], $MachinePrecision] + N[(x * N[(x * N[(10.0 * N[(N[(eps * N[(x * eps), $MachinePrecision]), $MachinePrecision] + N[Power[eps, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(x + \varepsilon\right)}^{5} - {x}^{5}\\
\mathbf{if}\;t_0 \leq -4 \cdot 10^{-270} \lor \neg \left(t_0 \leq 10^{-308}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon \cdot 5, {x}^{4}, x \cdot \left(x \cdot \left(10 \cdot \left(\varepsilon \cdot \left(x \cdot \varepsilon\right) + {\varepsilon}^{3}\right)\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x eps) 5) (pow.f64 x 5)) < -4.0000000000000002e-270 or 9.9999999999999991e-309 < (-.f64 (pow.f64 (+.f64 x eps) 5) (pow.f64 x 5)) Initial program 96.3%
if -4.0000000000000002e-270 < (-.f64 (pow.f64 (+.f64 x eps) 5) (pow.f64 x 5)) < 9.9999999999999991e-309Initial program 87.9%
Taylor expanded in x around inf 99.8%
fma-def99.8%
distribute-lft1-in99.8%
metadata-eval99.8%
*-commutative99.8%
+-commutative99.8%
*-commutative99.8%
*-commutative99.8%
unpow399.8%
unpow299.8%
associate-*l*99.8%
distribute-lft-out99.8%
Simplified99.8%
Taylor expanded in x around 0 99.8%
unpow299.8%
associate-*r*99.8%
unpow299.8%
cube-mult99.8%
associate-*r*99.8%
*-commutative99.8%
associate-*r*99.8%
distribute-rgt-in99.8%
fma-udef99.8%
associate-*l*99.8%
fma-udef99.8%
*-commutative99.8%
associate-*r*99.8%
unpow299.8%
Simplified99.8%
Final simplification99.1%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (pow (+ x eps) 5.0) (pow x 5.0))))
(if (or (<= t_0 -4e-270) (not (<= t_0 1e-308)))
t_0
(* (* eps 5.0) (pow x 4.0)))))
double code(double x, double eps) {
double t_0 = pow((x + eps), 5.0) - pow(x, 5.0);
double tmp;
if ((t_0 <= -4e-270) || !(t_0 <= 1e-308)) {
tmp = t_0;
} else {
tmp = (eps * 5.0) * pow(x, 4.0);
}
return tmp;
}
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 = ((x + eps) ** 5.0d0) - (x ** 5.0d0)
if ((t_0 <= (-4d-270)) .or. (.not. (t_0 <= 1d-308))) then
tmp = t_0
else
tmp = (eps * 5.0d0) * (x ** 4.0d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.pow((x + eps), 5.0) - Math.pow(x, 5.0);
double tmp;
if ((t_0 <= -4e-270) || !(t_0 <= 1e-308)) {
tmp = t_0;
} else {
tmp = (eps * 5.0) * Math.pow(x, 4.0);
}
return tmp;
}
def code(x, eps): t_0 = math.pow((x + eps), 5.0) - math.pow(x, 5.0) tmp = 0 if (t_0 <= -4e-270) or not (t_0 <= 1e-308): tmp = t_0 else: tmp = (eps * 5.0) * math.pow(x, 4.0) return tmp
function code(x, eps) t_0 = Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0)) tmp = 0.0 if ((t_0 <= -4e-270) || !(t_0 <= 1e-308)) tmp = t_0; else tmp = Float64(Float64(eps * 5.0) * (x ^ 4.0)); end return tmp end
function tmp_2 = code(x, eps) t_0 = ((x + eps) ^ 5.0) - (x ^ 5.0); tmp = 0.0; if ((t_0 <= -4e-270) || ~((t_0 <= 1e-308))) tmp = t_0; else tmp = (eps * 5.0) * (x ^ 4.0); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -4e-270], N[Not[LessEqual[t$95$0, 1e-308]], $MachinePrecision]], t$95$0, N[(N[(eps * 5.0), $MachinePrecision] * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(x + \varepsilon\right)}^{5} - {x}^{5}\\
\mathbf{if}\;t_0 \leq -4 \cdot 10^{-270} \lor \neg \left(t_0 \leq 10^{-308}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left(\varepsilon \cdot 5\right) \cdot {x}^{4}\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x eps) 5) (pow.f64 x 5)) < -4.0000000000000002e-270 or 9.9999999999999991e-309 < (-.f64 (pow.f64 (+.f64 x eps) 5) (pow.f64 x 5)) Initial program 96.3%
if -4.0000000000000002e-270 < (-.f64 (pow.f64 (+.f64 x eps) 5) (pow.f64 x 5)) < 9.9999999999999991e-309Initial program 87.9%
Taylor expanded in x around inf 99.8%
distribute-lft1-in99.8%
metadata-eval99.8%
*-commutative99.8%
Simplified99.8%
Final simplification99.1%
(FPCore (x eps) :precision binary64 (if (or (<= x -1.86e-59) (not (<= x 1.22e-48))) (* eps (+ (* (* x x) (* 5.0 (* x x))) (* eps (* 10.0 (pow x 3.0))))) (pow eps 5.0)))
double code(double x, double eps) {
double tmp;
if ((x <= -1.86e-59) || !(x <= 1.22e-48)) {
tmp = eps * (((x * x) * (5.0 * (x * x))) + (eps * (10.0 * pow(x, 3.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.86d-59)) .or. (.not. (x <= 1.22d-48))) then
tmp = eps * (((x * x) * (5.0d0 * (x * x))) + (eps * (10.0d0 * (x ** 3.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.86e-59) || !(x <= 1.22e-48)) {
tmp = eps * (((x * x) * (5.0 * (x * x))) + (eps * (10.0 * Math.pow(x, 3.0))));
} else {
tmp = Math.pow(eps, 5.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -1.86e-59) or not (x <= 1.22e-48): tmp = eps * (((x * x) * (5.0 * (x * x))) + (eps * (10.0 * math.pow(x, 3.0)))) else: tmp = math.pow(eps, 5.0) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -1.86e-59) || !(x <= 1.22e-48)) tmp = Float64(eps * Float64(Float64(Float64(x * x) * Float64(5.0 * Float64(x * x))) + Float64(eps * Float64(10.0 * (x ^ 3.0))))); else tmp = eps ^ 5.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -1.86e-59) || ~((x <= 1.22e-48))) tmp = eps * (((x * x) * (5.0 * (x * x))) + (eps * (10.0 * (x ^ 3.0)))); else tmp = eps ^ 5.0; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -1.86e-59], N[Not[LessEqual[x, 1.22e-48]], $MachinePrecision]], N[(eps * N[(N[(N[(x * x), $MachinePrecision] * N[(5.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(eps * N[(10.0 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[eps, 5.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.86 \cdot 10^{-59} \lor \neg \left(x \leq 1.22 \cdot 10^{-48}\right):\\
\;\;\;\;\varepsilon \cdot \left(\left(x \cdot x\right) \cdot \left(5 \cdot \left(x \cdot x\right)\right) + \varepsilon \cdot \left(10 \cdot {x}^{3}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\
\end{array}
\end{array}
if x < -1.86000000000000004e-59 or 1.21999999999999993e-48 < x Initial program 52.1%
Taylor expanded in eps around 0 90.9%
+-commutative90.9%
unpow290.9%
associate-*l*90.9%
distribute-lft-out90.9%
distribute-lft1-in90.9%
metadata-eval90.9%
*-commutative90.9%
*-commutative90.9%
distribute-rgt-out90.9%
associate-*r*90.9%
Simplified90.9%
add-sqr-sqrt90.8%
pow290.8%
*-commutative90.8%
sqrt-prod90.6%
sqrt-pow190.6%
metadata-eval90.6%
pow290.6%
Applied egg-rr90.6%
unpow290.6%
swap-sqr90.4%
add-sqr-sqrt90.9%
associate-*l*90.8%
Applied egg-rr90.8%
if -1.86000000000000004e-59 < x < 1.21999999999999993e-48Initial program 100.0%
Taylor expanded in x around 0 100.0%
Final simplification98.0%
(FPCore (x eps) :precision binary64 (if (or (<= x -7.5e-60) (not (<= x 1.7e-48))) (* 5.0 (* eps (pow x 4.0))) (pow eps 5.0)))
double code(double x, double eps) {
double tmp;
if ((x <= -7.5e-60) || !(x <= 1.7e-48)) {
tmp = 5.0 * (eps * pow(x, 4.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 <= (-7.5d-60)) .or. (.not. (x <= 1.7d-48))) then
tmp = 5.0d0 * (eps * (x ** 4.0d0))
else
tmp = eps ** 5.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -7.5e-60) || !(x <= 1.7e-48)) {
tmp = 5.0 * (eps * Math.pow(x, 4.0));
} else {
tmp = Math.pow(eps, 5.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -7.5e-60) or not (x <= 1.7e-48): tmp = 5.0 * (eps * math.pow(x, 4.0)) else: tmp = math.pow(eps, 5.0) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -7.5e-60) || !(x <= 1.7e-48)) tmp = Float64(5.0 * Float64(eps * (x ^ 4.0))); else tmp = eps ^ 5.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -7.5e-60) || ~((x <= 1.7e-48))) tmp = 5.0 * (eps * (x ^ 4.0)); else tmp = eps ^ 5.0; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -7.5e-60], N[Not[LessEqual[x, 1.7e-48]], $MachinePrecision]], N[(5.0 * N[(eps * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[eps, 5.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.5 \cdot 10^{-60} \lor \neg \left(x \leq 1.7 \cdot 10^{-48}\right):\\
\;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\
\end{array}
\end{array}
if x < -7.5000000000000002e-60 or 1.70000000000000014e-48 < x Initial program 52.1%
Taylor expanded in x around inf 89.1%
distribute-lft1-in89.1%
metadata-eval89.1%
associate-*l*89.0%
Simplified89.0%
if -7.5000000000000002e-60 < x < 1.70000000000000014e-48Initial program 100.0%
Taylor expanded in x around 0 100.0%
Final simplification97.6%
(FPCore (x eps) :precision binary64 (if (or (<= x -1.7e-59) (not (<= x 3.9e-48))) (* eps (* 5.0 (pow x 4.0))) (pow eps 5.0)))
double code(double x, double eps) {
double tmp;
if ((x <= -1.7e-59) || !(x <= 3.9e-48)) {
tmp = eps * (5.0 * pow(x, 4.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.7d-59)) .or. (.not. (x <= 3.9d-48))) then
tmp = eps * (5.0d0 * (x ** 4.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.7e-59) || !(x <= 3.9e-48)) {
tmp = eps * (5.0 * Math.pow(x, 4.0));
} else {
tmp = Math.pow(eps, 5.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -1.7e-59) or not (x <= 3.9e-48): tmp = eps * (5.0 * math.pow(x, 4.0)) else: tmp = math.pow(eps, 5.0) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -1.7e-59) || !(x <= 3.9e-48)) tmp = Float64(eps * Float64(5.0 * (x ^ 4.0))); else tmp = eps ^ 5.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -1.7e-59) || ~((x <= 3.9e-48))) tmp = eps * (5.0 * (x ^ 4.0)); else tmp = eps ^ 5.0; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -1.7e-59], N[Not[LessEqual[x, 3.9e-48]], $MachinePrecision]], N[(eps * N[(5.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[eps, 5.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{-59} \lor \neg \left(x \leq 3.9 \cdot 10^{-48}\right):\\
\;\;\;\;\varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\
\end{array}
\end{array}
if x < -1.70000000000000009e-59 or 3.9e-48 < x Initial program 52.1%
Taylor expanded in eps around 0 89.1%
Taylor expanded in x around 0 89.1%
if -1.70000000000000009e-59 < x < 3.9e-48Initial program 100.0%
Taylor expanded in x around 0 100.0%
Final simplification97.6%
(FPCore (x eps) :precision binary64 (if (or (<= x -1.86e-59) (not (<= x 5.2e-48))) (* (* eps 5.0) (pow x 4.0)) (pow eps 5.0)))
double code(double x, double eps) {
double tmp;
if ((x <= -1.86e-59) || !(x <= 5.2e-48)) {
tmp = (eps * 5.0) * pow(x, 4.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.86d-59)) .or. (.not. (x <= 5.2d-48))) then
tmp = (eps * 5.0d0) * (x ** 4.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.86e-59) || !(x <= 5.2e-48)) {
tmp = (eps * 5.0) * Math.pow(x, 4.0);
} else {
tmp = Math.pow(eps, 5.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -1.86e-59) or not (x <= 5.2e-48): tmp = (eps * 5.0) * math.pow(x, 4.0) else: tmp = math.pow(eps, 5.0) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -1.86e-59) || !(x <= 5.2e-48)) tmp = Float64(Float64(eps * 5.0) * (x ^ 4.0)); else tmp = eps ^ 5.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -1.86e-59) || ~((x <= 5.2e-48))) tmp = (eps * 5.0) * (x ^ 4.0); else tmp = eps ^ 5.0; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -1.86e-59], N[Not[LessEqual[x, 5.2e-48]], $MachinePrecision]], N[(N[(eps * 5.0), $MachinePrecision] * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision], N[Power[eps, 5.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.86 \cdot 10^{-59} \lor \neg \left(x \leq 5.2 \cdot 10^{-48}\right):\\
\;\;\;\;\left(\varepsilon \cdot 5\right) \cdot {x}^{4}\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\
\end{array}
\end{array}
if x < -1.86000000000000004e-59 or 5.19999999999999975e-48 < x Initial program 52.1%
Taylor expanded in x around inf 89.1%
distribute-lft1-in89.1%
metadata-eval89.1%
*-commutative89.1%
Simplified89.1%
if -1.86000000000000004e-59 < x < 5.19999999999999975e-48Initial program 100.0%
Taylor expanded in x around 0 100.0%
Final simplification97.6%
(FPCore (x eps) :precision binary64 (if (or (<= x -1.86e-59) (not (<= x 1.15e-48))) (* (* x x) (* (* eps 5.0) (* x x))) (pow eps 5.0)))
double code(double x, double eps) {
double tmp;
if ((x <= -1.86e-59) || !(x <= 1.15e-48)) {
tmp = (x * x) * ((eps * 5.0) * (x * x));
} 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.86d-59)) .or. (.not. (x <= 1.15d-48))) then
tmp = (x * x) * ((eps * 5.0d0) * (x * x))
else
tmp = eps ** 5.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -1.86e-59) || !(x <= 1.15e-48)) {
tmp = (x * x) * ((eps * 5.0) * (x * x));
} else {
tmp = Math.pow(eps, 5.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -1.86e-59) or not (x <= 1.15e-48): tmp = (x * x) * ((eps * 5.0) * (x * x)) else: tmp = math.pow(eps, 5.0) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -1.86e-59) || !(x <= 1.15e-48)) tmp = Float64(Float64(x * x) * Float64(Float64(eps * 5.0) * Float64(x * x))); else tmp = eps ^ 5.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -1.86e-59) || ~((x <= 1.15e-48))) tmp = (x * x) * ((eps * 5.0) * (x * x)); else tmp = eps ^ 5.0; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -1.86e-59], N[Not[LessEqual[x, 1.15e-48]], $MachinePrecision]], N[(N[(x * x), $MachinePrecision] * N[(N[(eps * 5.0), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[eps, 5.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.86 \cdot 10^{-59} \lor \neg \left(x \leq 1.15 \cdot 10^{-48}\right):\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(\left(\varepsilon \cdot 5\right) \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\
\end{array}
\end{array}
if x < -1.86000000000000004e-59 or 1.15e-48 < x Initial program 52.1%
Taylor expanded in x around inf 89.1%
distribute-lft1-in89.1%
metadata-eval89.1%
associate-*l*89.0%
Simplified89.0%
associate-*r*89.1%
*-commutative89.1%
add-sqr-sqrt66.6%
pow266.7%
*-commutative66.7%
sqrt-prod55.8%
sqrt-pow155.8%
metadata-eval55.8%
pow255.8%
*-commutative55.8%
Applied egg-rr55.8%
unpow255.8%
*-commutative55.8%
*-commutative55.8%
swap-sqr55.9%
add-sqr-sqrt88.9%
associate-*r*88.8%
*-commutative88.8%
Applied egg-rr88.8%
if -1.86000000000000004e-59 < x < 1.15e-48Initial program 100.0%
Taylor expanded in x around 0 100.0%
Final simplification97.6%
(FPCore (x eps) :precision binary64 (* (* x x) (* (* eps 5.0) (* x x))))
double code(double x, double eps) {
return (x * x) * ((eps * 5.0) * (x * x));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (x * x) * ((eps * 5.0d0) * (x * x))
end function
public static double code(double x, double eps) {
return (x * x) * ((eps * 5.0) * (x * x));
}
def code(x, eps): return (x * x) * ((eps * 5.0) * (x * x))
function code(x, eps) return Float64(Float64(x * x) * Float64(Float64(eps * 5.0) * Float64(x * x))) end
function tmp = code(x, eps) tmp = (x * x) * ((eps * 5.0) * (x * x)); end
code[x_, eps_] := N[(N[(x * x), $MachinePrecision] * N[(N[(eps * 5.0), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot x\right) \cdot \left(\left(\varepsilon \cdot 5\right) \cdot \left(x \cdot x\right)\right)
\end{array}
Initial program 89.5%
Taylor expanded in x around inf 82.5%
distribute-lft1-in82.5%
metadata-eval82.5%
associate-*l*82.5%
Simplified82.5%
associate-*r*82.5%
*-commutative82.5%
add-sqr-sqrt77.6%
pow277.6%
*-commutative77.6%
sqrt-prod40.8%
sqrt-pow140.8%
metadata-eval40.8%
pow240.8%
*-commutative40.8%
Applied egg-rr40.8%
unpow240.8%
*-commutative40.8%
*-commutative40.8%
swap-sqr40.9%
add-sqr-sqrt82.5%
associate-*r*82.5%
*-commutative82.5%
Applied egg-rr82.5%
Final simplification82.5%
herbie shell --seed 2023187
(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)))