
(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 10 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 -5e-302) (not (<= t_0 0.0)))
t_0
(* (* x (pow x 3.0)) (* eps 5.0)))))
double code(double x, double eps) {
double t_0 = pow((x + eps), 5.0) - pow(x, 5.0);
double tmp;
if ((t_0 <= -5e-302) || !(t_0 <= 0.0)) {
tmp = t_0;
} else {
tmp = (x * pow(x, 3.0)) * (eps * 5.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 <= (-5d-302)) .or. (.not. (t_0 <= 0.0d0))) then
tmp = t_0
else
tmp = (x * (x ** 3.0d0)) * (eps * 5.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 <= -5e-302) || !(t_0 <= 0.0)) {
tmp = t_0;
} else {
tmp = (x * Math.pow(x, 3.0)) * (eps * 5.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 <= -5e-302) or not (t_0 <= 0.0): tmp = t_0 else: tmp = (x * math.pow(x, 3.0)) * (eps * 5.0) return tmp
function code(x, eps) t_0 = Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0)) tmp = 0.0 if ((t_0 <= -5e-302) || !(t_0 <= 0.0)) tmp = t_0; else tmp = Float64(Float64(x * (x ^ 3.0)) * Float64(eps * 5.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 <= -5e-302) || ~((t_0 <= 0.0))) tmp = t_0; else tmp = (x * (x ^ 3.0)) * (eps * 5.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, -5e-302], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], t$95$0, N[(N[(x * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] * N[(eps * 5.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(x + \varepsilon\right)}^{5} - {x}^{5}\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-302} \lor \neg \left(t\_0 \leq 0\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot {x}^{3}\right) \cdot \left(\varepsilon \cdot 5\right)\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < -5.00000000000000033e-302 or 0.0 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) Initial program 98.9%
if -5.00000000000000033e-302 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < 0.0Initial program 89.6%
Taylor expanded in x around inf 100.0%
distribute-rgt1-in100.0%
metadata-eval100.0%
Simplified100.0%
add-sqr-sqrt99.9%
sqrt-unprod98.8%
pow-prod-up98.8%
metadata-eval98.8%
Applied egg-rr98.8%
sqrt-pow1100.0%
metadata-eval100.0%
metadata-eval100.0%
pow-prod-up99.9%
pow299.9%
associate-*r*100.0%
pow2100.0%
pow3100.0%
Applied egg-rr100.0%
Final simplification99.7%
(FPCore (x eps) :precision binary64 (if (or (<= x -6.2e-48) (not (<= x 8.2e-63))) (* eps (+ (* (* (+ x eps) (* x x)) (* eps 10.0)) (* 5.0 (pow x 4.0)))) (* (pow eps 5.0) (+ 1.0 (* 5.0 (/ x eps))))))
double code(double x, double eps) {
double tmp;
if ((x <= -6.2e-48) || !(x <= 8.2e-63)) {
tmp = eps * ((((x + eps) * (x * x)) * (eps * 10.0)) + (5.0 * pow(x, 4.0)));
} else {
tmp = pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((x <= (-6.2d-48)) .or. (.not. (x <= 8.2d-63))) then
tmp = eps * ((((x + eps) * (x * x)) * (eps * 10.0d0)) + (5.0d0 * (x ** 4.0d0)))
else
tmp = (eps ** 5.0d0) * (1.0d0 + (5.0d0 * (x / eps)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -6.2e-48) || !(x <= 8.2e-63)) {
tmp = eps * ((((x + eps) * (x * x)) * (eps * 10.0)) + (5.0 * Math.pow(x, 4.0)));
} else {
tmp = Math.pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -6.2e-48) or not (x <= 8.2e-63): tmp = eps * ((((x + eps) * (x * x)) * (eps * 10.0)) + (5.0 * math.pow(x, 4.0))) else: tmp = math.pow(eps, 5.0) * (1.0 + (5.0 * (x / eps))) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -6.2e-48) || !(x <= 8.2e-63)) tmp = Float64(eps * Float64(Float64(Float64(Float64(x + eps) * Float64(x * x)) * Float64(eps * 10.0)) + Float64(5.0 * (x ^ 4.0)))); else tmp = Float64((eps ^ 5.0) * Float64(1.0 + Float64(5.0 * Float64(x / eps)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -6.2e-48) || ~((x <= 8.2e-63))) tmp = eps * ((((x + eps) * (x * x)) * (eps * 10.0)) + (5.0 * (x ^ 4.0))); else tmp = (eps ^ 5.0) * (1.0 + (5.0 * (x / eps))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -6.2e-48], N[Not[LessEqual[x, 8.2e-63]], $MachinePrecision]], N[(eps * N[(N[(N[(N[(x + eps), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(eps * 10.0), $MachinePrecision]), $MachinePrecision] + N[(5.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[eps, 5.0], $MachinePrecision] * N[(1.0 + N[(5.0 * N[(x / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.2 \cdot 10^{-48} \lor \neg \left(x \leq 8.2 \cdot 10^{-63}\right):\\
\;\;\;\;\varepsilon \cdot \left(\left(\left(x + \varepsilon\right) \cdot \left(x \cdot x\right)\right) \cdot \left(\varepsilon \cdot 10\right) + 5 \cdot {x}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5} \cdot \left(1 + 5 \cdot \frac{x}{\varepsilon}\right)\\
\end{array}
\end{array}
if x < -6.20000000000000033e-48 or 8.1999999999999995e-63 < x Initial program 49.8%
Taylor expanded in x around -inf 97.3%
Simplified97.2%
Taylor expanded in eps around 0 95.5%
fma-define95.4%
distribute-lft-out95.4%
cube-mult95.4%
unpow295.4%
distribute-rgt-out95.4%
Simplified95.4%
fma-undefine95.5%
+-commutative95.5%
associate-*r*95.5%
*-commutative95.5%
+-commutative95.5%
Applied egg-rr95.5%
unpow295.5%
Applied egg-rr95.5%
if -6.20000000000000033e-48 < x < 8.1999999999999995e-63Initial program 100.0%
Taylor expanded in eps around inf 100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (if (or (<= x -7e-49) (not (<= x 8.2e-63))) (* (pow x 4.0) (* eps (+ 5.0 (* 10.0 (/ eps x))))) (* (pow eps 5.0) (+ 1.0 (* 5.0 (/ x eps))))))
double code(double x, double eps) {
double tmp;
if ((x <= -7e-49) || !(x <= 8.2e-63)) {
tmp = pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x))));
} else {
tmp = pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((x <= (-7d-49)) .or. (.not. (x <= 8.2d-63))) then
tmp = (x ** 4.0d0) * (eps * (5.0d0 + (10.0d0 * (eps / x))))
else
tmp = (eps ** 5.0d0) * (1.0d0 + (5.0d0 * (x / eps)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -7e-49) || !(x <= 8.2e-63)) {
tmp = Math.pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x))));
} else {
tmp = Math.pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -7e-49) or not (x <= 8.2e-63): tmp = math.pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x)))) else: tmp = math.pow(eps, 5.0) * (1.0 + (5.0 * (x / eps))) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -7e-49) || !(x <= 8.2e-63)) tmp = Float64((x ^ 4.0) * Float64(eps * Float64(5.0 + Float64(10.0 * Float64(eps / x))))); else tmp = Float64((eps ^ 5.0) * Float64(1.0 + Float64(5.0 * Float64(x / eps)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -7e-49) || ~((x <= 8.2e-63))) tmp = (x ^ 4.0) * (eps * (5.0 + (10.0 * (eps / x)))); else tmp = (eps ^ 5.0) * (1.0 + (5.0 * (x / eps))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -7e-49], N[Not[LessEqual[x, 8.2e-63]], $MachinePrecision]], N[(N[Power[x, 4.0], $MachinePrecision] * N[(eps * N[(5.0 + N[(10.0 * N[(eps / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[eps, 5.0], $MachinePrecision] * N[(1.0 + N[(5.0 * N[(x / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7 \cdot 10^{-49} \lor \neg \left(x \leq 8.2 \cdot 10^{-63}\right):\\
\;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot \left(5 + 10 \cdot \frac{\varepsilon}{x}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5} \cdot \left(1 + 5 \cdot \frac{x}{\varepsilon}\right)\\
\end{array}
\end{array}
if x < -7.00000000000000012e-49 or 8.1999999999999995e-63 < x Initial program 49.8%
Taylor expanded in x around -inf 94.0%
+-commutative94.0%
associate-+r+94.0%
mul-1-neg94.0%
unsub-neg94.0%
distribute-rgt1-in94.0%
metadata-eval94.0%
*-commutative94.0%
Simplified94.0%
Taylor expanded in eps around 0 94.0%
if -7.00000000000000012e-49 < x < 8.1999999999999995e-63Initial program 100.0%
Taylor expanded in eps around inf 100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification99.0%
(FPCore (x eps) :precision binary64 (if (or (<= x -6e-49) (not (<= x 8.2e-63))) (* eps (* (pow x 3.0) (+ (* eps 10.0) (* x 5.0)))) (* (pow eps 5.0) (+ 1.0 (* 5.0 (/ x eps))))))
double code(double x, double eps) {
double tmp;
if ((x <= -6e-49) || !(x <= 8.2e-63)) {
tmp = eps * (pow(x, 3.0) * ((eps * 10.0) + (x * 5.0)));
} else {
tmp = pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((x <= (-6d-49)) .or. (.not. (x <= 8.2d-63))) then
tmp = eps * ((x ** 3.0d0) * ((eps * 10.0d0) + (x * 5.0d0)))
else
tmp = (eps ** 5.0d0) * (1.0d0 + (5.0d0 * (x / eps)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -6e-49) || !(x <= 8.2e-63)) {
tmp = eps * (Math.pow(x, 3.0) * ((eps * 10.0) + (x * 5.0)));
} else {
tmp = Math.pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -6e-49) or not (x <= 8.2e-63): tmp = eps * (math.pow(x, 3.0) * ((eps * 10.0) + (x * 5.0))) else: tmp = math.pow(eps, 5.0) * (1.0 + (5.0 * (x / eps))) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -6e-49) || !(x <= 8.2e-63)) tmp = Float64(eps * Float64((x ^ 3.0) * Float64(Float64(eps * 10.0) + Float64(x * 5.0)))); else tmp = Float64((eps ^ 5.0) * Float64(1.0 + Float64(5.0 * Float64(x / eps)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -6e-49) || ~((x <= 8.2e-63))) tmp = eps * ((x ^ 3.0) * ((eps * 10.0) + (x * 5.0))); else tmp = (eps ^ 5.0) * (1.0 + (5.0 * (x / eps))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -6e-49], N[Not[LessEqual[x, 8.2e-63]], $MachinePrecision]], N[(eps * N[(N[Power[x, 3.0], $MachinePrecision] * N[(N[(eps * 10.0), $MachinePrecision] + N[(x * 5.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[eps, 5.0], $MachinePrecision] * N[(1.0 + N[(5.0 * N[(x / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6 \cdot 10^{-49} \lor \neg \left(x \leq 8.2 \cdot 10^{-63}\right):\\
\;\;\;\;\varepsilon \cdot \left({x}^{3} \cdot \left(\varepsilon \cdot 10 + x \cdot 5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5} \cdot \left(1 + 5 \cdot \frac{x}{\varepsilon}\right)\\
\end{array}
\end{array}
if x < -6e-49 or 8.1999999999999995e-63 < x Initial program 49.8%
Taylor expanded in x around -inf 97.3%
Simplified97.2%
Taylor expanded in eps around 0 95.5%
fma-define95.4%
distribute-lft-out95.4%
cube-mult95.4%
unpow295.4%
distribute-rgt-out95.4%
Simplified95.4%
fma-undefine95.5%
+-commutative95.5%
associate-*r*95.5%
*-commutative95.5%
+-commutative95.5%
Applied egg-rr95.5%
Taylor expanded in eps around 0 93.8%
*-commutative93.8%
metadata-eval93.8%
pow-plus93.9%
associate-*l*93.8%
*-commutative93.8%
associate-*r*93.8%
*-commutative93.8%
distribute-lft-out93.8%
*-commutative93.8%
Simplified93.8%
if -6e-49 < x < 8.1999999999999995e-63Initial program 100.0%
Taylor expanded in eps around inf 100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification99.0%
(FPCore (x eps)
:precision binary64
(if (<= x -3.2e-48)
(* eps (* (pow x 4.0) (+ 5.0 (* 10.0 (/ eps x)))))
(if (<= x 8.2e-63)
(* (pow eps 5.0) (+ 1.0 (* 5.0 (/ x eps))))
(* eps (* (pow x 3.0) (+ (* eps 10.0) (* x 5.0)))))))
double code(double x, double eps) {
double tmp;
if (x <= -3.2e-48) {
tmp = eps * (pow(x, 4.0) * (5.0 + (10.0 * (eps / x))));
} else if (x <= 8.2e-63) {
tmp = pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)));
} else {
tmp = eps * (pow(x, 3.0) * ((eps * 10.0) + (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 <= (-3.2d-48)) then
tmp = eps * ((x ** 4.0d0) * (5.0d0 + (10.0d0 * (eps / x))))
else if (x <= 8.2d-63) then
tmp = (eps ** 5.0d0) * (1.0d0 + (5.0d0 * (x / eps)))
else
tmp = eps * ((x ** 3.0d0) * ((eps * 10.0d0) + (x * 5.0d0)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -3.2e-48) {
tmp = eps * (Math.pow(x, 4.0) * (5.0 + (10.0 * (eps / x))));
} else if (x <= 8.2e-63) {
tmp = Math.pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)));
} else {
tmp = eps * (Math.pow(x, 3.0) * ((eps * 10.0) + (x * 5.0)));
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -3.2e-48: tmp = eps * (math.pow(x, 4.0) * (5.0 + (10.0 * (eps / x)))) elif x <= 8.2e-63: tmp = math.pow(eps, 5.0) * (1.0 + (5.0 * (x / eps))) else: tmp = eps * (math.pow(x, 3.0) * ((eps * 10.0) + (x * 5.0))) return tmp
function code(x, eps) tmp = 0.0 if (x <= -3.2e-48) tmp = Float64(eps * Float64((x ^ 4.0) * Float64(5.0 + Float64(10.0 * Float64(eps / x))))); elseif (x <= 8.2e-63) tmp = Float64((eps ^ 5.0) * Float64(1.0 + Float64(5.0 * Float64(x / eps)))); else tmp = Float64(eps * Float64((x ^ 3.0) * Float64(Float64(eps * 10.0) + Float64(x * 5.0)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -3.2e-48) tmp = eps * ((x ^ 4.0) * (5.0 + (10.0 * (eps / x)))); elseif (x <= 8.2e-63) tmp = (eps ^ 5.0) * (1.0 + (5.0 * (x / eps))); else tmp = eps * ((x ^ 3.0) * ((eps * 10.0) + (x * 5.0))); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -3.2e-48], N[(eps * N[(N[Power[x, 4.0], $MachinePrecision] * N[(5.0 + N[(10.0 * N[(eps / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8.2e-63], N[(N[Power[eps, 5.0], $MachinePrecision] * N[(1.0 + N[(5.0 * N[(x / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(eps * N[(N[Power[x, 3.0], $MachinePrecision] * N[(N[(eps * 10.0), $MachinePrecision] + N[(x * 5.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.2 \cdot 10^{-48}:\\
\;\;\;\;\varepsilon \cdot \left({x}^{4} \cdot \left(5 + 10 \cdot \frac{\varepsilon}{x}\right)\right)\\
\mathbf{elif}\;x \leq 8.2 \cdot 10^{-63}:\\
\;\;\;\;{\varepsilon}^{5} \cdot \left(1 + 5 \cdot \frac{x}{\varepsilon}\right)\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left({x}^{3} \cdot \left(\varepsilon \cdot 10 + x \cdot 5\right)\right)\\
\end{array}
\end{array}
if x < -3.1999999999999998e-48Initial program 52.7%
Taylor expanded in x around -inf 94.3%
Simplified94.2%
Taylor expanded in eps around 0 92.2%
fma-define92.1%
distribute-lft-out92.1%
cube-mult92.1%
unpow292.1%
distribute-rgt-out92.1%
Simplified92.1%
Taylor expanded in x around inf 90.3%
if -3.1999999999999998e-48 < x < 8.1999999999999995e-63Initial program 100.0%
Taylor expanded in eps around inf 100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
Simplified100.0%
if 8.1999999999999995e-63 < x Initial program 48.0%
Taylor expanded in x around -inf 99.0%
Simplified99.0%
Taylor expanded in eps around 0 97.3%
fma-define97.3%
distribute-lft-out97.3%
cube-mult97.3%
unpow297.3%
distribute-rgt-out97.3%
Simplified97.3%
fma-undefine97.3%
+-commutative97.3%
associate-*r*97.3%
*-commutative97.3%
+-commutative97.3%
Applied egg-rr97.3%
Taylor expanded in eps around 0 95.9%
*-commutative95.9%
metadata-eval95.9%
pow-plus96.0%
associate-*l*96.0%
*-commutative96.0%
associate-*r*96.0%
*-commutative96.0%
distribute-lft-out96.0%
*-commutative96.0%
Simplified96.0%
Final simplification99.0%
(FPCore (x eps)
:precision binary64
(if (<= x -4.4e-48)
(* (* eps 5.0) (pow x 4.0))
(if (<= x 8.2e-63)
(* (pow eps 5.0) (+ 1.0 (* 5.0 (/ x eps))))
(* (* x (pow x 3.0)) (* eps 5.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -4.4e-48) {
tmp = (eps * 5.0) * pow(x, 4.0);
} else if (x <= 8.2e-63) {
tmp = pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)));
} else {
tmp = (x * pow(x, 3.0)) * (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.4d-48)) then
tmp = (eps * 5.0d0) * (x ** 4.0d0)
else if (x <= 8.2d-63) then
tmp = (eps ** 5.0d0) * (1.0d0 + (5.0d0 * (x / eps)))
else
tmp = (x * (x ** 3.0d0)) * (eps * 5.0d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -4.4e-48) {
tmp = (eps * 5.0) * Math.pow(x, 4.0);
} else if (x <= 8.2e-63) {
tmp = Math.pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)));
} else {
tmp = (x * Math.pow(x, 3.0)) * (eps * 5.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -4.4e-48: tmp = (eps * 5.0) * math.pow(x, 4.0) elif x <= 8.2e-63: tmp = math.pow(eps, 5.0) * (1.0 + (5.0 * (x / eps))) else: tmp = (x * math.pow(x, 3.0)) * (eps * 5.0) return tmp
function code(x, eps) tmp = 0.0 if (x <= -4.4e-48) tmp = Float64(Float64(eps * 5.0) * (x ^ 4.0)); elseif (x <= 8.2e-63) tmp = Float64((eps ^ 5.0) * Float64(1.0 + Float64(5.0 * Float64(x / eps)))); else tmp = Float64(Float64(x * (x ^ 3.0)) * Float64(eps * 5.0)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -4.4e-48) tmp = (eps * 5.0) * (x ^ 4.0); elseif (x <= 8.2e-63) tmp = (eps ^ 5.0) * (1.0 + (5.0 * (x / eps))); else tmp = (x * (x ^ 3.0)) * (eps * 5.0); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -4.4e-48], N[(N[(eps * 5.0), $MachinePrecision] * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8.2e-63], N[(N[Power[eps, 5.0], $MachinePrecision] * N[(1.0 + N[(5.0 * N[(x / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] * N[(eps * 5.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.4 \cdot 10^{-48}:\\
\;\;\;\;\left(\varepsilon \cdot 5\right) \cdot {x}^{4}\\
\mathbf{elif}\;x \leq 8.2 \cdot 10^{-63}:\\
\;\;\;\;{\varepsilon}^{5} \cdot \left(1 + 5 \cdot \frac{x}{\varepsilon}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot {x}^{3}\right) \cdot \left(\varepsilon \cdot 5\right)\\
\end{array}
\end{array}
if x < -4.40000000000000025e-48Initial program 52.7%
Taylor expanded in x around inf 87.0%
distribute-rgt1-in87.0%
metadata-eval87.0%
Simplified87.0%
if -4.40000000000000025e-48 < x < 8.1999999999999995e-63Initial program 100.0%
Taylor expanded in eps around inf 100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
Simplified100.0%
if 8.1999999999999995e-63 < x Initial program 48.0%
Taylor expanded in x around inf 94.7%
distribute-rgt1-in94.7%
metadata-eval94.7%
Simplified94.7%
add-sqr-sqrt94.5%
sqrt-unprod88.7%
pow-prod-up88.7%
metadata-eval88.7%
Applied egg-rr88.7%
sqrt-pow194.7%
metadata-eval94.7%
metadata-eval94.7%
pow-prod-up94.6%
pow294.6%
associate-*r*94.7%
pow294.7%
pow394.7%
Applied egg-rr94.7%
Final simplification98.7%
(FPCore (x eps) :precision binary64 (if (<= x -1.05e-48) (* (* eps 5.0) (pow x 4.0)) (if (<= x 8.2e-63) (pow eps 5.0) (* (* x (pow x 3.0)) (* eps 5.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -1.05e-48) {
tmp = (eps * 5.0) * pow(x, 4.0);
} else if (x <= 8.2e-63) {
tmp = pow(eps, 5.0);
} else {
tmp = (x * pow(x, 3.0)) * (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.05d-48)) then
tmp = (eps * 5.0d0) * (x ** 4.0d0)
else if (x <= 8.2d-63) then
tmp = eps ** 5.0d0
else
tmp = (x * (x ** 3.0d0)) * (eps * 5.0d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -1.05e-48) {
tmp = (eps * 5.0) * Math.pow(x, 4.0);
} else if (x <= 8.2e-63) {
tmp = Math.pow(eps, 5.0);
} else {
tmp = (x * Math.pow(x, 3.0)) * (eps * 5.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -1.05e-48: tmp = (eps * 5.0) * math.pow(x, 4.0) elif x <= 8.2e-63: tmp = math.pow(eps, 5.0) else: tmp = (x * math.pow(x, 3.0)) * (eps * 5.0) return tmp
function code(x, eps) tmp = 0.0 if (x <= -1.05e-48) tmp = Float64(Float64(eps * 5.0) * (x ^ 4.0)); elseif (x <= 8.2e-63) tmp = eps ^ 5.0; else tmp = Float64(Float64(x * (x ^ 3.0)) * Float64(eps * 5.0)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -1.05e-48) tmp = (eps * 5.0) * (x ^ 4.0); elseif (x <= 8.2e-63) tmp = eps ^ 5.0; else tmp = (x * (x ^ 3.0)) * (eps * 5.0); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -1.05e-48], N[(N[(eps * 5.0), $MachinePrecision] * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8.2e-63], N[Power[eps, 5.0], $MachinePrecision], N[(N[(x * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] * N[(eps * 5.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.05 \cdot 10^{-48}:\\
\;\;\;\;\left(\varepsilon \cdot 5\right) \cdot {x}^{4}\\
\mathbf{elif}\;x \leq 8.2 \cdot 10^{-63}:\\
\;\;\;\;{\varepsilon}^{5}\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot {x}^{3}\right) \cdot \left(\varepsilon \cdot 5\right)\\
\end{array}
\end{array}
if x < -1.04999999999999994e-48Initial program 52.7%
Taylor expanded in x around inf 87.0%
distribute-rgt1-in87.0%
metadata-eval87.0%
Simplified87.0%
if -1.04999999999999994e-48 < x < 8.1999999999999995e-63Initial program 100.0%
Taylor expanded in x around 0 99.9%
if 8.1999999999999995e-63 < x Initial program 48.0%
Taylor expanded in x around inf 94.7%
distribute-rgt1-in94.7%
metadata-eval94.7%
Simplified94.7%
add-sqr-sqrt94.5%
sqrt-unprod88.7%
pow-prod-up88.7%
metadata-eval88.7%
Applied egg-rr88.7%
sqrt-pow194.7%
metadata-eval94.7%
metadata-eval94.7%
pow-prod-up94.6%
pow294.6%
associate-*r*94.7%
pow294.7%
pow394.7%
Applied egg-rr94.7%
Final simplification98.7%
(FPCore (x eps) :precision binary64 (if (or (<= x -1.2e-48) (not (<= x 8.2e-63))) (* (* eps 5.0) (pow x 4.0)) (pow eps 5.0)))
double code(double x, double eps) {
double tmp;
if ((x <= -1.2e-48) || !(x <= 8.2e-63)) {
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.2d-48)) .or. (.not. (x <= 8.2d-63))) 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.2e-48) || !(x <= 8.2e-63)) {
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.2e-48) or not (x <= 8.2e-63): 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.2e-48) || !(x <= 8.2e-63)) 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.2e-48) || ~((x <= 8.2e-63))) 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.2e-48], N[Not[LessEqual[x, 8.2e-63]], $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.2 \cdot 10^{-48} \lor \neg \left(x \leq 8.2 \cdot 10^{-63}\right):\\
\;\;\;\;\left(\varepsilon \cdot 5\right) \cdot {x}^{4}\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\
\end{array}
\end{array}
if x < -1.2e-48 or 8.1999999999999995e-63 < x Initial program 49.8%
Taylor expanded in x around inf 91.8%
distribute-rgt1-in91.8%
metadata-eval91.8%
Simplified91.8%
if -1.2e-48 < x < 8.1999999999999995e-63Initial program 100.0%
Taylor expanded in x around 0 99.9%
Final simplification98.6%
(FPCore (x eps) :precision binary64 (if (or (<= x -7e-49) (not (<= x 8.2e-63))) (* eps (* 5.0 (* (* x x) (* x x)))) (pow eps 5.0)))
double code(double x, double eps) {
double tmp;
if ((x <= -7e-49) || !(x <= 8.2e-63)) {
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 <= (-7d-49)) .or. (.not. (x <= 8.2d-63))) 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 <= -7e-49) || !(x <= 8.2e-63)) {
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 <= -7e-49) or not (x <= 8.2e-63): 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 <= -7e-49) || !(x <= 8.2e-63)) tmp = Float64(eps * Float64(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 <= -7e-49) || ~((x <= 8.2e-63))) 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, -7e-49], N[Not[LessEqual[x, 8.2e-63]], $MachinePrecision]], N[(eps * N[(5.0 * N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[eps, 5.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7 \cdot 10^{-49} \lor \neg \left(x \leq 8.2 \cdot 10^{-63}\right):\\
\;\;\;\;\varepsilon \cdot \left(5 \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\
\end{array}
\end{array}
if x < -7.00000000000000012e-49 or 8.1999999999999995e-63 < x Initial program 49.8%
Taylor expanded in x around inf 91.8%
*-commutative91.8%
distribute-rgt1-in91.8%
metadata-eval91.8%
*-commutative91.8%
associate-*r*91.6%
Simplified91.6%
metadata-eval91.6%
pow-prod-up91.7%
Applied egg-rr91.7%
unpow295.5%
Applied egg-rr91.7%
unpow295.5%
Applied egg-rr91.7%
if -7.00000000000000012e-49 < x < 8.1999999999999995e-63Initial program 100.0%
Taylor expanded in x around 0 99.9%
Final simplification98.6%
(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(eps * Float64(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[(eps * N[(5.0 * N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \left(5 \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)\right)
\end{array}
Initial program 91.9%
Taylor expanded in x around inf 76.6%
*-commutative76.6%
distribute-rgt1-in76.6%
metadata-eval76.6%
*-commutative76.6%
associate-*r*76.5%
Simplified76.5%
metadata-eval76.5%
pow-prod-up76.6%
Applied egg-rr76.6%
unpow277.2%
Applied egg-rr76.6%
unpow277.2%
Applied egg-rr76.6%
herbie shell --seed 2024177
(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)))