CALCULATORS: by Z53CAy4o

VIEWS: 29 PAGES: 18

									CALCULATORS:

  Know your entry system:

  (1) Infix or Reverse Polish Notation?

  INFIX: 2 + 3 =        5
  (most calculators)

  RPN:    2 [enter] 3 + 5
  (Hewlett-Packard)
    Infix calculators use parentheses to
select the order of operations. “(“ pushes the
stack, “)” executes one pending operation.

   (7-5) * (45) = 1.6

        Display    S1     S2      S3
    (
    7      7
    -      7       7
    5      5       7
    )      2
   -       2       2
   (       2       2      2
    4      4       2      2
          4       4      2
    5      5       4      2
    )      0.8     2
    =      1.6            (12 STROKES)
    RPN calculators do not need parentheses,
but have an ENTER key. This indicates that
the number is complete and “pushes the
stack”. Operations execute immediately.

    (7-5) * (45) = 1.6

        Display     S1       S2    S3
    7       7
    E       7       7
    5       5       7
    -       2
    E       2       2
    4       4       2
    E       4       4        2
    5       5       4        2
           0.8     2
x       1.6               (10 STROKES)
    -Arithmetic or algebraic grouping?

    ARITHMETIC:           2 + 3 x 4 = 20
(order of entry; requires only one “stack” register;
on very simple calculators only)

        DISP     S1
    2   2
    +   2        2
    3   3        2
    x   5        5
    4   4        5
    =   20

A calculator with arithmetic entry usually has NO
memory or parentheses. To compute some
expressions, such as (2x3) + (5x7) you will need
scratch paper.
    ALGEBRAIC:          2 + 3 x 4 = 14
unary operations
then exponents and logs
then multiplication and division
then addition and subtraction
(on all non-RPN scientific calculators)

        DISP   S1       S2
   2    2
   +    2      2
   3    3      2
   x    3      3         2
   4    4      3         2
   =   [12     2    this is not shown]
        14
   A NEW PROBLEM

    Are higher functions put before or after
the numbers they act on?

   TI83, etc: [ ] 10 , [log] 10, [sin] 45 etc.

Most other scientific calculators:

       10 [ ],    10 [log], 45 [sin]

     The second convention is traditional
because it requires less memory. However, it
is a “reverse notation” like RPN and not really
consistent with infix entry.
OTHER THINGS TO KNOW:

   How many levels of parenthesis do you
have? None? One? Three? Eight? 20?

    Do you have memory, and how do you
store and recall numbers? Do you have to
specify a register?

    What different angle modes does your
calculator have? Degrees/radians/grads?
(WARNING: The “mode change” key is NOT
the same as the “angle convert” key.)

        Does your calculator have scientific
notation? Engineering notation? How is the
exponent indicated? How do you convert?

FLOAT:     35462.1
                           04
SCI:       3.54621              (“ x 104 ”)
                           03
ENG:       35.4621               always a
                                multiple of 3
WRITTEN ALGORITHMS

ADDITION:

   A simple algorithm:

   356        Note that we may end up
  +869        carrying in the second step
     15       as well; this is potentially
   11         confusing!
  11
  1225

The “standard algorithm”:
  1 11
              “Carrying” (“regrouping”) is
   356
              indicated with a small digit
  +869
              above the next column to
  1225
              the left.
    SUBTRACTION:

    Standard algorithm: subtract individual
digits, regrouping as necessary.

     Each time you regroup, write 10 (or insert
a 1 in the 10’s place) over the digit you’re
working on and decrement the one to the left.
                        4 12           1 14 12


    1252             1252             1252
    -766             -766             -766
                        6               86
       0 11 14 12

       1252
       -766
        486
Other algorithms: Work left to right. Always
subtract the smaller digit from the larger
one, but if you take the top one from the
bottom write the answer in as a negative.
Then total top to bottom.

   1252
   -766
   1000
   -500 =500
    -10 =490
     -4 =486

The middle step may be done mentally (see
text, P157)
SUBTRACTION:

    Nines’ complement. Fill out with initial
zeros till the numbers are the same length.
Subtract each digit of the second number
from 9. Add this to the first number. Add 1
and throw away the first digit.

   1252        1252        1252
  -0766       +9233       +9233
                          10485

answer: 486

    (some people say “move it from the
beginning to the end” but this has no real
significance. )
CASHIER’S ALGORITHM:

     Count up from the smaller number to the
larger number, adding tokens to a heap at
the same rate that you are counting. This is
adapted to the particular situation in which
(a) tokens are available and (b) the larger
number is “round”.

    $20.00
   -$13.57

   “fifty eight   1
    fifty nine    11
    sixty         111
    seventy       1 1 1 10
    eighty        1 1 1 10 10
    ninety        1 1 1 10 10 10
    fourteen      1 1 1 10 10 10 10
    fifteen       1 1 1 10 10 10 10 $1
    twenty”       1 1 1 10 10 10 10 $1 $5
   MULTIPLICATION:

    SIMPLE ALGORITHM: apply the
distributive law to all combinations, keeping
track of place value (with or without zeros)
then add in columns, regrouping if needed.

       123              123
     x456             x456
        18                18
       120              12
       150              15
       600              6
      1000             10      Omitting place
      1200             12      value zeros may
      8000             8       make it easier
      5000             5       not to lose place.

     40000            4
     56088            56088
STANDARD ALGORITHM:

Multiply each digit of the second number by
the entire first number. (It may be easier to
reverse the numbers if the first number has
more small digits)

    123
  x456
   738 (=6 x 123)
  615 (= 5 x 123)
 492 (= 4 x 123)
 56088
RUSSIAN PEASANT METHOD:

Repeatedly halve one number and double the
other. If there is a remainder in halving,
ignore it. Add every number in the doubling
column that is opposite an odd number.



123    456               456
61     912               912
30     1824             3648
15     3648             7296
7      7296            14592
3      14592           29184
1      29184           56088
This resembles the method used by modern
computers!

123 = 64 + 32 + 16 + 8 + 2 + 1 = 11110112
    =26 + 25 + 24 + 23 + 21 + 20

123 = 64 + 32 + 16 + 8 + 2 + 1
61 = 32 + 16 + 8 + 4 + 1
30 = 16 + 8 + 4 + 2
15 = 8 + 4 + 2 + 1
7 = 4+2 +1
3 = 2 +1
1 = 1

The repeated-halving algorithm actually
computes the base-2 representation of the
number.
The Russian Peasant Algorithm Continued

123 = 64 + 32 + 16 + 8 + 2 + 1 = 11110112
    =26 + 25 + 24 + 23 + 21 + 20

123 x 456 =    20 x 456
              +21 x 456       we get these from
                              the repeated
                              doublings
              +22   x   456
              +23   x   456
              +24   x   456
              +25   x   456
              +26   x   456
DIVISION ALGORITHMS:

all division algorithms involve some sort of
repeated addition or multiplication “till you
get there”

-simplest: counting up and counting on fingers

20  5:     5,10,15,20: so the answer’s 4

27  5: 5,10,15,20,25,30,oops! 25, answer’s 5,
remainder is 2

-more complicated: use bigger blocks:
127  5:

          127
20        100
           27
 5         25
25          2

								
To top