Skip to main content

Scientific Computing

Essential Maths

Graphs []

Scientific Computing

Essential Maths

Differentiati... []

This material has been adapted from material by Fergus Cooper from the "Essential Mathematics" module of the SABS R³ Center for Doctoral Training.

This material has been adapted from material by Fergus Cooper from the "Essential Mathematics" module of the SABS R³ Center for Doctoral Training.

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

The following YouTube video was recorded for the 2020 iteration of the course. The material is still very similar:

Youtube lecture thumbnail


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.

(1) Multiplication of expressions with powers

Let's recap by example:

52=5×5=255^2 = 5 \times 5 = 25,

and

53=5×5×5=1255^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=312525 \times 125 = 3125.

So,

55=52×535^5 = 5^2 \times 5^3.

And, by extension:

am× an=am+na^m\times~a^n=a^{m+n}.

When we multiply two expressions with powers, we add the powers.

(2) 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=anm{a^n\over a^m}=a^{n-m}

When we divide two expressions with powers, we subtract the powers.

(3) 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=2441406255^{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.

(4) 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 35=23 - 5 = -2. And, so:

a2=1a2a^{-2}={1\over a^2}

and, in general,

an=1ana^{-n} ={1\over a^n}

where nn is a positive integer.

(5) 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 33=03-3=0.

Thus, anything to the power of zero equals one, except 000^0 which is undefined:

a0=1a^0=1

(6) Fractional (rational) indices

a1=a1/2×a1/2    so    a1/2=aa^1 = a^{1/2} \times a^{1/2} {\rm ~~~~so~~~~}a^{1/2} = \sqrt{a} a1n=ana^{1\over n} = \sqrt[n]{a} anm=(am)n     or   anma^{n\over m} = \left(\sqrt[m]{a}\right)^n ~~~~~{\rm or}~~~\sqrt[m]{a^n} anm=1(am)n   or    1anma^{-{n\over m}} = {1\over {\left(\sqrt[m]{a}\right)^n}}~~~{\rm or}~~~~{1\over {\sqrt[m]{a^n}}}

(7) Different bases, same index

(ab)x=axbxand(ab)x=axbx(a\cdot b)^x = a^x\cdot b^x\qquad {\rm and}\qquad\Bigl( {a\over b}\Bigr)^x={{\,a^x}\over{\,b^x}}

(8) Two Cautionary remarks

  1. Powers of sums are not pretty: (a+b)xax+bx(a+b)^x \ne a^x + b^x

  2. Powers of differences are not pretty: (ab)xaxbx(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+2ba+b2(a+b)^2=(a+b)(a+b)=a^2+2ba+b^2

  2. (ab)2=(ab)(ab)=a22ba+b2(a-b)^2=(a-b)(a-b)=a^2-2ba+b^2

  3. (a+b)(ab)=a2b2(a+b)(a-b)=a^2-b^2

Logarithms

  1. If y=axy=a^x,   x  \;x\; is the power to which the base   a  \;a\; must be raised to give yy, OR

  2.   x  \;x\; is the logarithm which, with base   a,  \;a,\; gives   y  \;y\;.

In general we write x=logayy=ax\quad x = \log_a y \quad \Leftrightarrow \quad y=a^x.

The base of a logarithm may be any number. Commonly, logarithms either have base 10 or base ee. It is almost always a good idea to explicitly state the base, e.g.   log39=2  \;\log_3 9=2\; implies   32=9  \;3^2=9\;.

Getting a feel for logarithms

Here's a graph of y=log10xy=\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)

  • Used a lot in computer programming to improve the speed and/or accuracy of calculations.

The laws of logarithms

(1) Using the same base aa for both operations

  • Taking the logarithm undoes raising to a power:

logaar=r\log_a\,a^r=r

  • Raising to a power undoes taking the logarithm:

alogab=ba^{\log_a\,b}=b

(2) Multiplication

loga(bc)=logab+logac     (Add)\log_a (bc) = \log_a b + \log_a c ~~~~~(Add)

(3) Division. In a similar way to multiplication

loga(bc)=logablogac     (Subtract)\log_a \left({b \over c}\right) = \log_a b - \log_a c ~~~~~(Subtract)

(4) Powers

logabn=nlogab      (Multiply)\log_a b^n = n \log_a b ~~~~~~ (Multiply)

(5) Changing the base of a logarithm

logac=logbclogba\log_a c = {\log_b c\over \log_b a}

(6) Special case: if bb and cc are the same, (5) reduces to

logab=logbblogba=1logba \log_a b ={\log_b b\over \log_b a}={1\over \log_b a}

(7) The log of any number to the base itself is 1

logaa=1\log_a a =1

(8) The log of 1 is 0 (unless a=0, in which case it is undefined)

loga1=0since   a0=1\log_a 1 = 0 \quad{\rm since~~~}\quad a^0=1

(9) Inverse operation

logaax=x\log_a a^x = x

(10) Or

alogax=xa^{\log_a x}=x

(11) Negative logs

loga1x=loga1logax=0logax=logax\log_a {1\over x} = \log_a1-\log_ax= 0 - \log_a x =-\log_ax

(12) Two cautionary remarks

  1.   loga(x+y)  \;\log_a (x + y)\; and   loga(xy)  \;\log_a (x-y)\; cannot be simplified any further, and should be left as they are.

  2. Neither can   logaxlogay  \;\log_a\,x \cdot \log_a\,y\; or   logaxlogay.  \;\displaystyle{{\log_a\,x}\over {\log_a\,y}}.\; Leave them as they are.

Example 1: graphs

Can the data below be fitted to the form: y=Axny=Ax^n?

xy
4.06.0
16.012.0
25.015.0
64.024.0

Graph of data table

Take logs of both sides: This is the equation of a straight line (cf. y=mx+cy=mx+c)

logy=logAxn=logA+logxn=logA+nlogx\log y =\log Ax^n = \log A + \log x^n= \log A + n \log x

Graph of data table, straightened

Gradient = 0.5 = nn

Intercept = 0.48=log10A0.48 = \log_{10}A so A=3.0A=3.0

Data fit curve of the form:

y=3.0×x1/2y=3.0\times x^{1/2}

Example 2: pH

  1. What is the pH of a 0.011M solution of HCl?

    pH=log10[H+]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[H+]=3     so   pH = -\log [H^+] = 3~~~~{\rm~so~~~}

    [H+] = 0.001 M

Example 3: Simplifying logs

Write an expression for xx without using logarithms:

log(x)=log(p)+2log(q)log(k)3\log(x) = \log(p) + 2 \log(q) - \log(k) -3 > log(x)=                                                \log(x) =~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > x=                                        x=~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  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   3  \;3\; as   3log(10)  \;3\log(10)\;.

  2. Raise both sides to the (same) power which will undo the logarithm function. (i.e. raise both sides to the power of 10)

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   1\;1.

Graph of exp

So for the function (called the exponential function):

y=ex   the gradient at (0,1) is  1=e0.y=e^x ~~~{\rm the~gradient~at~(0,1)~is~~}1 = e^0.

This turns out to be true at any point on the curve. The function y=exy=e^x is the only function that is unchanged when differentiated (more tomorrow).

ee has been found to arise in many branches of mathematics. It is also used as a base for logarithms. e.g.:

y=loge10=ln10  and   y=logex=lnxy=\log_e10=\ln 10 {\rm~~and~~~} 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   e  \;e\;. We usually write   ln(x)  \;\ln(x)\; for loge(x)\log_e(x). Here are some examples:

  • ln(e)=loge(e)=1\ln(e)=\log_e(e)=1

  • ln(10)=loge(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.30310e^{2.303}\approx 10

  • ln(exp(b))=lneb=logeeb=b\ln(\exp(b)) = \ln e^b =\log_e e^b = b

  • exp(ln(b))=eln(b)=elogeb=b\exp(\ln(b))=e^{\ln(b)}=e^{\log_e b}=b

Note that examples (d) and (e) confirm the property that the functions "exp\exp" and "ln\ln" are functional inverses of one another.

Introductory problems

Introductory problems 1

Simplify:

  1. a10a3\displaystyle \frac{a^{10}}{a^{-3}}

  2. (x)8x4\displaystyle \frac{\left(\sqrt {x}\right)^8}{x^4}

  3. y14y24\displaystyle \frac{y^{1\over 4}}{y^{-{2 \over 4}}}

  4. 102/3×107×1016×x1/2×y4×z1/31019×1043×102/3×z1/3×y1/4×x5/2\displaystyle \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. 24\displaystyle 2^{-4}

  2. 3612+6423\displaystyle 36^{1\over 2}+64^{2\over 3}

  3. (13)2\displaystyle \left( {1 \over 3}\right)^{-2}

  4. (819)32\displaystyle \left({81 \over 9}\right)^{3 \over 2}

Introductory problems 3

Express the following in logarithmic form:

  1. 53=125\displaystyle 5^3 = 125

  2. 813=12\displaystyle 8^{-{1\over 3}} = {1 \over 2}

  3. xy=4\displaystyle x^y = 4

Introductory problems 4

Evaluate the following expressions without using a calculator:

  1. log4(64)\displaystyle \log_4\,(64)

  2. logπ(1)\displaystyle \log_{\pi}\,(1)

  3. logb(ba)\displaystyle \log_{b}\, (b^a)

  4. 6log6(π)\displaystyle 6^{\log_6\,({\pi})}

Introductory problems 5

Solve the following equations for xx:

  1. ex=4\displaystyle e^x=4

  2. ex=2\displaystyle e^{-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)\displaystyle \ln \left(e^3\right)

  2. ln(12e)\displaystyle \ln \left(1\over{2e}\right)

  3. elnx4\displaystyle e^{\ln x^4}

  4. e3+lnx\displaystyle e^{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(a)\log (a), log(b)\log (b), log(c)\log (c) and log(d)\log (d):

  1. log(bac)\displaystyle \log\left({{b}\over ac}\right)

  2. log(a2bc3d4)\displaystyle \log (a^2 b c^3 d^4)

  3. log(cdab)\displaystyle \log \left(\sqrt {cd \over ab} \right)

Main problems 4

Simplify:

  1. log(8)+log(3)log(6)\displaystyle \log(8) + \log(3) - \log(6)

  2. log(x21)log(x2+1)\displaystyle \log\left(x^2-1\right) - \log\left(x^2+1\right)

  3. 3loga(4)+loga(5)2loga(9)\displaystyle 3\log_a(4) + \log_a(5) - 2\log_a(9)

  4. log(x9)log(x6)\displaystyle \log\left(x^9\right) - \log\left(x^6\right)

Main problems 5

This problem gives you a chance to use the identity loga(b)=1logb(a)\displaystyle\quad\log_a (b) ={\frac{1}{\log_b (a)}}.

Consider the equation log3(x)+4logx(3)=5\displaystyle\,\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=0\displaystyle 2\left(2^{2x}\right)- 5\left(2^x\right) + 2 = 0

  2. 32x+128(3x)+9=0\displaystyle 3^{2x+1} - 28\left(3^x\right) + 9 = 0

  3. 16=log2(x)\displaystyle 16 = \log_2 (x)

  4. (23log(x))27log(x2)+2=0\displaystyle \left(2 \sqrt 3 \log(x)\right)^2 - 7 \log(x^2) + 2 = 0

Main problems 7

Write an expression for xx or yy without using logarithms:

  1. log(x)=log(3r)5log(s)+3log(t)3\displaystyle \log(x) = \log(3r) - 5 \log(s) + 3\log(t) - 3

  2. log(2y)=5+5log(43)15log(2x)6log(y)\displaystyle \log(2y) = 5 + 5\log\left(4^3\right) -15\log\left({\frac{2}{x}}\right) - 6\log(y)

Main problems 8

Write xx in terms of yy for each of the following:

  1. y=2e4x\displaystyle y=2e^{4x}

  2. lny=3+2lnx\displaystyle \ln y = 3 + 2\ln x

Main problems 9

Express as a sum or difference of logarithms:

  1. ln(x1x+1)\displaystyle \ln\sqrt{\left({x-1\over x+1}\right)}

Main problems 10

Express as a single logarithm:

  1. 1ln4x\displaystyle 1 - \ln 4x

  2. 3lnx12ln(5x2)\displaystyle 3\ln x - {1\over 2} \ln\left(5-x^2\right)