
(FPCore (x eps) :precision binary64 (- (pow (+ x eps) 5.0) (pow x 5.0)))
double code(double x, double eps) {
return pow((x + eps), 5.0) - pow(x, 5.0);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = ((x + eps) ** 5.0d0) - (x ** 5.0d0)
end function
public static double code(double x, double eps) {
return Math.pow((x + eps), 5.0) - Math.pow(x, 5.0);
}
def code(x, eps): return math.pow((x + eps), 5.0) - math.pow(x, 5.0)
function code(x, eps) return Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0)) end
function tmp = code(x, eps) tmp = ((x + eps) ^ 5.0) - (x ^ 5.0); end
code[x_, eps_] := N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + \varepsilon\right)}^{5} - {x}^{5}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (- (pow (+ x eps) 5.0) (pow x 5.0)))
double code(double x, double eps) {
return pow((x + eps), 5.0) - pow(x, 5.0);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = ((x + eps) ** 5.0d0) - (x ** 5.0d0)
end function
public static double code(double x, double eps) {
return Math.pow((x + eps), 5.0) - Math.pow(x, 5.0);
}
def code(x, eps): return math.pow((x + eps), 5.0) - math.pow(x, 5.0)
function code(x, eps) return Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0)) end
function tmp = code(x, eps) tmp = ((x + eps) ^ 5.0) - (x ^ 5.0); end
code[x_, eps_] := N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + \varepsilon\right)}^{5} - {x}^{5}
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (pow (+ x eps) 5.0) (pow x 5.0))))
(if (<= t_0 -5e-296)
(pow eps 5.0)
(if (<= t_0 0.0) (* eps (* 5.0 (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-296) {
tmp = pow(eps, 5.0);
} else if (t_0 <= 0.0) {
tmp = eps * (5.0 * 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-296)) then
tmp = eps ** 5.0d0
else if (t_0 <= 0.0d0) then
tmp = eps * (5.0d0 * (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-296) {
tmp = Math.pow(eps, 5.0);
} else if (t_0 <= 0.0) {
tmp = eps * (5.0 * 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-296: tmp = math.pow(eps, 5.0) elif t_0 <= 0.0: tmp = eps * (5.0 * 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-296) tmp = eps ^ 5.0; elseif (t_0 <= 0.0) tmp = Float64(eps * Float64(5.0 * (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-296) tmp = eps ^ 5.0; elseif (t_0 <= 0.0) tmp = eps * (5.0 * (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-296], N[Power[eps, 5.0], $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(eps * N[(5.0 * 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^{-296}:\\
\;\;\;\;{\varepsilon}^{5}\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;\varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x eps) 5) (pow.f64 x 5)) < -5.0000000000000003e-296Initial program 100.0%
Taylor expanded in x around 0 100.0%
if -5.0000000000000003e-296 < (-.f64 (pow.f64 (+.f64 x eps) 5) (pow.f64 x 5)) < 0.0Initial program 88.3%
Taylor expanded in eps around 0 99.9%
Taylor expanded in x around 0 99.9%
if 0.0 < (-.f64 (pow.f64 (+.f64 x eps) 5) (pow.f64 x 5)) Initial program 97.0%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(if (<= x -8.4e-47)
(* 5.0 (* eps (pow x 4.0)))
(if (<= x 2.85e-71)
(pow eps 5.0)
(*
x
(+
(* x (* eps (* 5.0 (* x x))))
(* x (* 10.0 (* (+ x eps) (* eps eps)))))))))
double code(double x, double eps) {
double tmp;
if (x <= -8.4e-47) {
tmp = 5.0 * (eps * pow(x, 4.0));
} else if (x <= 2.85e-71) {
tmp = pow(eps, 5.0);
} else {
tmp = x * ((x * (eps * (5.0 * (x * x)))) + (x * (10.0 * ((x + eps) * (eps * eps)))));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-8.4d-47)) then
tmp = 5.0d0 * (eps * (x ** 4.0d0))
else if (x <= 2.85d-71) then
tmp = eps ** 5.0d0
else
tmp = x * ((x * (eps * (5.0d0 * (x * x)))) + (x * (10.0d0 * ((x + eps) * (eps * eps)))))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -8.4e-47) {
tmp = 5.0 * (eps * Math.pow(x, 4.0));
} else if (x <= 2.85e-71) {
tmp = Math.pow(eps, 5.0);
} else {
tmp = x * ((x * (eps * (5.0 * (x * x)))) + (x * (10.0 * ((x + eps) * (eps * eps)))));
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -8.4e-47: tmp = 5.0 * (eps * math.pow(x, 4.0)) elif x <= 2.85e-71: tmp = math.pow(eps, 5.0) else: tmp = x * ((x * (eps * (5.0 * (x * x)))) + (x * (10.0 * ((x + eps) * (eps * eps))))) return tmp
function code(x, eps) tmp = 0.0 if (x <= -8.4e-47) tmp = Float64(5.0 * Float64(eps * (x ^ 4.0))); elseif (x <= 2.85e-71) tmp = eps ^ 5.0; else tmp = Float64(x * Float64(Float64(x * Float64(eps * Float64(5.0 * Float64(x * x)))) + Float64(x * Float64(10.0 * Float64(Float64(x + eps) * Float64(eps * eps)))))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -8.4e-47) tmp = 5.0 * (eps * (x ^ 4.0)); elseif (x <= 2.85e-71) tmp = eps ^ 5.0; else tmp = x * ((x * (eps * (5.0 * (x * x)))) + (x * (10.0 * ((x + eps) * (eps * eps))))); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -8.4e-47], N[(5.0 * N[(eps * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.85e-71], N[Power[eps, 5.0], $MachinePrecision], N[(x * N[(N[(x * N[(eps * N[(5.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * N[(10.0 * N[(N[(x + eps), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.4 \cdot 10^{-47}:\\
\;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\
\mathbf{elif}\;x \leq 2.85 \cdot 10^{-71}:\\
\;\;\;\;{\varepsilon}^{5}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \left(\varepsilon \cdot \left(5 \cdot \left(x \cdot x\right)\right)\right) + x \cdot \left(10 \cdot \left(\left(x + \varepsilon\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\right)\right)\\
\end{array}
\end{array}
if x < -8.4000000000000003e-47Initial program 34.4%
Taylor expanded in x around inf 95.7%
distribute-lft1-in95.7%
metadata-eval95.7%
associate-*l*95.4%
Simplified95.4%
if -8.4000000000000003e-47 < x < 2.8500000000000001e-71Initial program 99.6%
Taylor expanded in x around 0 99.5%
if 2.8500000000000001e-71 < x Initial program 52.8%
Taylor expanded in x around inf 99.5%
fma-def99.6%
distribute-lft1-in99.6%
metadata-eval99.6%
*-commutative99.6%
+-commutative99.6%
*-commutative99.6%
*-commutative99.6%
unpow399.6%
unpow299.6%
associate-*l*99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in x around 0 99.6%
+-commutative99.6%
unpow299.6%
associate-*r*99.6%
associate-*r*99.6%
*-commutative99.6%
unpow299.6%
associate-*r*99.6%
cube-mult99.6%
associate-*r*99.6%
*-commutative99.6%
distribute-rgt-out99.6%
associate-*l*99.6%
*-commutative99.6%
associate-*r*99.6%
unpow299.6%
*-commutative99.6%
associate-*r*99.6%
Simplified99.6%
Taylor expanded in eps around 0 99.6%
distribute-lft-out99.6%
unpow299.6%
associate-*r*99.6%
unpow399.6%
unpow299.6%
associate-*r*99.6%
unpow299.6%
distribute-lft-out99.6%
unpow299.6%
Simplified99.6%
fma-udef99.5%
metadata-eval99.5%
pow-prod-up99.5%
pow299.5%
pow299.5%
associate-*l*99.3%
associate-*r*99.6%
*-commutative99.6%
distribute-rgt-out99.7%
associate-*l*99.7%
Applied egg-rr99.7%
Final simplification99.2%
(FPCore (x eps)
:precision binary64
(if (<= x -9.2e-47)
(* eps (* 5.0 (pow x 4.0)))
(if (<= x 2.85e-71)
(pow eps 5.0)
(*
x
(+
(* x (* eps (* 5.0 (* x x))))
(* x (* 10.0 (* (+ x eps) (* eps eps)))))))))
double code(double x, double eps) {
double tmp;
if (x <= -9.2e-47) {
tmp = eps * (5.0 * pow(x, 4.0));
} else if (x <= 2.85e-71) {
tmp = pow(eps, 5.0);
} else {
tmp = x * ((x * (eps * (5.0 * (x * x)))) + (x * (10.0 * ((x + eps) * (eps * eps)))));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-9.2d-47)) then
tmp = eps * (5.0d0 * (x ** 4.0d0))
else if (x <= 2.85d-71) then
tmp = eps ** 5.0d0
else
tmp = x * ((x * (eps * (5.0d0 * (x * x)))) + (x * (10.0d0 * ((x + eps) * (eps * eps)))))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -9.2e-47) {
tmp = eps * (5.0 * Math.pow(x, 4.0));
} else if (x <= 2.85e-71) {
tmp = Math.pow(eps, 5.0);
} else {
tmp = x * ((x * (eps * (5.0 * (x * x)))) + (x * (10.0 * ((x + eps) * (eps * eps)))));
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -9.2e-47: tmp = eps * (5.0 * math.pow(x, 4.0)) elif x <= 2.85e-71: tmp = math.pow(eps, 5.0) else: tmp = x * ((x * (eps * (5.0 * (x * x)))) + (x * (10.0 * ((x + eps) * (eps * eps))))) return tmp
function code(x, eps) tmp = 0.0 if (x <= -9.2e-47) tmp = Float64(eps * Float64(5.0 * (x ^ 4.0))); elseif (x <= 2.85e-71) tmp = eps ^ 5.0; else tmp = Float64(x * Float64(Float64(x * Float64(eps * Float64(5.0 * Float64(x * x)))) + Float64(x * Float64(10.0 * Float64(Float64(x + eps) * Float64(eps * eps)))))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -9.2e-47) tmp = eps * (5.0 * (x ^ 4.0)); elseif (x <= 2.85e-71) tmp = eps ^ 5.0; else tmp = x * ((x * (eps * (5.0 * (x * x)))) + (x * (10.0 * ((x + eps) * (eps * eps))))); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -9.2e-47], N[(eps * N[(5.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.85e-71], N[Power[eps, 5.0], $MachinePrecision], N[(x * N[(N[(x * N[(eps * N[(5.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * N[(10.0 * N[(N[(x + eps), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.2 \cdot 10^{-47}:\\
\;\;\;\;\varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\
\mathbf{elif}\;x \leq 2.85 \cdot 10^{-71}:\\
\;\;\;\;{\varepsilon}^{5}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \left(\varepsilon \cdot \left(5 \cdot \left(x \cdot x\right)\right)\right) + x \cdot \left(10 \cdot \left(\left(x + \varepsilon\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\right)\right)\\
\end{array}
\end{array}
if x < -9.19999999999999928e-47Initial program 34.4%
Taylor expanded in eps around 0 95.5%
Taylor expanded in x around 0 95.5%
if -9.19999999999999928e-47 < x < 2.8500000000000001e-71Initial program 99.6%
Taylor expanded in x around 0 99.5%
if 2.8500000000000001e-71 < x Initial program 52.8%
Taylor expanded in x around inf 99.5%
fma-def99.6%
distribute-lft1-in99.6%
metadata-eval99.6%
*-commutative99.6%
+-commutative99.6%
*-commutative99.6%
*-commutative99.6%
unpow399.6%
unpow299.6%
associate-*l*99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in x around 0 99.6%
+-commutative99.6%
unpow299.6%
associate-*r*99.6%
associate-*r*99.6%
*-commutative99.6%
unpow299.6%
associate-*r*99.6%
cube-mult99.6%
associate-*r*99.6%
*-commutative99.6%
distribute-rgt-out99.6%
associate-*l*99.6%
*-commutative99.6%
associate-*r*99.6%
unpow299.6%
*-commutative99.6%
associate-*r*99.6%
Simplified99.6%
Taylor expanded in eps around 0 99.6%
distribute-lft-out99.6%
unpow299.6%
associate-*r*99.6%
unpow399.6%
unpow299.6%
associate-*r*99.6%
unpow299.6%
distribute-lft-out99.6%
unpow299.6%
Simplified99.6%
fma-udef99.5%
metadata-eval99.5%
pow-prod-up99.5%
pow299.5%
pow299.5%
associate-*l*99.3%
associate-*r*99.6%
*-commutative99.6%
distribute-rgt-out99.7%
associate-*l*99.7%
Applied egg-rr99.7%
Final simplification99.2%
(FPCore (x eps)
:precision binary64
(if (<= x -6.5e-47)
(* (pow x 4.0) (* eps 5.0))
(if (<= x 2.8e-71)
(pow eps 5.0)
(*
x
(+
(* x (* eps (* 5.0 (* x x))))
(* x (* 10.0 (* (+ x eps) (* eps eps)))))))))
double code(double x, double eps) {
double tmp;
if (x <= -6.5e-47) {
tmp = pow(x, 4.0) * (eps * 5.0);
} else if (x <= 2.8e-71) {
tmp = pow(eps, 5.0);
} else {
tmp = x * ((x * (eps * (5.0 * (x * x)))) + (x * (10.0 * ((x + eps) * (eps * 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.5d-47)) then
tmp = (x ** 4.0d0) * (eps * 5.0d0)
else if (x <= 2.8d-71) then
tmp = eps ** 5.0d0
else
tmp = x * ((x * (eps * (5.0d0 * (x * x)))) + (x * (10.0d0 * ((x + eps) * (eps * eps)))))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -6.5e-47) {
tmp = Math.pow(x, 4.0) * (eps * 5.0);
} else if (x <= 2.8e-71) {
tmp = Math.pow(eps, 5.0);
} else {
tmp = x * ((x * (eps * (5.0 * (x * x)))) + (x * (10.0 * ((x + eps) * (eps * eps)))));
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -6.5e-47: tmp = math.pow(x, 4.0) * (eps * 5.0) elif x <= 2.8e-71: tmp = math.pow(eps, 5.0) else: tmp = x * ((x * (eps * (5.0 * (x * x)))) + (x * (10.0 * ((x + eps) * (eps * eps))))) return tmp
function code(x, eps) tmp = 0.0 if (x <= -6.5e-47) tmp = Float64((x ^ 4.0) * Float64(eps * 5.0)); elseif (x <= 2.8e-71) tmp = eps ^ 5.0; else tmp = Float64(x * Float64(Float64(x * Float64(eps * Float64(5.0 * Float64(x * x)))) + Float64(x * Float64(10.0 * Float64(Float64(x + eps) * Float64(eps * eps)))))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -6.5e-47) tmp = (x ^ 4.0) * (eps * 5.0); elseif (x <= 2.8e-71) tmp = eps ^ 5.0; else tmp = x * ((x * (eps * (5.0 * (x * x)))) + (x * (10.0 * ((x + eps) * (eps * eps))))); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -6.5e-47], N[(N[Power[x, 4.0], $MachinePrecision] * N[(eps * 5.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.8e-71], N[Power[eps, 5.0], $MachinePrecision], N[(x * N[(N[(x * N[(eps * N[(5.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * N[(10.0 * N[(N[(x + eps), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.5 \cdot 10^{-47}:\\
\;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot 5\right)\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{-71}:\\
\;\;\;\;{\varepsilon}^{5}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \left(\varepsilon \cdot \left(5 \cdot \left(x \cdot x\right)\right)\right) + x \cdot \left(10 \cdot \left(\left(x + \varepsilon\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\right)\right)\\
\end{array}
\end{array}
if x < -6.5000000000000004e-47Initial program 34.4%
Taylor expanded in x around inf 95.7%
distribute-lft1-in95.7%
metadata-eval95.7%
*-commutative95.7%
Simplified95.7%
if -6.5000000000000004e-47 < x < 2.8e-71Initial program 99.6%
Taylor expanded in x around 0 99.5%
if 2.8e-71 < x Initial program 52.8%
Taylor expanded in x around inf 99.5%
fma-def99.6%
distribute-lft1-in99.6%
metadata-eval99.6%
*-commutative99.6%
+-commutative99.6%
*-commutative99.6%
*-commutative99.6%
unpow399.6%
unpow299.6%
associate-*l*99.6%
distribute-lft-out99.6%
Simplified99.6%
Taylor expanded in x around 0 99.6%
+-commutative99.6%
unpow299.6%
associate-*r*99.6%
associate-*r*99.6%
*-commutative99.6%
unpow299.6%
associate-*r*99.6%
cube-mult99.6%
associate-*r*99.6%
*-commutative99.6%
distribute-rgt-out99.6%
associate-*l*99.6%
*-commutative99.6%
associate-*r*99.6%
unpow299.6%
*-commutative99.6%
associate-*r*99.6%
Simplified99.6%
Taylor expanded in eps around 0 99.6%
distribute-lft-out99.6%
unpow299.6%
associate-*r*99.6%
unpow399.6%
unpow299.6%
associate-*r*99.6%
unpow299.6%
distribute-lft-out99.6%
unpow299.6%
Simplified99.6%
fma-udef99.5%
metadata-eval99.5%
pow-prod-up99.5%
pow299.5%
pow299.5%
associate-*l*99.3%
associate-*r*99.6%
*-commutative99.6%
distribute-rgt-out99.7%
associate-*l*99.7%
Applied egg-rr99.7%
Final simplification99.2%
(FPCore (x eps)
:precision binary64
(if (or (<= x -6.5e-47) (not (<= x 2.85e-71)))
(*
x
(+ (* x (* eps (* 5.0 (* x x)))) (* x (* 10.0 (* (+ x eps) (* eps eps))))))
(pow eps 5.0)))
double code(double x, double eps) {
double tmp;
if ((x <= -6.5e-47) || !(x <= 2.85e-71)) {
tmp = x * ((x * (eps * (5.0 * (x * x)))) + (x * (10.0 * ((x + eps) * (eps * 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 <= (-6.5d-47)) .or. (.not. (x <= 2.85d-71))) then
tmp = x * ((x * (eps * (5.0d0 * (x * x)))) + (x * (10.0d0 * ((x + eps) * (eps * eps)))))
else
tmp = eps ** 5.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -6.5e-47) || !(x <= 2.85e-71)) {
tmp = x * ((x * (eps * (5.0 * (x * x)))) + (x * (10.0 * ((x + eps) * (eps * eps)))));
} else {
tmp = Math.pow(eps, 5.0);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -6.5e-47) or not (x <= 2.85e-71): tmp = x * ((x * (eps * (5.0 * (x * x)))) + (x * (10.0 * ((x + eps) * (eps * eps))))) else: tmp = math.pow(eps, 5.0) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -6.5e-47) || !(x <= 2.85e-71)) tmp = Float64(x * Float64(Float64(x * Float64(eps * Float64(5.0 * Float64(x * x)))) + Float64(x * Float64(10.0 * Float64(Float64(x + eps) * Float64(eps * eps)))))); else tmp = eps ^ 5.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -6.5e-47) || ~((x <= 2.85e-71))) tmp = x * ((x * (eps * (5.0 * (x * x)))) + (x * (10.0 * ((x + eps) * (eps * eps))))); else tmp = eps ^ 5.0; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -6.5e-47], N[Not[LessEqual[x, 2.85e-71]], $MachinePrecision]], N[(x * N[(N[(x * N[(eps * N[(5.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * N[(10.0 * N[(N[(x + eps), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[eps, 5.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.5 \cdot 10^{-47} \lor \neg \left(x \leq 2.85 \cdot 10^{-71}\right):\\
\;\;\;\;x \cdot \left(x \cdot \left(\varepsilon \cdot \left(5 \cdot \left(x \cdot x\right)\right)\right) + x \cdot \left(10 \cdot \left(\left(x + \varepsilon\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\
\end{array}
\end{array}
if x < -6.5000000000000004e-47 or 2.8500000000000001e-71 < x Initial program 43.6%
Taylor expanded in x around inf 97.6%
fma-def97.6%
distribute-lft1-in97.6%
metadata-eval97.6%
*-commutative97.6%
+-commutative97.6%
*-commutative97.6%
*-commutative97.6%
unpow397.6%
unpow297.6%
associate-*l*97.6%
distribute-lft-out97.6%
Simplified97.6%
Taylor expanded in x around 0 97.6%
+-commutative97.6%
unpow297.6%
associate-*r*97.6%
associate-*r*97.6%
*-commutative97.6%
unpow297.6%
associate-*r*97.6%
cube-mult97.6%
associate-*r*97.6%
*-commutative97.6%
distribute-rgt-out97.6%
associate-*l*97.6%
*-commutative97.6%
associate-*r*97.6%
unpow297.6%
*-commutative97.6%
associate-*r*97.6%
Simplified97.6%
Taylor expanded in eps around 0 97.6%
distribute-lft-out97.6%
unpow297.6%
associate-*r*97.6%
unpow397.6%
unpow297.6%
associate-*r*97.6%
unpow297.6%
distribute-lft-out97.6%
unpow297.6%
Simplified97.6%
fma-udef97.6%
metadata-eval97.6%
pow-prod-up97.4%
pow297.4%
pow297.4%
associate-*l*97.2%
associate-*r*97.5%
*-commutative97.5%
distribute-rgt-out97.5%
associate-*l*97.5%
Applied egg-rr97.5%
if -6.5000000000000004e-47 < x < 2.8500000000000001e-71Initial program 99.6%
Taylor expanded in x around 0 99.5%
Final simplification99.2%
(FPCore (x eps) :precision binary64 (* x (+ (* x (* eps (* 5.0 (* x x)))) (* x (* 10.0 (* (+ x eps) (* eps eps)))))))
double code(double x, double eps) {
return x * ((x * (eps * (5.0 * (x * x)))) + (x * (10.0 * ((x + eps) * (eps * eps)))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = x * ((x * (eps * (5.0d0 * (x * x)))) + (x * (10.0d0 * ((x + eps) * (eps * eps)))))
end function
public static double code(double x, double eps) {
return x * ((x * (eps * (5.0 * (x * x)))) + (x * (10.0 * ((x + eps) * (eps * eps)))));
}
def code(x, eps): return x * ((x * (eps * (5.0 * (x * x)))) + (x * (10.0 * ((x + eps) * (eps * eps)))))
function code(x, eps) return Float64(x * Float64(Float64(x * Float64(eps * Float64(5.0 * Float64(x * x)))) + Float64(x * Float64(10.0 * Float64(Float64(x + eps) * Float64(eps * eps)))))) end
function tmp = code(x, eps) tmp = x * ((x * (eps * (5.0 * (x * x)))) + (x * (10.0 * ((x + eps) * (eps * eps))))); end
code[x_, eps_] := N[(x * N[(N[(x * N[(eps * N[(5.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * N[(10.0 * N[(N[(x + eps), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(x \cdot \left(\varepsilon \cdot \left(5 \cdot \left(x \cdot x\right)\right)\right) + x \cdot \left(10 \cdot \left(\left(x + \varepsilon\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\right)\right)
\end{array}
Initial program 90.4%
Taylor expanded in x around inf 81.5%
fma-def81.5%
distribute-lft1-in81.5%
metadata-eval81.5%
*-commutative81.5%
+-commutative81.5%
*-commutative81.5%
*-commutative81.5%
unpow381.5%
unpow281.5%
associate-*l*81.5%
distribute-lft-out81.5%
Simplified81.5%
Taylor expanded in x around 0 81.5%
+-commutative81.5%
unpow281.5%
associate-*r*81.5%
associate-*r*81.5%
*-commutative81.5%
unpow281.5%
associate-*r*81.5%
cube-mult81.5%
associate-*r*81.5%
*-commutative81.5%
distribute-rgt-out81.5%
associate-*l*81.5%
*-commutative81.5%
associate-*r*81.5%
unpow281.5%
*-commutative81.5%
associate-*r*81.5%
Simplified81.5%
Taylor expanded in eps around 0 81.5%
distribute-lft-out81.5%
unpow281.5%
associate-*r*81.5%
unpow381.5%
unpow281.5%
associate-*r*81.5%
unpow281.5%
distribute-lft-out81.5%
unpow281.5%
Simplified81.5%
fma-udef81.5%
metadata-eval81.5%
pow-prod-up81.5%
pow281.5%
pow281.5%
associate-*l*81.4%
associate-*r*81.5%
*-commutative81.5%
distribute-rgt-out81.5%
associate-*l*81.5%
Applied egg-rr81.5%
Final simplification81.5%
(FPCore (x eps) :precision binary64 (* (* x x) (+ (* eps (* 5.0 (* x x))) (* 10.0 (* (+ x eps) (* eps eps))))))
double code(double x, double eps) {
return (x * x) * ((eps * (5.0 * (x * x))) + (10.0 * ((x + eps) * (eps * eps))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (x * x) * ((eps * (5.0d0 * (x * x))) + (10.0d0 * ((x + eps) * (eps * eps))))
end function
public static double code(double x, double eps) {
return (x * x) * ((eps * (5.0 * (x * x))) + (10.0 * ((x + eps) * (eps * eps))));
}
def code(x, eps): return (x * x) * ((eps * (5.0 * (x * x))) + (10.0 * ((x + eps) * (eps * eps))))
function code(x, eps) return Float64(Float64(x * x) * Float64(Float64(eps * Float64(5.0 * Float64(x * x))) + Float64(10.0 * Float64(Float64(x + eps) * Float64(eps * eps))))) end
function tmp = code(x, eps) tmp = (x * x) * ((eps * (5.0 * (x * x))) + (10.0 * ((x + eps) * (eps * eps)))); end
code[x_, eps_] := N[(N[(x * x), $MachinePrecision] * N[(N[(eps * N[(5.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(10.0 * N[(N[(x + eps), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot x\right) \cdot \left(\varepsilon \cdot \left(5 \cdot \left(x \cdot x\right)\right) + 10 \cdot \left(\left(x + \varepsilon\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\right)
\end{array}
Initial program 90.4%
Taylor expanded in x around inf 81.5%
fma-def81.5%
distribute-lft1-in81.5%
metadata-eval81.5%
*-commutative81.5%
+-commutative81.5%
*-commutative81.5%
*-commutative81.5%
unpow381.5%
unpow281.5%
associate-*l*81.5%
distribute-lft-out81.5%
Simplified81.5%
Taylor expanded in x around 0 81.5%
+-commutative81.5%
unpow281.5%
associate-*r*81.5%
associate-*r*81.5%
*-commutative81.5%
unpow281.5%
associate-*r*81.5%
cube-mult81.5%
associate-*r*81.5%
*-commutative81.5%
distribute-rgt-out81.5%
associate-*l*81.5%
*-commutative81.5%
associate-*r*81.5%
unpow281.5%
*-commutative81.5%
associate-*r*81.5%
Simplified81.5%
Taylor expanded in eps around 0 81.5%
distribute-lft-out81.5%
unpow281.5%
associate-*r*81.5%
unpow381.5%
unpow281.5%
associate-*r*81.5%
unpow281.5%
distribute-lft-out81.5%
unpow281.5%
Simplified81.5%
fma-udef81.5%
metadata-eval81.5%
pow-prod-up81.5%
pow281.5%
pow281.5%
associate-*l*81.4%
*-commutative81.4%
associate-*r*81.4%
distribute-lft-out81.5%
associate-*l*81.5%
Applied egg-rr81.5%
Final simplification81.5%
(FPCore (x eps) :precision binary64 (* eps (* (* x x) (* 5.0 (* x x)))))
double code(double x, double eps) {
return eps * ((x * x) * (5.0 * (x * x)));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps * ((x * x) * (5.0d0 * (x * x)))
end function
public static double code(double x, double eps) {
return eps * ((x * x) * (5.0 * (x * x)));
}
def code(x, eps): return eps * ((x * x) * (5.0 * (x * x)))
function code(x, eps) return Float64(eps * Float64(Float64(x * x) * Float64(5.0 * Float64(x * x)))) end
function tmp = code(x, eps) tmp = eps * ((x * x) * (5.0 * (x * x))); end
code[x_, eps_] := N[(eps * N[(N[(x * x), $MachinePrecision] * N[(5.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \left(\left(x \cdot x\right) \cdot \left(5 \cdot \left(x \cdot x\right)\right)\right)
\end{array}
Initial program 90.4%
Taylor expanded in eps around 0 81.2%
add-sqr-sqrt81.1%
sqrt-unprod79.0%
pow279.0%
distribute-lft1-in79.0%
metadata-eval79.0%
Applied egg-rr79.0%
unpow279.0%
*-commutative79.0%
*-commutative79.0%
swap-sqr79.0%
pow-sqr79.0%
metadata-eval79.0%
metadata-eval79.0%
Simplified79.0%
*-commutative79.0%
sqrt-prod79.0%
metadata-eval79.0%
sqrt-pow181.2%
metadata-eval81.2%
metadata-eval81.2%
pow-prod-up81.1%
pow281.1%
pow281.1%
associate-*r*81.1%
Applied egg-rr81.1%
Final simplification81.1%
(FPCore (x eps) :precision binary64 0.0)
double code(double x, double eps) {
return 0.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 0.0d0
end function
public static double code(double x, double eps) {
return 0.0;
}
def code(x, eps): return 0.0
function code(x, eps) return 0.0 end
function tmp = code(x, eps) tmp = 0.0; end
code[x_, eps_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 90.4%
sqr-pow41.2%
metadata-eval41.2%
metadata-eval41.2%
Applied egg-rr41.2%
pow241.2%
+-commutative41.2%
Applied egg-rr41.2%
Taylor expanded in x around inf 71.4%
distribute-rgt1-in71.4%
metadata-eval71.4%
mul0-lft71.4%
Simplified71.4%
Final simplification71.4%
herbie shell --seed 2023240
(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)))