
(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
(if (<= x -2.65e-48)
(* eps (* (pow x 4.0) (+ (/ (* eps 10.0) x) 5.0)))
(if (<= x 1.55e-69)
(pow eps 5.0)
(*
eps
(+
(* (pow x 4.0) 5.0)
(*
eps
(+ (* 10.0 (pow x 3.0)) (* eps (* x (+ (* eps 5.0) (* x 10.0)))))))))))
double code(double x, double eps) {
double tmp;
if (x <= -2.65e-48) {
tmp = eps * (pow(x, 4.0) * (((eps * 10.0) / x) + 5.0));
} else if (x <= 1.55e-69) {
tmp = pow(eps, 5.0);
} else {
tmp = eps * ((pow(x, 4.0) * 5.0) + (eps * ((10.0 * pow(x, 3.0)) + (eps * (x * ((eps * 5.0) + (x * 10.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.65d-48)) then
tmp = eps * ((x ** 4.0d0) * (((eps * 10.0d0) / x) + 5.0d0))
else if (x <= 1.55d-69) then
tmp = eps ** 5.0d0
else
tmp = eps * (((x ** 4.0d0) * 5.0d0) + (eps * ((10.0d0 * (x ** 3.0d0)) + (eps * (x * ((eps * 5.0d0) + (x * 10.0d0)))))))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -2.65e-48) {
tmp = eps * (Math.pow(x, 4.0) * (((eps * 10.0) / x) + 5.0));
} else if (x <= 1.55e-69) {
tmp = Math.pow(eps, 5.0);
} else {
tmp = eps * ((Math.pow(x, 4.0) * 5.0) + (eps * ((10.0 * Math.pow(x, 3.0)) + (eps * (x * ((eps * 5.0) + (x * 10.0)))))));
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -2.65e-48: tmp = eps * (math.pow(x, 4.0) * (((eps * 10.0) / x) + 5.0)) elif x <= 1.55e-69: tmp = math.pow(eps, 5.0) else: tmp = eps * ((math.pow(x, 4.0) * 5.0) + (eps * ((10.0 * math.pow(x, 3.0)) + (eps * (x * ((eps * 5.0) + (x * 10.0))))))) return tmp
function code(x, eps) tmp = 0.0 if (x <= -2.65e-48) tmp = Float64(eps * Float64((x ^ 4.0) * Float64(Float64(Float64(eps * 10.0) / x) + 5.0))); elseif (x <= 1.55e-69) tmp = eps ^ 5.0; else tmp = Float64(eps * Float64(Float64((x ^ 4.0) * 5.0) + Float64(eps * Float64(Float64(10.0 * (x ^ 3.0)) + Float64(eps * Float64(x * Float64(Float64(eps * 5.0) + Float64(x * 10.0)))))))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -2.65e-48) tmp = eps * ((x ^ 4.0) * (((eps * 10.0) / x) + 5.0)); elseif (x <= 1.55e-69) tmp = eps ^ 5.0; else tmp = eps * (((x ^ 4.0) * 5.0) + (eps * ((10.0 * (x ^ 3.0)) + (eps * (x * ((eps * 5.0) + (x * 10.0))))))); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -2.65e-48], N[(eps * N[(N[Power[x, 4.0], $MachinePrecision] * N[(N[(N[(eps * 10.0), $MachinePrecision] / x), $MachinePrecision] + 5.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.55e-69], N[Power[eps, 5.0], $MachinePrecision], N[(eps * N[(N[(N[Power[x, 4.0], $MachinePrecision] * 5.0), $MachinePrecision] + N[(eps * N[(N[(10.0 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(eps * N[(x * N[(N[(eps * 5.0), $MachinePrecision] + N[(x * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.65 \cdot 10^{-48}:\\
\;\;\;\;\varepsilon \cdot \left({x}^{4} \cdot \left(\frac{\varepsilon \cdot 10}{x} + 5\right)\right)\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{-69}:\\
\;\;\;\;{\varepsilon}^{5}\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left({x}^{4} \cdot 5 + \varepsilon \cdot \left(10 \cdot {x}^{3} + \varepsilon \cdot \left(x \cdot \left(\varepsilon \cdot 5 + x \cdot 10\right)\right)\right)\right)\\
\end{array}
\end{array}
if x < -2.65e-48Initial program 28.6%
Taylor expanded in x around -inf 99.5%
+-commutative99.5%
associate-+r+99.5%
mul-1-neg99.5%
unsub-neg99.5%
distribute-rgt1-in99.5%
metadata-eval99.5%
*-commutative99.5%
Simplified99.5%
associate-/l*99.5%
unpow299.5%
associate-*l*99.5%
Applied egg-rr99.5%
Taylor expanded in x around inf 99.5%
Simplified99.6%
if -2.65e-48 < x < 1.55e-69Initial program 100.0%
Taylor expanded in x around 0 100.0%
if 1.55e-69 < x Initial program 42.0%
Taylor expanded in eps around 0 97.5%
Simplified97.4%
Taylor expanded in x around 0 97.4%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(if (<= x -3.8e-48)
(* eps (* (pow x 4.0) (+ (/ (* eps 10.0) x) 5.0)))
(if (<= x 1.55e-69)
(pow eps 5.0)
(* eps (+ (* (pow x 4.0) 5.0) (* eps (* 10.0 (* (* x x) (+ x eps)))))))))
double code(double x, double eps) {
double tmp;
if (x <= -3.8e-48) {
tmp = eps * (pow(x, 4.0) * (((eps * 10.0) / x) + 5.0));
} else if (x <= 1.55e-69) {
tmp = pow(eps, 5.0);
} else {
tmp = eps * ((pow(x, 4.0) * 5.0) + (eps * (10.0 * ((x * x) * (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 <= (-3.8d-48)) then
tmp = eps * ((x ** 4.0d0) * (((eps * 10.0d0) / x) + 5.0d0))
else if (x <= 1.55d-69) then
tmp = eps ** 5.0d0
else
tmp = eps * (((x ** 4.0d0) * 5.0d0) + (eps * (10.0d0 * ((x * x) * (x + eps)))))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -3.8e-48) {
tmp = eps * (Math.pow(x, 4.0) * (((eps * 10.0) / x) + 5.0));
} else if (x <= 1.55e-69) {
tmp = Math.pow(eps, 5.0);
} else {
tmp = eps * ((Math.pow(x, 4.0) * 5.0) + (eps * (10.0 * ((x * x) * (x + eps)))));
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -3.8e-48: tmp = eps * (math.pow(x, 4.0) * (((eps * 10.0) / x) + 5.0)) elif x <= 1.55e-69: tmp = math.pow(eps, 5.0) else: tmp = eps * ((math.pow(x, 4.0) * 5.0) + (eps * (10.0 * ((x * x) * (x + eps))))) return tmp
function code(x, eps) tmp = 0.0 if (x <= -3.8e-48) tmp = Float64(eps * Float64((x ^ 4.0) * Float64(Float64(Float64(eps * 10.0) / x) + 5.0))); elseif (x <= 1.55e-69) tmp = eps ^ 5.0; else tmp = Float64(eps * Float64(Float64((x ^ 4.0) * 5.0) + Float64(eps * Float64(10.0 * Float64(Float64(x * x) * Float64(x + eps)))))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -3.8e-48) tmp = eps * ((x ^ 4.0) * (((eps * 10.0) / x) + 5.0)); elseif (x <= 1.55e-69) tmp = eps ^ 5.0; else tmp = eps * (((x ^ 4.0) * 5.0) + (eps * (10.0 * ((x * x) * (x + eps))))); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -3.8e-48], N[(eps * N[(N[Power[x, 4.0], $MachinePrecision] * N[(N[(N[(eps * 10.0), $MachinePrecision] / x), $MachinePrecision] + 5.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.55e-69], N[Power[eps, 5.0], $MachinePrecision], N[(eps * N[(N[(N[Power[x, 4.0], $MachinePrecision] * 5.0), $MachinePrecision] + N[(eps * N[(10.0 * N[(N[(x * x), $MachinePrecision] * N[(x + eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.8 \cdot 10^{-48}:\\
\;\;\;\;\varepsilon \cdot \left({x}^{4} \cdot \left(\frac{\varepsilon \cdot 10}{x} + 5\right)\right)\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{-69}:\\
\;\;\;\;{\varepsilon}^{5}\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left({x}^{4} \cdot 5 + \varepsilon \cdot \left(10 \cdot \left(\left(x \cdot x\right) \cdot \left(x + \varepsilon\right)\right)\right)\right)\\
\end{array}
\end{array}
if x < -3.80000000000000002e-48Initial program 28.6%
Taylor expanded in x around -inf 99.5%
+-commutative99.5%
associate-+r+99.5%
mul-1-neg99.5%
unsub-neg99.5%
distribute-rgt1-in99.5%
metadata-eval99.5%
*-commutative99.5%
Simplified99.5%
associate-/l*99.5%
unpow299.5%
associate-*l*99.5%
Applied egg-rr99.5%
Taylor expanded in x around inf 99.5%
Simplified99.6%
if -3.80000000000000002e-48 < x < 1.55e-69Initial program 100.0%
Taylor expanded in x around 0 100.0%
if 1.55e-69 < x Initial program 42.0%
Taylor expanded in eps around 0 97.5%
Simplified97.4%
Taylor expanded in eps around 0 96.8%
distribute-lft-out96.8%
cube-mult96.8%
unpow296.8%
distribute-rgt-out96.8%
Simplified96.8%
unpow296.8%
Applied egg-rr96.8%
Final simplification99.5%
(FPCore (x eps) :precision binary64 (if (or (<= x -1.4e-47) (not (<= x 1.55e-69))) (* eps (* (pow x 4.0) (+ (/ (* eps 10.0) x) 5.0))) (pow eps 5.0)))
double code(double x, double eps) {
double tmp;
if ((x <= -1.4e-47) || !(x <= 1.55e-69)) {
tmp = eps * (pow(x, 4.0) * (((eps * 10.0) / x) + 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.4d-47)) .or. (.not. (x <= 1.55d-69))) then
tmp = eps * ((x ** 4.0d0) * (((eps * 10.0d0) / x) + 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.4e-47) || !(x <= 1.55e-69)) {
tmp = eps * (Math.pow(x, 4.0) * (((eps * 10.0) / x) + 5.0));
} else {
tmp = Math.pow(eps, 5.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -1.4e-47) or not (x <= 1.55e-69): tmp = eps * (math.pow(x, 4.0) * (((eps * 10.0) / x) + 5.0)) else: tmp = math.pow(eps, 5.0) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -1.4e-47) || !(x <= 1.55e-69)) tmp = Float64(eps * Float64((x ^ 4.0) * Float64(Float64(Float64(eps * 10.0) / x) + 5.0))); else tmp = eps ^ 5.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -1.4e-47) || ~((x <= 1.55e-69))) tmp = eps * ((x ^ 4.0) * (((eps * 10.0) / x) + 5.0)); else tmp = eps ^ 5.0; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -1.4e-47], N[Not[LessEqual[x, 1.55e-69]], $MachinePrecision]], N[(eps * N[(N[Power[x, 4.0], $MachinePrecision] * N[(N[(N[(eps * 10.0), $MachinePrecision] / x), $MachinePrecision] + 5.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[eps, 5.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.4 \cdot 10^{-47} \lor \neg \left(x \leq 1.55 \cdot 10^{-69}\right):\\
\;\;\;\;\varepsilon \cdot \left({x}^{4} \cdot \left(\frac{\varepsilon \cdot 10}{x} + 5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\
\end{array}
\end{array}
if x < -1.39999999999999996e-47 or 1.55e-69 < x Initial program 37.1%
Taylor expanded in x around -inf 96.8%
+-commutative96.8%
associate-+r+96.8%
mul-1-neg96.8%
unsub-neg96.8%
distribute-rgt1-in96.8%
metadata-eval96.8%
*-commutative96.8%
Simplified96.8%
associate-/l*96.8%
unpow296.8%
associate-*l*96.8%
Applied egg-rr96.8%
Taylor expanded in x around inf 96.8%
Simplified97.0%
if -1.39999999999999996e-47 < x < 1.55e-69Initial program 100.0%
Taylor expanded in x around 0 100.0%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (if (or (<= x -6.2e-48) (not (<= x 1.55e-69))) (* eps (* (pow x 4.0) 5.0)) (pow eps 5.0)))
double code(double x, double eps) {
double tmp;
if ((x <= -6.2e-48) || !(x <= 1.55e-69)) {
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 <= (-6.2d-48)) .or. (.not. (x <= 1.55d-69))) 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 <= -6.2e-48) || !(x <= 1.55e-69)) {
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 <= -6.2e-48) or not (x <= 1.55e-69): 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 <= -6.2e-48) || !(x <= 1.55e-69)) 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 <= -6.2e-48) || ~((x <= 1.55e-69))) tmp = eps * ((x ^ 4.0) * 5.0); else tmp = eps ^ 5.0; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -6.2e-48], N[Not[LessEqual[x, 1.55e-69]], $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.2 \cdot 10^{-48} \lor \neg \left(x \leq 1.55 \cdot 10^{-69}\right):\\
\;\;\;\;\varepsilon \cdot \left({x}^{4} \cdot 5\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\
\end{array}
\end{array}
if x < -6.20000000000000033e-48 or 1.55e-69 < x Initial program 37.1%
Taylor expanded in x around inf 95.7%
*-commutative95.7%
distribute-rgt1-in95.7%
metadata-eval95.7%
*-commutative95.7%
associate-*r*95.9%
Simplified95.9%
if -6.20000000000000033e-48 < x < 1.55e-69Initial program 100.0%
Taylor expanded in x around 0 100.0%
Final simplification99.0%
(FPCore (x eps) :precision binary64 (if (<= x -3.5e-48) (* (pow x 5.0) (* (/ eps x) (- -5.0))) (if (<= x 1.55e-69) (pow eps 5.0) (* eps (* (pow x 4.0) 5.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -3.5e-48) {
tmp = pow(x, 5.0) * ((eps / x) * -(-5.0));
} else if (x <= 1.55e-69) {
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 <= (-3.5d-48)) then
tmp = (x ** 5.0d0) * ((eps / x) * -(-5.0d0))
else if (x <= 1.55d-69) 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 <= -3.5e-48) {
tmp = Math.pow(x, 5.0) * ((eps / x) * -(-5.0));
} else if (x <= 1.55e-69) {
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 <= -3.5e-48: tmp = math.pow(x, 5.0) * ((eps / x) * -(-5.0)) elif x <= 1.55e-69: 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 <= -3.5e-48) tmp = Float64((x ^ 5.0) * Float64(Float64(eps / x) * Float64(-(-5.0)))); elseif (x <= 1.55e-69) 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 <= -3.5e-48) tmp = (x ^ 5.0) * ((eps / x) * -(-5.0)); elseif (x <= 1.55e-69) tmp = eps ^ 5.0; else tmp = eps * ((x ^ 4.0) * 5.0); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -3.5e-48], N[(N[Power[x, 5.0], $MachinePrecision] * N[(N[(eps / x), $MachinePrecision] * (--5.0)), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.55e-69], 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 -3.5 \cdot 10^{-48}:\\
\;\;\;\;{x}^{5} \cdot \left(\frac{\varepsilon}{x} \cdot \left(--5\right)\right)\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{-69}:\\
\;\;\;\;{\varepsilon}^{5}\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left({x}^{4} \cdot 5\right)\\
\end{array}
\end{array}
if x < -3.49999999999999991e-48Initial program 28.6%
sqr-pow0.0%
metadata-eval0.0%
metadata-eval0.0%
Applied egg-rr0.0%
Taylor expanded in x around -inf 0.0%
mul-1-neg0.0%
distribute-rgt-neg-in0.0%
sub-neg0.0%
mul-1-neg0.0%
distribute-rgt1-in0.0%
metadata-eval0.0%
associate-*r/0.0%
*-commutative0.0%
distribute-rgt-neg-in0.0%
metadata-eval0.0%
unpow20.0%
rem-square-sqrt98.8%
metadata-eval98.8%
metadata-eval98.8%
Simplified98.8%
if -3.49999999999999991e-48 < x < 1.55e-69Initial program 100.0%
Taylor expanded in x around 0 100.0%
if 1.55e-69 < x Initial program 42.0%
Taylor expanded in x around inf 94.0%
*-commutative94.0%
distribute-rgt1-in94.0%
metadata-eval94.0%
*-commutative94.0%
associate-*r*94.2%
Simplified94.2%
Final simplification99.0%
(FPCore (x eps) :precision binary64 (if (<= x -1.6e-48) (* (* eps 5.0) (* (* x x) (* x x))) (if (<= x 1.55e-69) (pow eps 5.0) (* 5.0 (* eps (pow x 4.0))))))
double code(double x, double eps) {
double tmp;
if (x <= -1.6e-48) {
tmp = (eps * 5.0) * ((x * x) * (x * x));
} else if (x <= 1.55e-69) {
tmp = pow(eps, 5.0);
} else {
tmp = 5.0 * (eps * 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 <= (-1.6d-48)) then
tmp = (eps * 5.0d0) * ((x * x) * (x * x))
else if (x <= 1.55d-69) then
tmp = eps ** 5.0d0
else
tmp = 5.0d0 * (eps * (x ** 4.0d0))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -1.6e-48) {
tmp = (eps * 5.0) * ((x * x) * (x * x));
} else if (x <= 1.55e-69) {
tmp = Math.pow(eps, 5.0);
} else {
tmp = 5.0 * (eps * Math.pow(x, 4.0));
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -1.6e-48: tmp = (eps * 5.0) * ((x * x) * (x * x)) elif x <= 1.55e-69: tmp = math.pow(eps, 5.0) else: tmp = 5.0 * (eps * math.pow(x, 4.0)) return tmp
function code(x, eps) tmp = 0.0 if (x <= -1.6e-48) tmp = Float64(Float64(eps * 5.0) * Float64(Float64(x * x) * Float64(x * x))); elseif (x <= 1.55e-69) tmp = eps ^ 5.0; else tmp = Float64(5.0 * Float64(eps * (x ^ 4.0))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -1.6e-48) tmp = (eps * 5.0) * ((x * x) * (x * x)); elseif (x <= 1.55e-69) tmp = eps ^ 5.0; else tmp = 5.0 * (eps * (x ^ 4.0)); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -1.6e-48], N[(N[(eps * 5.0), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.55e-69], N[Power[eps, 5.0], $MachinePrecision], N[(5.0 * N[(eps * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6 \cdot 10^{-48}:\\
\;\;\;\;\left(\varepsilon \cdot 5\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{-69}:\\
\;\;\;\;{\varepsilon}^{5}\\
\mathbf{else}:\\
\;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\
\end{array}
\end{array}
if x < -1.5999999999999999e-48Initial program 28.6%
Taylor expanded in x around inf 98.6%
distribute-rgt1-in98.6%
metadata-eval98.6%
Simplified98.6%
metadata-eval98.6%
pow-prod-up98.6%
Applied egg-rr98.6%
unpow299.5%
Applied egg-rr98.6%
unpow299.5%
Applied egg-rr98.6%
if -1.5999999999999999e-48 < x < 1.55e-69Initial program 100.0%
Taylor expanded in x around 0 100.0%
if 1.55e-69 < x Initial program 42.0%
Taylor expanded in x around inf 94.0%
distribute-rgt1-in94.0%
metadata-eval94.0%
Simplified94.0%
Taylor expanded in x around 0 94.1%
Final simplification99.0%
(FPCore (x eps) :precision binary64 (if (or (<= x -2.8e-48) (not (<= x 1.55e-69))) (* (* eps 5.0) (* (* x x) (* x x))) (pow eps 5.0)))
double code(double x, double eps) {
double tmp;
if ((x <= -2.8e-48) || !(x <= 1.55e-69)) {
tmp = (eps * 5.0) * ((x * x) * (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 <= (-2.8d-48)) .or. (.not. (x <= 1.55d-69))) then
tmp = (eps * 5.0d0) * ((x * x) * (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 <= -2.8e-48) || !(x <= 1.55e-69)) {
tmp = (eps * 5.0) * ((x * x) * (x * x));
} else {
tmp = Math.pow(eps, 5.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -2.8e-48) or not (x <= 1.55e-69): tmp = (eps * 5.0) * ((x * x) * (x * x)) else: tmp = math.pow(eps, 5.0) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -2.8e-48) || !(x <= 1.55e-69)) tmp = Float64(Float64(eps * 5.0) * Float64(Float64(x * x) * Float64(x * x))); else tmp = eps ^ 5.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -2.8e-48) || ~((x <= 1.55e-69))) tmp = (eps * 5.0) * ((x * x) * (x * x)); else tmp = eps ^ 5.0; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -2.8e-48], N[Not[LessEqual[x, 1.55e-69]], $MachinePrecision]], N[(N[(eps * 5.0), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[eps, 5.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.8 \cdot 10^{-48} \lor \neg \left(x \leq 1.55 \cdot 10^{-69}\right):\\
\;\;\;\;\left(\varepsilon \cdot 5\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\
\end{array}
\end{array}
if x < -2.80000000000000005e-48 or 1.55e-69 < x Initial program 37.1%
Taylor expanded in x around inf 95.7%
distribute-rgt1-in95.7%
metadata-eval95.7%
Simplified95.7%
metadata-eval95.7%
pow-prod-up95.6%
Applied egg-rr95.6%
unpow297.8%
Applied egg-rr95.6%
unpow297.8%
Applied egg-rr95.6%
if -2.80000000000000005e-48 < x < 1.55e-69Initial program 100.0%
Taylor expanded in x around 0 100.0%
Final simplification99.0%
(FPCore (x eps) :precision binary64 (* (* eps 5.0) (* (* x x) (* x x))))
double code(double x, double eps) {
return (eps * 5.0) * ((x * x) * (x * x));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (eps * 5.0d0) * ((x * x) * (x * x))
end function
public static double code(double x, double eps) {
return (eps * 5.0) * ((x * x) * (x * x));
}
def code(x, eps): return (eps * 5.0) * ((x * x) * (x * x))
function code(x, eps) return Float64(Float64(eps * 5.0) * Float64(Float64(x * x) * Float64(x * x))) end
function tmp = code(x, eps) tmp = (eps * 5.0) * ((x * x) * (x * x)); end
code[x_, eps_] := N[(N[(eps * 5.0), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\varepsilon \cdot 5\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)
\end{array}
Initial program 85.3%
Taylor expanded in x around inf 84.3%
distribute-rgt1-in84.3%
metadata-eval84.3%
Simplified84.3%
metadata-eval84.3%
pow-prod-up84.3%
Applied egg-rr84.3%
unpow284.9%
Applied egg-rr84.3%
unpow284.9%
Applied egg-rr84.3%
Final simplification84.3%
herbie shell --seed 2024163
(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)))