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}

 

发布了26 篇原创文章 · 获赞 4 · 访问量 2538

猜你喜欢

转载自blog.csdn.net/u012296499/article/details/99242807