Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9dd4738

Browse files
added notes for 2.6 logarithms
1 parent 45df881 commit 9dd4738

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

‎_posts/2013-01-27-2.6-logarithms.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
layout: post
3+
title: 2.6 Logarithms
4+
---
5+
6+
* a logarithm is simply an inverse exponential function
7+
* b^x=y => x=log(y) where the base of the logarithm is b
8+
* exponential grows really fast, inverse exponential (log) grows slowly
9+
* logarithms arise in any process where things are repeatedly halved
10+
11+
## Applications
12+
13+
### binary search
14+
15+
* after each comparison half of the records can be discarded
16+
* worst case log2(n) steps (base 2)
17+
18+
### binary tree height
19+
20+
* binary tree of height 1 => 2 leaf nodes
21+
* binary tree of height 2 => 4 leaf nodes
22+
* height h of a rooted binary tree with n leaf nodes: h = log2(n)
23+
* trees with d children logd(n) (log base d)
24+
25+
### bits
26+
27+
* two bit patterns of length 1 (0,1)
28+
* four bit patterns of length 2 (00, 01, 10, and 11)
29+
* w bits representing n possibilities: 2^w=n -> w=log2(n)
30+
31+
### multiplication
32+
33+
* loga(xy) = loga(x) + loga(y)
34+
* loga(n^b) = b * loga(n)
35+
* a^b using exp(x) = e^x and ln(x) = loge(x):
36+
* a^b = exp(ln(a^b)) = exp(b ln a)
37+
38+
### fast exponentiation
39+
40+
* exactly compute a^n
41+
* simplest: n-1 multiplications a * a ...
42+
* n even a^n = (a^(n/2))^2
43+
* n odd a^n = a(a^(n/2))^2
44+
* we have halved the size of our exponent at the cost of two multiplications
45+
* O(log n) multiplication will be enough
46+
47+
### summations
48+
49+
* Harmonic numbers: special case of arithmetic progression
50+
* H(n) = S(n, -1)
51+
* the sum of the progression of simple reciprocals
52+
53+
![image](images/2.6-harmonic_numbers.jpg)

‎images/2.6-harmonic_numbers.jpg

1.71 KB
Loading[フレーム]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /