[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference rusure::math

Title:Mathematics at DEC
Moderator:RUSURE::EDP
Created:Mon Feb 03 1986
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2083
Total number of notes:14613

1091.0. "Square of sum of powers of 2" by RDVAX::NG () Tue Jun 27 1989 10:23

	I have this problem. Consider

	  M			N
	 Sum b(i)2^i = square( Sum a(i)2^i )  where a(i), b(i) = -1,0, or 1
	 i=0		       i=0

	1) How large does M need to be?
		I think M=2N+1 is sufficient. Is that correct?

	2) What would be a efficient way to find the b(j)'s?
	   You may used any representation. Is there a linear time algorithm?

	Thanks.
T.RTitleUserPersonal
Name
DateLines
1091.1TRACE::GILBERTOwnership ObligatesTue Jun 27 1989 11:155
Yes, M=2N+1 suffices.

Is there a linear-time squaring algorithm using this representation?
I don't know.  Check volume 2 of "The Art of Computer Programming",
by Donald Knuth.
1091.2RDVAX::NGTue Jun 27 1989 11:497
    Re .1
    
    I've checked Knuth. For multi-precision multiply, the problem is
    still unsolved. I think this would apply to square too. Anyway,
    there is no special attention to just square. In this case, it
    is a special form that I want to square, I was wondering if there
    are any tricks to it.
1091.3RDVAX::NGWed Jun 28 1989 11:285
    I have a related question:
    
    Given a sum of powers of two with coefficients equal -1, 0 or 1,
    is there a way to reduce the sum to another that represents the
    same value and has the minimal number of non-zero terms?
1091.4too many choicesNIZIAK::YARBROUGHI PREFER PIWed Jun 28 1989 17:248
>    Given a sum of powers of two with coefficients equal -1, 0 or 1,
>    is there a way to reduce the sum to another that represents the
>    same value and has the minimal number of non-zero terms?

I think this is optimal: If the most significant digit is 1, put the sum in
a canonical form in which only the coeff's 0 and 1 appear. Now replace a
zero followed by a sequence of 3 or more 1's by {10..0-1}. If the most
significant digit is -1, use the canonical form with only 0 and -1, etc.
1091.5One Plus:DWOVAX::YOUNGSharing is what Digital does best.Wed Jun 28 1989 23:389
    After applying Lynn's rule in .4:
    
    replace all		  and
    		{-1 1}		{ 1-1}
    with
    		{ 0-1}		{ 0 1}
    
    Apply this rule (and Lynn's) repeatdly until no transformations
    remain.