mscroggs.co.uk
mscroggs.co.uk

subscribe

Blog

Log-scaled axes

 2020-03-31 
Recently, you've probably seen a lot of graphs that look like this:
The graph above shows something that is growing exponentially: its equation is \(y=kr^x\), for some constants \(k\) and \(r\). The value of the constant \(r\) is very important, as it tells you how quickly the value is going to grow. Using a graph of some data, it is difficult to get an anywhere-near-accurate approximation of \(r\).
The following plot shows three different exponentials. It's very difficult to say anything about them except that they grow very quickly above around \(x=15\).
\(y=2^x\), \(y=40\times 1.5^x\), and \(y=0.002\times3^x\)
It would be nice if we could plot these in a way that their important properties—such as the value of the ratio \(r\)—were more clearly evident from the graph. To do this, we start by taking the log of both sides of the equation:
$$\log y=\log(kr^x)$$
Using the laws of logs, this simplifies to:
$$\log y=\log k+x\log r$$
This is now the equation of a straight line, \(\hat{y}=m\hat{x}+c\), with \(\hat{y}=\log y\), \(\hat{x}=x\), \(m=\log r\) and \(c=\log k\). So if we plot \(x\) against \(\log y\), we should get a straight line with gradient \(\log r\). If we plot the same three exponentials as above using a log-scaled \(y\)-axis, we get:
\(y=2^x\), \(y=40\times 1.5^x\), and \(y=0.002\times3^x\) with a log-scaled \(y\)-axis
From this picture alone, it is very clear that the blue exponential has the largest value of \(r\), and we could quickly work out a decent approximation of this value by calculating 10 (or the base of the log used if using a different log) to the power of the gradient.

Log-log plots

Exponential growth isn't the only situation where scaling the axes is beneficial. In my research in finite and boundary element methods, it is common that the error of the solution \(e\) is given in terms of a grid parameter \(h\) by a polynomial of the form \(e=ah^k\), for some constants \(a\) and \(k\).
We are often interested in the value of the power \(k\). If we plot \(e\) against \(h\), it's once again difficult to judge the value of \(k\) from the graph alone. The following graph shows three polynomials.
\(y=x^2\), \(y=x^{1.5}\), and \(y=0.5x^3\)
Once again is is difficult to judge any of the important properties of these. To improve this, we once again begin by taking the log of each side of the equation:
$$\log e=\log (ah^k)$$
Applying the laws of logs this time gives:
$$\log e=\log a+k\log h$$
This is now the equation of a straight line, \(\hat{y}=m\hat{x}+c\), with \(\hat{y}=\log e\), \(\hat{x}=\log h\), \(m=k\) and \(c=\log a\). So if we plot \(\log x\) against \(\log y\), we should get a straight line with gradient \(k\).
Doing this for the same three curves as above gives the following plot.
\(y=x^2\), \(y=x^{1.5}\), and \(y=0.5x^3\) with log-scaled \(x\)- and \(y\)-axes
It is easy to see that the blue line has the highest value of \(k\) (as it has the highest gradient, and we could get a decent approximation of this value by finding the line's gradient.

As well as making it easier to get good approximations of important parameters, making curves into straight lines in this way also makes it easier to plot the trend of real data. Drawing accurate exponentials and polynomials is hard at the best of times; and real data will not exactly follow the curve, so drawing an exponential or quadratic of best fit will be an even harder task. By scaling the axes first though, this task simplifies to drawing a straight line through the data; this is much easier.
So next time you're struggling with an awkward curve, why not try turning it into a straight line first.
                        
(Click on one of these icons to react to this blog post)

You might also enjoy...

Comments

Comments in green were written by me. Comments in blue were not written by me.
 Add a Comment 


I will only use your email address to reply to your comment (if a reply is needed).

Allowed HTML tags: <br> <a> <small> <b> <i> <s> <sup> <sub> <u> <spoiler> <ul> <ol> <li> <logo>
To prove you are not a spam bot, please type "k" then "i" then "t" then "e" in the box below (case sensitive):

Archive

Show me a random blog post
 2024 

Feb 2024

Zines, pt. 2

Jan 2024

Christmas (2023) is over
 2023 
▼ show ▼
 2022 
▼ show ▼
 2021 
▼ show ▼
 2020 
▼ show ▼
 2019 
▼ show ▼
 2018 
▼ show ▼
 2017 
▼ show ▼
 2016 
▼ show ▼
 2015 
▼ show ▼
 2014 
▼ show ▼
 2013 
▼ show ▼
 2012 
▼ show ▼

Tags

puzzles captain scarlet stirling numbers tennis bubble bobble datasaurus dozen databet harriss spiral london cross stitch football propositional calculus world cup talking maths in public cambridge accuracy quadrilaterals tmip numbers golden ratio coins error bars london underground asteroids frobel sport craft sobolev spaces manchester geometry news wave scattering countdown numerical analysis 24 hour maths crochet logs mean turtles braiding map projections pascal's triangle royal baby speed european cup dinosaurs mathsjam chebyshev mathsteroids ucl misleading statistics errors logic manchester science festival christmas card simultaneous equations exponential growth reuleaux polygons dataset plastic ratio stickers crossnumber rhombicuboctahedron hyperbolic surfaces finite group fonts guest posts phd standard deviation fence posts recursion sorting computational complexity inline code people maths matrices ternary signorini conditions game of life realhats game show probability pizza cutting polynomials hexapawn statistics weather station matrix multiplication books pythagoras flexagons games machine learning gaussian elimination convergence folding tube maps pac-man latex edinburgh correlation hannah fry platonic solids hats data triangles newcastle royal institution zines python matrix of cofactors electromagnetic field graph theory sound binary curvature noughts and crosses matt parker video games estimation live stream advent calendar finite element method reddit gerry anderson preconditioning determinants chalkdust magazine radio 4 dates arithmetic gather town the aperiodical youtube bempp draughts boundary element methods data visualisation anscombe's quartet folding paper dragon curves pi approximation day approximation javascript matrix of minors mathslogicbot graphs pi chess go trigonometry oeis wool christmas probability inverse matrices light nine men's morris interpolation logo squares php menace fractals martin gardner raspberry pi rugby palindromes weak imposition programming geogebra big internet math-off national lottery final fantasy a gamut of games golden spiral bodmas runge's phenomenon

Archive

Show me a random blog post
▼ show ▼
© Matthew Scroggs 2012–2024