CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download
Project: Lab Manual
Views: 14
Visibility: Unlisted (only visible to those who know the link)
Image: ubuntu2204
Kernel: Python 3 (system-wide)

6. Linearizing a Non-Linear Relationship

6.1 Introduction

The method of linear regression discussed in Chapter 5 provides a powerful tool for extracting information from data when there is a linear relationships between the variables measured. However, in many cases, the relationship between the experimental variables is not linear. As we will see in the next section, a straightforward graph of such a nonlinear relationship does not tell us very much. It is also more difficult to determine the “best fit” to a nonlinear graph. This chapter will introduce you to methods for creating a linear graph of quantities that we expect to be related nonlinearly. If you can artificially create a linear graph, you can use linear regression to extract information about the relationship that would otherwise be hard to obtain.

6.2 An Example of Linearization

Imagine an experiment where we want to determine an object’s acceleration as it slides from rest down a nearly frictionless incline by measuring its displacement as a function of time. The object should experience a constant acceleration along the incline with a magnitude a=g sinθa = g\ sin\theta, where θ\theta is the angle the incline makes with the horizontal. If we define the z-axis to point down along the incline, then theoretical displacement dd of the object as a funciton of the time tt since its release is

d=zz0=12at2,\begin{equation} d = z - z_0 = \frac{1}{2}at^2, \tag{6.1} \end{equation}

where z0z_0 is the starting position.

If we made a graph of dd vs. tt, we would expect a parabola as shown in Figure 6.1. However, it is difficult to distinguish a graph of a dt2d \propto t^2 relationship from one showing dt3d \propto t^3 or dt4d \propto t^4 or other relationships. Since there are a large number of relationships between dd and tt that could produce similar-looking curves, it is difficult to verify by just looking at the graph that our assumption that the object has constant acceleration is reasonable. In addition, there is no simple way to compute the value of aa from this graph.


Figure 6.1: Plot of dd vs. tt.

We can address both of these problems by plotting dd vs. t2t^2, instead of tt, as shown in Figure 6.2. In this case, if the object’s acceleration really is constant, then the graph will be a straight line, and if the object’s acceleration is not constant, the graph will be curved. Therefore, a glance at the graph helps us check whether our basic assumption is correct. If the graph does turn out to be a straight line, then the slope of such a graph, whose value and uncertainty can be easily determined using linear regression, will be a/2a/2, making it easy to determine the value and uncertainty of aa. In this case, we expect the intercept to be in agreement with zero when its uncertainty is taken into account. Note that we need to calculate the uncertainty in t2t^2 to draw the horizontal uncertainty bars in Figure 6.2. We get

Ut2=((t2)tUt)2=2tUt,\begin{equation} U_{t^2} = \sqrt{\left(\frac{\partial (t^2)}{\partial t} U_t\right)^2} = 2t \cdot U_t, \tag{6.2} \end{equation}

by using equation 3.1.


Figure 6.2: Plot of dd vs. t2t^2. Note the the uncertainties for t2t^2 are different than for tt.

For this example, there are other ways to get a linear graph. If we plotted, d\sqrt{d} vs. t, the slope should be a/2\sqrt{a/2}, since

d=(a/2)t.\begin{equation} \sqrt{d} = \left(\sqrt{a/2}\right) t. \tag{6.3} \end{equation}

Alternatively, taking the base-ten logarithm of both sides of equation 6.1 gives

logd=zz0=log(12at2)=log(12a)+2logt.\begin{equation} \log d = z - z_0 = log\left(\frac{1}{2}at^2\right) = log\left(\frac{1}{2}a\right) + 2 \log t. \tag{6.4} \end{equation}

If we were to plot logd\log d vs. logt\log t, then we should get a straight line with slope consistent with 2 and an intercept of log(a/2)\log \left(a / 2\right). This approach would be useful if you wanted to test if dd depends on t2t^2 or some other power of tt, since the power of tt is a fit parameter. Note that we would still have to propagated uncertainies to perform the linear regressions, to make the plots, and to find the uncertainty of aa.

6.3 General Approach to Linearization

It is often, but not always, possible to make a linear graph from measurements. Here are the steps to follow:

  1. Find a theoretical relation between the two quantities measured.

  2. Find a function of one variable that when plotted against the other variable (or a function of that second variable) will yield a straight line if the hypothetical relationship is true.

  3. Make a graph of the variables determined in step 2 using your experimental data to make sure that the plotted quantities lie on a roughly straight line. (If not, try to determine whether your theoretical relation is incorrect or there is some error in your measurements and/or calculations.)

  4. Compute the uncertainties in the plotted quantities (if different from the measured quantities) using the method described in Chapter 3.

  5. Use Python to find the slope and intercept of the best fit line and their uncertainties.

  6. Use the equation found in step 2 to interpret the slope and intercept. You may have to propagate their uncertainties.

6.4 Two Frequently-Used Examples

There are two particular examples that come up so frequently that they merit specific mention.

6.4.1 Exponential Relationships

Many processes, like the voltage across a capacitor as is discharges through a resistor, have an exponential dependence. The general form of an exponential law is

z=CeDx,\begin{equation} z = Ce^{Dx}, \tag{6.4} \end{equation}

where DD can be positive or negative. Taking the natural logarithm of both sides of equation 6.4 gives

lnz=lnC+Dx.\begin{equation} \ln z = \ln C + Dx. \tag{6.5} \end{equation}

If we plot lnz\ln z vs. xx, then comparing with y=mx+by = mx + b (with y=lnzy = \ln z) the slope should be DD and the intercept should be lnC\ln C. Don't forget to propagate uncertainties correctly (see Ch. 3). The uncertainty of lnz\ln z isn't the same as the uncertainty of zz. Also, the uncertainty of CC isn't the same as the uncertainty of the intercept.

6.4.2 Power Laws

Another common type of physical relationship is a power law, which is of the form

y=kxn,\begin{equation} y = kx^n, \tag{6.6} \end{equation}

where kk and nn are constants. For example the period of a mass on a spring depends on the square root (1/2 power) of the mass. Taking the base-10 logarithm of equation 6.6 gives

logy=logk+nlogx.\begin{equation} \log y = \log k + n\log x. \tag{6.7} \end{equation}

If we plot logy\log y vs. logx\log x, the slope should be nn and the intercept should be logk\log k. Don't forget to propagate uncertainties correctly (see Ch. 3). The uncertainty of logx\log x and logy\log y aren't the same as the uncertainties of xx and yy. Also, the uncertainty of kk isn't the same as the uncertainty of the intercept.

6.5 Exercises

6.1 For the hypothetical experiment in section 6.2, suppose that the acceleration aa is measured for various angles θ\theta.    (a) What would you plot in order to get a linear graph?    (b) How would the measured graviational acceleartion gg be related to the slope mm of the best fit line?    (c) If the uncertainty of the slope is UmU_m, what is the uncertainty of the measured graviational acceleartion?

6.2 For section 6.4.1, work out how to propagate the uncertainties.    (a) What is the uncertainty of lnz\ln z?    (b) Suppose that linear regression gives values for the slope (mm), intercept (bb), and their uncertainties (UmU_m and UbU_b). What are CC, DD, and their uncertainties?

6.3 For section 6.4.2, work out how to propagate the uncertainties.    (a) What is the uncertainty of logy\log y? (The expression for logx\log x will be similar.)    (b) Suppose that linear regression gives values for the slope (mm), intercept (bb), and their uncertainties (UmU_m and UbU_b). What are kk, nn, and their uncertainties?

6.4 The data for the number of bacteria as a function of time in the table below is expected to reflect an exponentially relationship, N(t)=N0eβtN(t) = N_0 e^{\beta t}.

time tt (min)Number of bacteria NN
10149,000 ± 15,000
20215,000 ± 20,000
30335,000 ± 35,000
40477,000 ± 45,000
50769,000 ± 75,000

   (a) Using Python, make a linearized plot of the data by taking a natural logarithm of the number of bacteria. Include error bars. Be sure to propagate the uncertainty in the number of bacteria at each time (see chapter 3).    (b) Use Python to perform a linear fit, finding the slope, the intercept, and their uncertainties.    (c) Find the values of β\beta and N0N_0 that best fit the data and their uncertainties.

6.5 The table below gives the orbital periods TT (in years) of the planets known to Newton as a function of their mean distance RR from the sun in AUs (where 1 AU = the earth’s mean orbital radius). The period and distance are related by a power-law of the form T=kRnT=kR^n.

PlanetDistance (AU)Period (yr)
Mercury0.390.24
Venus0.720.62
Earth1.001.00
Mars1.521.88
Jupiter5.2011.86
Saturn9.5429.46

   (a) Using Python, make a linearized plot of the data by taking the base-10 logarithm of the distance and period. Also, use Python to find the slope and the intercept of the best-fit line.    (b) What does the fit suggest are the likely values of kk and nn?