Equation of a Line
What is a rate constant?
I mentioned earlier that reactions occur at different rates. An explosion from setting hydrogen on fire may last only a couple of seconds. The reactions involved in baking a cake might take a few minutes to a few hours. The chemistry that rusts your bike can take months or years. In our example above, the decay of carbon-14 takes thousands of years.
A rate constant tells you how fast a reaction goes. We might expect our explosion to have a very large rate constant, while carbon-14 might have a very small one. But how do we find out what this rate constant is?
A neat trick that scientists often use is to linearlize data. Remember that exponential decay from before? If we take the natural log of both sides with can get a new equation that looks like this:
If you look closely you should be able to see that plotting ln[C-14]t on the y-axis and t on the x-axis should give a straight line with an intercept of ln[C-14] at time 0 and a slope of k. That allows us to find our rate constant! But first let's program this linear data in python. Remember our data file is called carbondecay.csv
1 #We will need to import numpy this time to calculate the natural log
2 import pandas
3 import matplotlib.pyplot as plt
4 import numpy
6 #Load the data file
9 #If you look at the carbondecay file you will see it has two columns labeled "Time" and "C14_Con" the following line takes the natural log of every entry in the C14_Con column and then prints it. Note that in python the command "log" means natural log, and not log base 10. I will use log to mean natural log for the remainder of this lesson
14 #Now we want to plot time v our new data to get a linear plot
16 plt.plot(carbon_decay.Time, logC_14)
17 plt.title('Amount of Carbon-14 in Sample') # this is the title of the graph (note it's a string)
18 plt.xlabel('Time (years)') # this is the label for the x-axis
19 plt.ylabel('log of Amount of Carbon-14 (parts per trillion)') # this is the label for the y-axis
You should be getting a graph that looks like the one below. We will talk about how to calculate the rate constant from this graph in the next section.