?

Average Accuracy: 88.4% → 98.8%
Time: 8.4s
Precision: binary64
Cost: 34056

?

\[\left(-1000000000 \leq x \land x \leq 1000000000\right) \land \left(-1 \leq \varepsilon \land \varepsilon \leq 1\right)\]
\[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
\[\begin{array}{l} t_0 := {\left(x + \varepsilon\right)}^{5} - {x}^{5}\\ \mathbf{if}\;t_0 \leq -2 \cdot 10^{-309}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_0 \leq 0:\\ \;\;\;\;\varepsilon \cdot \left(x \cdot \left(\left(x \cdot 2\right) \cdot \left(x \cdot \left(x \cdot 2\right)\right)\right) + {x}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;{\varepsilon}^{5}\\ \end{array} \]
(FPCore (x eps) :precision binary64 (- (pow (+ x eps) 5.0) (pow x 5.0)))
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (- (pow (+ x eps) 5.0) (pow x 5.0))))
   (if (<= t_0 -2e-309)
     t_0
     (if (<= t_0 0.0)
       (* eps (+ (* x (* (* x 2.0) (* x (* x 2.0)))) (pow x 4.0)))
       (pow eps 5.0)))))
double code(double x, double eps) {
	return pow((x + eps), 5.0) - pow(x, 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 <= -2e-309) {
		tmp = t_0;
	} else if (t_0 <= 0.0) {
		tmp = eps * ((x * ((x * 2.0) * (x * (x * 2.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
    code = ((x + eps) ** 5.0d0) - (x ** 5.0d0)
end function
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 <= (-2d-309)) then
        tmp = t_0
    else if (t_0 <= 0.0d0) then
        tmp = eps * ((x * ((x * 2.0d0) * (x * (x * 2.0d0)))) + (x ** 4.0d0))
    else
        tmp = eps ** 5.0d0
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	return Math.pow((x + eps), 5.0) - Math.pow(x, 5.0);
}
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 <= -2e-309) {
		tmp = t_0;
	} else if (t_0 <= 0.0) {
		tmp = eps * ((x * ((x * 2.0) * (x * (x * 2.0)))) + Math.pow(x, 4.0));
	} else {
		tmp = Math.pow(eps, 5.0);
	}
	return tmp;
}
def code(x, eps):
	return math.pow((x + eps), 5.0) - math.pow(x, 5.0)
def code(x, eps):
	t_0 = math.pow((x + eps), 5.0) - math.pow(x, 5.0)
	tmp = 0
	if t_0 <= -2e-309:
		tmp = t_0
	elif t_0 <= 0.0:
		tmp = eps * ((x * ((x * 2.0) * (x * (x * 2.0)))) + math.pow(x, 4.0))
	else:
		tmp = math.pow(eps, 5.0)
	return tmp
function code(x, eps)
	return Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0))
end
function code(x, eps)
	t_0 = Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0))
	tmp = 0.0
	if (t_0 <= -2e-309)
		tmp = t_0;
	elseif (t_0 <= 0.0)
		tmp = Float64(eps * Float64(Float64(x * Float64(Float64(x * 2.0) * Float64(x * Float64(x * 2.0)))) + (x ^ 4.0)));
	else
		tmp = eps ^ 5.0;
	end
	return tmp
end
function tmp = code(x, eps)
	tmp = ((x + eps) ^ 5.0) - (x ^ 5.0);
end
function tmp_2 = code(x, eps)
	t_0 = ((x + eps) ^ 5.0) - (x ^ 5.0);
	tmp = 0.0;
	if (t_0 <= -2e-309)
		tmp = t_0;
	elseif (t_0 <= 0.0)
		tmp = eps * ((x * ((x * 2.0) * (x * (x * 2.0)))) + (x ^ 4.0));
	else
		tmp = eps ^ 5.0;
	end
	tmp_2 = tmp;
end
code[x_, eps_] := N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]
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, -2e-309], t$95$0, If[LessEqual[t$95$0, 0.0], N[(eps * N[(N[(x * N[(N[(x * 2.0), $MachinePrecision] * N[(x * N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[eps, 5.0], $MachinePrecision]]]]
{\left(x + \varepsilon\right)}^{5} - {x}^{5}
\begin{array}{l}
t_0 := {\left(x + \varepsilon\right)}^{5} - {x}^{5}\\
\mathbf{if}\;t_0 \leq -2 \cdot 10^{-309}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;\varepsilon \cdot \left(x \cdot \left(\left(x \cdot 2\right) \cdot \left(x \cdot \left(x \cdot 2\right)\right)\right) + {x}^{4}\right)\\

\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Split input into 3 regimes
  2. if (-.f64 (pow.f64 (+.f64 x eps) 5) (pow.f64 x 5)) < -1.9999999999999988e-309

    1. Initial program 98.3%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]

    if -1.9999999999999988e-309 < (-.f64 (pow.f64 (+.f64 x eps) 5) (pow.f64 x 5)) < 0.0

    1. Initial program 86.2%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Taylor expanded in eps around 0 99.7%

      \[\leadsto \color{blue}{\varepsilon \cdot \left(4 \cdot {x}^{4} + {x}^{4}\right)} \]
    3. Applied egg-rr99.7%

      \[\leadsto \varepsilon \cdot \left(\color{blue}{{\left(2 \cdot \left(x \cdot x\right)\right)}^{2}} + {x}^{4}\right) \]
      Proof

      [Start]99.7

      \[ \varepsilon \cdot \left(4 \cdot {x}^{4} + {x}^{4}\right) \]

      add-sqr-sqrt [=>]99.7

      \[ \varepsilon \cdot \left(\color{blue}{\sqrt{4 \cdot {x}^{4}} \cdot \sqrt{4 \cdot {x}^{4}}} + {x}^{4}\right) \]

      pow2 [=>]99.7

      \[ \varepsilon \cdot \left(\color{blue}{{\left(\sqrt{4 \cdot {x}^{4}}\right)}^{2}} + {x}^{4}\right) \]

      sqrt-prod [=>]99.7

      \[ \varepsilon \cdot \left({\color{blue}{\left(\sqrt{4} \cdot \sqrt{{x}^{4}}\right)}}^{2} + {x}^{4}\right) \]

      metadata-eval [=>]99.7

      \[ \varepsilon \cdot \left({\left(\color{blue}{2} \cdot \sqrt{{x}^{4}}\right)}^{2} + {x}^{4}\right) \]

      sqrt-pow1 [=>]99.7

      \[ \varepsilon \cdot \left({\left(2 \cdot \color{blue}{{x}^{\left(\frac{4}{2}\right)}}\right)}^{2} + {x}^{4}\right) \]

      metadata-eval [=>]99.7

      \[ \varepsilon \cdot \left({\left(2 \cdot {x}^{\color{blue}{2}}\right)}^{2} + {x}^{4}\right) \]

      pow2 [<=]99.7

      \[ \varepsilon \cdot \left({\left(2 \cdot \color{blue}{\left(x \cdot x\right)}\right)}^{2} + {x}^{4}\right) \]
    4. Applied egg-rr99.7%

      \[\leadsto \varepsilon \cdot \left(\color{blue}{\left(\left(x \cdot \left(2 \cdot x\right)\right) \cdot \left(2 \cdot x\right)\right) \cdot x} + {x}^{4}\right) \]
      Proof

      [Start]99.7

      \[ \varepsilon \cdot \left({\left(2 \cdot \left(x \cdot x\right)\right)}^{2} + {x}^{4}\right) \]

      unpow2 [=>]99.7

      \[ \varepsilon \cdot \left(\color{blue}{\left(2 \cdot \left(x \cdot x\right)\right) \cdot \left(2 \cdot \left(x \cdot x\right)\right)} + {x}^{4}\right) \]

      associate-*r* [=>]99.7

      \[ \varepsilon \cdot \left(\left(2 \cdot \left(x \cdot x\right)\right) \cdot \color{blue}{\left(\left(2 \cdot x\right) \cdot x\right)} + {x}^{4}\right) \]

      associate-*r* [=>]99.7

      \[ \varepsilon \cdot \left(\color{blue}{\left(\left(2 \cdot \left(x \cdot x\right)\right) \cdot \left(2 \cdot x\right)\right) \cdot x} + {x}^{4}\right) \]

      associate-*r* [=>]99.7

      \[ \varepsilon \cdot \left(\left(\color{blue}{\left(\left(2 \cdot x\right) \cdot x\right)} \cdot \left(2 \cdot x\right)\right) \cdot x + {x}^{4}\right) \]

      *-commutative [=>]99.7

      \[ \varepsilon \cdot \left(\left(\color{blue}{\left(x \cdot \left(2 \cdot x\right)\right)} \cdot \left(2 \cdot x\right)\right) \cdot x + {x}^{4}\right) \]

    if 0.0 < (-.f64 (pow.f64 (+.f64 x eps) 5) (pow.f64 x 5))

    1. Initial program 97.8%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Taylor expanded in x around 0 91.8%

      \[\leadsto \color{blue}{{\varepsilon}^{5}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification98.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq -2 \cdot 10^{-309}:\\ \;\;\;\;{\left(x + \varepsilon\right)}^{5} - {x}^{5}\\ \mathbf{elif}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq 0:\\ \;\;\;\;\varepsilon \cdot \left(x \cdot \left(\left(x \cdot 2\right) \cdot \left(x \cdot \left(x \cdot 2\right)\right)\right) + {x}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;{\varepsilon}^{5}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy97.8%
Cost7689
\[\begin{array}{l} \mathbf{if}\;x \leq -1.9 \cdot 10^{-46} \lor \neg \left(x \leq 2.05 \cdot 10^{-46}\right):\\ \;\;\;\;\varepsilon \cdot \left(x \cdot \left(\left(x \cdot 2\right) \cdot \left(x \cdot \left(x \cdot 2\right)\right)\right) + {x}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;{\varepsilon}^{5} + x \cdot \left(5 \cdot \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\right)\\ \end{array} \]
Alternative 2
Accuracy97.8%
Cost7560
\[\begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{-47}:\\ \;\;\;\;\varepsilon \cdot \left(\left(x \cdot \left(x \cdot 5\right)\right) \cdot \left(x \cdot x\right)\right)\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-46}:\\ \;\;\;\;{\varepsilon}^{5} + x \cdot \left(5 \cdot \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\ \end{array} \]
Alternative 3
Accuracy97.7%
Cost7048
\[\begin{array}{l} \mathbf{if}\;x \leq -1.4 \cdot 10^{-47}:\\ \;\;\;\;\varepsilon \cdot \left(\left(x \cdot \left(x \cdot 5\right)\right) \cdot \left(x \cdot x\right)\right)\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{-46}:\\ \;\;\;\;{\varepsilon}^{5}\\ \mathbf{else}:\\ \;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\ \end{array} \]
Alternative 4
Accuracy97.7%
Cost6792
\[\begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{-47}:\\ \;\;\;\;\varepsilon \cdot \left(\left(x \cdot \left(x \cdot 5\right)\right) \cdot \left(x \cdot x\right)\right)\\ \mathbf{elif}\;x \leq 2.05 \cdot 10^{-46}:\\ \;\;\;\;{\varepsilon}^{5}\\ \mathbf{else}:\\ \;\;\;\;\varepsilon \cdot \left(\left(x \cdot x\right) \cdot \left(5 \cdot \left(x \cdot x\right)\right)\right)\\ \end{array} \]
Alternative 5
Accuracy82.7%
Cost704
\[\varepsilon \cdot \left(\left(x \cdot x\right) \cdot \left(5 \cdot \left(x \cdot x\right)\right)\right) \]
Alternative 6
Accuracy82.7%
Cost704
\[\varepsilon \cdot \left(\left(x \cdot \left(x \cdot 5\right)\right) \cdot \left(x \cdot x\right)\right) \]

Error

Reproduce?

herbie shell --seed 2023142 
(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)))