Average Error: 31.2 → 8.3
Time: 59.0s
Precision: 64
Internal precision: 1408
\[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;n \le -2744589958.7011433:\\
\;\;\;\;\frac{1}{n \cdot x} - \left(\frac{1}{2} \cdot \frac{1}{n \cdot {x}^2} + \frac{\log x}{{n}^2 \cdot x}\right)\\
\mathbf{if}\;n \le 2.6712054680957466 \cdot 10^{+25}:\\
\;\;\;\;e^{\log \left({\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x} - \left(\frac{1}{2} \cdot \frac{1}{n \cdot {x}^2} + \frac{\log x}{{n}^2 \cdot x}\right)\\
\end{array}\]
Derivation
- Split input into 2 regimes.
-
if n < -2744589958.7011433 or 2.6712054680957466e+25 < n
Initial program 43.4
\[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
Applied taylor 9.5
\[\leadsto \frac{1}{n \cdot x} - \left(\frac{1}{2} \cdot \frac{1}{n \cdot {x}^2} + \frac{\log x}{{n}^2 \cdot x}\right)\]
Taylor expanded around inf 9.5
\[\leadsto \color{blue}{\frac{1}{n \cdot x} - \left(\frac{1}{2} \cdot \frac{1}{n \cdot {x}^2} + \frac{\log x}{{n}^2 \cdot x}\right)}\]
if -2744589958.7011433 < n < 2.6712054680957466e+25
Initial program 5.9
\[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
- Using strategy
rm
Applied add-exp-log 5.9
\[\leadsto \color{blue}{e^{\log \left({\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\right)}}\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie shell --seed '#(2277612311 2645429965 1090895633 2857793080 2144184008 3989768357)'
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
(- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n))))