Skip to main content
This material has been adapted from material by Fergus Cooper and others from the "Essential Mathematics" module at the Doctoral Training Centre, University of Oxford.

This material has been adapted from material by Fergus Cooper and others from the "Essential Mathematics" module at the Doctoral Training Centre, University of Oxford.

Creative Commons License
This course material was developed as part of UNIVERSE-HPC, which is funded through the SPF ExCALIBUR programme under grant number EP/W035731/1

This course material was developed as part of UNIVERSE-HPC, which is funded through the SPF ExCALIBUR programme under grant number EP/W035731/1

Creative Commons License

Indices, logs and exponentials


YouTube lecture recording from October 2020

A recording of this lecture from October 2020; the material has changed a little since.
Youtube lecture thumbnail

Why indices and logs?

  • The laws of indices let us simplify and rearrange expressions with powers in them. We will need them throughout the course (e.g. when we cover differentiation).
  • Taking the logarithm undoes raising to a power. This means that we can use logarithms to solve for an unknown power, to work with quantities that have a huge dynamic range (e.g. pH), and to turn power laws and exponentials into straight lines.
  • We often want to describe growth and decay in biology, and for this we use the exponential function, exe^x, and its inverse, the natural logarithm.

Indices

In mathematics, an index refers to the power to which a number (the base) is raised. The index is usually written as a small number above and to the right of the base. For example, in the expression 232^3, 22 is the base, and 33 is the index or power. This expression is read as "2 to the power of 3" or simply "2 cubed", and it equals 2×2×2=82 \times 2 \times 2 = 8.

Multiplication of expressions with powers

Let's recap by example:
52=5×5=25,5^2 = 5 \times 5 = 25,
and
53=5×5×5=125.5^3 = 5 \times 5 \times 5 = 125.
Now,
55=5×5×5×5×5=31255^5 = 5 \times 5 \times 5 \times 5 \times 5 = 3125
and
25×125=3125.25 \times 125 = 3125.
So,
55=52×53.5^5 = 5^2 \times 5^3.
And, by extension:
am×an=am+n.a^m\times a^n=a^{m+n}.
When we multiply two expressions with powers, we add the powers.

Division of expressions with powers

Again, let's look at an example:
5352=5×5×55×5\frac{5^3}{5^2} = \frac{5 \times 5 \times 5}{5 \times 5}
We can cancel both fives on the bottom with two from the top, leaving just 55, or, 515^1 left.
Generalising, by extension:
anam=an−m\frac{a^n}{a^m}=a^{n-m}
When we divide two expressions with powers, we subtract the powers.

Powers of expressions with powers

Back to our example:
(53)4=53×53×53×53=244140625\left(5^3\right)^4 = 5^3 \times 5^3 \times 5^3 \times 5^3 = 244140625
Using the addition rule from above, the resulting power should be 3+3+3+3=123 + 3 + 3 + 3 = 12. And, sure enough:
512=244140625.5^{12} = 244140625.
So, generalising again:
(an)m=anm(a^n)^m=a^{nm}
When we raise an expression containing a power to another power, we multiply the powers.

Negative powers

What happens when we divide indices, but there are more numbers on the bottom of the fraction?
a3a5=a×a×aa×a×a×a×a=1a×a=1a2\frac{a^3}{a^5} = \frac{a \times a \times a}{a \times a \times a \times a \times a} = \frac{1}{a \times a} = \frac{1}{a^2}
Using the division rule above, the power should be 3−5=−23 - 5 = -2. And, so:
a−2=1a2a^{-2}=\frac{1}{a^2}
and, in general,
a−n=1ana^{-n} =\frac{1}{a^n}
where nn is a positive integer.

Zero index

Similarly,
a3a3=a×a×aa×a×a=1,\frac{a^3}{a^3} = \frac{a \times a \times a}{a \times a \times a} = 1,
and by using the division rule, the power should be 3−3=03-3=0.
Thus, anything to the power of zero equals one, except 000^0 which is undefined:
a0=1a^0=1

Fractional (rational) indices

For a>0a>0:
a1=a1/2×a1/2soa1/2=aa1/n=anan/m=(am)noranma−n/m=1(am)nor1anm\begin{aligned} a^1 &= a^{1/2} \times a^{1/2} &&\text{so}\quad a^{1/2} = \sqrt{a} \\ a^{1/n} &= \sqrt[n]{a} \\ a^{n/m} &= \left(\sqrt[m]{a}\right)^n &&\text{or}\quad \sqrt[m]{a^n} \\ a^{-n/m} &= \frac{1}{\left(\sqrt[m]{a}\right)^n} &&\text{or}\quad \frac{1}{\sqrt[m]{a^n}} \end{aligned}
For example,
a3/4=a34or(a4)3.a^{3/4}=\sqrt[4]{a^3} \quad \text{or} \quad \left(\sqrt[4]{a}\right)^3.
In Python:
a = 5.0 a**(3.0/4.0)
3.34370152488211
(a**3.0)**0.25
3.34370152488211
(a**0.25)**3.0
3.34370152488211
So, the order of these operations does not matter (for a>0a>0).

Different bases, same index

(a⋅b)x=ax⋅bxand(ab)x=axbx(a\cdot b)^x = a^x\cdot b^x\qquad \text{and}\qquad\left(\frac{a}{b}\right)^x=\frac{a^x}{b^x}

Two cautionary remarks

  1. Powers of sums are not pretty: (a+b)x≠ax+bx(a+b)^x \ne a^x + b^x
  2. Powers of differences are not pretty: (a−b)x≠ax−bx(a-b)^x \ne a^x - b^x
A useful formula for products of sums:
(p+q)⋅(s+t)=ps+pt+qs+qt(p+q)\cdot(s+t) = ps + pt+qs + qt
Three important consequences:
  1. (a+b)2=(a+b)(a+b)=a2+2ab+b2(a+b)^2=(a+b)(a+b)=a^2+2ab+b^2
  2. (a−b)2=(a−b)(a−b)=a2−2ab+b2(a-b)^2=(a-b)(a-b)=a^2-2ab+b^2
  3. (a+b)(a−b)=a2−b2(a+b)(a-b)=a^2-b^2

Logarithms

  1. If y=axy=a^x, xx is the power to which the base aa must be raised to give yy, OR
  2. xx is the logarithm which, with base aa, gives yy.
In general we write
x=log⁡ay⇔y=ax.x = \log_a y \quad \Leftrightarrow \quad y=a^x.
The base of a logarithm may be any positive number other than 1. Commonly, logarithms either have base 10 or base ee. It is almost always a good idea to explicitly state the base, e.g. log⁡39=2\log_3 9=2 implies 32=93^2=9. In this course we always write the base, e.g. log⁡10\log_{10}, except for base ee (more on this below).

Getting a feel for logarithms

Here's a graph of y=log⁡10xy=\log_{10}x:
Graph of log
Some physical phenomena use log metrics due to their huge dynamic range:
  • volume of sound (decibels)
  • pitch (1 octave is doubling of frequency, 2 octaves is quadrupling of frequency)
  • earthquakes (Richter scale)
  • pH ([H+][H^+] ion concentration)

The laws of logarithms

Using the same base aa for both operations

  • Taking the logarithm undoes raising to a power:
    log⁡a ar=r\log_a\,a^r=r
  • Raising to a power undoes taking the logarithm:
    alog⁡a b=ba^{\log_a\,b}=b

Multiplication, division and powers

Each law of logarithms comes from a law of indices. If b=amb=a^m and c=anc=a^n, then log⁡ab=m\log_a b = m and log⁡ac=n\log_a c = n, so:
IndicesLogarithms
Multiplicationam×an=am+na^m\times a^n=a^{m+n}log⁡a(bc)=log⁡ab+log⁡ac\log_a (bc) = \log_a b + \log_a c (add)
Divisionam/an=am−na^m/a^n=a^{m-n}log⁡a(b/c)=log⁡ab−log⁡ac\log_a (b/c) = \log_a b - \log_a c (subtract)
Powers(am)r=amr\left(a^m\right)^r=a^{mr}log⁡abr=rlog⁡ab\log_a b^r = r \log_a b (multiply)
This means that the laws of logarithms are the laws of indices written in terms of the powers, with the same (add), (subtract) and (multiply).

Changing the base of a logarithm

log⁡ac=log⁡bclog⁡ba\log_a c = \frac{\log_b c}{\log_b a}

Special case

If bb and cc are the same, changing the base reduces to
log⁡ab=log⁡bblog⁡ba=1log⁡ba\log_a b =\frac{\log_b b}{\log_b a}=\frac{1}{\log_b a}

The log of any number to the base itself is 1

log⁡aa=1\log_a a =1

The log of 1 is 0

log⁡a1=0sincea0=1\log_a 1 = 0 \quad\text{since}\quad a^0=1

Negative logs

log⁡a1x=log⁡a1−log⁡ax=0−log⁡ax=−log⁡ax\log_a \frac{1}{x} = \log_a1-\log_ax= 0 - \log_a x =-\log_ax

Two cautionary remarks about logarithms

  1. log⁡a(x+y)\log_a (x + y) and log⁡a(x−y)\log_a (x-y) cannot be simplified any further, and should be left as they are.
  2. Neither can log⁡a x⋅log⁡a y\log_a\,x \cdot \log_a\,y or log⁡ax/log⁡ay\log_a x/\log_a y. Leave them as they are.

The exponential function and the real number e

Definition of the real number ee

The real number ee, also known as Euler's number, is that base for which the graph y=exy=e^x passes through the point (0,1)(0, 1) with gradient exactly equal to 11.
Graph of exp
The dashed line in the graph is the tangent to y=exy=e^x at (0,1)(0, 1), which is the line y=x+1y = x + 1.
So for the function (called the exponential function):
y=exthe gradient at (0,1) is 1=e0.y=e^x \qquad \text{the gradient at } (0,1) \text{ is } 1 = e^0.
This turns out to be true at any point on the curve, i.e. the gradient of y=exy=e^x at any point is equal to the value of exe^x there. This means that the function y=exy=e^x is unchanged when differentiated (more on this when we cover differentiation).
ee has been found to arise in many branches of mathematics. It is also used as a base for logarithms. e.g.:
y=log⁡e10=ln⁡10andy=log⁡ex=ln⁡xy=\log_e10=\ln 10 \quad\text{and}\quad y=\log_ex=\ln x
Logs to base ee are called natural logarithms.

Definition of the natural logarithm

The natural logarithm of a number is the logarithm of that number taken using the base ee. We usually write ln⁡(x)\ln(x) for log⁡e(x)\log_e(x). Here are some examples:
  • ln⁡(e)=log⁡e(e)=1\ln(e)=\log_e(e)=1
  • ln⁡(10)=log⁡e(10)\ln(10)=\log_e(10) = "The power I need to raise ee to in order to get 10"
  • ln⁡(10)≈2.303\ln(10)\approx 2.303. Which means that e2.303≈10e^{2.303}\approx 10
  • ln⁡(exp⁡(b))=ln⁡eb=log⁡eeb=b\ln(\exp(b)) = \ln e^b =\log_e e^b = b
  • exp⁡(ln⁡(b))=eln⁡(b)=elog⁡eb=b\exp(\ln(b))=e^{\ln(b)}=e^{\log_e b}=b
Note that the last two examples confirm the property that the functions "exp⁡\exp" and "ln⁡\ln" are functional inverses of one another.

Logarithms in Python

In numpy, np.log is the natural logarithm, ln⁡\ln. For base 10 and base 2 there are np.log10 and np.log2:
import numpy as np print(np.log(10)) print(np.log10(1000)) print(np.log2(8))
2.302585092994046 3.0 3.0
For any other base, use the change of base formula, e.g. log⁡381=ln⁡81/ln⁡3\log_3 81 = \ln 81 / \ln 3:
print(np.log(81)/np.log(3))
4.0

Example 1: power laws

Can the data below be fitted to the form: y=Axny=Ax^n?
import numpy as np x = np.array([1, 2, 4, 6, 9, 12, 16, 20, 25, 30, 36, 42, 49, 56, 64]) y = np.array([3.03, 4.11, 5.85, 6.35, 10.03, 11.13, 11.77, 14.05, 15.26, 15.89, 19.09, 19.08, 20.59, 21.41, 24.66])
Graph of data table
Take logs of both sides:
log⁡10y=log⁡10Axn=log⁡10A+log⁡10xn=log⁡10A+nlog⁡10x\log_{10} y =\log_{10} Ax^n = \log_{10} A + \log_{10} x^n= \log_{10} A + n \log_{10} x
This is the equation of a straight line, Y=mX+cY=mX+c. Here Y=log⁡10yY=\log_{10} y, X=log⁡10xX=\log_{10} x, m=nm=n and c=log⁡10Ac=\log_{10} A.
Graph of data table, straightened
The points lie close to a straight line, so the data are consistent with the model. To find its gradient and intercept, we fit the best straight line through the points. np.polyfit(X, Y, 1) does this (in the least-squares sense, so the line passes as close as it can to all the points at once), and returns the gradient and then the intercept:
X = np.log10(x) Y = np.log10(y) # Fit the best straight line through the points gradient, intercept = np.polyfit(X, Y, 1) print('gradient =',gradient) print('intercept =',intercept)
gradient = 0.505264797790789 intercept = 0.47080411584219156
Gradient ≈0.5=n\approx 0.5 = n
Intercept ≈0.47=log⁡10A\approx 0.47 = \log_{10}A so A≈3.0A\approx 3.0
Data fit curve of the form:
y=3.0×x1/2y=3.0\times x^{1/2}
Plotting log⁡10y\log_{10} y against log⁡10x\log_{10} x is the same as plotting yy against xx on logarithmic axes (called a log-log plot).

Example 2: exponential growth

We often want to know how quickly a population grows. Here, a population of bacteria is counted every hour, for 10 hours. Can the data below be fitted to the form: N=N0ektN=N_0e^{kt}?
t = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) N = np.array([199, 292, 386, 570, 758, 1190, 1618, 2308, 3280, 4259, 6708])
Graph of bacterial growth data
Take the natural log of both sides:
ln⁡N=ln⁡N0ekt=ln⁡N0+ln⁡ekt=ln⁡N0+kt\ln N = \ln N_0e^{kt} = \ln N_0 + \ln e^{kt} = \ln N_0 + kt
This is the equation of a straight line, Y=mX+cY=mX+c. Here Y=ln⁡NY=\ln N, X=tX=t, m=km=k and c=ln⁡N0c=\ln N_0. Only the NN axis is on a log scale, so this is called a semi-log plot.
Graph of bacterial growth data, straightened
As in Example 1, we fit the best straight line through the points:
Y = np.log(N) # Fit the best straight line through the points gradient, intercept = np.polyfit(t, Y, 1) print('gradient =',gradient) print('intercept =',intercept)
gradient = 0.3480313382093428 intercept = 5.294429813364659
Gradient ≈0.35=k\approx 0.35 = k (per hour)
Intercept ≈5.3=ln⁡N0\approx 5.3 = \ln N_0 so N0=e5.3≈200N_0 = e^{5.3} \approx 200
Data fit curve of the form:
N=200 e0.35tN=200\,e^{0.35t}
The population doubles when ekt=2e^{kt}=2, i.e. when t=ln⁡2/k≈2t=\ln 2/k\approx 2 hours.

Example 3: pH

  1. What is the pH of a 0.011 M solution of HCl?
    pH=−log⁡10[H+]\text{pH} = -\log_{10}[H^+]
    import numpy as np pH = -np.log10(0.011) print('pH =',pH)
    pH = 1.958607314841775
  2. What is the H+^+ concentration of a solution of HCl with a pH of 3?
    pH=−log⁡10[H+]=3so[H+]=10−3\text{pH} = -\log_{10} [H^+] = 3 \quad \text{so} \quad [H^+] = 10^{-3}
    hydrogen = 10**(-3) print('[H+] =',hydrogen,'M')
    [H+] = 0.001 M

Example 4: simplifying logs

Write an expression for xx without using logarithms:
log⁡10(x)=log⁡10(p)+2log⁡10(q)−log⁡10(k)−3log⁡10(x)=x=\begin{aligned} \log_{10}(x) &= \log_{10}(p) + 2 \log_{10}(q) - \log_{10}(k) -3 \\ \log_{10}(x) &= \\ x &= \end{aligned}
  1. Use the laws of logarithms (above) to put all terms on the right hand side within the logarithm. This means we have to rewrite 33 as 3log⁡10(10)3\log_{10}(10).
  2. Raise 10 to the power of each side, which will undo the logarithm function.

Introductory problems

Tip

For more practice, an AI tool can write new problems like the ones below. Ask it for problems of the same type and difficulty, or for problems set in your own field. For example, you could ask it to "write five earth science problems on logarithms, at the level of these ones". Work them on paper first, then ask the tool to check your answers and to explain any step you are unsure of.

Introductory problems 1

Simplify:
  1. a10/a−3a^{10}/a^{-3}
  2. (x)8/x4\left(\sqrt{x}\right)^8/x^4
  3. y1/4/y−2/4y^{1/4}/y^{-2/4}
  4. 10−2/3×107×10−16×x1/2×y4×z−1/310−19×1043×102/3×z−1/3×y1/4×x5/2\frac{10^{-2/3} \times 10^7 \times 10^{-16} \times x^{1/2} \times y^4 \times z^{-1/3}}{10^{-19}\times 10^{43} \times 10^{2/3} \times z^{-1/3} \times y^{1/4} \times x^{5/2}}

Introductory problems 2

Evaluate the following expressions without using a calculator:
  1. 2−42^{-4}
  2. 361/2+642/336^{1/2}+64^{2/3}
  3. (1/3)−2\left(1/3\right)^{-2}
  4. (81/9)3/2\left(81/9\right)^{3/2}

Introductory problems 3

Express the following in logarithmic form:
  1. 53=1255^3 = 125
  2. 8−1/3=1/28^{-1/3} = 1/2
  3. xy=4x^y = 4

Introductory problems 4

Evaluate the following expressions without using a calculator:
  1. log⁡4 (64)\log_4\,(64)
  2. log⁡π (1)\log_{\pi}\,(1)
  3. log⁡b (ba)\log_{b}\, (b^a)
  4. 6log⁡6 (π)6^{\log_6\,(\pi)}

Introductory problems 5

Solve the following equations for xx:
  1. ex=4e^x=4
  2. e−x=2e^{-x}=2
One of your solutions should be exactly −2-2 times the value of your other solution. Why?

Introductory problems 6

Simplify:
  1. ln⁡(e3)\ln \left(e^3\right)
  2. ln⁡(1/(2e))\ln \left(1/(2e)\right)
  3. eln⁡x4e^{\ln x^4}
  4. e3+ln⁡xe^{3+\ln x}

Main problems

Main problems 1

In an experiment, the mass, mm grams, of a reaction product is measured at various times, tt minutes. It is believed that mm and tt are related by a law of the form:
m=Atnm=At^n
The results are shown in the table below:
time (min)1234567812
mass (g)0.50.630.720.80.850.90.950.991.0
  1. Confirm this postulate graphically. There is one result that does not conform to this law. Which?
  2. Find appropriate values of AA and nn, and in this context, explain the meaning of nn. What are the units of AA?
  3. Explain, with reasons, whether you would use these results to predict the mass when t=15t=15.

Main problems 2

These problems deal with pH:
  1. What is the pH of 130ml of a solution containing 4.7mg HCl, assuming that HCl is completely ionised in solution, and its molecular mass is 36.46?
  2. What would be the pH if the concentration of HCl were tripled?

Main problems 3

Express in terms of log⁡10(a)\log_{10} (a), log⁡10(b)\log_{10} (b), log⁡10(c)\log_{10} (c) and log⁡10(d)\log_{10} (d):
  1. log⁡10(b/(ac))\log_{10}\left(b/(ac)\right)
  2. log⁡10(a2bc3d4)\log_{10} (a^2 b c^3 d^4)
  3. log⁡10(cd/(ab))\log_{10} \left(\sqrt{cd/(ab)} \right)

Main problems 4

Simplify:
  1. log⁡10(8)+log⁡10(3)−log⁡10(6)\log_{10}(8) + \log_{10}(3) - \log_{10}(6)
  2. log⁡10(x2−1)−log⁡10(x2+1)\log_{10}\left(x^2-1\right) - \log_{10}\left(x^2+1\right)
  3. 3log⁡a(4)+log⁡a(5)−2log⁡a(9)3\log_a(4) + \log_a(5) - 2\log_a(9)
  4. log⁡10(x9)−log⁡10(x6)\log_{10}\left(x^9\right) - \log_{10}\left(x^6\right)

Main problems 5

This problem gives you a chance to use the identity
log⁡a(b)=1log⁡b(a).\log_a (b) =\frac{1}{\log_b (a)}.
Consider the equation log⁡3(x)+4log⁡x(3)=5\log_3(x) + 4\log_x(3) = 5:
  1. Verify that x=3x=3 satisfies this equation
  2. There is one other value of xx that also satisfies this equation. Find it.

Main problems 6

Solve the following equations for xx:
  1. 2(22x)−5(2x)+2=02\left(2^{2x}\right)- 5\left(2^x\right) + 2 = 0
  2. 32x+1−28(3x)+9=03^{2x+1} - 28\left(3^x\right) + 9 = 0
  3. 16=log⁡2(x)16 = \log_2 (x)
  4. (23log⁡10(x))2−7log⁡10(x2)+2=0\left(2 \sqrt 3 \log_{10}(x)\right)^2 - 7 \log_{10}(x^2) + 2 = 0

Main problems 7

Write an expression for xx or yy without using logarithms:
  1. log⁡10(x)=log⁡10(3r)−5log⁡10(s)+3log⁡10(t)−3\log_{10}(x) = \log_{10}(3r) - 5 \log_{10}(s) + 3\log_{10}(t) - 3
  2. log⁡10(2y)=5+5log⁡10(43)−15log⁡10(2/x)−6log⁡10(y)\log_{10}(2y) = 5 + 5\log_{10}\left(4^3\right) -15\log_{10}\left(2/x\right) - 6\log_{10}(y)

Main problems 8

Write xx in terms of yy for each of the following:
  1. y=2e4xy=2e^{4x}
  2. ln⁡y=3+2ln⁡x\ln y = 3 + 2\ln x

Main problems 9

Express as a sum or difference of logarithms:
  1. ln⁡(x−1)/(x+1)\ln\sqrt{(x-1)/(x+1)}

Main problems 10

Express as a single logarithm:
  1. 1−ln⁡4x1 - \ln 4x
  2. 3ln⁡x−12ln⁡(5−x2)3\ln x - \frac{1}{2} \ln\left(5-x^2\right)