
(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 11 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 -6.2e-38)
(* eps (+ (sqrt (* 25.0 (pow x 8.0))) (* eps (* (pow x 3.0) 10.0))))
(if (<= x 4.7e-60)
(+ (pow eps 5.0) (* x (* 5.0 (pow eps 4.0))))
(fma
(* eps 5.0)
(pow x 4.0)
(* x (* x (* 10.0 (+ (* x (* eps eps)) (pow eps 3.0)))))))))
double code(double x, double eps) {
double tmp;
if (x <= -6.2e-38) {
tmp = eps * (sqrt((25.0 * pow(x, 8.0))) + (eps * (pow(x, 3.0) * 10.0)));
} else if (x <= 4.7e-60) {
tmp = pow(eps, 5.0) + (x * (5.0 * pow(eps, 4.0)));
} else {
tmp = fma((eps * 5.0), pow(x, 4.0), (x * (x * (10.0 * ((x * (eps * eps)) + pow(eps, 3.0))))));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -6.2e-38) tmp = Float64(eps * Float64(sqrt(Float64(25.0 * (x ^ 8.0))) + Float64(eps * Float64((x ^ 3.0) * 10.0)))); elseif (x <= 4.7e-60) tmp = Float64((eps ^ 5.0) + Float64(x * Float64(5.0 * (eps ^ 4.0)))); else tmp = fma(Float64(eps * 5.0), (x ^ 4.0), Float64(x * Float64(x * Float64(10.0 * Float64(Float64(x * Float64(eps * eps)) + (eps ^ 3.0)))))); end return tmp end
code[x_, eps_] := If[LessEqual[x, -6.2e-38], N[(eps * N[(N[Sqrt[N[(25.0 * N[Power[x, 8.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(eps * N[(N[Power[x, 3.0], $MachinePrecision] * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.7e-60], N[(N[Power[eps, 5.0], $MachinePrecision] + N[(x * N[(5.0 * N[Power[eps, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(eps * 5.0), $MachinePrecision] * N[Power[x, 4.0], $MachinePrecision] + N[(x * N[(x * N[(10.0 * N[(N[(x * N[(eps * eps), $MachinePrecision]), $MachinePrecision] + N[Power[eps, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.2 \cdot 10^{-38}:\\
\;\;\;\;\varepsilon \cdot \left(\sqrt{25 \cdot {x}^{8}} + \varepsilon \cdot \left({x}^{3} \cdot 10\right)\right)\\
\mathbf{elif}\;x \leq 4.7 \cdot 10^{-60}:\\
\;\;\;\;{\varepsilon}^{5} + x \cdot \left(5 \cdot {\varepsilon}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon \cdot 5, {x}^{4}, x \cdot \left(x \cdot \left(10 \cdot \left(x \cdot \left(\varepsilon \cdot \varepsilon\right) + {\varepsilon}^{3}\right)\right)\right)\right)\\
\end{array}
\end{array}
if x < -6.19999999999999966e-38Initial program 25.3%
Taylor expanded in eps around 0 99.7%
+-commutative99.7%
unpow299.7%
associate-*l*99.7%
distribute-lft-out99.7%
distribute-lft1-in99.7%
metadata-eval99.7%
*-commutative99.7%
*-commutative99.7%
distribute-rgt-out99.7%
associate-*r*99.7%
Simplified99.7%
add-sqr-sqrt99.1%
sqrt-unprod99.7%
swap-sqr99.5%
metadata-eval99.5%
pow-prod-up100.0%
metadata-eval100.0%
Applied egg-rr100.0%
if -6.19999999999999966e-38 < x < 4.7e-60Initial program 99.5%
Taylor expanded in x around 0 99.5%
distribute-lft1-in99.5%
metadata-eval99.5%
Simplified99.5%
if 4.7e-60 < x Initial program 39.2%
Taylor expanded in x around inf 94.6%
fma-def94.7%
distribute-lft1-in94.7%
metadata-eval94.7%
*-commutative94.7%
+-commutative94.7%
*-commutative94.7%
*-commutative94.7%
unpow394.7%
unpow294.7%
associate-*l*94.7%
distribute-lft-out94.7%
Simplified94.7%
Taylor expanded in x around 0 94.7%
+-commutative94.7%
*-commutative94.7%
*-commutative94.7%
unpow294.7%
*-commutative94.7%
associate-*r*94.7%
unpow294.7%
*-commutative94.7%
associate-*r*94.7%
*-commutative94.7%
cube-mult94.7%
associate-*l*94.7%
*-commutative94.7%
distribute-lft-in94.7%
fma-udef94.7%
associate-*l*94.7%
Simplified94.7%
Final simplification99.0%
(FPCore (x eps)
:precision binary64
(if (<= x -5.2e-38)
(* eps (+ (sqrt (* 25.0 (pow x 8.0))) (* eps (* (pow x 3.0) 10.0))))
(if (<= x 4.7e-60)
(+ (pow eps 5.0) (* x (* 5.0 (pow eps 4.0))))
(+
(* (* eps 5.0) (pow x 4.0))
(* x (* 10.0 (* x (* (* eps eps) (+ x eps)))))))))
double code(double x, double eps) {
double tmp;
if (x <= -5.2e-38) {
tmp = eps * (sqrt((25.0 * pow(x, 8.0))) + (eps * (pow(x, 3.0) * 10.0)));
} else if (x <= 4.7e-60) {
tmp = pow(eps, 5.0) + (x * (5.0 * pow(eps, 4.0)));
} else {
tmp = ((eps * 5.0) * pow(x, 4.0)) + (x * (10.0 * (x * ((eps * eps) * (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 <= (-5.2d-38)) then
tmp = eps * (sqrt((25.0d0 * (x ** 8.0d0))) + (eps * ((x ** 3.0d0) * 10.0d0)))
else if (x <= 4.7d-60) then
tmp = (eps ** 5.0d0) + (x * (5.0d0 * (eps ** 4.0d0)))
else
tmp = ((eps * 5.0d0) * (x ** 4.0d0)) + (x * (10.0d0 * (x * ((eps * eps) * (x + eps)))))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -5.2e-38) {
tmp = eps * (Math.sqrt((25.0 * Math.pow(x, 8.0))) + (eps * (Math.pow(x, 3.0) * 10.0)));
} else if (x <= 4.7e-60) {
tmp = Math.pow(eps, 5.0) + (x * (5.0 * Math.pow(eps, 4.0)));
} else {
tmp = ((eps * 5.0) * Math.pow(x, 4.0)) + (x * (10.0 * (x * ((eps * eps) * (x + eps)))));
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -5.2e-38: tmp = eps * (math.sqrt((25.0 * math.pow(x, 8.0))) + (eps * (math.pow(x, 3.0) * 10.0))) elif x <= 4.7e-60: tmp = math.pow(eps, 5.0) + (x * (5.0 * math.pow(eps, 4.0))) else: tmp = ((eps * 5.0) * math.pow(x, 4.0)) + (x * (10.0 * (x * ((eps * eps) * (x + eps))))) return tmp
function code(x, eps) tmp = 0.0 if (x <= -5.2e-38) tmp = Float64(eps * Float64(sqrt(Float64(25.0 * (x ^ 8.0))) + Float64(eps * Float64((x ^ 3.0) * 10.0)))); elseif (x <= 4.7e-60) tmp = Float64((eps ^ 5.0) + Float64(x * Float64(5.0 * (eps ^ 4.0)))); else tmp = Float64(Float64(Float64(eps * 5.0) * (x ^ 4.0)) + Float64(x * Float64(10.0 * Float64(x * Float64(Float64(eps * eps) * Float64(x + eps)))))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -5.2e-38) tmp = eps * (sqrt((25.0 * (x ^ 8.0))) + (eps * ((x ^ 3.0) * 10.0))); elseif (x <= 4.7e-60) tmp = (eps ^ 5.0) + (x * (5.0 * (eps ^ 4.0))); else tmp = ((eps * 5.0) * (x ^ 4.0)) + (x * (10.0 * (x * ((eps * eps) * (x + eps))))); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -5.2e-38], N[(eps * N[(N[Sqrt[N[(25.0 * N[Power[x, 8.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(eps * N[(N[Power[x, 3.0], $MachinePrecision] * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.7e-60], N[(N[Power[eps, 5.0], $MachinePrecision] + N[(x * N[(5.0 * N[Power[eps, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(eps * 5.0), $MachinePrecision] * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(x * N[(10.0 * N[(x * N[(N[(eps * eps), $MachinePrecision] * N[(x + eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.2 \cdot 10^{-38}:\\
\;\;\;\;\varepsilon \cdot \left(\sqrt{25 \cdot {x}^{8}} + \varepsilon \cdot \left({x}^{3} \cdot 10\right)\right)\\
\mathbf{elif}\;x \leq 4.7 \cdot 10^{-60}:\\
\;\;\;\;{\varepsilon}^{5} + x \cdot \left(5 \cdot {\varepsilon}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\varepsilon \cdot 5\right) \cdot {x}^{4} + x \cdot \left(10 \cdot \left(x \cdot \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \left(x + \varepsilon\right)\right)\right)\right)\\
\end{array}
\end{array}
if x < -5.20000000000000022e-38Initial program 25.3%
Taylor expanded in eps around 0 99.7%
+-commutative99.7%
unpow299.7%
associate-*l*99.7%
distribute-lft-out99.7%
distribute-lft1-in99.7%
metadata-eval99.7%
*-commutative99.7%
*-commutative99.7%
distribute-rgt-out99.7%
associate-*r*99.7%
Simplified99.7%
add-sqr-sqrt99.1%
sqrt-unprod99.7%
swap-sqr99.5%
metadata-eval99.5%
pow-prod-up100.0%
metadata-eval100.0%
Applied egg-rr100.0%
if -5.20000000000000022e-38 < x < 4.7e-60Initial program 99.5%
Taylor expanded in x around 0 99.5%
distribute-lft1-in99.5%
metadata-eval99.5%
Simplified99.5%
if 4.7e-60 < x Initial program 39.2%
Taylor expanded in x around inf 94.6%
fma-def94.7%
distribute-lft1-in94.7%
metadata-eval94.7%
*-commutative94.7%
+-commutative94.7%
*-commutative94.7%
*-commutative94.7%
unpow394.7%
unpow294.7%
associate-*l*94.7%
distribute-lft-out94.7%
Simplified94.7%
Taylor expanded in x around 0 94.7%
+-commutative94.7%
*-commutative94.7%
*-commutative94.7%
unpow294.7%
*-commutative94.7%
associate-*r*94.7%
unpow294.7%
*-commutative94.7%
associate-*r*94.7%
*-commutative94.7%
cube-mult94.7%
associate-*l*94.7%
*-commutative94.7%
distribute-lft-in94.7%
fma-udef94.7%
associate-*l*94.7%
Simplified94.7%
fma-udef94.6%
*-commutative94.6%
associate-*l*94.6%
cube-mult94.6%
distribute-rgt-out94.6%
Applied egg-rr94.6%
Final simplification99.0%
(FPCore (x eps)
:precision binary64
(if (or (<= x -5.2e-38) (not (<= x 4.7e-60)))
(+
(* (* eps 5.0) (pow x 4.0))
(* x (* 10.0 (* x (* (* eps eps) (+ x eps))))))
(+ (pow eps 5.0) (* x (* 5.0 (pow eps 4.0))))))
double code(double x, double eps) {
double tmp;
if ((x <= -5.2e-38) || !(x <= 4.7e-60)) {
tmp = ((eps * 5.0) * pow(x, 4.0)) + (x * (10.0 * (x * ((eps * eps) * (x + eps)))));
} else {
tmp = pow(eps, 5.0) + (x * (5.0 * pow(eps, 4.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.2d-38)) .or. (.not. (x <= 4.7d-60))) then
tmp = ((eps * 5.0d0) * (x ** 4.0d0)) + (x * (10.0d0 * (x * ((eps * eps) * (x + eps)))))
else
tmp = (eps ** 5.0d0) + (x * (5.0d0 * (eps ** 4.0d0)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -5.2e-38) || !(x <= 4.7e-60)) {
tmp = ((eps * 5.0) * Math.pow(x, 4.0)) + (x * (10.0 * (x * ((eps * eps) * (x + eps)))));
} else {
tmp = Math.pow(eps, 5.0) + (x * (5.0 * Math.pow(eps, 4.0)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -5.2e-38) or not (x <= 4.7e-60): tmp = ((eps * 5.0) * math.pow(x, 4.0)) + (x * (10.0 * (x * ((eps * eps) * (x + eps))))) else: tmp = math.pow(eps, 5.0) + (x * (5.0 * math.pow(eps, 4.0))) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -5.2e-38) || !(x <= 4.7e-60)) tmp = Float64(Float64(Float64(eps * 5.0) * (x ^ 4.0)) + Float64(x * Float64(10.0 * Float64(x * Float64(Float64(eps * eps) * Float64(x + eps)))))); else tmp = Float64((eps ^ 5.0) + Float64(x * Float64(5.0 * (eps ^ 4.0)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -5.2e-38) || ~((x <= 4.7e-60))) tmp = ((eps * 5.0) * (x ^ 4.0)) + (x * (10.0 * (x * ((eps * eps) * (x + eps))))); else tmp = (eps ^ 5.0) + (x * (5.0 * (eps ^ 4.0))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -5.2e-38], N[Not[LessEqual[x, 4.7e-60]], $MachinePrecision]], N[(N[(N[(eps * 5.0), $MachinePrecision] * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(x * N[(10.0 * N[(x * N[(N[(eps * eps), $MachinePrecision] * N[(x + eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[eps, 5.0], $MachinePrecision] + N[(x * N[(5.0 * N[Power[eps, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.2 \cdot 10^{-38} \lor \neg \left(x \leq 4.7 \cdot 10^{-60}\right):\\
\;\;\;\;\left(\varepsilon \cdot 5\right) \cdot {x}^{4} + x \cdot \left(10 \cdot \left(x \cdot \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \left(x + \varepsilon\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5} + x \cdot \left(5 \cdot {\varepsilon}^{4}\right)\\
\end{array}
\end{array}
if x < -5.20000000000000022e-38 or 4.7e-60 < x Initial program 34.2%
Taylor expanded in x around inf 96.5%
fma-def96.5%
distribute-lft1-in96.5%
metadata-eval96.5%
*-commutative96.5%
+-commutative96.5%
*-commutative96.5%
*-commutative96.5%
unpow396.5%
unpow296.5%
associate-*l*96.5%
distribute-lft-out96.5%
Simplified96.5%
Taylor expanded in x around 0 96.5%
+-commutative96.5%
*-commutative96.5%
*-commutative96.5%
unpow296.5%
*-commutative96.5%
associate-*r*96.5%
unpow296.5%
*-commutative96.5%
associate-*r*96.5%
*-commutative96.5%
cube-mult96.5%
associate-*l*96.5%
*-commutative96.5%
distribute-lft-in96.5%
fma-udef96.5%
associate-*l*96.5%
Simplified96.5%
fma-udef96.5%
*-commutative96.5%
associate-*l*96.5%
cube-mult96.5%
distribute-rgt-out96.5%
Applied egg-rr96.5%
if -5.20000000000000022e-38 < x < 4.7e-60Initial program 99.5%
Taylor expanded in x around 0 99.5%
distribute-lft1-in99.5%
metadata-eval99.5%
Simplified99.5%
Final simplification99.0%
(FPCore (x eps)
:precision binary64
(if (or (<= x -7.2e-38) (not (<= x 4.7e-60)))
(+
(* (* eps 5.0) (pow x 4.0))
(* x (* 10.0 (* x (* (* eps eps) (+ x eps))))))
(- (pow (+ x eps) 5.0) (pow x 5.0))))
double code(double x, double eps) {
double tmp;
if ((x <= -7.2e-38) || !(x <= 4.7e-60)) {
tmp = ((eps * 5.0) * pow(x, 4.0)) + (x * (10.0 * (x * ((eps * eps) * (x + eps)))));
} 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 <= (-7.2d-38)) .or. (.not. (x <= 4.7d-60))) then
tmp = ((eps * 5.0d0) * (x ** 4.0d0)) + (x * (10.0d0 * (x * ((eps * eps) * (x + eps)))))
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 <= -7.2e-38) || !(x <= 4.7e-60)) {
tmp = ((eps * 5.0) * Math.pow(x, 4.0)) + (x * (10.0 * (x * ((eps * eps) * (x + eps)))));
} else {
tmp = Math.pow((x + eps), 5.0) - Math.pow(x, 5.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -7.2e-38) or not (x <= 4.7e-60): tmp = ((eps * 5.0) * math.pow(x, 4.0)) + (x * (10.0 * (x * ((eps * eps) * (x + eps))))) else: tmp = math.pow((x + eps), 5.0) - math.pow(x, 5.0) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -7.2e-38) || !(x <= 4.7e-60)) tmp = Float64(Float64(Float64(eps * 5.0) * (x ^ 4.0)) + Float64(x * Float64(10.0 * Float64(x * Float64(Float64(eps * eps) * Float64(x + eps)))))); 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 <= -7.2e-38) || ~((x <= 4.7e-60))) tmp = ((eps * 5.0) * (x ^ 4.0)) + (x * (10.0 * (x * ((eps * eps) * (x + eps))))); else tmp = ((x + eps) ^ 5.0) - (x ^ 5.0); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -7.2e-38], N[Not[LessEqual[x, 4.7e-60]], $MachinePrecision]], N[(N[(N[(eps * 5.0), $MachinePrecision] * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(x * N[(10.0 * N[(x * N[(N[(eps * eps), $MachinePrecision] * N[(x + eps), $MachinePrecision]), $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 -7.2 \cdot 10^{-38} \lor \neg \left(x \leq 4.7 \cdot 10^{-60}\right):\\
\;\;\;\;\left(\varepsilon \cdot 5\right) \cdot {x}^{4} + x \cdot \left(10 \cdot \left(x \cdot \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \left(x + \varepsilon\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(x + \varepsilon\right)}^{5} - {x}^{5}\\
\end{array}
\end{array}
if x < -7.2000000000000001e-38 or 4.7e-60 < x Initial program 34.2%
Taylor expanded in x around inf 96.5%
fma-def96.5%
distribute-lft1-in96.5%
metadata-eval96.5%
*-commutative96.5%
+-commutative96.5%
*-commutative96.5%
*-commutative96.5%
unpow396.5%
unpow296.5%
associate-*l*96.5%
distribute-lft-out96.5%
Simplified96.5%
Taylor expanded in x around 0 96.5%
+-commutative96.5%
*-commutative96.5%
*-commutative96.5%
unpow296.5%
*-commutative96.5%
associate-*r*96.5%
unpow296.5%
*-commutative96.5%
associate-*r*96.5%
*-commutative96.5%
cube-mult96.5%
associate-*l*96.5%
*-commutative96.5%
distribute-lft-in96.5%
fma-udef96.5%
associate-*l*96.5%
Simplified96.5%
fma-udef96.5%
*-commutative96.5%
associate-*l*96.5%
cube-mult96.5%
distribute-rgt-out96.5%
Applied egg-rr96.5%
if -7.2000000000000001e-38 < x < 4.7e-60Initial program 99.5%
Final simplification99.0%
(FPCore (x eps)
:precision binary64
(if (or (<= x -7.2e-38) (not (<= x 4.7e-60)))
(+
(* (* eps 5.0) (pow x 4.0))
(* x (* 10.0 (* x (* (* eps eps) (+ x eps))))))
(pow eps 5.0)))
double code(double x, double eps) {
double tmp;
if ((x <= -7.2e-38) || !(x <= 4.7e-60)) {
tmp = ((eps * 5.0) * pow(x, 4.0)) + (x * (10.0 * (x * ((eps * eps) * (x + 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 <= (-7.2d-38)) .or. (.not. (x <= 4.7d-60))) then
tmp = ((eps * 5.0d0) * (x ** 4.0d0)) + (x * (10.0d0 * (x * ((eps * eps) * (x + eps)))))
else
tmp = eps ** 5.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -7.2e-38) || !(x <= 4.7e-60)) {
tmp = ((eps * 5.0) * Math.pow(x, 4.0)) + (x * (10.0 * (x * ((eps * eps) * (x + eps)))));
} else {
tmp = Math.pow(eps, 5.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -7.2e-38) or not (x <= 4.7e-60): tmp = ((eps * 5.0) * math.pow(x, 4.0)) + (x * (10.0 * (x * ((eps * eps) * (x + eps))))) else: tmp = math.pow(eps, 5.0) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -7.2e-38) || !(x <= 4.7e-60)) tmp = Float64(Float64(Float64(eps * 5.0) * (x ^ 4.0)) + Float64(x * Float64(10.0 * Float64(x * Float64(Float64(eps * eps) * Float64(x + eps)))))); else tmp = eps ^ 5.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -7.2e-38) || ~((x <= 4.7e-60))) tmp = ((eps * 5.0) * (x ^ 4.0)) + (x * (10.0 * (x * ((eps * eps) * (x + eps))))); else tmp = eps ^ 5.0; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -7.2e-38], N[Not[LessEqual[x, 4.7e-60]], $MachinePrecision]], N[(N[(N[(eps * 5.0), $MachinePrecision] * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(x * N[(10.0 * N[(x * N[(N[(eps * eps), $MachinePrecision] * N[(x + eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[eps, 5.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.2 \cdot 10^{-38} \lor \neg \left(x \leq 4.7 \cdot 10^{-60}\right):\\
\;\;\;\;\left(\varepsilon \cdot 5\right) \cdot {x}^{4} + x \cdot \left(10 \cdot \left(x \cdot \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \left(x + \varepsilon\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\
\end{array}
\end{array}
if x < -7.2000000000000001e-38 or 4.7e-60 < x Initial program 34.2%
Taylor expanded in x around inf 96.5%
fma-def96.5%
distribute-lft1-in96.5%
metadata-eval96.5%
*-commutative96.5%
+-commutative96.5%
*-commutative96.5%
*-commutative96.5%
unpow396.5%
unpow296.5%
associate-*l*96.5%
distribute-lft-out96.5%
Simplified96.5%
Taylor expanded in x around 0 96.5%
+-commutative96.5%
*-commutative96.5%
*-commutative96.5%
unpow296.5%
*-commutative96.5%
associate-*r*96.5%
unpow296.5%
*-commutative96.5%
associate-*r*96.5%
*-commutative96.5%
cube-mult96.5%
associate-*l*96.5%
*-commutative96.5%
distribute-lft-in96.5%
fma-udef96.5%
associate-*l*96.5%
Simplified96.5%
fma-udef96.5%
*-commutative96.5%
associate-*l*96.5%
cube-mult96.5%
distribute-rgt-out96.5%
Applied egg-rr96.5%
if -7.2000000000000001e-38 < x < 4.7e-60Initial program 99.5%
Taylor expanded in x around 0 99.5%
Final simplification98.9%
(FPCore (x eps) :precision binary64 (if (or (<= x -5.2e-38) (not (<= x 4.7e-60))) (* 5.0 (* eps (pow x 4.0))) (pow eps 5.0)))
double code(double x, double eps) {
double tmp;
if ((x <= -5.2e-38) || !(x <= 4.7e-60)) {
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 <= (-5.2d-38)) .or. (.not. (x <= 4.7d-60))) 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 <= -5.2e-38) || !(x <= 4.7e-60)) {
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 <= -5.2e-38) or not (x <= 4.7e-60): 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 <= -5.2e-38) || !(x <= 4.7e-60)) 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 <= -5.2e-38) || ~((x <= 4.7e-60))) tmp = 5.0 * (eps * (x ^ 4.0)); else tmp = eps ^ 5.0; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -5.2e-38], N[Not[LessEqual[x, 4.7e-60]], $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 -5.2 \cdot 10^{-38} \lor \neg \left(x \leq 4.7 \cdot 10^{-60}\right):\\
\;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\
\end{array}
\end{array}
if x < -5.20000000000000022e-38 or 4.7e-60 < x Initial program 34.2%
Taylor expanded in x around inf 93.0%
distribute-lft1-in93.0%
metadata-eval93.0%
associate-*l*92.9%
Simplified92.9%
if -5.20000000000000022e-38 < x < 4.7e-60Initial program 99.5%
Taylor expanded in x around 0 99.5%
Final simplification98.3%
(FPCore (x eps) :precision binary64 (if (<= x -5.2e-38) (* 5.0 (* eps (pow x 4.0))) (if (<= x 4.7e-60) (pow eps 5.0) (* eps (* 5.0 (pow x 4.0))))))
double code(double x, double eps) {
double tmp;
if (x <= -5.2e-38) {
tmp = 5.0 * (eps * pow(x, 4.0));
} else if (x <= 4.7e-60) {
tmp = pow(eps, 5.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) :: tmp
if (x <= (-5.2d-38)) then
tmp = 5.0d0 * (eps * (x ** 4.0d0))
else if (x <= 4.7d-60) then
tmp = eps ** 5.0d0
else
tmp = eps * (5.0d0 * (x ** 4.0d0))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -5.2e-38) {
tmp = 5.0 * (eps * Math.pow(x, 4.0));
} else if (x <= 4.7e-60) {
tmp = Math.pow(eps, 5.0);
} else {
tmp = eps * (5.0 * Math.pow(x, 4.0));
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -5.2e-38: tmp = 5.0 * (eps * math.pow(x, 4.0)) elif x <= 4.7e-60: tmp = math.pow(eps, 5.0) else: tmp = eps * (5.0 * math.pow(x, 4.0)) return tmp
function code(x, eps) tmp = 0.0 if (x <= -5.2e-38) tmp = Float64(5.0 * Float64(eps * (x ^ 4.0))); elseif (x <= 4.7e-60) tmp = eps ^ 5.0; else tmp = Float64(eps * Float64(5.0 * (x ^ 4.0))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -5.2e-38) tmp = 5.0 * (eps * (x ^ 4.0)); elseif (x <= 4.7e-60) tmp = eps ^ 5.0; else tmp = eps * (5.0 * (x ^ 4.0)); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -5.2e-38], N[(5.0 * N[(eps * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.7e-60], N[Power[eps, 5.0], $MachinePrecision], N[(eps * N[(5.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.2 \cdot 10^{-38}:\\
\;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\
\mathbf{elif}\;x \leq 4.7 \cdot 10^{-60}:\\
\;\;\;\;{\varepsilon}^{5}\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\
\end{array}
\end{array}
if x < -5.20000000000000022e-38Initial program 25.3%
Taylor expanded in x around inf 98.7%
distribute-lft1-in98.7%
metadata-eval98.7%
associate-*l*98.7%
Simplified98.7%
if -5.20000000000000022e-38 < x < 4.7e-60Initial program 99.5%
Taylor expanded in x around 0 99.5%
if 4.7e-60 < x Initial program 39.2%
Taylor expanded in eps around 0 89.9%
*-un-lft-identity89.9%
distribute-rgt-out89.9%
metadata-eval89.9%
Applied egg-rr89.9%
Final simplification98.4%
(FPCore (x eps) :precision binary64 (if (or (<= x -5.2e-38) (not (<= x 4.7e-60))) (* eps (* (* x (* x 5.0)) (* x x))) (pow eps 5.0)))
double code(double x, double eps) {
double tmp;
if ((x <= -5.2e-38) || !(x <= 4.7e-60)) {
tmp = eps * ((x * (x * 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 <= (-5.2d-38)) .or. (.not. (x <= 4.7d-60))) then
tmp = eps * ((x * (x * 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 <= -5.2e-38) || !(x <= 4.7e-60)) {
tmp = eps * ((x * (x * 5.0)) * (x * x));
} else {
tmp = Math.pow(eps, 5.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -5.2e-38) or not (x <= 4.7e-60): tmp = eps * ((x * (x * 5.0)) * (x * x)) else: tmp = math.pow(eps, 5.0) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -5.2e-38) || !(x <= 4.7e-60)) tmp = Float64(eps * Float64(Float64(x * Float64(x * 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 <= -5.2e-38) || ~((x <= 4.7e-60))) tmp = eps * ((x * (x * 5.0)) * (x * x)); else tmp = eps ^ 5.0; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -5.2e-38], N[Not[LessEqual[x, 4.7e-60]], $MachinePrecision]], N[(eps * N[(N[(x * N[(x * 5.0), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[eps, 5.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.2 \cdot 10^{-38} \lor \neg \left(x \leq 4.7 \cdot 10^{-60}\right):\\
\;\;\;\;\varepsilon \cdot \left(\left(x \cdot \left(x \cdot 5\right)\right) \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\
\end{array}
\end{array}
if x < -5.20000000000000022e-38 or 4.7e-60 < x Initial program 34.2%
Taylor expanded in eps around 0 93.1%
distribute-lft1-in93.1%
metadata-eval93.1%
metadata-eval93.1%
pow-sqr92.8%
pow292.8%
pow292.8%
associate-*r*92.7%
Applied egg-rr92.7%
Taylor expanded in x around 0 92.7%
unpow292.7%
*-commutative92.7%
associate-*r*92.8%
Simplified92.8%
if -5.20000000000000022e-38 < x < 4.7e-60Initial program 99.5%
Taylor expanded in x around 0 99.5%
Final simplification98.3%
(FPCore (x eps) :precision binary64 (* 5.0 (* (* x x) (* eps (* x x)))))
double code(double x, double eps) {
return 5.0 * ((x * x) * (eps * (x * x)));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 5.0d0 * ((x * x) * (eps * (x * x)))
end function
public static double code(double x, double eps) {
return 5.0 * ((x * x) * (eps * (x * x)));
}
def code(x, eps): return 5.0 * ((x * x) * (eps * (x * x)))
function code(x, eps) return Float64(5.0 * Float64(Float64(x * x) * Float64(eps * Float64(x * x)))) end
function tmp = code(x, eps) tmp = 5.0 * ((x * x) * (eps * (x * x))); end
code[x_, eps_] := N[(5.0 * N[(N[(x * x), $MachinePrecision] * N[(eps * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
5 \cdot \left(\left(x \cdot x\right) \cdot \left(\varepsilon \cdot \left(x \cdot x\right)\right)\right)
\end{array}
Initial program 88.2%
Taylor expanded in x around inf 80.3%
distribute-lft1-in80.3%
metadata-eval80.3%
associate-*l*80.3%
Simplified80.3%
add-sqr-sqrt74.1%
pow274.1%
*-commutative74.1%
sqrt-prod38.4%
sqrt-pow138.4%
metadata-eval38.4%
pow238.4%
Applied egg-rr38.4%
unpow238.4%
*-commutative38.4%
*-commutative38.4%
swap-sqr38.4%
add-sqr-sqrt80.3%
associate-*r*80.3%
Applied egg-rr80.3%
Final simplification80.3%
(FPCore (x eps) :precision binary64 (* eps (* (* x x) (* 5.0 (* x x)))))
double code(double x, double eps) {
return eps * ((x * x) * (5.0 * (x * x)));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps * ((x * x) * (5.0d0 * (x * x)))
end function
public static double code(double x, double eps) {
return eps * ((x * x) * (5.0 * (x * x)));
}
def code(x, eps): return eps * ((x * x) * (5.0 * (x * x)))
function code(x, eps) return Float64(eps * Float64(Float64(x * x) * Float64(5.0 * Float64(x * x)))) end
function tmp = code(x, eps) tmp = eps * ((x * x) * (5.0 * (x * x))); end
code[x_, eps_] := N[(eps * N[(N[(x * x), $MachinePrecision] * N[(5.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \left(\left(x \cdot x\right) \cdot \left(5 \cdot \left(x \cdot x\right)\right)\right)
\end{array}
Initial program 88.2%
Taylor expanded in eps around 0 80.4%
distribute-lft1-in80.4%
metadata-eval80.4%
metadata-eval80.4%
pow-sqr80.3%
pow280.3%
pow280.3%
associate-*r*80.3%
Applied egg-rr80.3%
Final simplification80.3%
(FPCore (x eps) :precision binary64 (* eps (* (* x (* x 5.0)) (* x x))))
double code(double x, double eps) {
return eps * ((x * (x * 5.0)) * (x * x));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps * ((x * (x * 5.0d0)) * (x * x))
end function
public static double code(double x, double eps) {
return eps * ((x * (x * 5.0)) * (x * x));
}
def code(x, eps): return eps * ((x * (x * 5.0)) * (x * x))
function code(x, eps) return Float64(eps * Float64(Float64(x * Float64(x * 5.0)) * Float64(x * x))) end
function tmp = code(x, eps) tmp = eps * ((x * (x * 5.0)) * (x * x)); end
code[x_, eps_] := N[(eps * N[(N[(x * N[(x * 5.0), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \left(\left(x \cdot \left(x \cdot 5\right)\right) \cdot \left(x \cdot x\right)\right)
\end{array}
Initial program 88.2%
Taylor expanded in eps around 0 80.4%
distribute-lft1-in80.4%
metadata-eval80.4%
metadata-eval80.4%
pow-sqr80.3%
pow280.3%
pow280.3%
associate-*r*80.3%
Applied egg-rr80.3%
Taylor expanded in x around 0 80.3%
unpow280.3%
*-commutative80.3%
associate-*r*80.3%
Simplified80.3%
Final simplification80.3%
herbie shell --seed 2023192
(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)))