Average Error: 30.9 → 13.3
Time: 1.9m
Precision: 64
Ground Truth: 128
\[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;n \le -31.329673016395393:\\
\;\;\;\;\frac{1}{n \cdot x} - \left(\frac{\log x}{{n}^2 \cdot x} + \frac{1}{2} \cdot \frac{1}{\log \left(e^{n \cdot {x}^2}\right)}\right)\\
\mathbf{if}\;n \le 5667669302503732.0:\\
\;\;\;\;{\left(\sqrt[3]{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}\right)}^3\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x} - \left(\frac{\log x}{{n}^2 \cdot x} + \frac{1}{2} \cdot \frac{1}{\log \left(e^{n \cdot {x}^2}\right)}\right)\\
\end{array}\]
Derivation
- Split input into 2 regimes.
-
if n < -31.329673016395393 or 5667669302503732.0 < n
Initial program 43.9
\[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
Applied taylor 17.9
\[\leadsto \frac{1}{n \cdot x} - \left(\frac{\log x}{{n}^2 \cdot x} + \frac{1}{2} \cdot \frac{1}{n \cdot {x}^2}\right)\]
Taylor expanded around inf 17.9
\[\leadsto \color{blue}{\frac{1}{n \cdot x} - \left(\frac{\log x}{{n}^2 \cdot x} + \frac{1}{2} \cdot \frac{1}{n \cdot {x}^2}\right)}\]
- Using strategy
rm
Applied add-log-exp 18.0
\[\leadsto \frac{1}{n \cdot x} - \left(\frac{\log x}{{n}^2 \cdot x} + \frac{1}{2} \cdot \frac{1}{\color{blue}{\log \left(e^{n \cdot {x}^2}\right)}}\right)\]
if -31.329673016395393 < n < 5667669302503732.0
Initial program 3.5
\[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
- Using strategy
rm
Applied add-cube-cbrt 3.5
\[\leadsto \color{blue}{{\left(\sqrt[3]{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}\right)}^3}\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(1317229083 385665165 927243142 4133899538 3082641653 3120456537)'
(FPCore (x n)
:name "NMSE problem 3.4.6"
(- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n))))