Average Error: 29.0 → 22.0
Time: 50.8s
Precision: 64
\[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
\[\begin{array}{l} \mathbf{if}\;n \le -152059583.1304194033145904541015625:\\ \;\;\;\;\left(\frac{1}{x \cdot n} + \frac{1 \cdot \log x}{\left(n \cdot n\right) \cdot x}\right) - \frac{0.5}{n \cdot \left(x \cdot x\right)}\\ \mathbf{elif}\;n \le 3751685039024179200330301440:\\ \;\;\;\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{x \cdot n} + \frac{1 \cdot \log x}{\left(n \cdot n\right) \cdot x}\right) - \frac{0.5}{n \cdot \left(x \cdot x\right)}\\ \end{array}\]
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\begin{array}{l}
\mathbf{if}\;n \le -152059583.1304194033145904541015625:\\
\;\;\;\;\left(\frac{1}{x \cdot n} + \frac{1 \cdot \log x}{\left(n \cdot n\right) \cdot x}\right) - \frac{0.5}{n \cdot \left(x \cdot x\right)}\\

\mathbf{elif}\;n \le 3751685039024179200330301440:\\
\;\;\;\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\\

\mathbf{else}:\\
\;\;\;\;\left(\frac{1}{x \cdot n} + \frac{1 \cdot \log x}{\left(n \cdot n\right) \cdot x}\right) - \frac{0.5}{n \cdot \left(x \cdot x\right)}\\

\end{array}
double f(double x, double n) {
        double r8993040 = x;
        double r8993041 = 1.0;
        double r8993042 = r8993040 + r8993041;
        double r8993043 = n;
        double r8993044 = r8993041 / r8993043;
        double r8993045 = pow(r8993042, r8993044);
        double r8993046 = pow(r8993040, r8993044);
        double r8993047 = r8993045 - r8993046;
        return r8993047;
}

double f(double x, double n) {
        double r8993048 = n;
        double r8993049 = -152059583.1304194;
        bool r8993050 = r8993048 <= r8993049;
        double r8993051 = 1.0;
        double r8993052 = x;
        double r8993053 = r8993052 * r8993048;
        double r8993054 = r8993051 / r8993053;
        double r8993055 = log(r8993052);
        double r8993056 = r8993051 * r8993055;
        double r8993057 = r8993048 * r8993048;
        double r8993058 = r8993057 * r8993052;
        double r8993059 = r8993056 / r8993058;
        double r8993060 = r8993054 + r8993059;
        double r8993061 = 0.5;
        double r8993062 = r8993052 * r8993052;
        double r8993063 = r8993048 * r8993062;
        double r8993064 = r8993061 / r8993063;
        double r8993065 = r8993060 - r8993064;
        double r8993066 = 3.751685039024179e+27;
        bool r8993067 = r8993048 <= r8993066;
        double r8993068 = r8993052 + r8993051;
        double r8993069 = r8993051 / r8993048;
        double r8993070 = pow(r8993068, r8993069);
        double r8993071 = pow(r8993052, r8993069);
        double r8993072 = r8993070 - r8993071;
        double r8993073 = r8993067 ? r8993072 : r8993065;
        double r8993074 = r8993050 ? r8993065 : r8993073;
        return r8993074;
}

Error

Bits error versus x

Bits error versus n

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if n < -152059583.1304194 or 3.751685039024179e+27 < n

    1. Initial program 44.5

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
    2. Taylor expanded around inf 31.8

      \[\leadsto \color{blue}{1 \cdot \frac{1}{x \cdot n} - \left(1 \cdot \frac{\log \left(\frac{1}{x}\right)}{x \cdot {n}^{2}} + 0.5 \cdot \frac{1}{{x}^{2} \cdot n}\right)}\]
    3. Simplified31.8

      \[\leadsto \color{blue}{\left(\frac{1}{x \cdot n} + \frac{1 \cdot \log x}{\left(n \cdot n\right) \cdot x}\right) - \frac{0.5}{n \cdot \left(x \cdot x\right)}}\]

    if -152059583.1304194 < n < 3.751685039024179e+27

    1. Initial program 10.0

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification22.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \le -152059583.1304194033145904541015625:\\ \;\;\;\;\left(\frac{1}{x \cdot n} + \frac{1 \cdot \log x}{\left(n \cdot n\right) \cdot x}\right) - \frac{0.5}{n \cdot \left(x \cdot x\right)}\\ \mathbf{elif}\;n \le 3751685039024179200330301440:\\ \;\;\;\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{x \cdot n} + \frac{1 \cdot \log x}{\left(n \cdot n\right) \cdot x}\right) - \frac{0.5}{n \cdot \left(x \cdot x\right)}\\ \end{array}\]

Reproduce

herbie shell --seed 2019173 +o rules:numerics
(FPCore (x n)
  :name "2nthrt (problem 3.4.6)"
  (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))