top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the fastest way to compute cube root?

0 votes
283 views

Detail algo with code may be helpful?

posted Nov 16, 2015 by Brijesh Talwar

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

Suppose we want to find cube root of a, that is, we wish to solve x^3 - a = 0. Apply Newton Raphson method, that is, apply iterative method
xn+1 = xn - f(xn)/ f'(xn), where f(x) = x^3 - a, f'(x) = 3x^2, so the process is
xn+1 = xn - (xn/3 - a/(3xn^2) = ( 2xn + a/xn^2)/ 3

answer Nov 17, 2015 by Ramesh Chand Mittal
0 votes

Perfect Solution Ramesh, Just iterating more with example -

Cube root of a number a is obtained by starting with a guess x1 of the cube root and using the formula
x2 = (1/3)[2 x1 + a/(x1^2)]

So say to find the cube root of 5, we take x1 as 3/2. (This guess is based on the reasoning that a value of 2 will be too high since the cube of 2 is 8 wheres as a value of 1 is too low since the cube of 1 is 1)

So x2 = (1/3)(2(3/2) + 5/(9/4)) = 1 + 20/27 = 47/27. We then let x1 = 47/27 and repeat the process, successively finding better and better approximations to the cube root of 5.

answer Nov 17, 2015 by Salil Agrawal
Similar Questions
0 votes
for(i=0;i<n;i++)
  for(j=0;j<n;j++)
     for(k=0;k<n;k++)
        C[i][j]+=A[i][k]*B[k][j];

In this algorithm, there are 6 combinations of loops : the one given above is ijk. The others are ikj,jki,jik,kij and kji. Which one executes the fastest and why?

+3 votes

I went through this Discussion:

http://stackoverflow.com/questions/7087036/fetching-images-from-server-while-drawing-the-cell

I have a web server server-1.example.com. There is a JSON-Server running on another server server-2.example.com. What I have to achieve is to fetch a list of URLs (in form of JSON response) from server-2 and loop through the urls and fetch them from the server-1. In the meantime i have to animate these images on the browser by Fading the images one after the another.

The algorithm is something like this:-

START:
   FETCH the URLs from server-1 and store them in a cache C
   Loop until C.length
      Fetch first K images by forking a thread.
      animate k images
 END

How can I optimize K? Is my approach right?

...