$f(x)=\sqrt{x^2+1}-x$
$x=10,10^2,...,10^6$
I want to calculate $f(x)$ and $\frac{1}{f(x)}$ and I want to use polynomial nesting technique that closest approximation to the real value.
I'm beginner in this topics so how can I use polynomial nesting when there is square?
when we don't have square, for example
$f(x) = 6x^2 -7x + 3x^4 +11 - 2x^3$
we can write as:
$((((3)x - 2)x + 6)x - 7)x + 11$
Sorry for trivial question but I'm really confused.
In comments, you precised that your goal is "to reduce round-off error by rearranging calculations" .
Using Horner's method means that you will approximate $f(x)$ by a long polynomial, probably comming from series expansions.
Expanded as series, we have $$f(x)=\sqrt{x^2+1}-x=\frac{1}{2 x}-\frac{1}{8 x^3}+O\left(\frac{1}{x^5}\right)$$
So, better than series would be the $[n,n+1]$ Padé approximant $P_n$. I give you below the very first ones $$P_1=P_2=\frac{2 x}{4 x^2+1} \qquad P_3=P_4=\frac{4x\left(2 x^2+1\right)}{16 x^4+12 x^2+1}$$ The last one is quite accurate since $$f(x)-P_3=\frac{1}{512 x^9}+O\left(\frac{1}{x^{11}}\right)$$
For the "worst" case $x=10$ $$\sqrt{101}-10= \color{red}{0.0498756211}21\quad \text{and} \quad P_3=\frac{8040}{161201}=\color{red}{0.049875621119}$$
For the reciprocal of $f(x)$, it would be the $[n+1,n]$ Padé approximant $Q_n=\frac 1{P_n}$. Tried again for $x=10$ $$\frac{1}{\sqrt{101}-10}=\color{red}{20.049875621}12\quad \text{and} \quad Q_3=\frac{161201}{8040}=\color{red}{20.04987562189}$$
For sure, we can do better. I give you the next one $$P_5=P_6=\frac{x(32 x^4+32 x^2+6)}{64 x^6+80 x^4+24 x^2+1}$$ which, for $x=10$ will give an absolute error of $1.18\times 10^{-17}$.