Site banner
.
Home Forums Blogs Articles Photos Videos Contact FAQ                    
.
.
Wisdom Archive
Body Mind and Soul
Faith and Belief
God and Religion
Law of Attraction
Life and Beyond
Love and Happiness
Peace of Mind
Peace on Earth
Personal Faith
Spiritual Festivals
Spiritual Growth
Spiritual Guidance
Spiritual Inspiration
Spirituality and Science
Spiritual Retreats
More Wisdom
Buddhism Archives
Hinduism Archives
Sustainability
Theology Archives
Even more Wisdom
2012 - Year 2012
Affirmations
Aura
Ayurveda
Chakras
Consciousness
Cultural Creatives
Diksha (Deeksha)
Dream Dictionary
Dream Interpretation
Dream interpreter
Dreams
Enlightenment
Essential Oils
Feng Shui
Flower Essences
Gaia Hypothesis
Indigo Children
Kalki Bhagavan
Karma
Kundalini
Kundalini Yoga
Life after death
Mayan Calendar
Meaning of Dreams
Meditation
Morphogenetic Fields
Psychic Ability
Reincarnation
Spiritual Art, Music & Dance
Spiritual Awakening
Spiritual Enlightenment
Spiritual Healing
Spirituality and Health
Spiritual Jokes
Spiritual Parenting
Vastu Shastra
Womens Spirituality
Yoga Positions
Site map 2
Site map


Dream Sharing Forum

at Global Oneness Community.

Share your dreams and let others help you with the interpretation!
Dream Sharing Forum



.

Shifting nth-root algorithm - Algorithm

Shifting nth-root algorithm - Algorithm: Encyclopedia II - Shifting nth-root algorithm - Algorithm

Shifting nth-root algorithm - Notation. Let B be the base of the number system you are using, and n be the degree of the root to be extracted. Let x be the radicand processed thus far, y be the root extracted thus far, and r be the remainder. Let α be the next n digits of the radicand, and β be the next digit of the root. Let x' be the new value of x for the next iteration, y' be the new value of y for the next iteration, and r' be the new value of r for the next iteration. These are all integers. < ...

See also:

Shifting nth-root algorithm, Shifting nth-root algorithm - Algorithm, Shifting nth-root algorithm - Notation, Shifting nth-root algorithm - Invariants, Shifting nth-root algorithm - Initialization, Shifting nth-root algorithm - Main loop, Shifting nth-root algorithm - Paper and pencil nth roots, Shifting nth-root algorithm - Performance, Shifting nth-root algorithm - Examples, Shifting nth-root algorithm - Square root of 2 in binary, Shifting nth-root algorithm - Square root of 3, Shifting nth-root algorithm - Cube root of 5, Shifting nth-root algorithm - Fourth root of 7

Shifting nth-root algorithm, Shifting nth-root algorithm - Algorithm, Shifting nth-root algorithm - Cube root of 5, Shifting nth-root algorithm - Examples, Shifting nth-root algorithm - Fourth root of 7, Shifting nth-root algorithm - Initialization, Shifting nth-root algorithm - Invariants, Shifting nth-root algorithm - Main loop, Shifting nth-root algorithm - Notation, Shifting nth-root algorithm - Paper and pencil nth roots, Shifting nth-root algorithm - Performance, Shifting nth-root algorithm - Square root of 2 in binary, Shifting nth-root algorithm - Square root of 3

Shifting nth-root algorithm: Encyclopedia II - Shifting nth-root algorithm - Algorithm



Shifting nth-root algorithm - Algorithm

Shifting nth-root algorithm - Notation

Let B be the base of the number system you are using, and n be the degree of the root to be extracted. Let x be the radicand processed thus far, y be the root extracted thus far, and r be the remainder. Let α be the next n digits of the radicand, and β be the next digit of the root. Let x' be the new value of x for the next iteration, y' be the new value of y for the next iteration, and r' be the new value of r for the next iteration. These are all integers.

Shifting nth-root algorithm - Invariants

At each iteration, the invariant yn + r = x will hold. The invariant (y + 1)n > x will hold. Thus y is the largest integer less than the nth root of x, and r is the remainder.

Shifting nth-root algorithm - Initialization

The initial values of x, y, and r should be 0. The value of α for the first iteration should be the most significant aligned block of n digits of the radicand. An aligned block of n digits means a block of digits aligned so that the decimal point falls between blocks. For example, in 123.4 the most significant aligned block of 2 digits is 01, the next most significant is 23, and the third most significant is 40.

Shifting nth-root algorithm - Main loop

On each iteration we shift in n digits of the radicand, so we have x' = Bnx + α and we produce 1 digit of the root, so we have y' = By + β. We want to choose β and r' so that the invariants described above hold. It turns out that there is always exactly one such choice, as will be proved below.

The first invariant says that:

x' = y'n + r'

or

Bnx + α = (By + β)n + r'

So, pick the largest integer β such that

and let

r' = Bnx + α − (By + β)n

Such a β always exists, since if β = 0 then the condition is , but , so this is always true. Also, β must be less than B, since if β = B then we would have

but the second invariant implies that

Bnx < Bn(y + 1)n

and since Bnx and Bn(y + 1)n are both multiples of Bn the difference between them must be at least Bn, and then we have

but by definition of α, so this can't be true, and (By + β)n is a monotonically increasing function of β, so it can't be true for larger β either, so we conclude that there exists an integer γ with γ < B such that an integer r' with exists such that the first invariant holds if and only if .

Now consider the second invariant. It says:

(y' + 1)n > x'

or

(By + β + 1)n > Bnx + α

Now, if β is not the largest admissible β for the first invariant as described above, then β + 1 is also admissible, and we have

This violates the second invariant, so to satisfy both invariants we must pick the largest β allowed by the first invariant. Thus we have proven the existence and uniqueness of β and r'.

To summarize, on each iteration:

  1. Let α be the next aligned block of digits from the radicand
  2. Let x' = Bnx + α
  3. Let β be the largest β such that
  4. Let y' = By + β
  5. Let r' = x' − y'n

Now, note that x = yn + r, so the condition

is equivalent to

and

r' = x' − y'n = Bnx + α − (By + β)n

is equivalent to

r' = Bnr + α − ((By + β)nBnyn)

Thus, we don't actually need x, and since r = xyn and x < (y + 1)n, r < (y + 1)nyn or r < nyn − 1 + O(yn − 2), or , so by using r instead of x we save time and space by a factor of 1/n. Also, the Bnyn we subtract in the new test cancels the one in (By + β)n, so now the highest power of y we have to evaluate is yn − 1 rather than yn.

The final algorithm is:

  1. Initialize r and y to 0
  2. Repeat until desired precision is obtained:
    1. Let α be the next aligned block of digits from the radicand
    2. Let β be the largest β such that
    3. Let y' = By + β
    4. Let r' = Bnr + α − ((By + β)nBnyn)
    5. Assign and
  3. y is the largest integer such that yn < xBk, and yn + r = xBk, where k is the number of digits of the radicand after the decimal point that have been consumed (a negative number if the algorithm hasn't reached the decimal point yet).

Shifting nth-root algorithm - Paper and pencil nth roots

As noted above, this algorithm is similar to long division, and it lends itself to the same notation:

     1.  4   4   2   2   4
    ----------------------
  3/ 3.000 000 000 000 000
/\/  1 = 300*(0^2)*1+30*0*(1^2)+1^3
     -
     2 000
     1 744 = 300*(1^2)*4+30*1*(4^2)+4^3
     -----
       256 000
       241 984 = 300*(14^2)*4+30*14*(4^2)+4^3
       -------
        14 016 000
        12 458 888 = 300*(144^2)*2+30*144*(2^2)+2^3
        ----------
         1 557 112 000
         1 247 791 448 = 300*(1442^2)*2+30*1442*(2^2)+2^3
         -------------
           309 320 552 000
           249 599 823 424 = 300*(14422^2)*4+30*14422*(4^2)+4^3
           ---------------
            59 720 728 576

Note that after the first iteration or two the leading term dominates the (By + β)nBnyn, so we can get an often correct first guess at β by dividing Br + α by nBn − 1yn − 1.

Shifting nth-root algorithm - Performance

On each iteration, the most time-consuming task is to select β. We know that there are B possible values, so we can find β using O(log(B)) comparisons. Each comparison will require evaluating (By + β)nBnyn. In the kth iteration, y has k digits, and the polynomial can be evaluated with 2n − 4 multiplications of up to k(n − 1) digits and n − 2 additions of up to k(n − 1) digits, once we know the powers of y and β up through n − 1 for y and n for β. β has a restricted range, so we can get the powers of β in constant time. We can get the powers of y with n − 2 multiplications of up to k(n − 1) digits. Assuming n-digit multiplication takes time O(n2) and addition takes time O(n), we take time O(k2n2) for each comparison, or time O(k2n2log(B)) to pick β. The remainder of the algorithm is addition and subtraction that takes time O(k), so each iteration takes O(k2n2log(B)). For all k digits, we need time O(k3n2log(B)).

The only internal storage needed is r, which is O(k) digits on the kth iteration. That this algorithm doesn't have bounded memory usage puts an upper bound on the number of digits which can be computed mentally, unlike the more elementary algorithms of arithmetic. Unfortunately, any bounded memory state machine with periodic inputs can only produce periodic outputs, so there are no such algorithms which can compute irrational numbers from rational ones, and thus no bounded memory root extraction algorithms.

Note that increasing the base increases the time needed to pick β by a factor of O(log(B)), but decreases the number of digits needed to achieve a given precision by the same factor, and since the algorithm is cubic time in the number of digits, increasing the base gives an overall speedup of O(log2(B)). When the base is larger than the radicand, the algorithm degenerates to binary search, so it follows that this algorithm is completely useless, as it is always outperformed by much simpler binary search, and has the same memory complexity.




Adapted from the Wikipedia article "Algorithm", under the G.N U Free Docmentation License. Please also see http://en.wikipedia.org/wiki

More material related to Shifting Nth-root Algorithm can be found here:
Main Page
for
Shifting Nth-root Algorit...
Index of Articles
related to
Shifting Nth-root Algorit...


« Back








Search the Global Oneness web site
Global Oneness is a huge, really huge, web site. Almost whatever you are searching for within health, spirituality, personal development and inspirationals - you will find it here!
Google
 
 

Rate this article!

Please rate this article with 10 as very good and 1 as very poor.

.








Sneak-Peek of Global Oneness Community

Hi friend! The Global Oneness Community, the place for information and sharing about Oneness is not really launched yet (you will see there is still some clean up to do) ...but it is now open for a sneak-peek! And if you wish - please register and become one of the very first members to do so! Jonas

Forum Home, Articles, Photo Gallery, Videos, News, Sitemap
...and much more!


Dream Sharing Forum

at Global Oneness Community.

Share your dreams and let others help you with the interpretation!
Dream Sharing Forum



Forum
Articles
Images Pictures
Videos
News
Sitemap




 

 

 

 

 


 








  » Home » » Home »