Author 
Message 
paulv66
Posted on: Wed Aug 08, 2018 8:03 pm
Posts: 368 Joined: Tue Mar 01, 2016 10:03 pm

mod and negative numbers
I have a question about the mod function where negative numbers are included. Two of the puzzles in the new book have numbers from 1 to +7 and include some cells with the mod function. I'm trying to figure out the logic where one of these cells includes 1.
if we look at a 'normal' cell with positive only values  say 2,5  the answer can be either 1 or 2. If zero is included, the only answer can be 0 as division by 0 is undefined. If we take a cell with 1 and 4 (for example), 1 divided by 4 leaves a remainder of 1, while 4 divided by 1 leaves a remainder of 0. Is this correct? Or should 1 divided by 4 leave a remainder of 3?
EDIT; I've just had another look at the puzzles and I notice that none of the non zero mod cells can contain a 1. So I guess the question is moot as far as those puzzles are concerned.




paulv66
Posted on: Tue Aug 28, 2018 9:12 am
Posts: 368 Joined: Tue Mar 01, 2016 10:03 pm

Re: what should volume IV have?
paulv66 wrote: I have a question about the mod function where negative numbers are included. Two of the puzzles in the new book have numbers from 1 to +7 and include some cells with the mod function. I'm trying to figure out the logic where one of these cells includes 1.
if we look at a 'normal' cell with positive only values  say 2,5  the answer can be either 1 or 2. If zero is included, the only answer can be 0 as division by 0 is undefined. If we take a cell with 1 and 4 (for example), 1 divided by 4 leaves a remainder of 1, while 4 divided by 1 leaves a remainder of 0. Is this correct? Or should 1 divided by 4 leave a remainder of 3?
EDIT; I've just had another look at the puzzles and I notice that none of the non zero mod cells can contain a 1. So I guess the question is moot as far as those puzzles are concerned. I would be interested to know the answer to my question above. Should I post it as a new topic?




jpoos
Posted on: Tue Aug 28, 2018 5:44 pm
Posts: 132 Joined: Sun Nov 03, 2013 10:28 pm

Re: what should volume IV have?
Instead of thinking of the mod function as the remainder after division, you can also think of it in the following way:
Usually, one may say that 7 mod 3 is equal to 1, since 7 divided by 3 leaves a remainder of 1. Another way of saying this is: if we repeatedly substract 3 from 7 until we have a number between 0 and 3 (0 included), we get 1, since 733=1. Similarly, you would say that 1 mod 3 is equal to 2, since if we repeatedly add 3 to 1 until we have a number between 0 and 3 (0 included), we get 2, since 1+3=2. In this way, you can also pull negative numbers (or even fractions) through the mod function. Some more examples: 6 mod 2 = 0 10 mod 7 = 4 6.5 mod 3 =2.5 3 mod 2.5 = 0.5 pi mod 2 = 1.1415926535897932384626433832795028841.....
Hopefully this clarifies things a bit.




beaker
Posted on: Tue Aug 28, 2018 6:13 pm
Posts: 556 Location: Ladysmith, BC, Canada Joined: Fri May 13, 2011 1:37 am

Re: what should volume IV have?
That is going to help a lot for the weekly mod puzzles for me........thank you Am going to print this and keep it with the mod tables




calcpnm
Site Admin
Posted on: Tue Aug 28, 2018 6:20 pm
Posts: 109 Joined: Wed May 11, 2011 6:44 pm

Re: mod and negative numbers
Thanks jpoos Also, moved this from the "what should volume IV have" thread..




paulv66
Posted on: Wed Aug 29, 2018 12:41 am
Posts: 368 Joined: Tue Mar 01, 2016 10:03 pm

Re: mod and negative numbers
Thanks jpoos. That clears things up for me. I guess where the negative number is the denominator, repeated subtraction (i.e. double negative) of the denominator is required until you reach the lowest possible positive number? Therefore mod (3,7) could be either 4 (where 7 is the denominator) or 2 (where 3 is the denominator). Or am I missing something?




jpoos
Posted on: Thu Aug 30, 2018 11:46 am
Posts: 132 Joined: Sun Nov 03, 2013 10:28 pm

Re: mod and negative numbers
paulv66 wrote: Thanks jpoos. That clears things up for me. I guess where the negative number is the denominator, repeated subtraction (i.e. double negative) of the denominator is required until you reach the lowest possible positive number? Therefore mod (3,7) could be either 4 (where 7 is the denominator) or 2 (where 3 is the denominator). Or am I missing something? I don't think it's formally possible to have a negative number in the denominator, even though you could certainly extend the definition of the mod function to make that happen. If you were to do this, you would say either 7 mod 3 = 1, since 7+(3)+(3)=1, or 7 mod 3 = 2, since 7+(3)+(3)+(3)=2, depending on the representatives you use. The other calculation is definitely correct: 3 mod 7 = 4.




paulv66
Posted on: Thu Aug 30, 2018 3:43 pm
Posts: 368 Joined: Tue Mar 01, 2016 10:03 pm

Re: mod and negative numbers
Thanks jpoos. My reasoning where 3 is the denominator was faulty  too many double negatives!
Perhaps Patrick could clarify whether a negative denominator is permitted in mod cages?




paulv66
Posted on: Mon Sep 17, 2018 3:54 pm
Posts: 368 Joined: Tue Mar 01, 2016 10:03 pm

Re: mod and negative numbers
paulv66 wrote: Thanks jpoos. My reasoning where 3 is the denominator was faulty  too many double negatives!
Perhaps Patrick could clarify whether a negative denominator is permitted in mod cages? Patrick, can you clarify please? Also, is zero allowed as the denominator in a mod cell? For example, could you give 2 mod 0 as a solution for a cage with value mod 2? Or will a mod cage with zero in it always have to have value zero?




pnm
Posted on: Mon Sep 17, 2018 7:28 pm
Posts: 2356 Joined: Thu May 12, 2011 11:58 pm

Re: mod and negative numbers
paulv66 wrote: Patrick, can you clarify please? Also, is zero allowed as the denominator in a mod cell? For example, could you give 2 mod 0 as a solution for a cage with value mod 2? Or will a mod cage with zero in it always have to have value zero? No, for a divisor zero the modulo operation is not defined, so it's not allowed. ( edit: I'll doublecheck this too, I've seen a definition where "x mod 0 = x", so maybe that would work) When the divisor is negative, the result is "implementation dependent" as they say (so it depends on the programming language used). In my case, the language is C++: here the remainder has the same sign as the dividend. But a puzzle generator script is written in Perl, which uses the convention that the remainder has the same sign as the divisor.. I need to check if this causes any problems for the puzzle generation, will keep you posted.




