View
215
Download
1
Category
Tags:
Preview:
Citation preview
Nov. 2005 Math in Computers Slide 1
Math in ComputersA Lesson in the “Math + Fun!” Series
Nov. 2005 Math in Computers Slide 2
About This Presentation
Edition Released Revised Revised
First Nov. 2005
This presentation is part of the “Math + Fun!” series devised by Behrooz Parhami, Professor of Computer Engineering at University of California, Santa Barbara. It was first prepared for special lessons in mathematics at Goleta Family School during three school years (2003-06). “Math + Fun!” material can be used freely in teaching and other educational settings. Unauthorized uses are strictly prohibited. © Behrooz Parhami
Nov. 2005 Math in Computers Slide 3
Counters and Clocks
5
0
3
9
4
1
2
7
8
6
Nov. 2005 Math in Computers Slide 4
A Mechanical Calculator
Odhner calculator: invented by Willgodt T. Odhner (Russia) in 1874
Photo of production version, made in Sweden (ca. 1940)
Photo of the 1874 hand-made version
Nov. 2005 Math in Computers Slide 5
The Inside of an Odhner Calculator
. . . 0 8 6 4 2
70
7
0
9
4
1
1
+ 5 3 6 5
Nov. 2005 Math in Computers Slide 6
Decimal versus Binary Calculator
After movement by 10 notches (one revolution), move the next wheel to the left by 1 notch.
0
1
2
3
4
After movement by 2 notches (one revolution), move the next wheel to the left by 1 notch.
0
5 0 2 5 1000 100 10 1
5000 + no hundred + 20 + 5= Five thousand twenty-five
1 0 1 1 8 4 2 1
8 + no 4 + 2 + 1 = Eleven
Nov. 2005 Math in Computers Slide 7
Decimal versus Binary Abacus
If all 10 beads have moved, push them back and move a bead in the next position
If both beads have moved, push them back and move a bead in the next position
Decimal Binary
Nov. 2005 Math in Computers Slide 8
Other Types of Abacus
3 1 4 1 5 9 2 6 5 4Each of these beads is worth 5 units
Each of these beads is worth 1 unit Display the digit 9 by
shifting one 5-unit bead and four 1-unit beads
0 0 0 0 1 1 0 1 1 0
512 256 128 64 32 16 8 4 2 1
Display the digit 1 by shifting one bead
Nov. 2005 Math in Computers Slide 9
Activity 1: Counting on a Binary Abacus1. Form a binary abacus with 6 positions, using people as beads
32 16 8 4 2 1
2. The person who controls the counting stands at the right end, but is not part of the binary abacus
A person sits for 0, stands up for 1
3. The leader sits down any time he/she wants the count to go up
4. Each person switches pose (sitting to standing, or standing to sitting) whenever the person to his/her left switches from standing to sitting
Questions:
What number is shown?
What happens if the leader sits down?
Leader
1 0 0 0 1 1
32 16 8 4 2 1
Nov. 2005 Math in Computers Slide 10
Activity 2: Adding on a Binary Abacus1. Form a binary abacus with 6 positions, using people as beads
This number is16 + 4 + 2 = 22
32 16 8 4 2 1
32 16 8 4 2 1
3. Now add the binary number 0 0 1 1 0 0 to the one shown0 0 1 1 0 0 This number is
8 + 4 = 12
32 16 8 4 2 1
This number is32 + 2 = 34
A person sits for 0, stands up for 1
2. Show the binary number 0 1 0 1 1 0 on the abacus
Nov. 2005 Math in Computers Slide 11
hour min sec1
2
4
8
Activity 3: Reading a Binary Clock
1 2 : 3 4 : 5 6Each decimal digit is represented as a 4-bit binary number.For example:
1: 0 0 0 1 6: 0 1 1 0
8 4 2 1
__ :__ :__
__ :__ :__
What time is it?
__ :__ :__
Show the time:
8 :41 :22
15 :09 :43
9 :15 :00
Dark = 0
Light = 1
Nov. 2005 Math in Computers Slide 12
IN
OUT
Ten-State versus Two-State DevicesTo remember one decimal digit,we need a wheel with 10 notches(a ten-state device)
A binary digit (aka bit) needs just two states
01
01
0 1
0 10
1
Nov. 2005 Math in Computers Slide 13
Addition Table
+ 0 1
0
1
1
1
0
10
Binary additiontable
Write downin place
Carry overto the left
Write downin place
Carry overto the left
Nov. 2005 Math in Computers Slide 14
Secret of Mind-Reading Game Revealed1. Think of a number between 1 and 30.2. Tell me in which of the five lists below the number appears.
List A: 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29
List B: 2 3 6 7 10 11 14 15 18 19 22 23 26 27 30
List C: 4 5 6 7 12 13 14 15 20 21 22 23 28 29 30
List D: 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30
List E: 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
Find the number by adding the first entries of the lists in which it appears
0 0 0 1 1 = 316 8 4 2 1
AB
1 1 0 1 0 = 2616 8 4 2 1
BDE
Nov. 2005 Math in Computers Slide 15
Activity 4: Binary Addition
Check: 1 2+ 2 9+ 7+ 1 1-------- 5 7
+ 0 1
0
1
1
1
0
10
Binary addition
table
Wow! Binary addition is a snap! 0 0 1 1 0 0
+ 0 1 1 1 0 1+ 0 0 0 1 1 1+ 0 0 1 0 1 1------------- 1 1 1 0 1 1
32 16 8 4 2 1
32 16 8 4 2 1
Rule: for every pair of 1s in a column, put a 1 in the next column to the left
Think of 5 numbers and add them
Nov. 2005 Math in Computers Slide 16
128 64 32 16 8 4 2 1
Adding with a Checkerboard Binary Calculator128 64 32 16 8 4 2 1
12
+ 29
+ 7
+ 11
59
32 16 8 2 1
1. Set up the binary numbers on different rows2. Shift all beads straight down to bottom row3. Remove pairs of beads and replace each pair with one bead in the square to the left
Nov. 2005 Math in Computers Slide 17
Multiplication Table
0 1
0
1
0
0
0
1
Binary multiplication
table
Write downin place
Carry overto the left
Nov. 2005 Math in Computers Slide 18
Activity 5: Binary Multiplication
0 1 1 0 0 1 0 1 ------- 0 1 1 0 0 0 0 0 0 1 1 00 0 0 0-------------0 0 1 1 1 1 0
Check: 6 0 1 1 0 5
0 1 0 1---- ----
---------------30 1 1 1 1
0
16 8 4 2 1
0 1
0
1
0
0
0
1
Binary multiplication
table
I ♥ this simple multiplication
table!
Think of two 3-bit binary numbers and multiply them
Nov. 2005 Math in Computers Slide 19
Idea 1: Break the 12-digit addition into three 4-digit additions
and let each person complete one of the parts
3 9 7 26 0 2 7
2 7 2 4 3 1 7 5
5 6 2 14 9 8 5
2 7 2 4 3 1 7 5
3 9 7 26 0 2 7
5 6 2 14 9 8 5
Fast Addition in a ComputerForget for a moment that computers work in binarySuppose we want to add the following 12-digit numbersIs there a way to use three people to find the sum faster?
1st number: 2nd number: 1st number:2nd number:
This won’t work, because the three groups of digits cannot be processed independently
9 9 9 9
0
0 6 0 6
1
5 8 9 9
0
Nov. 2005 Math in Computers Slide 20
Idea 2: Break the 12-digit addition into two 6-digit additions;
use two people to do the left half in two different forms
2 7 2 4 3 9 3 1 7 5 6 0
7 2 5 6 2 12 7 4 9 8 5
2 7 2 4 3 9 3 1 7 5 6 0
7 2 5 6 2 12 7 4 9 8 5
Fast Addition in a Computer: 2nd Try
1st number: 2nd number: 1st number:2nd number:
Once the carry from the right half is known, the correct left-halfof the sum can be chosen quickly from the two possible values
0 0 0 6 0 6
1
5 9 0 0 0 0
0
2 7 2 4 3 9 3 1 7 5 6 0
5 8 9 9 9 9
0
1
Sum
Nov. 2005 Math in Computers Slide 21
Next LessonJanuary 2006
Recommended