Download Lecture 01

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Large numbers wikipedia , lookup

Law of large numbers wikipedia , lookup

Big O notation wikipedia , lookup

Elementary arithmetic wikipedia , lookup

History of Grandi's series wikipedia , lookup

Factorization wikipedia , lookup

Collatz conjecture wikipedia , lookup

Non-standard calculus wikipedia , lookup

Mathematics of radio engineering wikipedia , lookup

Proofs of Fermat's little theorem wikipedia , lookup

Arithmetic wikipedia , lookup

Elementary mathematics wikipedia , lookup

Addition wikipedia , lookup

Transcript
COT 5405: Design and Analysis of Algorithms
Lecture 1 ~ August 26, 2003:
Mr. Arup Guha
Conditional Sums
Definition:
n
 f (i )
Sum of all elements for which P(i) is true.
i 1
P(i)
Example:
2n
i  n
2
.....1,3,5,7,..., (2n  1)
i 1
i  odd
This is for the series of all odd numbers
Series
Arithmetic Series
Definition: An Arithmetic Series is a series where the difference between the
numbers in the series is constant.
e.g: 3,5,7,--where the difference d = 2. Let a1, a2, ... an, be an arithmetic series with
difference d, then
Formula for finding the last term:
an  a1  (n  1) * d where d = difference between terms
One way to find the sum of an arithmetic sequence is as follows:
AvgTerm 
a1  an
2
Take the average term and multiply it by the number of terms n:
Sum 
(a1  an )
*n
2
Note: This technique of find the average value of a term ONLY works because
each value in the sum is "spaced out evenly." The proof of the formula for the
sum shown in class is the more proper way of arriving at this result. (This proof
involved writing down the sum twice, once backwards, then showing that each of
the n columns summed to a1 + an.
Important Formulas:
n(n  1)
2
i 1
n
n(n  1)( 2n  1)
2)  i 2 
6
i 1
n
1)
i 
n
3)
i3 
i 1
n 2 (n  1) 2
4
Geometric Series:
Common Ratio (r):
a n  a1 r ( n 1)
a1  a1 r  a1 r 2  ...  a1 r ( n 1)

 a1 1  r  r 2  ...  r ( n 1)
1 r n
 a1 
 1 r
where r ≠ 1




Example: Given a geometric sequence with the first term 2 and a common ratio
of 3, which term in the sequence is equal to 192?
an
192
 2 ( n1) 
 2 ( n1)  64  2 ( n1)  n  7
a1
3
Infinite Geometric Series:
If | r | < 1,then the series has a finite sum and the terms successively approach 0.
We can determine this sum by using the formula for a finite geometric sequence
and taking its limit as n approaches infinity. In this situation rn approaches 0 so
the actual sum of an infinite geometric sequence is a1/(1-r).
Example:
1 1 1
1  
 ...
2 8 32
lim
n 
  1 n 
1    
4
2   
1 

 1 4 


2

1

1
4
8
3
L’Hopital’s Rule:
f ( x)
g ( x)
lim
x 
Both functions have to be differentiable for all values to ∞ and defined on a
range: [c,∞], and g(x) ≠ 0
Example of a sequence that is neither arithmetic nor geometric:
2 3 4 5
S  1      ...
2 4 8 16
S 1 2 3 4
5
    
 ...
2 2 4 8 16 32
If we subtract S/2 from S, we get the following series:
S 1 1 1 1 1
      ...
2 1 2 4 8 16
Denominator follows the Geometric Sequence, while the Numerators are all “1”.
The sum would be as follows using the rule for finding the sum of a Geometric
Series now that the problem has been reduced to a simple Geometric series.
a
1
Sum = 1
first term = 1, r =
2
1 r
1
S
 2S 4
Sum =
1  12
2
Another way to come to this solution would be as follows:

x
i
i 0

1
1 x
Take the Derivative of both sides of the equation:
d  i d  1 
 x  dx  1  x 
dx i 0

 ix
i 0
2
( i 1)

 1 
 1 
( i 1)
 

 (1)   ix

1 x 
1 x 
i 0
2

1
i 

i 0  2 
( i 1)
2
 1 
 4
 
1 
1 2 
The next few techniques are for sums of series that are not of Arithmetic or
Geometric Origins:
Telescoping Sum
Start with something like this:
n
 k ( k!)
k 1
Which can be simplified to this using the rules of factorials:
n
 (k  1)!k!
k 1
When k=1, while evaluating (k+1)!-k!, the following results:
2!3!4!....  n!(n  1)!
 1!2!3!4!....  n!
–1!
+ (n + 1)!
It can be seen how the summation simplifies to only the first and last terms of the
series, as all other terms in between will be canceled out no matter the number of
terms. The function is our factorial f(x) = x! :
n
 f (k  1)  f (k ) 
f (n  1)  f (1)
k 1
Another way to look at this is using a change of index method, where the first
step is to break our summation into two separate sums:
n
n
n
k 1
k 1
k 1
 (k  1)!k!   (k  1)!   k!
Now let j=k+1 for the first sum as well as adjust the value of n accordingly, and
change the index from k to j on the second sum:
n 1
n
j 2
j 1
 j!   j!
This can be simplified to the following summation when the extra n term on the
first sum and the first term of the second sum are separated as follows:
n 1
n
n 
n 
1.  j!   j!  (n  1)!
2.  j!   j!  1!
j 2
j 1
 j 2 
 j 2 
Now the terms in the square brackets will cancel each other out leaving behind
the two terms (n+1)! and 1!, which corresponds with the first solution.
Bounding Summations
With this method, it is necessary to find a term that is either greater than or less
than the term being evaluated. This new term might be easier to calculate a
solution for. So for a function f:
n
n
n
i 1
i 1
i 1
 min  f (1), f (2),...., f (n)   f (i)   max  f (1), f (2),...., f (n)
As a note, the only time that this inequality would reach equality would be in the
case that all terms in the series are equal. Another way to represent this in a
more simplified form:
n
n
n
i 1
i 1
i 1
 h(i)   f (i)   g (i)
if g(i) > f(i) for all i, and if h(i) < f(i) for all i.
Now consider two examples, first:
2 k 1
Ex:
1 1

2
i  2 k 1 i

We can bound the sum from below, substituting the minimum term in the entire
series for each term. This minimum term is achieved for i=2k+1, since successive
terms in the sequence are decreasing. Thus, we have:
2 k 1
k 1
1 2
1
k i  k 2 k 1
i  2 1
i  2 1
When i is not part of the term being summed, it is a constant being added to itself
multiple times. The equation used for determining the number of times to use
this term is (last – first + 1)*constant. This will give us the sum of the second
summation.
1
1
[( 2 k 1 )  (2 k  1)  1] * k 1
distribute the negative sign: (2 k 1  2 k  1  1) * k 1
2
2
This will reduce our expression to:
1
(2 k 1  2 k ) * k 1
2
After performing some algebra, the expression can be simplified to a number:
1
1
2 k * k 1 
2
2
The second example utilizes the Harmonic Series
n
1
i 1 i
Hn  
We will prove the following assertion for positive integers n:
n
Hn
1
1 1 1

 1     ...
2
3 5 7
i 1 2i  1
This time smaller terms will be used to demonstrate bounding summations. In
this case, all of the terms of 1/2i will be smaller than the terms of the original
series, which satisfies the original statement made about bounding summations.
n
n
1
1



i 1 2i  1
i 1 2i
n
1
1
1
1
1
 2i  2  4  6  8  ...
i 1
From this, a ½ can be factored out, leaving the Harmonic Series:
n
1 1 n 1 1
   Hn

2 i 1 i 2
i 1 2i
Bound By Integral
With this example, again the Harmonic series will be utilized.
n
1
1 1 1 1
1
Hn    1      ... 
2 3 4 5
n
i 1 i
Now each of these terms will be represented on a graph as a rectangle, with the
first rectangle being a 1x1, and the next 1/2 of the original’s size, then 1/3 of the
original’s size, and so forth. Next the following function will be graphed over the
rectangles:
f ( x) 
1
x
This shows that the rectangles are contained under the curve, meaning that the
area under the function represented by that curve will bound our series
summation. The area under the curve, or the definite integral of f(x) from 1 to n
will be greater than the combined summation of areas of the rectangles. In order
to prevent have to take a natural logarithm of zero, the first rectangle is
calculated in advance, otherwise our definite integral would not be
uncomputable.
n
1
Hn  1   dx
x
1
After integration, the result is:
Hn  1  ln( n)  0
Hn  1  ln( n)
n = 1 would be the only case where there would be an equality, rather than the
Harmonic Series being less than natural logarithm of the function + 1.