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 course material was developed as part of UNIVERSE-HPC, which is funded through the SPF ExCALIBUR programme under grant number EP/W035731/1
Indices, logs and exponentials
Learning outcomes
Understand the meaning of raising a number to an index
Be able to rearrange algebraic expressions with indices
Understand logarithms and their relationship with indices
Be able to apply the laws of logarithms to algebraic expressions
Understand the use of logarithmic axes in graphs
YouTube lecture recording from October 2020
A recording of this lecture from October 2020; the material has changed a little since.
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, ex, 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 23, 2 is the base, and 3 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=8.
Multiplication of expressions with powers
Let's recap by example:
52=5×5=25,
and
53=5×5×5=125.
Now,
55=5×5×5×5×5=3125
and
25×125=3125.
So,
55=52×53.
And, by extension:
am×an=am+n.
When we multiply two expressions with powers, we add the powers.
Division of expressions with powers
Again, let's look at an example:
5253=5×55×5×5
We can cancel both fives on the bottom with two from the top, leaving just 5, or, 51 left.
Generalising, by extension:
aman=an−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
Using the addition rule from above, the resulting power should be 3+3+3+3=12.
And, sure enough:
512=244140625.
So, generalising again:
(an)m=anm
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?
a5a3=a×a×a×a×aa×a×a=a×a1=a21
Using the division rule above, the power should be 3−5=−2.
And, so:
a−2=a21
and, in general,
a−n=an1
where n is a positive integer.
Zero index
Similarly,
a3a3=a×a×aa×a×a=1,
and by using the division rule, the power should be 3−3=0.
Thus, anything to the power of zero equals one, except 00
which is undefined:
So, the order of these operations does not matter (for a>0).
Different bases, same index
(a⋅b)x=ax⋅bxand(ba)x=bxax
Two cautionary remarks
Powers of sums are not pretty: (a+b)x=ax+bx
Powers of differences are not pretty: (a−b)x=ax−bx
A useful formula for products of sums:
(p+q)⋅(s+t)=ps+pt+qs+qt
Three important consequences:
(a+b)2=(a+b)(a+b)=a2+2ab+b2
(a−b)2=(a−b)(a−b)=a2−2ab+b2
(a+b)(a−b)=a2−b2
Logarithms
If y=ax, x is the power to which the basea must be raised to give
y, OR
x is the logarithm which, with basea, gives y.
In general we write
x=logay⇔y=ax.
The base of a logarithm may be any positive number other than 1. Commonly, logarithms either have base 10 or basee.
It is almost always a good idea to explicitly state the base, e.g. log39=2 implies 32=9.
In this course we always write the base, e.g. log10, except for base e (more on this below).
Getting a feel for logarithms
Here's a graph of y=log10x:
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+] ion concentration)
The laws of logarithms
Using the same base a for both operations
Taking the logarithm undoes raising to a power:
logaar=r
Raising to a power undoes taking the logarithm:
alogab=b
Multiplication, division and powers
Each law of logarithms comes from a law of indices.
If b=am and c=an, then logab=m and logac=n, so:
Indices
Logarithms
Multiplication
am×an=am+n
loga(bc)=logab+logac (add)
Division
am/an=am−n
loga(b/c)=logab−logac (subtract)
Powers
(am)r=amr
logabr=rlogab (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
logac=logbalogbc
Special case
If b and c are the same, changing the base reduces to
logab=logbalogbb=logba1
The log of any number to the base itself is 1
logaa=1
The log of 1 is 0
loga1=0sincea0=1
Negative logs
logax1=loga1−logax=0−logax=−logax
Two cautionary remarks about logarithms
loga(x+y) and loga(x−y) cannot be simplified any further, and should be left as they are.
Neither can logax⋅logay or logax/logay. Leave them as they are.
The exponential function and the real number e
Definition of the real number e
The real number e, also known as Euler's number, is that base for which the graph y=ex
passes through the point (0,1) with gradient exactly equal to 1.
The dashed line in the graph is the tangent to y=ex at (0,1), which is the line y=x+1.
So for the function (called the exponential function):
y=exthe gradient at (0,1) is 1=e0.
This turns out to be true at any point on the curve, i.e. the gradient of y=ex at any point is equal to the value of ex there.
This means that the function y=ex is unchanged when differentiated (more on this when we cover differentiation).
e has been found to arise in many branches of mathematics. It is also used as a base for logarithms. e.g.:
y=loge10=ln10andy=logex=lnx
Logs to base e 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 e.
We usually write ln(x) for loge(x). Here are some examples:
ln(e)=loge(e)=1
ln(10)=loge(10) = "The power I need to raise e to in order to get 10"
ln(10)≈2.303. Which means that e2.303≈10
ln(exp(b))=lneb=logeeb=b
exp(ln(b))=eln(b)=elogeb=b
Note that the last two examples confirm the property that
the functions "exp" and "ln" are functional
inverses of one another.
Logarithms in Python
In numpy, np.log is the natural logarithm, 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. log381=ln81/ln3:
print(np.log(81)/np.log(3))
4.0
Example 1: power laws
Can the data below be fitted to the form: y=Axn?
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])
This is the equation of a straight line, Y=mX+c.
Here Y=log10y, X=log10x, m=n and c=log10A.
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 pointsgradient, intercept = np.polyfit(X, Y,1)print('gradient =',gradient)print('intercept =',intercept)
Plotting log10y against log10x is the same as plotting y against x 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=N0ekt?
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])
Take the natural log of both sides:
lnN=lnN0ekt=lnN0+lnekt=lnN0+kt
This is the equation of a straight line, Y=mX+c.
Here Y=lnN, X=t, m=k and c=lnN0.
Only the N axis is on a log scale, so this is called a semi-log plot.
As in Example 1, we fit the best straight line through the points:
Y = np.log(N)# Fit the best straight line through the pointsgradient, intercept = np.polyfit(t, Y,1)print('gradient =',gradient)print('intercept =',intercept)
Use the laws of logarithms (above) to put all terms on the right hand side
within the logarithm. This means we have to rewrite 3 as 3log10(10).
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.
Collect the powers of each base, subtracting the powers in the denominator from those in the numerator.
For the powers of 10:
(−32+7−16)−(−19+43+32)=−329−374=−3103
The powers of x give 1/2−5/2=−2, the powers of y give 4−1/4=15/4, and the z terms cancel.
So, the expression simplifies to
10−103/3x−2y15/4
Introductory problems 2
Evaluate the following expressions without using a calculator:
2−4
361/2+642/3
(1/3)−2
(81/9)3/2
2−4=1/24=1/16
361/2+642/3=36+(364)2=6+42=22
(1/3)−2=32=9
(81/9)3/2=93/2=(9)3=33=27
Introductory problems 3
Express the following in logarithmic form:
53=125
8−1/3=1/2
xy=4
log5(125)=3
log8(1/2)=−1/3
logx(4)=y
Introductory problems 4
Evaluate the following expressions without using a calculator:
log4(64)
logπ(1)
logb(ba)
6log6(π)
43=64, so log4(64)=3.
π0=1, so logπ(1)=0 (the log of 1 is 0 in any base).
logb(ba)=a, since logb undoes raising b to a power.
6log6(π)=π, since raising 6 to a power undoes log6.
Introductory problems 5
Solve the following equations for x:
ex=4
e−x=2
One of your solutions should be exactly −2 times the value of your other solution. Why?
Take the natural log of both sides: x=ln4≈1.386.
Take the natural log of both sides: −x=ln2, so x=−ln2≈−0.693.
4=22, so ln4=2ln2.
This means that the first solution, 2ln2, is exactly −2 times the second, −ln2.
Introductory problems 6
Simplify:
ln(e3)
ln(1/(2e))
elnx4
e3+lnx
ln(e3)=3
ln(1/(2e))=ln1−ln2−lne=−1−ln2
elnx4=x4
e3+lnx=e3elnx=e3x
Main problems
Main problems 1
In an experiment, the mass, m grams, of a reaction product is measured at various times, t minutes. It is believed that m and t are related by a law of the form:
m=Atn
The results are shown in the table below:
time (min)
1
2
3
4
5
6
7
8
12
mass (g)
0.5
0.63
0.72
0.8
0.85
0.9
0.95
0.99
1.0
Confirm this postulate graphically. There is one result that does not conform to this law. Which?
Find appropriate values of A and n, and in this context, explain the meaning of n. What are the units of A?
Explain, with reasons, whether you would use these results to predict the mass when t=15.
Take logs of both sides, as in Example 1:
log10m=log10A+nlog10t
So, if the law holds, plotting Y=log10m against X=log10t should result in a straight line.
import numpy as np
from matplotlib import pyplot as plt
t = np.array([1,2,3,4,5,6,7,8,12])m = np.array([0.5,0.63,0.72,0.8,0.85,0.9,0.95,0.99,1.0])X = np.log10(t)Y = np.log10(m)plt.plot(X, Y,'o')plt.xlabel('$X = \\log_{10}(t)$')plt.ylabel('$Y = \\log_{10}(m)$')
The first eight points lie close to a straight line, so they are consistent with the law.
The last point (t=12, m=1.0) falls well below the line, so this is the result that does not conform.
We fit the best straight line through the first eight points, leaving out the last one:
# Fit the best straight line through the first eight points, leaving out t = 12gradient, intercept = np.polyfit(X[:-1], Y[:-1],1)print('gradient =',gradient)print('intercept =',intercept)print('A =',10**intercept)
gradient = 0.3284064309500228
intercept = -0.29959116068954406
A = 0.5016592670730619
Gradient ≈0.33=n, and intercept ≈−0.30=log10A, so A≈0.50.
So, the data fit a curve of the form
m=0.5t1/3
The power n tells us how the mass grows with time.
Here n≈1/3, so the mass grows like the cube root of time.
This means that doubling the time multiplies the mass by only 21/3≈1.26, and the growth slows down as time goes on.
m is in grams and tn is in minutesn, so the units of A are g min−n, here g min−1/3.
No.
The law predicts m=0.5×151/3≈1.2 g at t=15, but the result at t=12 suggests the mass has stopped growing at about 1 g (perhaps because one of the reactants has run out).
t=15 is beyond the range where the law holds, so a prediction from it would not be reliable.
Main problems 2
These problems deal with pH:
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?
What would be the pH if the concentration of HCl were tripled?
First find the number of moles of HCl:
36.46gmol−14.7×10−3g≈1.289×10−4mol
This is in 130ml=0.130dm3, and each HCl gives one H+, so