News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

square roots and squaring without multiplication and division

Started by Mikl__, April 22, 2015, 12:41:54 PM

Previous topic - Next topic

Mikl__

  • Difficult to surprise anyone that √(1022N)=102N but √(1022N+1)=102N x √(2)
    √(2)=1.4142135623730950488016887242097...10=1.6A09E66...16
    for example integer square root 263 is √{263}=√{2} x 231=3037000499=1.0110.1010.0000.1001.1110.0110.0110.0112
  • if quantity of 1-s is 2N then √(1111...1112)= 111...12 quantity of 1-s is N in result
  • if quantity of 1-s is 2N+1 then √(1111...1112)=√(2)x 2N
  • if quantity of 1-s is N then 11..122=111..1100..001 at the first location is quantity of 1-s equal (N-1), at the second location is quantity of 0-ss equal N, at the third location is 1
P.S. excuse me for my bad english, but I think you understood the idea

Gunther

Hi Mikl__,

your idea looks at a first glance not so bad. Could you provide a paper with the formulae, please? You could write it with Latex or an office writer with a formula editor.

Gunther
You have to know the facts before you can distort them.

Mikl__

Hi, Gunther!
picture with formulas in attach
maybe I'll show specific examples?
√{237}=√137438953472=370727=1.0110.1010.0000.1001.11
√{249-1}=√562949953421311=23726566=1.0110.1010.0000.1001.1110.0110
√{250-1}=√1125899906842623=√11111111111111111111111111111111111111111111111111=33554431=1111111111111111111111111
11111111111111111111111112=335544312=1125899839733761=11111111111111111111111100000000000000000000000001
111112=312=961=11110000012


dedndave


Mikl__


qWord

MREAL macros - when you need floating point arithmetic while assembling!

Gunther

Mikl__,

your image makes it clear. Thank you.

qWord,

:t

Gunther
You have to know the facts before you can distort them.

Mikl__

Quote from: qWord on April 22, 2015, 11:43:32 PM
Exponentation: Identities and properties

e.g.
sqrt(237) = (232 * 24 * 21)1/2 = (232)1/2 (24)1/2 (21)1/2 = 2162221/2
Hi, qWord!
talked about another case
sqrt(237) =sqrt(22x18+1) =sqrt(2)x218 in the square root is 18+1=19 binary digits, square root from 2 we know, it is 1,4142135623730950488016887242097 or 1.6A09E66...16=1,0110.1010.0000.1001.1110.0110.0110...2
therefore sqrt(237) =1.0110.1010.0000.1001.11=370727

rrr314159

Hi Miki,

It took some thought to see what you're doing here, pretty clever but I don't think it's worth a Fields medal yet.

1) ------------------------------------------------------------------------------------

First, let x = sqrt(2^(2n+1)) = sqrt(2^2n)*sqrt(2) = 2^n * sqrt(2) = sqrt(2) left-shifted by n.

So, if you express sqrt(2) in binary, = 1.0110101000001001 etc, you can immediately write down x by shifting the "decimal" (or, radix) point by n.

Thus, sqrt(2^7) = sqrt(2^(2n+1)) = 1011 (plus remainder of course) = 11, which is right - that's the truncated sqrt of 128. And, you give a good example in the last post using sqrt(2^37).

Now, this is generally true. Given any radix r, if we can express a number

x = sqrt(r^(2n+1)) = r^n*sqrt(r)

, and we know sqrt(r) in that radix, we can use the same trick. For example base 10:

x = sqrt(10^7) = 10^3 * sqrt(10) = 3.162278... shifted 3 places = 3,162 + remainder.

In fact it doesn't have to be a square root. If we know the number's representation in a radix, to find it times r^n just shift the radix point. For instance

pi*10^3 = 3.14159265 shifted 3 places (a.k.a. 3.14159265 e3) = 3141 (remainder .59265 etc)

Which of course is very well known. Another example, since 1.6875 = 1.1011 binary, times 8 = 1101.1 binary.

2) ------------------------------------------------------------------------------------

Now, the other main point you have is the fact that in binary, (111...(n times))^2 = 111(n-1 times)...000(n times)...1. An example will make it more clear,

In binary: 11111^2 = 1111000001. In decimal: 31^2 = 961 = 512+256+128+64+1

We can see why this is as follows. 111...(n times) = 2^(n+1) - 1. So

111...(n times)^2 = (2^(n+1) - 1)^2 = 2^(n+1)^2 - 2*2^(n+1) + 1 = 2^(2n+2) - 2^(n+2) + 1

Now in general, 2^m - 2^n (with m > n) will consist of (m-n) 1's followed by n zeroes. For example, 2^10 - 2^6 =

10000000000 -
       1000000 =
01111000000

You see, subtracting in the normal way, on the right it's all zeros till we get to "0-1" which gives a 1, carry the 1. then it continues being 1's until the end when the carry from the right makes the last digit 0. So in this case,

1024 - 64 = 960 = 512+256+128+64 (+ zero's)

Stick on the last 1, and we have the example given above, 31^2 = 961.

And so, in binary given n-1 1's followed by n 0's and a 1, we can immediately write the sqrt:

sqrt(1) = 1, sqrt(1001) = 11, sqrt(110001) = 111, sqrt(11100001) = 1111, sqrt(11111100000001) = 1111111 etc

i.e. sqrt(9) = 3, sqrt(32+16+1) = sqrt(49) = 7, sqrt(128+64+32+1) = sqrt(225) = 15, sqrt(16129) = 127 etc

In base 10 there's a similar trick, but instead of a 1 we must use 5, namely, half the radix.

99995^2 = (2^5 - 5)^2 = 9999000025

Because the same subtraction as above gives a very analogous result, for the same reason (consider the "carry"):

10000000000 -
       1000000 =
09999000000

So given n 9's followed by n zero's then 25, we immediately know the square root is n 9's and a 5, without having to compute it. For instance,

sqrt(9999999999000000000025) = 99999999995. Or sqrt(9025) = 95, sqrt(990025) = 995, etc.

3) ------------------------------------------------------------------------------------

Ok, apart from those rather clever points, you have a couple mistakes. You seem to have confused 2^n with n 1's. Thus you say,

sqrt(111...(2n 1's)) = 111...(n 1's)

, in the first post and also in the picture, but no that's not true. For instance sqrt(15) does not equal 3. What is true, sqrt(2^2n) = 2^n, thus sqrt(16) does equal 4. And, the same confusion appears in couple other places. Actually a string of 1's, in radix 2, can never be a perfect square.

4) ------------------------------------------------------------------------------------

Off the top of my head I thought you could never have such a form in any radix. Thus in base 10 it can easily be shown a string of 1's can't be a perfect square: 11, 111, 1111, 11111 ... never square, forget it. Well, of course, "1" is square in any radix, and "11" in any radix 1 less than a square: thus 11 (radix 3) = 4, 11 (radix 63) = 64 etc. But 3 or more, seems impossible at first.

But if you think about it, it's interesting to note there are two cases (at least).

radix 3: sqrt(11111) = (decimal) sqrt(81+27+9+3+1) = sqrt(121) = sqrt(11) or, back to radix 3, = 102

and,

radix 7: sqrt(1111) = (decimal) sqrt(343+49+7+1) = sqrt(400) = sqrt(20) or, back to radix 7, = 26

I doubt there are any others?

------------------------------------------------------------------------------------

Miki, keep at it, a Fields medal is only $15,000 but a millenium prize is a million bucks...! I expect a cut, for helping you on the road to success ;)
I am NaN ;)

Mikl__

Hi, rrr314159!
many thanks for the tips
QuoteOk, apart from those rather clever points, you have a couple mistakes. You seem to have confused 2^n with n 1's. Thus you say,

sqrt(111...(2n 1's)) = 111...(n 1's)

, in the first post and also in the picture, but no that's not true. For instance sqrt(15) does not equal 3. What is true, sqrt(2^2n) = 2^n, thus sqrt(16) does equal 4. And, the same confusion appears in couple other places. Actually a string of 1's, in radix 2, can never be a perfect square.
I wrote about the integer part of the square root. It's easy enough to check:
integer(√1111)=integer(√15)=integer(3,8729833462074168851792653997824)=112
integer(√11111111)=integer(√255)=integer(15,968719422671311999070245176981)=11112
integer(√1111111111111111)=integer(√65535)=integer(255,99804686754936255911520419041)=111111112
P.S. I do not fall under the criteria for awarding the Fields Medal, since I'm not a mathematician and I am more than 40


rrr314159

Of course, it's correct with the understanding that you're talking about the integer part. I don't see it in the picture you attached, but that's alright.

ps, the millennium prize is still open to old people, and since Perlman didn't take it, I think they've got plenty of cash on hand
I am NaN ;)

Mikl__

rrr314159,
Quotethe millennium prize is still open to old people
After these words, I feel decrepit invalid. I wanted to write that "The Fields Medal is a prize awarded to two, three, or four mathematicians under 40 years of age at the International Congress of the International Mathematical Union (IMU), a meeting that takes place every four years." and I am 42

Gunther

You have to know the facts before you can distort them.

Mikl__

QuoteThat's a little bit to old
Gunther,

QuoteBad luck.
Why?

Gunther

Quote from: Mikl__ on April 24, 2015, 10:19:25 AM
Why?

It has to do with the age limit for the Fields Medal.  :lol: But there are other open questions, for example the Collatz conjecture. By solving it, you can achieve a lot of fame. It is perhaps partly solved, but I'm not sure. You can check some interesting details here.

Gunther
You have to know the facts before you can distort them.