Task

Implement the algorithm to compute the principal   nth   root   





A

n





{\displaystyle {\sqrt[{n}]{A}}}

   of a positive real number   A,   as explained at the   Wikipedia page.



nth_root(a, n) := block(
   [x, y, d, p: fpprec],
   fpprec: p + 10,
   x: bfloat(a),
   eps: 10.0b0^-p,
   y: do (
      d: bfloat((a / x^(n - 1) - x) / n),
      if abs(d) < eps * x then return(x),
      x: x + d
   ),
   fpprec: p,
   bfloat(y)
)$