Graphs
YouTube lecture recording from October 2020
A recording of this lecture from October 2020; the material has changed a little since.
Why graphs?
We often want to go between a formula and its graph, in either direction:
- Given a formula, what shape will its graph have? This is called sketching.
- Given some data, which formula describes them, and what are its parameters? We can often answer this by linearising the data.
Anatomy of a graph
Terminology:
- or is the dependent variable, sometimes called the ordinate, marked on the vertical axis
- or is the independent variable, sometimes called the abscissa, marked on the horizontal axis
- The dependent variable is said to be graphed against the independent variable
Essential features:
- Title
- Axis labels (and units if appropriate)
Equation of a straight line
Defined by a gradient, , and a -axis intercept, :
Interpretation:
- The intercept of this line on the axis is given by , since at ,
- The gradient of this line (also called its "slope") is given by("change in divided by change in ")
- The gradient is also known as the rate of change of with respect to (more on this when we cover differentiation)
- The intercept of this line on the axis is given by , since at we must have
For example, the line has gradient , intercept and intercept :
Sketching graphs
Given a formula, what shape is its graph?
Polynomials are a good place to start.
Graphs of polynomials
An expression involving higher powers of is called a polynomial in :
The highest power, , is its degree.
The graph of a polynomial of degree has at most bends (turning points) in it.
Sketching a polynomial
Consider
- To sketch this, we first find where . It factorises asso at
- For large , the term dominates, so rises to the right and falls to the leftHere is the absolute value (or modulus) of , its size ignoring its sign, so . So "large " means far from zero, in either direction.
- It has degree 5, so it has at most 4 bends, just enough to pass through all five zeros
- Each zero comes from a single factor, so changes sign there
This is enough to sketch the graph. Plotting it in Python confirms the sketch:
A checklist for sketching
To sketch the graph of a function:
- Find where it is zero, positive and negative
- Look at which terms dominate as
- Look at the limit behaviour as approaches any points where the function is undefined (e.g. for ), which may give an asymptote
- Work out how many bends it can have (more on this when we cover differentiation)
Then check your sketch by plotting the function in Python.
From data to a model
Now for the other direction.
Given some data, which formula describes them, and what are its parameters?
- It is hard to tell by eye whether a curve is quadratic, exponential or something else.
- It is much easier to see whether points lie on a straight line, and a straight line is described by just two numbers, its gradient and intercept.
- If we wish to test visually whether some data fit a particular relationship, we can transform the data to plot something which should be linear if the relationship holds.
Linearising: the recipe
- Write down the model, e.g. .
- Rearrange it into the form , where and depend only on the data, and and only on the parameters. Here , , and .
- Plot against . If the points lie on a straight line, the data are consistent with the model. If they curve, the model is wrong.
- Read off the gradient and intercept, and work back to the parameters.
Example: is this quadratic?
There's a definite curve, and we may suspect the trend is quadratic: .
Testing the model
If the parabolic relationship holds, plotting against should result in a straight line.
Plotting against or instead would leave the points on a curve.
Gradient and intercept
We next add a trendline through these points which we can use to determine the gradient and intercept.
- We find lie along a straight line with slope 5 and -intercept 87.
- This means that , so and .
- So, and can be modelled by the polynomial equation .
Example: enzyme kinetics
The rate at which a given enzyme can catalyse a reaction can be dependent upon the substrate concentration.
This is often modelled by the Michaelis-Menten equation:
where is the rate of the reaction, is the substrate concentration, is the maximum rate, and is the substrate concentration at which the rate is half its maximum.
First, plot the original data, which are observations of given varying :
Straight-line form
Take the reciprocal of both sides:
- We can derive a straight line graph from the above formula by plotting against (this is called the Lineweaver-Burk plot)
- It will have gradient and ordinate intercept
Transformed data
If the Michaelis-Menten model holds, plotting against should result in a straight line.
Gradient and intercept
We next add a trendline through these points which we can use to determine the gradient and intercept.
- We find lie along a straight line with slope 3 and -intercept 5.
- This means that , so and .
- So, and can be modelled by the equation .
Linearising in practice
- Note, transforming the data also transforms any noise in it. Taking magnifies the errors in small values of , and these points then have the most influence on the trendline.
- In practice, it is usually better to fit the nonlinear model directly, e.g. using
scipy.optimize.curve_fit. - Plotting in straight-line form is still a good way to check a model visually, and you will see these plots in many papers (e.g. Lineweaver-Burk, Arrhenius).
- Logarithms, which we cover next, let us do the same for exponentials and power laws.
Introductory problems
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 ecology problems on straightening curved data into straight lines, 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
Sketch the following graphs.
First, use pen & paper, then use Python to check your answers.
The notation after each equation indicates the range of values that the variable can take.
# hint import numpy as np from matplotlib import pyplot as plt x = np.linspace(0, 10, 100) y = 3 * x + 5 plt.plot(x, y)
Introductory problems 2
For which values of are the following functions positive? Negative? Zero?
Introductory problems 3
A straight line passes through the points and .
- What is its gradient?
- Write down its equation in the form .
- Where does it cross the axis? The axis?
- Does the point lie on the line?
Introductory problems 4
Use the checklist for sketching to sketch the graph of
Hint: start by factorising.
Then use Python to check your sketch.
Main problems
Text relevant to these problems: Croft and Davison, 5th Edition, Chapters 17 & 18.
Main problems 1
The Lennard-Jones potential energy between two non-polar atoms may be given by the equation:
where and are positive constants, is the potential energy, measured in Joules, and is the internuclear distance measured in .
- For which values of is positive? Negative? Zero?
- Sketch a graph (on paper) showing the potential energy between the two atoms as a function of given that and (the values for argon).
- What is the potential energy between the two atoms at infinite separation?
- What would happen to the two atoms if they were brought very close together?
- What is the physical interpretation of the sign of , and of its slope?
- What are the dimensions ([Length], [Mass], [Time]) and units of the constants and ?
- Use Python to plot the graph of versus for and . Remember to add relevant axis labels. Plot on the same graph the line of , so you can verify your answers to 1. and 2. Choose the limits of your plot with care.
Main problems 2
How should these equations be rearranged to allow the plotting of a suitable linear graph, assuming that the constant parameters and are unknown, and we wish to use the graph to find them?
Write down expressions for the gradient, -intercept and -intercept of each rearranged equation:
Main problems 3
The osmotic pressure of a solution of a protein is related to the concentration of that protein by the equation:
where is the osmotic pressure in kPa, is the temperature in Kelvin, is the gas constant () and is the molarity of the protein (mol. solute per dm solution).
Plot a suitable graph to determine, as accurately as possible, the molecular mass (take care with units!) of the protein given the following data taken at room temperature (usually taken as 21C):
| Protein concentration (in g dm) | 7.3 | 18.4 | 27.6 | 42.1 | 57.4 |
| Osmotic pressure (in kPa) | 0.211 | 0.533 | 0.804 | 1.236 | 1.701 |
Hint: compare the function with the equation of a straight line, , and think about the relationship between concentration, molar concentration and molecular weight.
Use Python to plot the graph and confirm your pen & paper solution.
Extension problems
Extension problems 1
The rate at which a given enzyme catalyses a reaction is dependent upon the substrate concentration:
where is the rate of the reaction, is the substrate concentration and and are unknown constants.
- How can we transform and to derive a straight line graph relating them? What will be the gradient and the ordinate intercepts?
- There is more than one way to do this. Show that plotting against also gives a straight line, and find its gradient and intercepts.
