
(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 -4.4e-41)
(+ (* (* eps (* eps 10.0)) (pow x 3.0)) (* (pow x 4.0) (* eps 5.0)))
(if (<= x 2.65e-39)
(- (pow (+ x eps) 5.0) (pow x 5.0))
(fma
(* eps eps)
(fma 4.0 (pow x 3.0) (* x (* (* x x) 6.0)))
(fma eps (* (pow x 4.0) 5.0) (* (pow eps 3.0) (* 10.0 (* x x))))))))
double code(double x, double eps) {
double tmp;
if (x <= -4.4e-41) {
tmp = ((eps * (eps * 10.0)) * pow(x, 3.0)) + (pow(x, 4.0) * (eps * 5.0));
} else if (x <= 2.65e-39) {
tmp = pow((x + eps), 5.0) - pow(x, 5.0);
} else {
tmp = fma((eps * eps), fma(4.0, pow(x, 3.0), (x * ((x * x) * 6.0))), fma(eps, (pow(x, 4.0) * 5.0), (pow(eps, 3.0) * (10.0 * (x * x)))));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -4.4e-41) tmp = Float64(Float64(Float64(eps * Float64(eps * 10.0)) * (x ^ 3.0)) + Float64((x ^ 4.0) * Float64(eps * 5.0))); elseif (x <= 2.65e-39) tmp = Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0)); else tmp = fma(Float64(eps * eps), fma(4.0, (x ^ 3.0), Float64(x * Float64(Float64(x * x) * 6.0))), fma(eps, Float64((x ^ 4.0) * 5.0), Float64((eps ^ 3.0) * Float64(10.0 * Float64(x * x))))); end return tmp end
code[x_, eps_] := If[LessEqual[x, -4.4e-41], N[(N[(N[(eps * N[(eps * 10.0), $MachinePrecision]), $MachinePrecision] * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[Power[x, 4.0], $MachinePrecision] * N[(eps * 5.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.65e-39], N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision], N[(N[(eps * eps), $MachinePrecision] * N[(4.0 * N[Power[x, 3.0], $MachinePrecision] + N[(x * N[(N[(x * x), $MachinePrecision] * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(eps * N[(N[Power[x, 4.0], $MachinePrecision] * 5.0), $MachinePrecision] + N[(N[Power[eps, 3.0], $MachinePrecision] * N[(10.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.4 \cdot 10^{-41}:\\
\;\;\;\;\left(\varepsilon \cdot \left(\varepsilon \cdot 10\right)\right) \cdot {x}^{3} + {x}^{4} \cdot \left(\varepsilon \cdot 5\right)\\
\mathbf{elif}\;x \leq 2.65 \cdot 10^{-39}:\\
\;\;\;\;{\left(x + \varepsilon\right)}^{5} - {x}^{5}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon \cdot \varepsilon, \mathsf{fma}\left(4, {x}^{3}, x \cdot \left(\left(x \cdot x\right) \cdot 6\right)\right), \mathsf{fma}\left(\varepsilon, {x}^{4} \cdot 5, {\varepsilon}^{3} \cdot \left(10 \cdot \left(x \cdot x\right)\right)\right)\right)\\
\end{array}
\end{array}
if x < -4.4e-41Initial program 30.0%
Taylor expanded in x around inf 99.7%
+-commutative99.7%
fma-def99.7%
distribute-rgt-out99.7%
unpow299.7%
metadata-eval99.7%
associate-*l*99.7%
distribute-lft1-in99.7%
metadata-eval99.7%
*-commutative99.7%
Simplified99.7%
fma-udef99.7%
*-commutative99.7%
Applied egg-rr99.7%
if -4.4e-41 < x < 2.65000000000000002e-39Initial program 99.1%
if 2.65000000000000002e-39 < x Initial program 22.1%
Taylor expanded in eps around 0 99.5%
fma-def99.5%
unpow299.5%
fma-def99.5%
*-commutative99.5%
distribute-rgt-out99.5%
unpow299.5%
metadata-eval99.5%
fma-def99.5%
distribute-lft1-in99.5%
metadata-eval99.5%
distribute-rgt-out99.5%
unpow299.5%
metadata-eval99.5%
Simplified99.5%
Final simplification99.2%
(FPCore (x eps) :precision binary64 (if (or (<= x -2.5e-39) (not (<= x 2.65e-39))) (+ (* (* eps (* eps 10.0)) (pow x 3.0)) (* (pow x 4.0) (* eps 5.0))) (- (pow (+ x eps) 5.0) (pow x 5.0))))
double code(double x, double eps) {
double tmp;
if ((x <= -2.5e-39) || !(x <= 2.65e-39)) {
tmp = ((eps * (eps * 10.0)) * pow(x, 3.0)) + (pow(x, 4.0) * (eps * 5.0));
} 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 <= (-2.5d-39)) .or. (.not. (x <= 2.65d-39))) then
tmp = ((eps * (eps * 10.0d0)) * (x ** 3.0d0)) + ((x ** 4.0d0) * (eps * 5.0d0))
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 <= -2.5e-39) || !(x <= 2.65e-39)) {
tmp = ((eps * (eps * 10.0)) * Math.pow(x, 3.0)) + (Math.pow(x, 4.0) * (eps * 5.0));
} else {
tmp = Math.pow((x + eps), 5.0) - Math.pow(x, 5.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -2.5e-39) or not (x <= 2.65e-39): tmp = ((eps * (eps * 10.0)) * math.pow(x, 3.0)) + (math.pow(x, 4.0) * (eps * 5.0)) else: tmp = math.pow((x + eps), 5.0) - math.pow(x, 5.0) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -2.5e-39) || !(x <= 2.65e-39)) tmp = Float64(Float64(Float64(eps * Float64(eps * 10.0)) * (x ^ 3.0)) + Float64((x ^ 4.0) * Float64(eps * 5.0))); 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 <= -2.5e-39) || ~((x <= 2.65e-39))) tmp = ((eps * (eps * 10.0)) * (x ^ 3.0)) + ((x ^ 4.0) * (eps * 5.0)); else tmp = ((x + eps) ^ 5.0) - (x ^ 5.0); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -2.5e-39], N[Not[LessEqual[x, 2.65e-39]], $MachinePrecision]], N[(N[(N[(eps * N[(eps * 10.0), $MachinePrecision]), $MachinePrecision] * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[Power[x, 4.0], $MachinePrecision] * N[(eps * 5.0), $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 -2.5 \cdot 10^{-39} \lor \neg \left(x \leq 2.65 \cdot 10^{-39}\right):\\
\;\;\;\;\left(\varepsilon \cdot \left(\varepsilon \cdot 10\right)\right) \cdot {x}^{3} + {x}^{4} \cdot \left(\varepsilon \cdot 5\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(x + \varepsilon\right)}^{5} - {x}^{5}\\
\end{array}
\end{array}
if x < -2.4999999999999999e-39 or 2.65000000000000002e-39 < x Initial program 26.8%
Taylor expanded in x around inf 99.5%
+-commutative99.5%
fma-def99.5%
distribute-rgt-out99.5%
unpow299.5%
metadata-eval99.5%
associate-*l*99.5%
distribute-lft1-in99.5%
metadata-eval99.5%
*-commutative99.5%
Simplified99.5%
fma-udef99.5%
*-commutative99.5%
Applied egg-rr99.5%
if -2.4999999999999999e-39 < x < 2.65000000000000002e-39Initial program 99.1%
Final simplification99.1%
(FPCore (x eps)
:precision binary64
(if (<= x -3.3e-40)
(* (pow x 4.0) (* eps 5.0))
(if (<= x 2.65e-39)
(- (pow (+ x eps) 5.0) (pow x 5.0))
(* eps (* (pow x 4.0) 5.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -3.3e-40) {
tmp = pow(x, 4.0) * (eps * 5.0);
} else if (x <= 2.65e-39) {
tmp = pow((x + eps), 5.0) - pow(x, 5.0);
} else {
tmp = eps * (pow(x, 4.0) * 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 <= (-3.3d-40)) then
tmp = (x ** 4.0d0) * (eps * 5.0d0)
else if (x <= 2.65d-39) then
tmp = ((x + eps) ** 5.0d0) - (x ** 5.0d0)
else
tmp = eps * ((x ** 4.0d0) * 5.0d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -3.3e-40) {
tmp = Math.pow(x, 4.0) * (eps * 5.0);
} else if (x <= 2.65e-39) {
tmp = Math.pow((x + eps), 5.0) - Math.pow(x, 5.0);
} else {
tmp = eps * (Math.pow(x, 4.0) * 5.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -3.3e-40: tmp = math.pow(x, 4.0) * (eps * 5.0) elif x <= 2.65e-39: tmp = math.pow((x + eps), 5.0) - math.pow(x, 5.0) else: tmp = eps * (math.pow(x, 4.0) * 5.0) return tmp
function code(x, eps) tmp = 0.0 if (x <= -3.3e-40) tmp = Float64((x ^ 4.0) * Float64(eps * 5.0)); elseif (x <= 2.65e-39) tmp = Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0)); else tmp = Float64(eps * Float64((x ^ 4.0) * 5.0)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -3.3e-40) tmp = (x ^ 4.0) * (eps * 5.0); elseif (x <= 2.65e-39) tmp = ((x + eps) ^ 5.0) - (x ^ 5.0); else tmp = eps * ((x ^ 4.0) * 5.0); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -3.3e-40], N[(N[Power[x, 4.0], $MachinePrecision] * N[(eps * 5.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.65e-39], N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision], N[(eps * N[(N[Power[x, 4.0], $MachinePrecision] * 5.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.3 \cdot 10^{-40}:\\
\;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot 5\right)\\
\mathbf{elif}\;x \leq 2.65 \cdot 10^{-39}:\\
\;\;\;\;{\left(x + \varepsilon\right)}^{5} - {x}^{5}\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left({x}^{4} \cdot 5\right)\\
\end{array}
\end{array}
if x < -3.29999999999999993e-40Initial program 30.0%
Taylor expanded in x around inf 97.8%
distribute-lft1-in97.8%
metadata-eval97.8%
*-commutative97.8%
Simplified97.8%
if -3.29999999999999993e-40 < x < 2.65000000000000002e-39Initial program 99.1%
if 2.65000000000000002e-39 < x Initial program 22.1%
Taylor expanded in eps around 0 94.1%
Taylor expanded in x around 0 94.1%
Final simplification98.8%
(FPCore (x eps) :precision binary64 (if (<= x -4.3e-41) (* 5.0 (* eps (pow x 4.0))) (if (<= x 8.2e-43) (pow eps 5.0) (* eps (* (pow x 4.0) 5.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -4.3e-41) {
tmp = 5.0 * (eps * pow(x, 4.0));
} else if (x <= 8.2e-43) {
tmp = pow(eps, 5.0);
} else {
tmp = eps * (pow(x, 4.0) * 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 <= (-4.3d-41)) then
tmp = 5.0d0 * (eps * (x ** 4.0d0))
else if (x <= 8.2d-43) then
tmp = eps ** 5.0d0
else
tmp = eps * ((x ** 4.0d0) * 5.0d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -4.3e-41) {
tmp = 5.0 * (eps * Math.pow(x, 4.0));
} else if (x <= 8.2e-43) {
tmp = Math.pow(eps, 5.0);
} else {
tmp = eps * (Math.pow(x, 4.0) * 5.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -4.3e-41: tmp = 5.0 * (eps * math.pow(x, 4.0)) elif x <= 8.2e-43: tmp = math.pow(eps, 5.0) else: tmp = eps * (math.pow(x, 4.0) * 5.0) return tmp
function code(x, eps) tmp = 0.0 if (x <= -4.3e-41) tmp = Float64(5.0 * Float64(eps * (x ^ 4.0))); elseif (x <= 8.2e-43) tmp = eps ^ 5.0; else tmp = Float64(eps * Float64((x ^ 4.0) * 5.0)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -4.3e-41) tmp = 5.0 * (eps * (x ^ 4.0)); elseif (x <= 8.2e-43) tmp = eps ^ 5.0; else tmp = eps * ((x ^ 4.0) * 5.0); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -4.3e-41], N[(5.0 * N[(eps * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8.2e-43], N[Power[eps, 5.0], $MachinePrecision], N[(eps * N[(N[Power[x, 4.0], $MachinePrecision] * 5.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.3 \cdot 10^{-41}:\\
\;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\
\mathbf{elif}\;x \leq 8.2 \cdot 10^{-43}:\\
\;\;\;\;{\varepsilon}^{5}\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left({x}^{4} \cdot 5\right)\\
\end{array}
\end{array}
if x < -4.2999999999999999e-41Initial program 30.0%
Taylor expanded in eps around 0 97.4%
Taylor expanded in x around 0 97.5%
if -4.2999999999999999e-41 < x < 8.1999999999999996e-43Initial program 99.2%
Taylor expanded in x around 0 98.2%
if 8.1999999999999996e-43 < x Initial program 36.6%
Taylor expanded in eps around 0 90.0%
Taylor expanded in x around 0 90.0%
Final simplification97.7%
(FPCore (x eps) :precision binary64 (if (<= x -4.3e-41) (* (pow x 4.0) (* eps 5.0)) (if (<= x 8.2e-43) (pow eps 5.0) (* eps (* (pow x 4.0) 5.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -4.3e-41) {
tmp = pow(x, 4.0) * (eps * 5.0);
} else if (x <= 8.2e-43) {
tmp = pow(eps, 5.0);
} else {
tmp = eps * (pow(x, 4.0) * 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 <= (-4.3d-41)) then
tmp = (x ** 4.0d0) * (eps * 5.0d0)
else if (x <= 8.2d-43) then
tmp = eps ** 5.0d0
else
tmp = eps * ((x ** 4.0d0) * 5.0d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -4.3e-41) {
tmp = Math.pow(x, 4.0) * (eps * 5.0);
} else if (x <= 8.2e-43) {
tmp = Math.pow(eps, 5.0);
} else {
tmp = eps * (Math.pow(x, 4.0) * 5.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -4.3e-41: tmp = math.pow(x, 4.0) * (eps * 5.0) elif x <= 8.2e-43: tmp = math.pow(eps, 5.0) else: tmp = eps * (math.pow(x, 4.0) * 5.0) return tmp
function code(x, eps) tmp = 0.0 if (x <= -4.3e-41) tmp = Float64((x ^ 4.0) * Float64(eps * 5.0)); elseif (x <= 8.2e-43) tmp = eps ^ 5.0; else tmp = Float64(eps * Float64((x ^ 4.0) * 5.0)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -4.3e-41) tmp = (x ^ 4.0) * (eps * 5.0); elseif (x <= 8.2e-43) tmp = eps ^ 5.0; else tmp = eps * ((x ^ 4.0) * 5.0); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -4.3e-41], N[(N[Power[x, 4.0], $MachinePrecision] * N[(eps * 5.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8.2e-43], N[Power[eps, 5.0], $MachinePrecision], N[(eps * N[(N[Power[x, 4.0], $MachinePrecision] * 5.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.3 \cdot 10^{-41}:\\
\;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot 5\right)\\
\mathbf{elif}\;x \leq 8.2 \cdot 10^{-43}:\\
\;\;\;\;{\varepsilon}^{5}\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left({x}^{4} \cdot 5\right)\\
\end{array}
\end{array}
if x < -4.2999999999999999e-41Initial program 30.0%
Taylor expanded in x around inf 97.8%
distribute-lft1-in97.8%
metadata-eval97.8%
*-commutative97.8%
Simplified97.8%
if -4.2999999999999999e-41 < x < 8.1999999999999996e-43Initial program 99.2%
Taylor expanded in x around 0 98.2%
if 8.1999999999999996e-43 < x Initial program 36.6%
Taylor expanded in eps around 0 90.0%
Taylor expanded in x around 0 90.0%
Final simplification97.7%
(FPCore (x eps) :precision binary64 (if (<= x -7.8e-41) (* 5.0 (* eps (pow x 4.0))) (if (<= x 8.2e-43) (pow eps 5.0) (* eps (* (* x x) (* 5.0 (* x x)))))))
double code(double x, double eps) {
double tmp;
if (x <= -7.8e-41) {
tmp = 5.0 * (eps * pow(x, 4.0));
} else if (x <= 8.2e-43) {
tmp = pow(eps, 5.0);
} else {
tmp = eps * ((x * x) * (5.0 * (x * x)));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-7.8d-41)) then
tmp = 5.0d0 * (eps * (x ** 4.0d0))
else if (x <= 8.2d-43) then
tmp = eps ** 5.0d0
else
tmp = eps * ((x * x) * (5.0d0 * (x * x)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -7.8e-41) {
tmp = 5.0 * (eps * Math.pow(x, 4.0));
} else if (x <= 8.2e-43) {
tmp = Math.pow(eps, 5.0);
} else {
tmp = eps * ((x * x) * (5.0 * (x * x)));
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -7.8e-41: tmp = 5.0 * (eps * math.pow(x, 4.0)) elif x <= 8.2e-43: tmp = math.pow(eps, 5.0) else: tmp = eps * ((x * x) * (5.0 * (x * x))) return tmp
function code(x, eps) tmp = 0.0 if (x <= -7.8e-41) tmp = Float64(5.0 * Float64(eps * (x ^ 4.0))); elseif (x <= 8.2e-43) tmp = eps ^ 5.0; else tmp = Float64(eps * Float64(Float64(x * x) * Float64(5.0 * Float64(x * x)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -7.8e-41) tmp = 5.0 * (eps * (x ^ 4.0)); elseif (x <= 8.2e-43) tmp = eps ^ 5.0; else tmp = eps * ((x * x) * (5.0 * (x * x))); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -7.8e-41], N[(5.0 * N[(eps * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8.2e-43], N[Power[eps, 5.0], $MachinePrecision], N[(eps * N[(N[(x * x), $MachinePrecision] * N[(5.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.8 \cdot 10^{-41}:\\
\;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\
\mathbf{elif}\;x \leq 8.2 \cdot 10^{-43}:\\
\;\;\;\;{\varepsilon}^{5}\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(\left(x \cdot x\right) \cdot \left(5 \cdot \left(x \cdot x\right)\right)\right)\\
\end{array}
\end{array}
if x < -7.79999999999999982e-41Initial program 30.0%
Taylor expanded in eps around 0 97.4%
Taylor expanded in x around 0 97.5%
if -7.79999999999999982e-41 < x < 8.1999999999999996e-43Initial program 99.2%
Taylor expanded in x around 0 98.2%
if 8.1999999999999996e-43 < x Initial program 36.6%
Taylor expanded in eps around 0 90.0%
+-commutative90.0%
metadata-eval90.0%
pow-prod-up89.9%
pow289.9%
pow289.9%
fma-def90.0%
Applied egg-rr90.0%
fma-udef89.9%
pow289.9%
pow-prod-down89.9%
pow-sqr90.0%
metadata-eval90.0%
distribute-rgt1-in90.0%
metadata-eval90.0%
metadata-eval90.0%
pow-sqr89.8%
pow289.8%
pow289.8%
associate-*r*89.8%
Applied egg-rr89.8%
Final simplification97.7%
(FPCore (x eps) :precision binary64 (if (or (<= x -4.3e-41) (not (<= x 1.12e-42))) (* eps (* (* x x) (* 5.0 (* x x)))) (pow eps 5.0)))
double code(double x, double eps) {
double tmp;
if ((x <= -4.3e-41) || !(x <= 1.12e-42)) {
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 <= (-4.3d-41)) .or. (.not. (x <= 1.12d-42))) 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 <= -4.3e-41) || !(x <= 1.12e-42)) {
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 <= -4.3e-41) or not (x <= 1.12e-42): 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 <= -4.3e-41) || !(x <= 1.12e-42)) tmp = Float64(eps * Float64(Float64(x * x) * Float64(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 <= -4.3e-41) || ~((x <= 1.12e-42))) 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, -4.3e-41], N[Not[LessEqual[x, 1.12e-42]], $MachinePrecision]], N[(eps * N[(N[(x * x), $MachinePrecision] * N[(5.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[eps, 5.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.3 \cdot 10^{-41} \lor \neg \left(x \leq 1.12 \cdot 10^{-42}\right):\\
\;\;\;\;\varepsilon \cdot \left(\left(x \cdot x\right) \cdot \left(5 \cdot \left(x \cdot x\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\
\end{array}
\end{array}
if x < -4.2999999999999999e-41 or 1.1199999999999999e-42 < x Initial program 33.0%
Taylor expanded in eps around 0 94.1%
+-commutative94.1%
metadata-eval94.1%
pow-prod-up94.0%
pow294.0%
pow294.0%
fma-def94.1%
Applied egg-rr94.1%
fma-udef94.0%
pow294.0%
pow-prod-down94.0%
pow-sqr94.1%
metadata-eval94.1%
distribute-rgt1-in94.1%
metadata-eval94.1%
metadata-eval94.1%
pow-sqr93.9%
pow293.9%
pow293.9%
associate-*r*93.8%
Applied egg-rr93.8%
if -4.2999999999999999e-41 < x < 1.1199999999999999e-42Initial program 99.2%
Taylor expanded in x around 0 98.2%
Final simplification97.7%
(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 90.6%
Taylor expanded in eps around 0 84.3%
+-commutative84.3%
metadata-eval84.3%
pow-prod-up84.3%
pow284.3%
pow284.3%
fma-def84.3%
Applied egg-rr84.3%
fma-udef84.3%
pow284.3%
pow-prod-down84.3%
pow-sqr84.3%
metadata-eval84.3%
distribute-rgt1-in84.3%
metadata-eval84.3%
metadata-eval84.3%
pow-sqr84.3%
pow284.3%
pow284.3%
associate-*r*84.3%
Applied egg-rr84.3%
Final simplification84.3%
(FPCore (x eps) :precision binary64 0.0)
double code(double x, double eps) {
return 0.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 0.0d0
end function
public static double code(double x, double eps) {
return 0.0;
}
def code(x, eps): return 0.0
function code(x, eps) return 0.0 end
function tmp = code(x, eps) tmp = 0.0; end
code[x_, eps_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 90.6%
sqr-pow44.1%
metadata-eval44.1%
metadata-eval44.1%
Applied egg-rr44.1%
pow244.1%
Applied egg-rr44.1%
Taylor expanded in x around inf 74.5%
distribute-rgt1-in74.5%
metadata-eval74.5%
mul0-lft74.5%
Simplified74.5%
Final simplification74.5%
herbie shell --seed 2023194
(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)))