Don't +. and *. map to GCD and LCM for integers?

On Mon, Oct 1, 2012 at 10:55 AM, Raul Miller <[email protected]> wrote:
> George Boole worked with a system of algebra which modern math texts
> call a "boolean ring".  In J, we have +. and *. which correspond to
> operations within that system.
>
> "Type" gets used to describe a system for representing a set of values
> or for classifying the instructions for manipulating those
> representations.
>
> It's interesting to think about numeric types and how they relate to
> arithmetic correctness, and Boole's operations give us something to
> compare other things with.
>
> You can visualize the relationship between a rank 0 operation and a
> small domain using viewmat:
>
>    require 'viewmat'
>    illustrate=: 1 :'viewmat domain e.~ u"0/~ domain=.y'
>
> The boolean operations happen to be particularly boring to look at.
> For example:
>
>    +. illustrate i. 100
>    *. illustrate i. 100
>
> The implementation of viewmat which I am using shows these as solid
> white: if the domain is a sequence of integers 0..n all of the results
> from these operations are within the domain.
>
> So when I say "boolean integer" I mean a bounded non-negative integer domain.
>
> In C, this corresponds to types like "unsigned int", "unsigned long",
> "unsigned short" and "unsigned char".
>
> This kind of thinking turns out to be useful in the context of
> computers, because computers have finite memory and we expect them to
> produce results in finite time.
>
> It's interesting to take regular arithmetic operations, and see how
> well they map onto a boolean integer domain:
>
>    + illustrate i. 100
>    - illustrate i. 100
>    * illustrate i. 100
>    % illustrate i. 100
>
> + and - are rather nice -- half of the possibilities represent valid
> arithmetic.  * and % are not so nice.
>
> Another interesting domain is the "2s complement" domain.  Here, we
> take a boolean integer where the size of the set is 2^n and we
> represent values in the range (-2^n-1) .. (2^n-1)-1
>
> For example:
>
>    + illustrate (i. 256) - 128
>    - illustrate (i. 256) - 128
>    * illustrate (i. 256) - 128
>    % illustrate (i. 256) - 128
>
> Twos complement gives us a nice property: zero is in the center of the
> set, and mostly we have valid results when are arguments are near
> zero.
>
> (It's also interesting to look at the type system that J uses for
> numbers (http://www.jsoftware.com/help/dictionary/dictg.htm) and think
> about the tradeoffs and what they say about the kinds of arithmetic
> people use.)
>
> --
> Raul
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm



-- 
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to