
(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 (or (<= x -4.2e-60) (not (<= x 9.5e-52)))
(+
(* (pow x 2.0) (+ (* 4.0 (pow eps 3.0)) (* eps (* eps (* eps 6.0)))))
(+
(* (pow x 3.0) (* eps (* eps 10.0)))
(* (pow x 4.0) (+ eps (* 4.0 eps)))))
(pow eps 5.0)))
double code(double x, double eps) {
double tmp;
if ((x <= -4.2e-60) || !(x <= 9.5e-52)) {
tmp = (pow(x, 2.0) * ((4.0 * pow(eps, 3.0)) + (eps * (eps * (eps * 6.0))))) + ((pow(x, 3.0) * (eps * (eps * 10.0))) + (pow(x, 4.0) * (eps + (4.0 * eps))));
} else {
tmp = pow(eps, 5.0);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((x <= (-4.2d-60)) .or. (.not. (x <= 9.5d-52))) then
tmp = ((x ** 2.0d0) * ((4.0d0 * (eps ** 3.0d0)) + (eps * (eps * (eps * 6.0d0))))) + (((x ** 3.0d0) * (eps * (eps * 10.0d0))) + ((x ** 4.0d0) * (eps + (4.0d0 * eps))))
else
tmp = eps ** 5.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -4.2e-60) || !(x <= 9.5e-52)) {
tmp = (Math.pow(x, 2.0) * ((4.0 * Math.pow(eps, 3.0)) + (eps * (eps * (eps * 6.0))))) + ((Math.pow(x, 3.0) * (eps * (eps * 10.0))) + (Math.pow(x, 4.0) * (eps + (4.0 * eps))));
} else {
tmp = Math.pow(eps, 5.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -4.2e-60) or not (x <= 9.5e-52): tmp = (math.pow(x, 2.0) * ((4.0 * math.pow(eps, 3.0)) + (eps * (eps * (eps * 6.0))))) + ((math.pow(x, 3.0) * (eps * (eps * 10.0))) + (math.pow(x, 4.0) * (eps + (4.0 * eps)))) else: tmp = math.pow(eps, 5.0) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -4.2e-60) || !(x <= 9.5e-52)) tmp = Float64(Float64((x ^ 2.0) * Float64(Float64(4.0 * (eps ^ 3.0)) + Float64(eps * Float64(eps * Float64(eps * 6.0))))) + Float64(Float64((x ^ 3.0) * Float64(eps * Float64(eps * 10.0))) + Float64((x ^ 4.0) * Float64(eps + Float64(4.0 * eps))))); else tmp = eps ^ 5.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -4.2e-60) || ~((x <= 9.5e-52))) tmp = ((x ^ 2.0) * ((4.0 * (eps ^ 3.0)) + (eps * (eps * (eps * 6.0))))) + (((x ^ 3.0) * (eps * (eps * 10.0))) + ((x ^ 4.0) * (eps + (4.0 * eps)))); else tmp = eps ^ 5.0; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -4.2e-60], N[Not[LessEqual[x, 9.5e-52]], $MachinePrecision]], N[(N[(N[Power[x, 2.0], $MachinePrecision] * N[(N[(4.0 * N[Power[eps, 3.0], $MachinePrecision]), $MachinePrecision] + N[(eps * N[(eps * N[(eps * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[x, 3.0], $MachinePrecision] * N[(eps * N[(eps * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[x, 4.0], $MachinePrecision] * N[(eps + N[(4.0 * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[eps, 5.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.2 \cdot 10^{-60} \lor \neg \left(x \leq 9.5 \cdot 10^{-52}\right):\\
\;\;\;\;{x}^{2} \cdot \left(4 \cdot {\varepsilon}^{3} + \varepsilon \cdot \left(\varepsilon \cdot \left(\varepsilon \cdot 6\right)\right)\right) + \left({x}^{3} \cdot \left(\varepsilon \cdot \left(\varepsilon \cdot 10\right)\right) + {x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\
\end{array}
\end{array}
if x < -4.19999999999999982e-60 or 9.50000000000000007e-52 < x Initial program 41.3%
Taylor expanded in x around inf 98.5%
distribute-rgt-out98.5%
metadata-eval98.5%
*-commutative98.5%
unpow298.5%
associate-*r*98.5%
Applied egg-rr98.5%
distribute-rgt-out98.5%
unpow298.5%
associate-*l*98.5%
metadata-eval98.5%
Applied egg-rr98.5%
if -4.19999999999999982e-60 < x < 9.50000000000000007e-52Initial program 100.0%
Taylor expanded in x around 0 100.0%
Final simplification99.7%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (pow (+ x eps) 5.0) (pow x 5.0))))
(if (<= t_0 -5e-256)
(pow eps 5.0)
(if (<= t_0 0.0) (* 5.0 (* eps (pow x 4.0))) t_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-256) {
tmp = pow(eps, 5.0);
} else if (t_0 <= 0.0) {
tmp = 5.0 * (eps * pow(x, 4.0));
} else {
tmp = t_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-256)) then
tmp = eps ** 5.0d0
else if (t_0 <= 0.0d0) then
tmp = 5.0d0 * (eps * (x ** 4.0d0))
else
tmp = t_0
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-256) {
tmp = Math.pow(eps, 5.0);
} else if (t_0 <= 0.0) {
tmp = 5.0 * (eps * Math.pow(x, 4.0));
} else {
tmp = t_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-256: tmp = math.pow(eps, 5.0) elif t_0 <= 0.0: tmp = 5.0 * (eps * math.pow(x, 4.0)) else: tmp = t_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-256) tmp = eps ^ 5.0; elseif (t_0 <= 0.0) tmp = Float64(5.0 * Float64(eps * (x ^ 4.0))); else tmp = t_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-256) tmp = eps ^ 5.0; elseif (t_0 <= 0.0) tmp = 5.0 * (eps * (x ^ 4.0)); else tmp = t_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[LessEqual[t$95$0, -5e-256], N[Power[eps, 5.0], $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(5.0 * N[(eps * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(x + \varepsilon\right)}^{5} - {x}^{5}\\
\mathbf{if}\;t_0 \leq -5 \cdot 10^{-256}:\\
\;\;\;\;{\varepsilon}^{5}\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x eps) 5) (pow.f64 x 5)) < -5e-256Initial program 100.0%
Taylor expanded in x around 0 100.0%
if -5e-256 < (-.f64 (pow.f64 (+.f64 x eps) 5) (pow.f64 x 5)) < 0.0Initial program 84.9%
Taylor expanded in x around inf 99.9%
*-commutative99.9%
distribute-rgt1-in99.9%
metadata-eval99.9%
*-commutative99.9%
associate-*r*99.9%
Simplified99.9%
Taylor expanded in eps around 0 99.9%
if 0.0 < (-.f64 (pow.f64 (+.f64 x eps) 5) (pow.f64 x 5)) Initial program 92.6%
Final simplification99.2%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* eps (pow x 4.0))))
(if (<= x -2.7e-58)
(+ (* (pow x 3.0) (* 10.0 (pow eps 2.0))) (* 5.0 t_0))
(if (<= x 1.15e-51)
(pow eps 5.0)
(fma 5.0 t_0 (* 10.0 (* (pow x 3.0) (pow eps 2.0))))))))
double code(double x, double eps) {
double t_0 = eps * pow(x, 4.0);
double tmp;
if (x <= -2.7e-58) {
tmp = (pow(x, 3.0) * (10.0 * pow(eps, 2.0))) + (5.0 * t_0);
} else if (x <= 1.15e-51) {
tmp = pow(eps, 5.0);
} else {
tmp = fma(5.0, t_0, (10.0 * (pow(x, 3.0) * pow(eps, 2.0))));
}
return tmp;
}
function code(x, eps) t_0 = Float64(eps * (x ^ 4.0)) tmp = 0.0 if (x <= -2.7e-58) tmp = Float64(Float64((x ^ 3.0) * Float64(10.0 * (eps ^ 2.0))) + Float64(5.0 * t_0)); elseif (x <= 1.15e-51) tmp = eps ^ 5.0; else tmp = fma(5.0, t_0, Float64(10.0 * Float64((x ^ 3.0) * (eps ^ 2.0)))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(eps * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.7e-58], N[(N[(N[Power[x, 3.0], $MachinePrecision] * N[(10.0 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(5.0 * t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.15e-51], N[Power[eps, 5.0], $MachinePrecision], N[(5.0 * t$95$0 + N[(10.0 * N[(N[Power[x, 3.0], $MachinePrecision] * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \varepsilon \cdot {x}^{4}\\
\mathbf{if}\;x \leq -2.7 \cdot 10^{-58}:\\
\;\;\;\;{x}^{3} \cdot \left(10 \cdot {\varepsilon}^{2}\right) + 5 \cdot t_0\\
\mathbf{elif}\;x \leq 1.15 \cdot 10^{-51}:\\
\;\;\;\;{\varepsilon}^{5}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(5, t_0, 10 \cdot \left({x}^{3} \cdot {\varepsilon}^{2}\right)\right)\\
\end{array}
\end{array}
if x < -2.6999999999999999e-58Initial program 44.1%
Taylor expanded in x around inf 99.3%
+-commutative99.3%
fma-def99.3%
distribute-rgt1-in99.3%
metadata-eval99.3%
*-commutative99.3%
*-commutative99.3%
distribute-rgt-out99.3%
metadata-eval99.3%
associate-*l*99.3%
Simplified99.3%
fma-udef99.3%
+-commutative99.3%
associate-*r*99.3%
*-commutative99.3%
*-commutative99.3%
*-commutative99.3%
associate-*r*99.3%
*-commutative99.3%
associate-*l*99.3%
Applied egg-rr99.3%
if -2.6999999999999999e-58 < x < 1.15000000000000001e-51Initial program 100.0%
Taylor expanded in x around 0 100.0%
if 1.15000000000000001e-51 < x Initial program 38.9%
add-cbrt-cube12.0%
unpow38.7%
pow-pow12.0%
metadata-eval12.0%
Applied egg-rr12.0%
Taylor expanded in x around inf 97.2%
+-commutative97.2%
distribute-rgt-out97.2%
metadata-eval97.2%
*-commutative97.2%
*-commutative97.2%
distribute-rgt1-in97.2%
metadata-eval97.2%
associate-*r*97.3%
fma-def97.3%
*-commutative97.3%
associate-*r*97.3%
Simplified97.3%
Final simplification99.6%
(FPCore (x eps) :precision binary64 (if (or (<= x -2.7e-58) (not (<= x 1e-51))) (+ (* (pow eps 2.0) (* (pow x 3.0) 10.0)) (* eps (* (pow x 4.0) 5.0))) (pow eps 5.0)))
double code(double x, double eps) {
double tmp;
if ((x <= -2.7e-58) || !(x <= 1e-51)) {
tmp = (pow(eps, 2.0) * (pow(x, 3.0) * 10.0)) + (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 <= (-2.7d-58)) .or. (.not. (x <= 1d-51))) then
tmp = ((eps ** 2.0d0) * ((x ** 3.0d0) * 10.0d0)) + (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 <= -2.7e-58) || !(x <= 1e-51)) {
tmp = (Math.pow(eps, 2.0) * (Math.pow(x, 3.0) * 10.0)) + (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 <= -2.7e-58) or not (x <= 1e-51): tmp = (math.pow(eps, 2.0) * (math.pow(x, 3.0) * 10.0)) + (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 <= -2.7e-58) || !(x <= 1e-51)) tmp = Float64(Float64((eps ^ 2.0) * Float64((x ^ 3.0) * 10.0)) + 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 <= -2.7e-58) || ~((x <= 1e-51))) tmp = ((eps ^ 2.0) * ((x ^ 3.0) * 10.0)) + (eps * ((x ^ 4.0) * 5.0)); else tmp = eps ^ 5.0; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -2.7e-58], N[Not[LessEqual[x, 1e-51]], $MachinePrecision]], N[(N[(N[Power[eps, 2.0], $MachinePrecision] * N[(N[Power[x, 3.0], $MachinePrecision] * 10.0), $MachinePrecision]), $MachinePrecision] + N[(eps * N[(N[Power[x, 4.0], $MachinePrecision] * 5.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[eps, 5.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.7 \cdot 10^{-58} \lor \neg \left(x \leq 10^{-51}\right):\\
\;\;\;\;{\varepsilon}^{2} \cdot \left({x}^{3} \cdot 10\right) + \varepsilon \cdot \left({x}^{4} \cdot 5\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\
\end{array}
\end{array}
if x < -2.6999999999999999e-58 or 1e-51 < x Initial program 41.3%
add-cbrt-cube13.0%
unpow311.2%
pow-pow13.0%
metadata-eval13.0%
Applied egg-rr13.0%
Taylor expanded in x around inf 98.2%
+-commutative98.2%
distribute-rgt-out98.2%
metadata-eval98.2%
*-commutative98.2%
*-commutative98.2%
distribute-rgt1-in98.2%
metadata-eval98.2%
associate-*r*98.2%
fma-def98.2%
*-commutative98.2%
associate-*r*98.2%
Simplified98.2%
fma-udef98.2%
+-commutative98.2%
*-commutative98.2%
associate-*l*98.2%
*-commutative98.2%
associate-*r*98.2%
*-commutative98.2%
Applied egg-rr98.2%
if -2.6999999999999999e-58 < x < 1e-51Initial program 100.0%
Taylor expanded in x around 0 100.0%
Final simplification99.6%
(FPCore (x eps) :precision binary64 (if (or (<= x -2.1e-58) (not (<= x 1.1e-51))) (+ (* (pow x 3.0) (* 10.0 (pow eps 2.0))) (* 5.0 (* eps (pow x 4.0)))) (pow eps 5.0)))
double code(double x, double eps) {
double tmp;
if ((x <= -2.1e-58) || !(x <= 1.1e-51)) {
tmp = (pow(x, 3.0) * (10.0 * pow(eps, 2.0))) + (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 <= (-2.1d-58)) .or. (.not. (x <= 1.1d-51))) then
tmp = ((x ** 3.0d0) * (10.0d0 * (eps ** 2.0d0))) + (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 <= -2.1e-58) || !(x <= 1.1e-51)) {
tmp = (Math.pow(x, 3.0) * (10.0 * Math.pow(eps, 2.0))) + (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 <= -2.1e-58) or not (x <= 1.1e-51): tmp = (math.pow(x, 3.0) * (10.0 * math.pow(eps, 2.0))) + (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 <= -2.1e-58) || !(x <= 1.1e-51)) tmp = Float64(Float64((x ^ 3.0) * Float64(10.0 * (eps ^ 2.0))) + 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 <= -2.1e-58) || ~((x <= 1.1e-51))) tmp = ((x ^ 3.0) * (10.0 * (eps ^ 2.0))) + (5.0 * (eps * (x ^ 4.0))); else tmp = eps ^ 5.0; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -2.1e-58], N[Not[LessEqual[x, 1.1e-51]], $MachinePrecision]], N[(N[(N[Power[x, 3.0], $MachinePrecision] * N[(10.0 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(5.0 * N[(eps * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[eps, 5.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.1 \cdot 10^{-58} \lor \neg \left(x \leq 1.1 \cdot 10^{-51}\right):\\
\;\;\;\;{x}^{3} \cdot \left(10 \cdot {\varepsilon}^{2}\right) + 5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\
\end{array}
\end{array}
if x < -2.09999999999999988e-58 or 1.1e-51 < x Initial program 41.3%
Taylor expanded in x around inf 98.2%
+-commutative98.2%
fma-def98.2%
distribute-rgt1-in98.2%
metadata-eval98.2%
*-commutative98.2%
*-commutative98.2%
distribute-rgt-out98.2%
metadata-eval98.2%
associate-*l*98.2%
Simplified98.2%
fma-udef98.2%
+-commutative98.2%
associate-*r*98.2%
*-commutative98.2%
*-commutative98.2%
*-commutative98.2%
associate-*r*98.2%
*-commutative98.2%
associate-*l*98.2%
Applied egg-rr98.2%
if -2.09999999999999988e-58 < x < 1.1e-51Initial program 100.0%
Taylor expanded in x around 0 100.0%
Final simplification99.6%
(FPCore (x eps) :precision binary64 (if (or (<= x -2.7e-58) (not (<= x 1.2e-51))) (* 5.0 (* eps (pow x 4.0))) (pow eps 5.0)))
double code(double x, double eps) {
double tmp;
if ((x <= -2.7e-58) || !(x <= 1.2e-51)) {
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 <= (-2.7d-58)) .or. (.not. (x <= 1.2d-51))) 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 <= -2.7e-58) || !(x <= 1.2e-51)) {
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 <= -2.7e-58) or not (x <= 1.2e-51): 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 <= -2.7e-58) || !(x <= 1.2e-51)) 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 <= -2.7e-58) || ~((x <= 1.2e-51))) tmp = 5.0 * (eps * (x ^ 4.0)); else tmp = eps ^ 5.0; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -2.7e-58], N[Not[LessEqual[x, 1.2e-51]], $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 -2.7 \cdot 10^{-58} \lor \neg \left(x \leq 1.2 \cdot 10^{-51}\right):\\
\;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\
\end{array}
\end{array}
if x < -2.6999999999999999e-58 or 1.2e-51 < x Initial program 41.3%
Taylor expanded in x around inf 95.7%
*-commutative95.7%
distribute-rgt1-in95.7%
metadata-eval95.7%
*-commutative95.7%
associate-*r*95.8%
Simplified95.8%
Taylor expanded in eps around 0 95.8%
if -2.6999999999999999e-58 < x < 1.2e-51Initial program 100.0%
Taylor expanded in x around 0 100.0%
Final simplification99.1%
(FPCore (x eps) :precision binary64 (if (<= x -2.7e-58) (* 5.0 (* eps (pow x 4.0))) (if (<= x 1.02e-51) (pow eps 5.0) (* eps (* (pow x 4.0) 5.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -2.7e-58) {
tmp = 5.0 * (eps * pow(x, 4.0));
} else if (x <= 1.02e-51) {
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 <= (-2.7d-58)) then
tmp = 5.0d0 * (eps * (x ** 4.0d0))
else if (x <= 1.02d-51) 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 <= -2.7e-58) {
tmp = 5.0 * (eps * Math.pow(x, 4.0));
} else if (x <= 1.02e-51) {
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 <= -2.7e-58: tmp = 5.0 * (eps * math.pow(x, 4.0)) elif x <= 1.02e-51: 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 <= -2.7e-58) tmp = Float64(5.0 * Float64(eps * (x ^ 4.0))); elseif (x <= 1.02e-51) 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 <= -2.7e-58) tmp = 5.0 * (eps * (x ^ 4.0)); elseif (x <= 1.02e-51) tmp = eps ^ 5.0; else tmp = eps * ((x ^ 4.0) * 5.0); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -2.7e-58], N[(5.0 * N[(eps * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.02e-51], 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 -2.7 \cdot 10^{-58}:\\
\;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\
\mathbf{elif}\;x \leq 1.02 \cdot 10^{-51}:\\
\;\;\;\;{\varepsilon}^{5}\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left({x}^{4} \cdot 5\right)\\
\end{array}
\end{array}
if x < -2.6999999999999999e-58Initial program 44.1%
Taylor expanded in x around inf 94.4%
*-commutative94.4%
distribute-rgt1-in94.4%
metadata-eval94.4%
*-commutative94.4%
associate-*r*94.4%
Simplified94.4%
Taylor expanded in eps around 0 94.4%
if -2.6999999999999999e-58 < x < 1.01999999999999998e-51Initial program 100.0%
Taylor expanded in x around 0 100.0%
if 1.01999999999999998e-51 < x Initial program 38.9%
Taylor expanded in x around inf 96.8%
*-commutative96.8%
distribute-rgt1-in96.8%
metadata-eval96.8%
*-commutative96.8%
associate-*r*97.0%
Simplified97.0%
Final simplification99.1%
(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.8%
Taylor expanded in x around 0 86.9%
Final simplification86.9%
herbie shell --seed 2023301
(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)))