Applications of Mathematics in Computer Science (MACS)


Introduction;
Logarithm and Exponent

David Tolpin, david.tolpin@gmail.com

Course organization

Course website

Computing with large and small numbers

Computations work well when numbers are

  • of similar magnitude:
    10, 20, 15, 32, 1, 5
    but not
    1, 100000000, 0.00000000001
  • Not too large and not too small:
    $10^{-10}$ and $10^{10}$
    but not
    $10^{-1000}$ and $10^{1000}$

Computing with large and small numbers

  • What if we need to compute $10000! = \prod_{i=1}^{10000} i$?
  • How about analyzing a sequence $a_i = \exp(i^2)$ for $i \in \{1, ..., 1000\}$?
  • We can compute on logarithmic scale! and then exponentiate the final result if needed

Logarithm: definition

Logarithm is a function $\mathbb{R}^+ \rightarrow \mathbb{R}$: $$\log_b x = y$$

  • b — base (בסיס), $b > 1$
  • y - power (חזקה)

By definition, $$b^y = x$$

Logarithm: shape

  • defined on $\mathbb{R}^+$
  • maps to $\mathbb{R}$
  • increasing and concave

Logarithm: properties

  • $ \log 1 = 0$
  • $ \log x\cdot y = \log x + \log y$
  • $ \log \frac 1 x = - \log x$
  • $ \log x^a = a \log x$

Logarithm: bases

$\log x$ assumes a base (binary, natural, decimal):

BaseNotationUsed in
2 (binary)$\mathrm{lb}\,x$computer science, information theory
$e$ (natural)$\ln x$statistics, engineering
$10$ (decimal)$\lg x$physics, engineering

The base can be explicit: $\log_2 x$, $\log_e x$, $\log_{10} x$

Logarithm: bases

Application examples

Open In Colab