fundamentals\PropertiesOfIntegers

Properties Of Integers

Summary

A specail property exhibited by the subset of positive integers

The triangular numbers ti =i(i+1)/2 made triangulars

The harmonic numbers

The Fibonacci numbers

The Lucas numbers  L0 = 2, L1 = 1; and Ln = Ln-1  + Ln-2 for n ∈Z+ with n ≥ 2

The Eulerian numbers C(n+1, r) = C(n, r) + C(n, r-1)

The primes

When x,y ∈Z, we know that x+y, xy, x-y ∈Z. Thus we say that the set Z is closed under (the binary operations of) addition, multiplication, and subtraction.

The primes turn out to be the “building blocks” of the integers.

The Well-Ordering Principle

We find that we can define the set of positive elements of Z as

Z^{+}= \{ x \in Z | x > 0 \} = \{ x \in Z | x \geq 1\}

But we cannot represent Q+ or R+ using ≥ as we did for Z+

Q^{+}= \{ x \in Q | x > 0 \}

R^{+}= \{ x \in R | x > 0 \}

That is, X contains a least smallest elements.

The Well-Ordering Principle: Every nonempty subset of Z+ contains a smallest element.(We ofen express this by saying that Z+ is well ordered.)

The Pinciple of Mathematical Induction. Let S(n) denote an open mathematical statement (or set of such open statements) that involves one or more occurrences of the variable n which represents a positive integer.

  1. If S(1) is trues; and
  2. If whenever S(k) is trues (for some particular. But arbitrarily chosen, k ∈ Z+), then S(k+1) is true;

Part (a) is referred to as the basis step, while that in part (b) is called the inductive step.

這種方法的原理在於:首先證明在某個起點值時命題成立,然後證明從一個值到下一個值的過程有效。當這兩點都已經證明,那麼任意值都可以通過反覆使用這個方法推導出來。把這個方法想成多米諾效應也許更容易理解一些。例如:你有一列很長的直立着的多米諾骨牌,如果你可以:

  1. 證明第一張骨牌會倒。

  2. 證明只要任意一張骨牌倒了,那麼與其相鄰的下一張骨牌也會倒。

那麼便可以下結論:所有的骨牌都會倒下。
那麼便可以下結論:所有的骨牌都會倒下。

Set Examples of Mathematical Induction = null;

triangular number

                                                                                                1 
                                                                                             1+2=3 
                                                                                          (1+2)+3=6 
                                                                                        (1+2+3)+4=10 
                                                                                       (1+2+3+4)+5=15 
                                                                                                ...

triangular numbers
三角數

The Sum of Squares

計算平方和
Cubic

Procedure SumOfSquares1 (n: positive integer)

Begin

  Sum := 0

  For i := 1 to n do

Sum := sum + i^{2}

End

一種更有效的算法
Qadratic

Procedure sumOfSquares2 (n: positive integer)

Begin

 Sum := n * (n+1) * (2 * n + 1) / 6

end

to determine whether r \in A , we must compare no more than \log_{2} |A| + 1 times

0 1 2 3 4 5 6 7 8

3

6

7

10

11

16

20

33

56

low  mid high

Mathematical Induction in program.

while n ≠ 0 do
  Begin
    x := x * y
    n := n – 1
  end
answer := x

The flow chart

數學歸納法與結構化編程
數學歸納法與結構化編程

start

Initialize the real variables x,y and the nonnegative integer variable n

While n ≠0

X := x * y

N = n - 1

Answer := x

End

Mathematical Induction And The SubSet

元素的所有子集數量爲 2^{n}
因爲新元素可以加入原有堆和追加爲一個新堆兩種選擇
(n=1) 1  
 
(n=2) 2  
1 + 1  
 
(n=3) (1) 3
(2) 1 + 2
(3) 2 + 1
(4) 1 + 1 + 1

Principle of Mathematical Induction – Alternative Form

  1. If S(n0),S(n0+1),S(n0+2),…S(n1-1), and S(n1) are true; and
  2. If whenever S(n0), S(n0+1),S(n0+2) ,…S(k-1), and S(k) are true for some(particular but arbitrarily chosen) k ∈ Z+, where k ≥ n1, then the statement S(k+1) is also true

Then S(n) is true for all n ≥ n0

real world model a lamberjack, I 瞎編的 Laugh death you know! (一般有個簡陋的木架子防倒的吧!)

Mathematical Induction Real World
看-博主瞎扯淡

A lamberjack 

Logs total = 4n + 1

Layer = n

Layern+1 = layern + 2

Layer1 = 6

Real world model compare

設計模式中的迭代模式,其目標也是將Items變成Well-Ordering化,便於執行迭代

比較、查找、等算法,都有一個前提,Items一般都是Well-Ordering的。慄如:1 班有40個學生,一天體育老師讓他們排成四隊....(中值法排隊,啊不,排序)

Recursive

Recursive definition (associative)

a_{n} = a_{n-1} + a_{n-2}+a_{n-3}

Proposition Recursive

P1 ∧ (P2 ∧ P3) ⇔ (P1 ∧ P2) ∧ P3

(p_{1} \wedge p_{2} \wedge ... \wedge p_{r}) \wedge (p_{r+1} \wedge p_{r+2} \wedge ... \wedge p_{n}) = p_{1} \wedge p_{2} \wedge ... \wedge p_{r} \wedge p_{r+1} \wedge ... \wedge p_{n}

Sets Recursive

The liner algorithm we learned on textbooks

  1. allot memory which A1 ∩ A2 ∩ A3,…An
  2. n -> A1
  3. n = n + 1 and P(n) = An

a recursively defined set X. start with an initial collection of elements that are in X – and this provides the base of the recursion. Then we provide a rule or list of rules that tell us how to find new elements in X from other elements already known to be in X.

real world recursion

感覺如果 A_{1} \cap A_{2} \cap ... \cap A_{n}也叫做遞歸的話

C語言版 數據結構 第二章 線性表

set real world recursion Lucas numbers = null

栗子:線性相關的狀態變化

(P -> S) ∧ Q -> R

這是個啥?假設 P=餓了,Q=飯錢夠,R=喫飽了。狀態第一版。感覺這個狀態怪怪的,不連續,不閉包 (@_@;)

剛喫飽的博主 --> 餓了去喫飯 --> 夠飯錢 -->  喫飽了

第二版

剛喫飽的博主 --> 餓了  && 夠飯錢 --> 喫飽了

Primes Numbers

If a, b Z and b 0, we say that that b divides a, and we write b|a, if there is an integer n such that a = bn. When this occurs we say that b is a divisor of a, or a is a multiple of b.

1 1|a and a|0
2 [(a|b) \wedge (b|a)] => a = \pm b
3 [(a|b) \wedge (b|c)] => a|c
4 a|b => a|bx, for all x \in Z
5 If x = y + z, for some x, y, z \in Z, and a divides two of the three integers x, y, and z, then a divides the remaining integer.
6 [(a|b) \wedge (a|c)] => a|(bx +cy), for all x, y \in Z .(The expression bx + cy is called a linear combination of b, c)
7 For 1 \leq i \leq n, let c_{i} \in Z. If a divides each c_{i}, then a|(c_{1}x_{1} + c_{2}x_{2} + ... + c_{n}x_{n}), where x_{i} \in Z for all 1 \leq i \leq n

舉個栗子:兩個圓筒,一個9升,一個4升,怎樣才能得到6升水啊?

問題即爲:假設a,b 爲整數,讓9a + 4b爲6的倍數。可以求得 a= 2, b = -3(2 * 9 + 4 * (-3) = 6)。

我們得到一個S_{0} {9, 4},下面我們可以推導還有哪些圓筒組合可以得到 6 升水。

根據 4 我們可以得到 {9 * 2, 4 * 2} = {18, 8},用18升和8升的圓筒也可以做到 (18 * 2 + 8 * (-3)) = 12,艾瑪,匡瓢了!

根據 5 我們可以得到 {9*2 - 6, 4 * 2 - 6} = {12, 2},用12升和2升的圓筒也可以做到(12 * 1 + 2 * (-3)) = 6。哈哈

重複以上兩步,就可以獲得一系列可以得到 6 升水的圓筒組合了(儘管博主還是直接拿 6 升的圓筒最省事<( ̄ c ̄)y▂ξ)

Using this binary operation of integer division we find ourselves in the area of mathmatics called number theory. which examines the properties of integers and other sets of numbers.

which have exactly two positive divisors, these integers are called primes.

If n \in Z and n is composite, then there is a prime p such that p|n

證明過程:
1 我們假設存在不能被質數整除的合數
2 這些合數組成一個集合 S 且 S 不爲空
3 根據 Well-Ordering Principle ,S 一定存在一個最小元素,假設這個元素爲 m
4 m 是一個合數,根據合數的性質 m=m_{1}m_{2}
5 m_{1} 和 m_{2} 都是正整數,1 < m_{1} < m 和 1 < m_{2} < m
6 m 是 S 中最小元素,m_{1} \notin S,也就是說 m_{1} 能被素數整除 或者 m_{1} 本身就是素數,也就是說 p|m_{1}
7 因爲 m = m_{1} m_{2} 且 p | m_{1} 根據 (a|b => a|bx, for all x \in Z)得到 p|m,m是能被素數整除的合數,矛盾,命題得證

There are infinitely many primes.

The Division Algorithm. If a, b \in Z, with b > 0, then there exist unique q, r \in Z with a = qb + r, 0 \leq r < b.

證明過程:
1 a = qb + r, 0 \leq r < b,當 r = 0 時,a 能被 b 整除 b|a ,結論成立,考慮 a 不能被 b整除
2 在 q 和 r 兩個變量中 r 得條件最多,我們從條件最多的變量 r 開始分析,r = 0 時,成立。考慮 r \neq 0
2.1 同上一個證明過程,我們有 r 的取值集合 S = \{ a - tb | t \in Z, a - tb > 0 \}
2.1.1 當 a > 0 時,令 t = 0, S \neq \oslash
2.1.2 當 a \leq 0 時,令 t = a - 1,a - tb = a - (a - 1)b =  a(1 - b) + b, 因爲 b \geq 1,所以 a(1 - b) + b > 0
2.1.3 S \neq \oslash
2.2 根據 Well-Ordering Principle ,S 一定存在一個最小元素,假設這個元素爲 r 且 0 < r = a - qb
2.2.1 如果 r = b, a = (q + 1)b 這與  a 不能被 b整除 矛盾
2.2.2

如果 r > b

2.2.2.1 假設 r = b + c, c 爲 增量 c \in Z^{+}
2.2.2.2 a - qb = r = b + c \Rightarrow c = a - (q + 1)b
2.2.2.3 a - (q + 1)b \in S 這和 r 時 S 中的最小元素相矛盾
2.3 S 最小元素 r 存在,且 r < b
3 下面證明唯一性
3.1 假設 q,r 不唯一,假設存在 q^{'} r^{'} 
3.2 設 q_{1}, q_{2}, r_{1}, r_{2} \in Z 有 a = q_{1} b + r_{1} 和 a = q_{2} b + r_{2} 且 0 \leq r_{1} < b 和 0 \leq r_{2} < b
3.3 q_{1} b + r_{1} = q_{2} b + r_{2} \Rightarrow b|q_{1} - q_{2}| = |r_{1} - r_{2}|
3.4 因爲 0 \leq r_{1}, r_{2} < b 我們得出矛盾 b|q_{1} - q_{2}| < b,矛盾
4 命題得證

pseudocode of integer division

procedure IntegerDivision(a, b : Integers)
begin
    if a = 0 then
        begin
            quotient := 0
            remainder := 0
        end
    else
        begin
            r := abs(a) {the absolute value of a }
            q := 0
            while r >= b do
                begin
                    r := r - b
                    q := q + 1
                end
            if a > 0 then
                begin
                    quotient := q
                    remainder := r
                end
            else if r = 0 then
                begin
                    quotient := -q
                    remainder := 0
                end
            else
                begin
                    quotient := -q -1
                    remainder := b - r
                end
        end
end

實際應用:數制轉換

十進制78
78 ÷ 2 = 39 餘 0
39 ÷ 2 = 19 餘 1
19 ÷ 2 = 9  餘 1
9 ÷ 2 = 4   餘 1
4 ÷ 2 = 2   餘 0
2 ÷ 2 = 1   餘 0
1 ÷ 2 = 0   餘 1 (商爲0結束)
倒序得到 1001110 即爲對應的二進制

an algorithm

  1. an algorithm is a list of precise instructions designed to solve a particular type of problem - not just one special case
  2. In general, we expect all of our algorithms to receive input and provide the needed result(s) as output
  3. Also an algorithm should provide the same result whenever we repeat the value(s) for the input. which means each instruction is unique, and on any results depending on only the (initial) input.
  4. the instructions must be described in a simiple yet unambiguous manner, which can be executed by a machine.
  5. algorithms cannot go on indefinitely

the greatest common divisor algorithm

procedure gcd(a, b : positive integers)
begin
    r := a mod b
    d := b
    while r > 0 do
        begin
            c := d
            d := r
            r := c mod d
        end
end {gcd(a,b) is d, the last nonzero remainder}

if a, b \in Z^{+} and p is prime, then p|ab => p|a or p|b

Every integer n > 1 can be written as a product of primes uniquely.

980220=2^{1}(490110)=2^{2}(245055)=2^{2}3^{1}(81685)=2^{2}3^{1}5^{1}(16337)=2^{2}3^{1}5^{1}17^{1}(961)=2^{2}3^{1}5^{1}17^{1}31^{2}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章