I can't figure out how Newton's formula gets transformed into Babylonian in this article: https://en.wikipedia.org/wiki/Methods_of_computing_square_roots
How is this possible?
$x_{n+1}=x_n-\frac{f(x_n)}{f'(x_n)}=x_n-\frac{x_n^2-S}{2x_n}=\frac{1}{2}(x_n+\frac{S}{x_n})$
I mean, I feel like I'm missing some basic algebraic knowledge to simplify $x_n-\frac{x_n^2-S}{2x_n}$ into $\frac{1}{2}(x_n+\frac{S}{x_n})$.
P.S. I need this to make my own square root function implementation, but I don't want to use code that I don't understand.
You're probably overthinking it; you can manipulate
$$ x_n - \frac{x_n^2 - S}{2x_n}$$
by finding a common denominator and then subtracting two fractions:
$$ x_n - \frac{x_n^2 - S}{2x_n} = \frac{2 x_n^2}{2x^n} - \frac{x_n^2 - S}{2x_n} = \frac{2x_n^2 - (x_n^2 - S)}{2x_n} = \frac{x_n^2 + S}{2x_n} $$