require(ggplot2)
require(dplyr)
require(tidyr)
cbPalette <- c("#999999", "#E69F00", "#56B4E9", "#009E73",
"#F0E442", "#0072B2", "#D55E00", "#CC79A7")
Important Basics on exponentials and logarithms
x <- seq(from = -2, to = 2, by = 0.1)
y <- exp(x)
y1 <- 2^x
y2 <- 10^x
df <- data.frame(x = x, exp = y, base_2 = y1, base_10 = y2)
df <- gather(df, Base, Value, -x)
ggplot(df, aes(x=x, y = Value, colour = Base)) + geom_vline(xintercept = 0, color = cbPalette[1]) + geom_line() + scale_colour_manual(values = cbPalette[2:4]) + ylim(0,5) + theme_bw(14) + ylab("Exponential") + xlab("'log'") + theme(panel.grid.minor = element_blank()) + theme(panel.background = element_rect(colour = cbPalette[1],size = 2))

So \(base^{0}\) is always 1, \(base^{1} = base\)
Some exponential rules
- First rule: \(2^{2}*2^{3} = 2^{2+3}\)
- Second rule: \(\frac{2^{3}}{2^{2}} = 2^{3-2}\)
- consequently: \(2^{-3} = 2^{0-3} = \frac{2^{0}}{2^{3}} = \frac{1}{2^{3}}\)
- so exp(x) is never negative (unless the base is negative). For x from -Inf to 0, exp(x) ranges from 0 to 1. exp(1) is the base. For integers x > 1 exponentials are easy to understand. But what for x between 0 and 1. You know that exp(x) in that case will be between 1 and base. But why.
- see (https://www.mathsisfun.com/algebra/exponent-fractional.html)
- e.g. \(2^{\frac{1}{3}}\). Thanks to the first rule you know: \(2^{\frac{1}{3}}\times2^{\frac{1}{3}}\times2^{\frac{1}{3}} = 2^{1} = 2\) That means that \(2^{\frac{1}{3}} = \sqrt[3]{2}\)
- so albeit that does not help much with imagining the calculation, but remember \(x^{\frac{1}{4}}\) is a number that multiplied for times with itself is x.
- and more complicated fractions? \(2^{\frac{3}{4}} = 2^{3*\frac{1}{4}}\)
- Third rule: \((2^{3})^{3} = 2^{3*3} = 2^{9}\)
- so \(2^{\frac{3}{4}} = 2^{3*\frac{1}{4}} = \sqrt[4]{2^{3}}\)
And for the logarithms
- log of y to a base is the number x you have to power base with to get y.
- so in the plot above, choose a y value, look what is the corresponding x value, it is the log(y) to the respective base (in the plot exp, 2, 10)
- note for relative abundances, y is betwen 0 and 1, so the log(y) are from -Inf to 0.
- log(1) is 0 independent of base
- What if you have log to base e (as in R), but you want to base 2?
- \(2^{3} = (e^{z})^3 = e^{z*3}\) with \(e^{z} = 2\) so \(z = log(2)\) so the log base e of 2.
- that means \(log_{2}(y)\) is \(z\times log(y) = \frac{log(y)}{log(2)}\)
- so general rule: log of y to the base x = log(y)/log(x)
all other rules come directly from the exponential rules:
- take \(a = 2^{4}\) so log(a) = 4 (base 2) and \(b = 2^{3}\), so log(b) = 2
- then rule 1: log(a*b) = log(a) + log(b) (think of base 2, \(2^{4}\times2^{3} = 2^{3+4}\) )
- rule 2: \(log(\frac{a}{b}) = log(a) - log(b)\)
- rule 3: \(log(a^{z}) = z*log(a)\)
x <- seq(from = 0, to = 1, by = 0.01)
y <- log(x)
df <- data.frame(x = x, log_x = y)
df$Base = "exp"
ggplot(df, aes(x=x, y = log_x, colour = Base)) + geom_vline(xintercept = 0, color = cbPalette[1]) + geom_line() + scale_colour_manual(values = cbPalette[2]) + theme_bw(14) + ylab("log(x)") + theme(panel.grid.minor = element_blank()) + theme(panel.background = element_rect(colour = cbPalette[1],size = 2))
