0
$\begingroup$

I need to write a parallel code for finding p'th root of n with newton method. I know how the serial code must be. The only method I found to get rid of the do-while loop in the code is finding a formula to calculate the number of iterations, so that I can use a for loop with predetermined number of iterations.

So, I am looking for a formula to find the number of iterations in newton method to find the root of a number. Is there any way to do so?

Thanks a lot.

$\endgroup$
  • 1
    $\begingroup$ How small does the error have to be? You will not get the exact result with a numerical method. $\endgroup$ – naslundx Feb 28 '14 at 10:10
  • $\begingroup$ Where do you start for solving $x^p=n$ ? $\endgroup$ – Claude Leibovici Feb 28 '14 at 10:15
  • $\begingroup$ Do you need multi-precision or integer root? Otherwise you have $\exp(\ln(x)/p)$ and maybe one Newton step. And for complex roots there are some fractal subleties for the convergence regions. $\endgroup$ – gammatester Feb 28 '14 at 10:21
  • $\begingroup$ @user132112 How will the for loop do anything to parallelize your code? You'd still have each loop result depending serially on the previous one. $\endgroup$ – Erick Wong Mar 1 '14 at 16:47
  • $\begingroup$ @ErickWong Well, is there any way at all to parallelize such a code? $\endgroup$ – far Mar 2 '14 at 17:55
0
$\begingroup$

Usually you do not code for a fixed number of iterations. You finish the loop when the difference between two consecutive iterates is smaller that a predefined error. The difference between two successive approximations is not he exact error, but almost.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.