how to calcule the division modulo 2 reminder

  • Follow


Hello,

I can't find how to calcule the division modulo 2 reminder.

I need it to calculate Cyclic Redundancy Check.

I already search on the manual and the only thing I found was REMAINDER
(Euclidean reminder of two polynomials), which is not what I need.


I'll show an example:

(x7 + x6 + x5 + x3)  (x3 + 1)  (/division modulo 2) should give the
reminder: x2 + x;

thanks,

Rui

0
Reply ruimaximo (18) 1/18/2007 5:44:58 PM

2 MODSTO
DIV2MOD

"RMX" <ruimaximo@hotmail.com> wrote in message 
news:1169142298.589022.3730@a75g2000cwd.googlegroups.com...
> Hello,
>
> I can't find how to calcule the division modulo 2 reminder.
>
> I need it to calculate Cyclic Redundancy Check.
>
> I already search on the manual and the only thing I found was REMAINDER
> (Euclidean reminder of two polynomials), which is not what I need.
>
>
> I'll show an example:
>
> (x7 + x6 + x5 + x3)  (x3 + 1)  (/division modulo 2) should give the
> reminder: x2 + x;
>
> thanks,
>
> Rui
> 


0
Reply Veli 1/18/2007 6:06:44 PM


Hi Veli,

2 MODSTO
DIV2MOD

doesn't return the remainder between 2 polynominals division!

take care

Rui

Veli-Pekka Nousiainen escreveu:
> 2 MODSTO
> DIV2MOD
>
> "RMX" <ruimaximo@hotmail.com> wrote in message
> news:1169142298.589022.3730@a75g2000cwd.googlegroups.com...
> > Hello,
> >
> > I can't find how to calcule the division modulo 2 reminder.
> >
> > I need it to calculate Cyclic Redundancy Check.
> >
> > I already search on the manual and the only thing I found was REMAINDER
> > (Euclidean reminder of two polynomials), which is not what I need.
> >
> >
> > I'll show an example:
> >
> > (x7 + x6 + x5 + x3)  (x3 + 1)  (/division modulo 2) should give the
> > reminder: x2 + x;
> >
> > thanks,
> >
> > Rui
> >

0
Reply RMX 1/19/2007 2:47:51 AM

> 2 MODSTO
> DIV2MOD
>
> doesn't return the remainder between 2 polynominals division!
>
> take care

Why not?  From the Advanced Users Reference:

DIV2MOD
Type: Command
Description:  Performs euclidean division on two expressions modulo the
current modulus.

Input:  Level 2/Argument 1: The dividend.
Level 1/Argument 2: The divisor.
Output:  Level 2/Item 1: The quotient.
Level 1/Item 2: The remainder.
Flags:  Exact mode must be set (flag -105 clear).
Numeric mode must not be set (flag =F13 clear).
Radians mode must be set (flag -17 set).

Example:

DIV2MOD(X^3+4,X^2-1)
Result:  {X X+1}

Is this not the exact command?  Are you sure your remained is correct.
Doesn't seem to be just looking at it offhand. . .

TW

0
Reply TW 1/19/2007 4:30:22 AM

RMX wrote:
> 2 MODSTO
> DIV2MOD
> 
> doesn't return the remainder between 2 polynominals division!

Sure it does. 2 MODSTO 'X^7+X^6+X^5+X^3' 'X^3+1' DIV2MOD gives
'X^4+X^3++X^2-X' '-(X^2-X)' on my calc, the latter is the remainder.
Never mind that 1==-1 mod 2. :)

-- 
Dr. Albert Gr"af
Dept. of Music-Informatics, University of Mainz, Germany
Email:  Dr.Graef@t-online.de, ag@muwiinfa.geschichte.uni-mainz.de
WWW:    http://www.musikinformatik.uni-mainz.de/ag
0
Reply Albert 1/19/2007 9:59:30 AM

Albert Graef wrote:

> Never mind that 1 == -1 mod 2. :)

The CAS mod functions (for some dumb reason) return values between -m/2
and m/2 (where m is the current modulus), rather than the MOD
function's more useful output (between 0 and m, when the second
argument is positive). <rant> The answers from the CAS MOD functions
are mathematically correct but annoying. If -1 ATAN returned an answer
of -153*pi/4, it'd be mathematically correct, but VERY annoying!  Would
we tolerate a square root function that returned negative answers half
the time?  No, and we shouldn't have to tolerate these silly CAS MOD
functions' results either. </rant>

Workaround: Just do << m MOD >> after any CAS MOD function to
"normalize" the result to its positive equivalent.

Example: What's 12345 ^ 56789 (mod 789)?
789 MODSTO 12345 56789 POWMOD --> -267
That answer is correct, but silly.  So just follow it with
789 MOD
to see 522, as God intended.  ;-)

Disclaimer: Rodger Rosenbaum is allowed to disagree, but nobody else!
:-b

-Joe-

0
Reply Joe 1/19/2007 11:11:09 AM

On Fri, 19 Jan 2007 05:11:09 -0600, Joe Horn wrote:

> Workaround: Just do << m MOD >> after any CAS MOD function
> to "normalize" the result to its positive equivalent.

To automate, taking 'm' from CASDIR (or HOME):

\<< PATH CASDIR 'MODULO' RCL SWAP EVAL MOD \>>

HOME 'CASMOD' STO @ ???

By the way, although not many people
will have their CAS variables in HOME,
that's where they originally were in early HP49G,
and if so, that's where they will remain,
hence the above, for backward compatibility
(except not so backward that there isn't even
a possibly empty CASDIR at present :)

[r->] [OFF]
0
Reply John 1/19/2007 12:28:31 PM

Joe Horn wrote:
> Albert Graef wrote:
> 
>> Never mind that 1 == -1 mod 2. :)

I didn't actually complain about that, just wanted to point out to the
OP that the method suggested *twice* to him (by VPN) *did* give the
result he wanted after all, albeit in a somewhat non-standard form.

> The CAS mod functions (for some dumb reason) return values between -m/2
> and m/2 (where m is the current modulus), rather than the MOD
> function's more useful output (between 0 and m, when the second
> argument is positive).

Well, it's just a convention, but it would be nice if the CAS modulo
functions and MOD worked consistently.

> Workaround: Just do << m MOD >> after any CAS MOD function to
> "normalize" the result to its positive equivalent.

Those normalizing tricks that everybody uses should actually make for a
nice thread and/or wiki page. Speaking of which, does anyone know a
speedy way to distribute just unary minus a.k.a. NEG (push it "inward")
*without* distributing other factors, e.g.: '-(7*(X^2-1))' =>
'7*(-X^2+1)'? I know that you can shuffle around factors manually or
write an RPL program to achieve that, but is there a quicker way using
the existing rewriting utilities?

> to see 522, as God intended.  ;-)

"God only made the positive integers." Hmm, maybe the 0, too? But does
that include the finite rings? ;-)

> Disclaimer: Rodger Rosenbaum is allowed to disagree, but nobody else!

Oops.

Albert

-- 
Dr. Albert Gr"af
Dept. of Music-Informatics, University of Mainz, Germany
Email:  Dr.Graef@t-online.de, ag@muwiinfa.geschichte.uni-mainz.de
WWW:    http://www.musikinformatik.uni-mainz.de/ag
0
Reply Albert 1/19/2007 1:16:40 PM

"Joe Horn" <joehorn@holyjoe.net> wrote in message 
news:1169205069.274492.12240@s34g2000cwa.googlegroups.com...
X
> Disclaimer: Rodger Rosenbaum is allowed to disagree, but nobody else!
> :-b

I disagree...
-- 
Rodger Rosenbaum


0
Reply Veli 1/19/2007 2:28:22 PM

Joe Horn wrote:
> Albert Graef wrote:
> 
> 
>>Never mind that 1 == -1 mod 2. :)
> 
> 
> The CAS mod functions (for some dumb reason) return values between -m/2
> and m/2 (where m is the current modulus), rather than the MOD
> function's more useful output (between 0 and m, when the second
> argument is positive). <rant> The answers from the CAS MOD functions
> are mathematically correct but annoying. If -1 ATAN returned an answer
> of -153*pi/4, it'd be mathematically correct, but VERY annoying!  Would
> we tolerate a square root function that returned negative answers half
> the time?  No, and we shouldn't have to tolerate these silly CAS MOD
> functions' results either. </rant>

CAS use symmetric modular representation, which is more
efficient for computation. That's also true if you do
computation by hand, it's easier to compute e.g.
(-1)^3 mod 13 than 12^3 mod 13
0
Reply none 1/19/2007 6:04:28 PM

On 19 Jan 2007 03:11:09 -0800, "Joe Horn" <joehorn@holyjoe.net> wrote:

>Albert Graef wrote:
>
>> Never mind that 1 == -1 mod 2. :)
>
>The CAS mod functions (for some dumb reason) return values between -m/2
>and m/2 (where m is the current modulus), rather than the MOD
>function's more useful output (between 0 and m, when the second
>argument is positive). <rant> The answers from the CAS MOD functions
>are mathematically correct but annoying. If -1 ATAN returned an answer
>of -153*pi/4, it'd be mathematically correct, but VERY annoying!  Would
>we tolerate a square root function that returned negative answers half
>the time?  No, and we shouldn't have to tolerate these silly CAS MOD
>functions' results either. </rant>
>
>Workaround: Just do << m MOD >> after any CAS MOD function to
>"normalize" the result to its positive equivalent.
>
>Example: What's 12345 ^ 56789 (mod 789)?
>789 MODSTO 12345 56789 POWMOD --> -267
>That answer is correct, but silly.  So just follow it with
>789 MOD
>to see 522, as God intended.  ;-)
>
>Disclaimer: Rodger Rosenbaum is allowed to disagree, but nobody else!

  Remember the HP-71? It had MOD, RMD and RED.
  You pays your money and you makes your choice!

>:-b
>
>-Joe-

0
Reply Rodger 1/19/2007 6:21:57 PM

"@(none)" <""parisse\"@(none)"> wrote in message 
news:45b10731$0$27403$ba4acef3@news.orange.fr...
> Joe Horn wrote:
>> Albert Graef wrote:
>>
>>
>>>Never mind that 1 == -1 mod 2. :)
>>
>>
>> The CAS mod functions (for some dumb reason) return values between -m/2
>> and m/2 (where m is the current modulus), rather than the MOD
>> function's more useful output (between 0 and m, when the second
>> argument is positive). <rant> The answers from the CAS MOD functions
>> are mathematically correct but annoying. If -1 ATAN returned an answer
>> of -153*pi/4, it'd be mathematically correct, but VERY annoying!  Would
>> we tolerate a square root function that returned negative answers half
>> the time?  No, and we shouldn't have to tolerate these silly CAS MOD
>> functions' results either. </rant>
>
> CAS use symmetric modular representation, which is more
> efficient for computation. That's also true if you do
> computation by hand, it's easier to compute e.g.
> (-1)^3 mod 13 than 12^3 mod 13

and by adding yet another flag
we could choose to get the pretty answer
<sigh> but Parisse is out and now JYA 2 


0
Reply Veli 1/19/2007 6:22:54 PM

Joe Horn wrote:
> Workaround: Just do << m MOD >> after any CAS MOD function to
> "normalize" the result to its positive equivalent.
> 
> Example: What's 12345 ^ 56789 (mod 789)?
> 789 MODSTO 12345 56789 POWMOD --> -267
> That answer is correct, but silly.  So just follow it with
> 789 MOD
> to see 522, as God intended.  ;-)

BTW, this procedure only works as advertised with numbers. For
polynomials you get something like: '-X^2-1' 2 MOD EVAL => '(X^2+1) MOD
2'. Of course, you can then get rid of the 'MOD 2' with OBJ\-> DROP DROP
DROP, but I wonder what the rationale behind this peculiar form of the
simplified result is?

Albert

-- 
Dr. Albert Gr"af
Dept. of Music-Informatics, University of Mainz, Germany
Email:  Dr.Graef@t-online.de, ag@muwiinfa.geschichte.uni-mainz.de
WWW:    http://www.musikinformatik.uni-mainz.de/ag
0
Reply Albert 1/19/2007 9:34:29 PM

Veli-Pekka Nousiainen wrote:
> and by adding yet another flag
> we could choose to get the pretty answer
> <sigh> but Parisse is out and now JYA 2 

The CAS is open source: if you want to make the change then I'm sure HP 
can find some way to incorporate it into the next official release.

:-)

-- 
Bruce Horrocks
Surrey
England
<firstname>@<surname>.plus.com -- fix the obvious for email
0
Reply Bruce 1/19/2007 9:40:29 PM

On Fri, 19 Jan 2007 15:40:29 -0600, Bruce Horrocks wrote:

> The CAS is open source

The "catch," however, is that it must be linked
with object modules (the rest of the entire ROM)
that are *not* openly available at all --
the only set of them which seems to have been made available
is as of ROM version 1.24, which is quite obsolete now.

I think that even the symbolic references need the symbol table
correponding to the ROM version that it's to be linked with.

> if you want to make the change then I'm sure HP
> can find some way to incorporate it into the next official release.

Yes, just like printing shops where you can submit your own job
via the web, no doubt there will shortly be a "customize your
own ROM" service from HP, where you submit your CAS source,
and then they email you back your customized current ROM --
I think they may call it "One hour proto,"
or some such thing :)

[r->] [OFF]
0
Reply John 1/19/2007 10:22:17 PM

14 Replies
471 Views

(page loaded in 0.106 seconds)

Similiar Articles:


















7/24/2012 12:54:22 PM


Reply: