
(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
(if (<= x -3.2e-55)
(* eps (+ (* 5.0 (pow x 4.0)) (* eps (* (pow x 3.0) 10.0))))
(if (<= x 5e-80)
(fma x (* 5.0 (pow eps 4.0)) (pow eps 5.0))
(* (pow x 3.0) (* eps (+ (* x 5.0) (* eps 10.0)))))))
double code(double x, double eps) {
double tmp;
if (x <= -3.2e-55) {
tmp = eps * ((5.0 * pow(x, 4.0)) + (eps * (pow(x, 3.0) * 10.0)));
} else if (x <= 5e-80) {
tmp = fma(x, (5.0 * pow(eps, 4.0)), pow(eps, 5.0));
} else {
tmp = pow(x, 3.0) * (eps * ((x * 5.0) + (eps * 10.0)));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -3.2e-55) tmp = Float64(eps * Float64(Float64(5.0 * (x ^ 4.0)) + Float64(eps * Float64((x ^ 3.0) * 10.0)))); elseif (x <= 5e-80) tmp = fma(x, Float64(5.0 * (eps ^ 4.0)), (eps ^ 5.0)); else tmp = Float64((x ^ 3.0) * Float64(eps * Float64(Float64(x * 5.0) + Float64(eps * 10.0)))); end return tmp end
code[x_, eps_] := If[LessEqual[x, -3.2e-55], N[(eps * N[(N[(5.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(eps * N[(N[Power[x, 3.0], $MachinePrecision] * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5e-80], N[(x * N[(5.0 * N[Power[eps, 4.0], $MachinePrecision]), $MachinePrecision] + N[Power[eps, 5.0], $MachinePrecision]), $MachinePrecision], N[(N[Power[x, 3.0], $MachinePrecision] * N[(eps * N[(N[(x * 5.0), $MachinePrecision] + N[(eps * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.2 \cdot 10^{-55}:\\
\;\;\;\;\varepsilon \cdot \left(5 \cdot {x}^{4} + \varepsilon \cdot \left({x}^{3} \cdot 10\right)\right)\\
\mathbf{elif}\;x \leq 5 \cdot 10^{-80}:\\
\;\;\;\;\mathsf{fma}\left(x, 5 \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right)\\
\mathbf{else}:\\
\;\;\;\;{x}^{3} \cdot \left(\varepsilon \cdot \left(x \cdot 5 + \varepsilon \cdot 10\right)\right)\\
\end{array}
\end{array}
if x < -3.2000000000000001e-55Initial program 41.7%
Taylor expanded in eps around 0 96.2%
+-commutative96.2%
associate-+r+96.2%
distribute-lft1-in96.2%
metadata-eval96.2%
*-commutative96.2%
distribute-rgt-out96.2%
associate-*r*96.2%
unpow296.2%
cube-mult96.2%
distribute-lft-out96.2%
metadata-eval96.2%
metadata-eval96.2%
Simplified96.2%
if -3.2000000000000001e-55 < x < 5e-80Initial program 100.0%
Taylor expanded in x around 0 100.0%
fma-define100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
Simplified100.0%
if 5e-80 < x Initial program 53.3%
Taylor expanded in eps around 0 99.7%
+-commutative99.7%
associate-+r+99.7%
distribute-lft1-in99.7%
metadata-eval99.7%
*-commutative99.7%
distribute-rgt-out99.7%
associate-*r*99.7%
unpow299.7%
cube-mult99.7%
distribute-lft-out99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 99.8%
*-commutative99.8%
associate-*r*99.9%
unpow299.9%
associate-*r*99.9%
distribute-rgt-out99.9%
*-commutative99.9%
Simplified99.9%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(if (<= x -2.8e-55)
(* eps (+ (* 5.0 (pow x 4.0)) (* eps (* (pow x 3.0) 10.0))))
(if (<= x 2e-81)
(* (pow eps 5.0) (+ 1.0 (* 5.0 (/ x eps))))
(* (pow x 3.0) (* eps (+ (* x 5.0) (* eps 10.0)))))))
double code(double x, double eps) {
double tmp;
if (x <= -2.8e-55) {
tmp = eps * ((5.0 * pow(x, 4.0)) + (eps * (pow(x, 3.0) * 10.0)));
} else if (x <= 2e-81) {
tmp = pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)));
} else {
tmp = pow(x, 3.0) * (eps * ((x * 5.0) + (eps * 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.8d-55)) then
tmp = eps * ((5.0d0 * (x ** 4.0d0)) + (eps * ((x ** 3.0d0) * 10.0d0)))
else if (x <= 2d-81) then
tmp = (eps ** 5.0d0) * (1.0d0 + (5.0d0 * (x / eps)))
else
tmp = (x ** 3.0d0) * (eps * ((x * 5.0d0) + (eps * 10.0d0)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -2.8e-55) {
tmp = eps * ((5.0 * Math.pow(x, 4.0)) + (eps * (Math.pow(x, 3.0) * 10.0)));
} else if (x <= 2e-81) {
tmp = Math.pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)));
} else {
tmp = Math.pow(x, 3.0) * (eps * ((x * 5.0) + (eps * 10.0)));
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -2.8e-55: tmp = eps * ((5.0 * math.pow(x, 4.0)) + (eps * (math.pow(x, 3.0) * 10.0))) elif x <= 2e-81: tmp = math.pow(eps, 5.0) * (1.0 + (5.0 * (x / eps))) else: tmp = math.pow(x, 3.0) * (eps * ((x * 5.0) + (eps * 10.0))) return tmp
function code(x, eps) tmp = 0.0 if (x <= -2.8e-55) tmp = Float64(eps * Float64(Float64(5.0 * (x ^ 4.0)) + Float64(eps * Float64((x ^ 3.0) * 10.0)))); elseif (x <= 2e-81) tmp = Float64((eps ^ 5.0) * Float64(1.0 + Float64(5.0 * Float64(x / eps)))); else tmp = Float64((x ^ 3.0) * Float64(eps * Float64(Float64(x * 5.0) + Float64(eps * 10.0)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -2.8e-55) tmp = eps * ((5.0 * (x ^ 4.0)) + (eps * ((x ^ 3.0) * 10.0))); elseif (x <= 2e-81) tmp = (eps ^ 5.0) * (1.0 + (5.0 * (x / eps))); else tmp = (x ^ 3.0) * (eps * ((x * 5.0) + (eps * 10.0))); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -2.8e-55], N[(eps * N[(N[(5.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(eps * N[(N[Power[x, 3.0], $MachinePrecision] * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2e-81], N[(N[Power[eps, 5.0], $MachinePrecision] * N[(1.0 + N[(5.0 * N[(x / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, 3.0], $MachinePrecision] * N[(eps * N[(N[(x * 5.0), $MachinePrecision] + N[(eps * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.8 \cdot 10^{-55}:\\
\;\;\;\;\varepsilon \cdot \left(5 \cdot {x}^{4} + \varepsilon \cdot \left({x}^{3} \cdot 10\right)\right)\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-81}:\\
\;\;\;\;{\varepsilon}^{5} \cdot \left(1 + 5 \cdot \frac{x}{\varepsilon}\right)\\
\mathbf{else}:\\
\;\;\;\;{x}^{3} \cdot \left(\varepsilon \cdot \left(x \cdot 5 + \varepsilon \cdot 10\right)\right)\\
\end{array}
\end{array}
if x < -2.79999999999999984e-55Initial program 41.7%
Taylor expanded in eps around 0 96.2%
+-commutative96.2%
associate-+r+96.2%
distribute-lft1-in96.2%
metadata-eval96.2%
*-commutative96.2%
distribute-rgt-out96.2%
associate-*r*96.2%
unpow296.2%
cube-mult96.2%
distribute-lft-out96.2%
metadata-eval96.2%
metadata-eval96.2%
Simplified96.2%
if -2.79999999999999984e-55 < x < 1.9999999999999999e-81Initial program 100.0%
Taylor expanded in eps around inf 100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
Simplified100.0%
if 1.9999999999999999e-81 < x Initial program 53.3%
Taylor expanded in eps around 0 99.7%
+-commutative99.7%
associate-+r+99.7%
distribute-lft1-in99.7%
metadata-eval99.7%
*-commutative99.7%
distribute-rgt-out99.7%
associate-*r*99.7%
unpow299.7%
cube-mult99.7%
distribute-lft-out99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 99.8%
*-commutative99.8%
associate-*r*99.9%
unpow299.9%
associate-*r*99.9%
distribute-rgt-out99.9%
*-commutative99.9%
Simplified99.9%
Final simplification99.6%
(FPCore (x eps) :precision binary64 (if (or (<= x -3.1e-54) (not (<= x 1.4e-79))) (* (pow x 3.0) (* eps (+ (* x 5.0) (* eps 10.0)))) (* (pow eps 5.0) (+ 1.0 (* 5.0 (/ x eps))))))
double code(double x, double eps) {
double tmp;
if ((x <= -3.1e-54) || !(x <= 1.4e-79)) {
tmp = pow(x, 3.0) * (eps * ((x * 5.0) + (eps * 10.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 <= (-3.1d-54)) .or. (.not. (x <= 1.4d-79))) then
tmp = (x ** 3.0d0) * (eps * ((x * 5.0d0) + (eps * 10.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 <= -3.1e-54) || !(x <= 1.4e-79)) {
tmp = Math.pow(x, 3.0) * (eps * ((x * 5.0) + (eps * 10.0)));
} else {
tmp = Math.pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -3.1e-54) or not (x <= 1.4e-79): tmp = math.pow(x, 3.0) * (eps * ((x * 5.0) + (eps * 10.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 <= -3.1e-54) || !(x <= 1.4e-79)) tmp = Float64((x ^ 3.0) * Float64(eps * Float64(Float64(x * 5.0) + Float64(eps * 10.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 <= -3.1e-54) || ~((x <= 1.4e-79))) tmp = (x ^ 3.0) * (eps * ((x * 5.0) + (eps * 10.0))); else tmp = (eps ^ 5.0) * (1.0 + (5.0 * (x / eps))); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -3.1e-54], N[Not[LessEqual[x, 1.4e-79]], $MachinePrecision]], N[(N[Power[x, 3.0], $MachinePrecision] * N[(eps * N[(N[(x * 5.0), $MachinePrecision] + N[(eps * 10.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 -3.1 \cdot 10^{-54} \lor \neg \left(x \leq 1.4 \cdot 10^{-79}\right):\\
\;\;\;\;{x}^{3} \cdot \left(\varepsilon \cdot \left(x \cdot 5 + \varepsilon \cdot 10\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5} \cdot \left(1 + 5 \cdot \frac{x}{\varepsilon}\right)\\
\end{array}
\end{array}
if x < -3.10000000000000004e-54 or 1.40000000000000006e-79 < x Initial program 48.3%
Taylor expanded in eps around 0 98.2%
+-commutative98.2%
associate-+r+98.2%
distribute-lft1-in98.2%
metadata-eval98.2%
*-commutative98.2%
distribute-rgt-out98.2%
associate-*r*98.2%
unpow298.2%
cube-mult98.2%
distribute-lft-out98.2%
metadata-eval98.2%
metadata-eval98.2%
Simplified98.2%
Taylor expanded in x around 0 98.1%
*-commutative98.1%
associate-*r*98.2%
unpow298.2%
associate-*r*98.2%
distribute-rgt-out98.2%
*-commutative98.2%
Simplified98.2%
if -3.10000000000000004e-54 < x < 1.40000000000000006e-79Initial program 100.0%
Taylor expanded in eps around inf 100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(if (<= x -5e-55)
(* (pow x 4.0) (* eps (+ 5.0 (* 10.0 (/ eps x)))))
(if (<= x 2e-80)
(* (pow eps 5.0) (+ 1.0 (* 5.0 (/ x eps))))
(* (pow x 3.0) (* eps (+ (* x 5.0) (* eps 10.0)))))))
double code(double x, double eps) {
double tmp;
if (x <= -5e-55) {
tmp = pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x))));
} else if (x <= 2e-80) {
tmp = pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)));
} else {
tmp = pow(x, 3.0) * (eps * ((x * 5.0) + (eps * 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 <= (-5d-55)) then
tmp = (x ** 4.0d0) * (eps * (5.0d0 + (10.0d0 * (eps / x))))
else if (x <= 2d-80) then
tmp = (eps ** 5.0d0) * (1.0d0 + (5.0d0 * (x / eps)))
else
tmp = (x ** 3.0d0) * (eps * ((x * 5.0d0) + (eps * 10.0d0)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -5e-55) {
tmp = Math.pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x))));
} else if (x <= 2e-80) {
tmp = Math.pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)));
} else {
tmp = Math.pow(x, 3.0) * (eps * ((x * 5.0) + (eps * 10.0)));
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -5e-55: tmp = math.pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x)))) elif x <= 2e-80: tmp = math.pow(eps, 5.0) * (1.0 + (5.0 * (x / eps))) else: tmp = math.pow(x, 3.0) * (eps * ((x * 5.0) + (eps * 10.0))) return tmp
function code(x, eps) tmp = 0.0 if (x <= -5e-55) tmp = Float64((x ^ 4.0) * Float64(eps * Float64(5.0 + Float64(10.0 * Float64(eps / x))))); elseif (x <= 2e-80) tmp = Float64((eps ^ 5.0) * Float64(1.0 + Float64(5.0 * Float64(x / eps)))); else tmp = Float64((x ^ 3.0) * Float64(eps * Float64(Float64(x * 5.0) + Float64(eps * 10.0)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -5e-55) tmp = (x ^ 4.0) * (eps * (5.0 + (10.0 * (eps / x)))); elseif (x <= 2e-80) tmp = (eps ^ 5.0) * (1.0 + (5.0 * (x / eps))); else tmp = (x ^ 3.0) * (eps * ((x * 5.0) + (eps * 10.0))); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -5e-55], N[(N[Power[x, 4.0], $MachinePrecision] * N[(eps * N[(5.0 + N[(10.0 * N[(eps / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2e-80], N[(N[Power[eps, 5.0], $MachinePrecision] * N[(1.0 + N[(5.0 * N[(x / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, 3.0], $MachinePrecision] * N[(eps * N[(N[(x * 5.0), $MachinePrecision] + N[(eps * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-55}:\\
\;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot \left(5 + 10 \cdot \frac{\varepsilon}{x}\right)\right)\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-80}:\\
\;\;\;\;{\varepsilon}^{5} \cdot \left(1 + 5 \cdot \frac{x}{\varepsilon}\right)\\
\mathbf{else}:\\
\;\;\;\;{x}^{3} \cdot \left(\varepsilon \cdot \left(x \cdot 5 + \varepsilon \cdot 10\right)\right)\\
\end{array}
\end{array}
if x < -5.0000000000000002e-55Initial program 41.7%
Taylor expanded in x around -inf 96.1%
+-commutative96.1%
associate-+r+96.1%
mul-1-neg96.1%
unsub-neg96.1%
distribute-rgt1-in96.1%
metadata-eval96.1%
*-commutative96.1%
Simplified96.1%
Taylor expanded in eps around 0 96.1%
*-commutative96.1%
Simplified96.1%
if -5.0000000000000002e-55 < x < 1.99999999999999992e-80Initial program 100.0%
Taylor expanded in eps around inf 100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
Simplified100.0%
if 1.99999999999999992e-80 < x Initial program 53.3%
Taylor expanded in eps around 0 99.7%
+-commutative99.7%
associate-+r+99.7%
distribute-lft1-in99.7%
metadata-eval99.7%
*-commutative99.7%
distribute-rgt-out99.7%
associate-*r*99.7%
unpow299.7%
cube-mult99.7%
distribute-lft-out99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 99.8%
*-commutative99.8%
associate-*r*99.9%
unpow299.9%
associate-*r*99.9%
distribute-rgt-out99.9%
*-commutative99.9%
Simplified99.9%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(if (<= x -6.5e-56)
(* eps (* 5.0 (pow x 4.0)))
(if (<= x 1.4e-79)
(* (pow eps 5.0) (+ 1.0 (* 5.0 (/ x eps))))
(* (pow x 3.0) (* eps (* x 5.0))))))
double code(double x, double eps) {
double tmp;
if (x <= -6.5e-56) {
tmp = eps * (5.0 * pow(x, 4.0));
} else if (x <= 1.4e-79) {
tmp = pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)));
} else {
tmp = pow(x, 3.0) * (eps * (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 <= (-6.5d-56)) then
tmp = eps * (5.0d0 * (x ** 4.0d0))
else if (x <= 1.4d-79) then
tmp = (eps ** 5.0d0) * (1.0d0 + (5.0d0 * (x / eps)))
else
tmp = (x ** 3.0d0) * (eps * (x * 5.0d0))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -6.5e-56) {
tmp = eps * (5.0 * Math.pow(x, 4.0));
} else if (x <= 1.4e-79) {
tmp = Math.pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)));
} else {
tmp = Math.pow(x, 3.0) * (eps * (x * 5.0));
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -6.5e-56: tmp = eps * (5.0 * math.pow(x, 4.0)) elif x <= 1.4e-79: tmp = math.pow(eps, 5.0) * (1.0 + (5.0 * (x / eps))) else: tmp = math.pow(x, 3.0) * (eps * (x * 5.0)) return tmp
function code(x, eps) tmp = 0.0 if (x <= -6.5e-56) tmp = Float64(eps * Float64(5.0 * (x ^ 4.0))); elseif (x <= 1.4e-79) tmp = Float64((eps ^ 5.0) * Float64(1.0 + Float64(5.0 * Float64(x / eps)))); else tmp = Float64((x ^ 3.0) * Float64(eps * Float64(x * 5.0))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -6.5e-56) tmp = eps * (5.0 * (x ^ 4.0)); elseif (x <= 1.4e-79) tmp = (eps ^ 5.0) * (1.0 + (5.0 * (x / eps))); else tmp = (x ^ 3.0) * (eps * (x * 5.0)); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -6.5e-56], N[(eps * N[(5.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.4e-79], N[(N[Power[eps, 5.0], $MachinePrecision] * N[(1.0 + N[(5.0 * N[(x / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, 3.0], $MachinePrecision] * N[(eps * N[(x * 5.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.5 \cdot 10^{-56}:\\
\;\;\;\;\varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{-79}:\\
\;\;\;\;{\varepsilon}^{5} \cdot \left(1 + 5 \cdot \frac{x}{\varepsilon}\right)\\
\mathbf{else}:\\
\;\;\;\;{x}^{3} \cdot \left(\varepsilon \cdot \left(x \cdot 5\right)\right)\\
\end{array}
\end{array}
if x < -6.4999999999999997e-56Initial program 41.7%
Taylor expanded in x around inf 94.5%
*-commutative94.5%
distribute-rgt1-in94.5%
metadata-eval94.5%
*-commutative94.5%
associate-*r*94.6%
Simplified94.6%
if -6.4999999999999997e-56 < x < 1.40000000000000006e-79Initial program 100.0%
Taylor expanded in eps around inf 100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
Simplified100.0%
if 1.40000000000000006e-79 < x Initial program 53.3%
Taylor expanded in eps around 0 99.7%
+-commutative99.7%
associate-+r+99.7%
distribute-lft1-in99.7%
metadata-eval99.7%
*-commutative99.7%
distribute-rgt-out99.7%
associate-*r*99.7%
unpow299.7%
cube-mult99.7%
distribute-lft-out99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 99.8%
*-commutative99.8%
associate-*r*99.9%
unpow299.9%
associate-*r*99.9%
distribute-rgt-out99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in eps around 0 99.1%
pow199.1%
*-commutative99.1%
associate-*l*99.2%
Applied egg-rr99.2%
unpow199.2%
*-commutative99.2%
Simplified99.2%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (if (<= x -8.6e-54) (* eps (* 5.0 (pow x 4.0))) (if (<= x 1.4e-79) (pow eps 5.0) (* (pow x 3.0) (* eps (* x 5.0))))))
double code(double x, double eps) {
double tmp;
if (x <= -8.6e-54) {
tmp = eps * (5.0 * pow(x, 4.0));
} else if (x <= 1.4e-79) {
tmp = pow(eps, 5.0);
} else {
tmp = pow(x, 3.0) * (eps * (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 <= (-8.6d-54)) then
tmp = eps * (5.0d0 * (x ** 4.0d0))
else if (x <= 1.4d-79) then
tmp = eps ** 5.0d0
else
tmp = (x ** 3.0d0) * (eps * (x * 5.0d0))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -8.6e-54) {
tmp = eps * (5.0 * Math.pow(x, 4.0));
} else if (x <= 1.4e-79) {
tmp = Math.pow(eps, 5.0);
} else {
tmp = Math.pow(x, 3.0) * (eps * (x * 5.0));
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -8.6e-54: tmp = eps * (5.0 * math.pow(x, 4.0)) elif x <= 1.4e-79: tmp = math.pow(eps, 5.0) else: tmp = math.pow(x, 3.0) * (eps * (x * 5.0)) return tmp
function code(x, eps) tmp = 0.0 if (x <= -8.6e-54) tmp = Float64(eps * Float64(5.0 * (x ^ 4.0))); elseif (x <= 1.4e-79) tmp = eps ^ 5.0; else tmp = Float64((x ^ 3.0) * Float64(eps * Float64(x * 5.0))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -8.6e-54) tmp = eps * (5.0 * (x ^ 4.0)); elseif (x <= 1.4e-79) tmp = eps ^ 5.0; else tmp = (x ^ 3.0) * (eps * (x * 5.0)); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -8.6e-54], N[(eps * N[(5.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.4e-79], N[Power[eps, 5.0], $MachinePrecision], N[(N[Power[x, 3.0], $MachinePrecision] * N[(eps * N[(x * 5.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.6 \cdot 10^{-54}:\\
\;\;\;\;\varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{-79}:\\
\;\;\;\;{\varepsilon}^{5}\\
\mathbf{else}:\\
\;\;\;\;{x}^{3} \cdot \left(\varepsilon \cdot \left(x \cdot 5\right)\right)\\
\end{array}
\end{array}
if x < -8.5999999999999999e-54Initial program 41.7%
Taylor expanded in x around inf 94.5%
*-commutative94.5%
distribute-rgt1-in94.5%
metadata-eval94.5%
*-commutative94.5%
associate-*r*94.6%
Simplified94.6%
if -8.5999999999999999e-54 < x < 1.40000000000000006e-79Initial program 100.0%
Taylor expanded in x around 0 100.0%
if 1.40000000000000006e-79 < x Initial program 53.3%
Taylor expanded in eps around 0 99.7%
+-commutative99.7%
associate-+r+99.7%
distribute-lft1-in99.7%
metadata-eval99.7%
*-commutative99.7%
distribute-rgt-out99.7%
associate-*r*99.7%
unpow299.7%
cube-mult99.7%
distribute-lft-out99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 99.8%
*-commutative99.8%
associate-*r*99.9%
unpow299.9%
associate-*r*99.9%
distribute-rgt-out99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in eps around 0 99.1%
pow199.1%
*-commutative99.1%
associate-*l*99.2%
Applied egg-rr99.2%
unpow199.2%
*-commutative99.2%
Simplified99.2%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (if (<= x -4.8e-56) (* eps (* 5.0 (pow x 4.0))) (if (<= x 1.4e-79) (pow eps 5.0) (* (pow x 3.0) (* 5.0 (* x eps))))))
double code(double x, double eps) {
double tmp;
if (x <= -4.8e-56) {
tmp = eps * (5.0 * pow(x, 4.0));
} else if (x <= 1.4e-79) {
tmp = pow(eps, 5.0);
} else {
tmp = pow(x, 3.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 <= (-4.8d-56)) then
tmp = eps * (5.0d0 * (x ** 4.0d0))
else if (x <= 1.4d-79) then
tmp = eps ** 5.0d0
else
tmp = (x ** 3.0d0) * (5.0d0 * (x * eps))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -4.8e-56) {
tmp = eps * (5.0 * Math.pow(x, 4.0));
} else if (x <= 1.4e-79) {
tmp = Math.pow(eps, 5.0);
} else {
tmp = Math.pow(x, 3.0) * (5.0 * (x * eps));
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -4.8e-56: tmp = eps * (5.0 * math.pow(x, 4.0)) elif x <= 1.4e-79: tmp = math.pow(eps, 5.0) else: tmp = math.pow(x, 3.0) * (5.0 * (x * eps)) return tmp
function code(x, eps) tmp = 0.0 if (x <= -4.8e-56) tmp = Float64(eps * Float64(5.0 * (x ^ 4.0))); elseif (x <= 1.4e-79) tmp = eps ^ 5.0; else tmp = Float64((x ^ 3.0) * Float64(5.0 * Float64(x * eps))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -4.8e-56) tmp = eps * (5.0 * (x ^ 4.0)); elseif (x <= 1.4e-79) tmp = eps ^ 5.0; else tmp = (x ^ 3.0) * (5.0 * (x * eps)); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -4.8e-56], N[(eps * N[(5.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.4e-79], N[Power[eps, 5.0], $MachinePrecision], N[(N[Power[x, 3.0], $MachinePrecision] * N[(5.0 * N[(x * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.8 \cdot 10^{-56}:\\
\;\;\;\;\varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{-79}:\\
\;\;\;\;{\varepsilon}^{5}\\
\mathbf{else}:\\
\;\;\;\;{x}^{3} \cdot \left(5 \cdot \left(x \cdot \varepsilon\right)\right)\\
\end{array}
\end{array}
if x < -4.80000000000000001e-56Initial program 41.7%
Taylor expanded in x around inf 94.5%
*-commutative94.5%
distribute-rgt1-in94.5%
metadata-eval94.5%
*-commutative94.5%
associate-*r*94.6%
Simplified94.6%
if -4.80000000000000001e-56 < x < 1.40000000000000006e-79Initial program 100.0%
Taylor expanded in x around 0 100.0%
if 1.40000000000000006e-79 < x Initial program 53.3%
Taylor expanded in eps around 0 99.7%
+-commutative99.7%
associate-+r+99.7%
distribute-lft1-in99.7%
metadata-eval99.7%
*-commutative99.7%
distribute-rgt-out99.7%
associate-*r*99.7%
unpow299.7%
cube-mult99.7%
distribute-lft-out99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 99.8%
*-commutative99.8%
associate-*r*99.9%
unpow299.9%
associate-*r*99.9%
distribute-rgt-out99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in eps around 0 99.1%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (if (or (<= x -3.2e-54) (not (<= x 2e-80))) (* eps (* 5.0 (pow x 4.0))) (pow eps 5.0)))
double code(double x, double eps) {
double tmp;
if ((x <= -3.2e-54) || !(x <= 2e-80)) {
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 <= (-3.2d-54)) .or. (.not. (x <= 2d-80))) 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 <= -3.2e-54) || !(x <= 2e-80)) {
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 <= -3.2e-54) or not (x <= 2e-80): 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 <= -3.2e-54) || !(x <= 2e-80)) tmp = Float64(eps * Float64(5.0 * (x ^ 4.0))); else tmp = eps ^ 5.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -3.2e-54) || ~((x <= 2e-80))) tmp = eps * (5.0 * (x ^ 4.0)); else tmp = eps ^ 5.0; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -3.2e-54], N[Not[LessEqual[x, 2e-80]], $MachinePrecision]], N[(eps * N[(5.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[eps, 5.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.2 \cdot 10^{-54} \lor \neg \left(x \leq 2 \cdot 10^{-80}\right):\\
\;\;\;\;\varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\
\end{array}
\end{array}
if x < -3.19999999999999998e-54 or 1.99999999999999992e-80 < x Initial program 48.3%
Taylor expanded in x around inf 97.1%
*-commutative97.1%
distribute-rgt1-in97.1%
metadata-eval97.1%
*-commutative97.1%
associate-*r*97.2%
Simplified97.2%
if -3.19999999999999998e-54 < x < 1.99999999999999992e-80Initial program 100.0%
Taylor expanded in x around 0 100.0%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (if (or (<= x -1.7e-54) (not (<= x 1.4e-79))) (* 5.0 (* eps (pow x 4.0))) (pow eps 5.0)))
double code(double x, double eps) {
double tmp;
if ((x <= -1.7e-54) || !(x <= 1.4e-79)) {
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 <= (-1.7d-54)) .or. (.not. (x <= 1.4d-79))) 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 <= -1.7e-54) || !(x <= 1.4e-79)) {
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 <= -1.7e-54) or not (x <= 1.4e-79): 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 <= -1.7e-54) || !(x <= 1.4e-79)) 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 <= -1.7e-54) || ~((x <= 1.4e-79))) tmp = 5.0 * (eps * (x ^ 4.0)); else tmp = eps ^ 5.0; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -1.7e-54], N[Not[LessEqual[x, 1.4e-79]], $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 -1.7 \cdot 10^{-54} \lor \neg \left(x \leq 1.4 \cdot 10^{-79}\right):\\
\;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\
\end{array}
\end{array}
if x < -1.69999999999999994e-54 or 1.40000000000000006e-79 < x Initial program 48.3%
Taylor expanded in x around inf 97.1%
*-commutative97.1%
distribute-rgt1-in97.1%
metadata-eval97.1%
*-commutative97.1%
associate-*r*97.2%
Simplified97.2%
Taylor expanded in eps around 0 97.0%
if -1.69999999999999994e-54 < x < 1.40000000000000006e-79Initial program 100.0%
Taylor expanded in x around 0 100.0%
Final simplification99.3%
(FPCore (x eps) :precision binary64 (pow eps 5.0))
double code(double x, double eps) {
return pow(eps, 5.0);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps ** 5.0d0
end function
public static double code(double x, double eps) {
return Math.pow(eps, 5.0);
}
def code(x, eps): return math.pow(eps, 5.0)
function code(x, eps) return eps ^ 5.0 end
function tmp = code(x, eps) tmp = eps ^ 5.0; end
code[x_, eps_] := N[Power[eps, 5.0], $MachinePrecision]
\begin{array}{l}
\\
{\varepsilon}^{5}
\end{array}
Initial program 87.7%
Taylor expanded in x around 0 87.3%
herbie shell --seed 2024108
(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)))