Author: Thomas A. Moore
Date: August 2007
This program is a general-purpose graphing and data analysis program specifically designed for the lab program for the introductory calculus-based physics course at Pomona College. You can use this program to tabulate, save, and plot experimental data. This program will also do a linear regression analysis to calculate the line that is the best (least-squares) fit to your experimental data (hence the name).
Uncertainty Analysis Tools
The main advantage of this program over commercial spreadsheet and graphing applications is that this program correctly and transparently handles the kinds of experimental uncertainties one typically encounters in introductory physics. The data entry panel has columns for uncertainties, and all graphs are plotted with uncertainty bars. (Please note that this program assumes that the range from a given datum minus its specified uncertainty to the datum plus that uncertainty specifies a 95% confidence range for that datum.)
When the program calculates a best-fit line through your data, it calculates the uncertainties of the slope and intercept of that line by creating 99 fictitious experimental teams whose data is like your data except that each datum has been randomly perturbed within the normal distribution defined by your datum's value and uncertainty range. (To see the data for these ficticious teams, use the "Display" slider on either the data entry or graphics panel.) The program calculates the best-fit line for each of these fictitious sets as well as for your actual data. The uncertaintiy in the slope fitting your data is then estimated by calculating the standard deviation of the 100 slopes thus obtained and multiplying by the Student t-factor for the 95% confidence range for 100 data. The uncertainty for the intercept is calculated in the same way. This method is much more accurate than most other methods when the uncertainties of the data are fairly large and not necessarily very similar, as is often the case for data taken in an introductory physics lab.
The program also has built-in facilities for evaluating uncertainties in practical circumstances. If you press the "r" key in a data entry cell, the program displays a worksheet that allows you to compute the mean value and the uncertainty of that mean from a set of repeated measurements. If you press the "=" key in a data entry cell, the program displays a worksheet that allows you to determine the value and uncertainty of a quantity that is calculated from other uncertain quantities. The uncertainty for the calculated value is again estimated by generating multiple sets of the quantities going into the calculation (in this case, 1000 sets) where each quantity has been randomly perturbed within the normal distribution defined by its stated value and uncertainty. The uncertainty of the final calculated result is estimated from the spread of the 1000 results for the value thus obtained. This is a nearly fool-proof technique for handling propagation of uncertainties for almost any calculated result. See the section "More About Entering Expressions" below for more information about how to enter valid expressions.
Plotting Values Calculated From Your Entered Data
To linearize a graph, it is often advantageous to plot a function of the horizontal data against a function of the vertical data (for example, the logarithm of the horizontal data against a logarithm of the vertical data). To display and plot an arbitrary function of either set of entered data, select the "Data Calculated Using" radio button for that set and type a mathematical expression into the box below (for example, ln(x) or x*x if the name of your variable is x). The program will automatically estimate the uncertainties of the calculated values from those of the entered data using the same technique as described in the previous paragraph. To re-evaluate the expression after changing it, type the return or enter keys or press the "Data Calculated Using radio button again. Note that when the program displays calculated data in a column, you cannot change the calculated data: you can only change the originally entered data.
The default expression is ln(x), where x is your variable name. Therefore, the first time you press the "Data Calculated Using" button, your column of entered data will be replaced by the natural logarithm of your data. (This is to make it easy to plot log-log or semilog graphs.) If you want a different expression, simply type in the new expression. As you type, or if your expression generates an error, your data column will go blank, signaling that you have no valid calculated data. But don't worry, your originally entered data has not been erased, as you can check by pressing the "Data originally entered" button. See the section "More About Expressions" below for more information about how to enter expressions.
Importing Text Data
You can also import data files from other applications or text editors as long as the file is a tab-delimited text file. Select the "Import" item from the File menu, open the file, and select the appropriate format. Your text file can contain four columns of data, two columns (data and uncertainty for either horizontal or vertical data or horizontal and vertical data with no uncertanties), one column of tab-delimited values per line of text, or one column consisting of a single datum per line. You can select which column(s) any partial set of data fills.
When plotting graphs, the program tries to make its best possible guess about axis limits and graph labels, but you can change any of these items. (You should particularly note that the program will have a hard time guessing appropritate units for the slope of any best-fit line.) If the items in rectangular boxes obscure part of the graph, simply drag the boxes to new locations.
More About Entering Expressions
Please note the following when entering mathematical expressions into either the propagation of uncertainty dialog box (the window that pops up when you press "=" in a data cell) or the "Data Calculated Using:" box above each column. The variable "pi" is automatically defined and can be used in any expression. Valid operators are + (addition), - (subtraction), * (multiplication), / (division), and ^ (raising to a power). Some examples of valid expressions are"
(Val1 + Val2 + Val3)/3
The usual rules of precedence of operations apply: for example in the expression a+b*c^-(d+e), the quantity (d+e) is evaluated first (because it is in paretheses), the result is then negated, the value of c is then raised to that power (since powers have precedence over other operations), the result is then multiplied by b (because multiplication and division take precedence over addition and subtraction), and finally a is added to the result.
The panel on the right side of the propagation of uncertainty dialog box shows a complete list of the valid functions you can use in your expressions. Simply type the function into the expression as it is shown in the list (or, if the list is visible, you can simply click on the function's name in the list to enter it into the expression.) The names are pretty self-explanatory, but here are some notes about ones that may not be so obvious. "
pow(x,y) is equivalent to x^y
deg(x) converts an angle x in radians to degrees
rad(x) converts an angle x in degrees to radians
ln(x) is the natural logarithm
log(x) is the base-10 logarithm
sin(x), cos(x), and tan(x) all take arguments in radians
asin(x), acos(x), and atan(x) are inverse trig functions and return results in radians
ceil(x) returns the next integer above (less negative than) x
floor(x) returns the next integer below (more negatve than) x
frac(x) returns the fractional part of x (e.g. frac(-2.51) = 0.51)
rnd returns a random number between 0 and 1
min(x,y) returns x if x < y, or y if y < x
max(x,y) returns x if x > y, or y if y > x
mod(x,y) returns x mod y
sinh(x), cosh(x), and tanh(x) are hyperbolic trig functions
asinh(x), acosh(x), and atanh(x) are inverse hyperbolic trig functions
I have tried to make this program as transparent and as easy-to-use as possible. Please send any bug reports or feature requests to me at firstname.lastname@example.org. This program was written using REALBasic, a superb development environment for Macintosh, Windows, and Linux platforms. For more information, visit www.realbasic.com. This program is freeware, and may be freely distributed, used, and/or modified, subject to the terms of the GNU General Public License, version 2 or higher (http://www.opensource.org/licenses/gpl-license.php).