Average Error: 30.9 → 9.6
Time: 1.2m
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 -1.026789586962528 \cdot 10^{+30}:\\
\;\;\;\;\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 4.273983850589163 \cdot 10^{+17}:\\
\;\;\;\;\sqrt[3]{{\left({\left(\sqrt[3]{{\left(\sqrt[3]{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}\right)}^3}\right)}^3\right)}^3}\\
\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 < -1.026789586962528e+30 or 4.273983850589163e+17 < n
Initial program 43.2
\[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
Applied taylor 10.0
\[\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 10.0
\[\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 -1.026789586962528e+30 < n < 4.273983850589163e+17
Initial program 8.9
\[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
- Using strategy
rm
Applied add-cbrt-cube 9.0
\[\leadsto \color{blue}{\sqrt[3]{{\left({\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\right)}^3}}\]
- Using strategy
rm
Applied add-cube-cbrt 9.0
\[\leadsto \sqrt[3]{{\color{blue}{\left({\left(\sqrt[3]{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}\right)}^3\right)}}^3}\]
- Using strategy
rm
Applied add-cube-cbrt 9.0
\[\leadsto \sqrt[3]{{\left({\left(\sqrt[3]{\color{blue}{{\left(\sqrt[3]{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}\right)}^3}}\right)}^3\right)}^3}\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie shell --seed '#(3283856077 3183919125 3399458751 396155847 3688194147 1862413033)'
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
(- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n))))