Appendix B: Using Graphical Analysis Graphical Analysis (GA) is a program by Vernier Software. This program is loaded on all of the Physics 170A computers as well as all of the regular Physics 170 computers. GA can also be purchased from Vernier Software at http://www.vernier.com/soft/ga.html. In this section, I will show you how to use our older version of GA. For information about newer versions, consult Vernier Software s website. Important Note: Because we have an older version of GA, students will need to be logged in under the TA s password on the Physics 170A computers. The TA should not give you his/her password; you should ask the TA to log on for you. GA will not run under the student limited account on XP. In order to use GA in the lab, you need to learn how to enter data, fit a linear regression, and perform an arbitrary curve fit. Figure B-1 This is how GA looks upon start-up. I will use the terms Data Table Window and Graph Window as they are labeled in the figure to describe the program. Entering Data To enter data, simply start typing in the data sheet contained in the Data Table Window. As you do so, the data will automatically start plotting in the Graph Window. The graph will automatically scale to the data that you are entering. You can enter scientific notation into the data table. For example, you can type 1.5E-5, and the data table will understand that you mean 1.5 x10-5. For example, let s suppose this is your data: Frictional Force [N] Normal Force [N] 0.60 0.69 0.81 0.872 0.975 1.096 1.405 1.294 1.200 1.51 1.601 2.34 2.84 3.33 3.82 4.31 4.80 6.27 5.78 5.29 6.76 7.25 93
Entering the Frictional Force in the Y column and the Normal Force into the X column yields the screens shown in Fig. B-2. Figure B-2 A screen shot of the data entered into GA Of course, X and Y are not very descriptive titles. Let s give the data some titles. To get to the Data options, you can go through the Data menu (Data Column Options) or you can simply double click on the x or y at the top of the column (underneath Data Set 1: Data ). Either way, you will get the options menu shown in Fig. B-3. Figure B-3 The data options menu is easily reached by double clicking on the data column header labeled x and y. Here you should give the column a name (such as Frictional Force), a unit (such as N), and an error. GA can understand percent errors and constant errors. The normal force has negligible errors (0%), but in the case of the friction, I estimate my error to be about 4%, based on a calculation done previously. (You need to do this analysis before you enter data!) 94
As soon as I enter these labels into the column options box, the headers on the data table immediately change to the new titles and the graph now sports the title Frictional Force vs. Normal Force as well as labels on the X and Y axes. However, the error bars that you have entered do not appear. To show error bars, get rid of those annoying connecting lines, change the scaling of the graph, and other options, you need to get to the Graph Options menu. To get to the Graph Options menu, simply double click inside the Graph Window or use the Graph menu. Figure B-3 The Graph Options menu is easily accessed by double clicking on the Graph Window You should always uncheck the Connecting Lines option and check the Error Bars option. Now your graph should look like Fig. B-4. Figure B-4 The Frictional Force vs. the Normal Force with 4% errors in the frictional force. Now that we have data entered in the graph, we want to fit the data. 95
Linear Fits: Doing a Linear Regression There are actually two ways to fit the data to a line. The best way, however, is to do a linear regression. This option works best because it yields a statistical error in M and B, rather than simply giving you the mean square error. To do a Linear Regression, click in the Graph Window and drag your mouse (diagonally) from one corner to the opposite corner. What you want to do is grab all the data in the Graph Window. When you have successfully grabbed all of your data, the grabbed data points will be shown between two thick black lines, as shown in Fig. B-5. Figure B-5 This shows a successful grab of all of the data points in the Graph Window When you have grabbed all of your data points, one of the buttons on the toolbar will activate. It has an R= written on it. This is the regression button; if you press it, GA will perform a linear regression on the selected data. Figure B-6 The button with the R= written on it is the regression button 96
Congratulations! Now that you have preformed a linear regression, your Graph Window should look like Fig. B-7. Figure B-7 The Graph Window upon a successful linear regression The great thing about a linear regression is that it tells you the slope, the error in the slope, the y- intercept, and the error in the y-intercept. For example: Figure B-8: The regression gives you many parameters which you need. (Note: this is not the regression of the data given earlier as you can easily tell from the units!). Arbitrary Curve Fits GA can also do other curve fits. There are two kinds of other fits you can do: those that are in the menu and those that aren t! Either way, you need to get to the Automatic Curve Fitting menu. To do this, simply click anywhere in the Graph Window (there s no need to select data points this time). After you have done this, you can either click on the button which says f(x) right next to the regression button or you can go to Analyze Automatic Curve Fit. 97
Figure B-9 The Automatic Curve Fitting menu allows you to pick a function from a list or type in your own function. Once you have gotten to the Automatic Curve Fitting menu, you will notice that there is an entire list of prepared fits that you can do! Notice at the top of the list there is the linear fit. This is the other way to get a linear fit. However, you should not use this method to get linear fits. All automatic curve fits will give you a mean square error rather than the errors in the parameters. (There is a good reason for this! If you ever try propagating from the mean square error to general parameters you will see why!) Let s try a Gaussian fit, A * exp( -K * (x-b)^2 ) (recall the Gaussian from Chapter 2?). The Gaussian function is at the bottom of the list. Figure B-10 The Fitting Window When you select the Gaussian function and click OK, you are sent to the window shown in Fig. B- 10. Immediately, GA warns you that you don t have enough information to get a closed solution. In other words, there are other possible parameters which can be fit successfully. That means we should try to find one of the parameters by other means, if possible, in order to be sure about the parameters. Nevertheless, GA will try to find at least one set of parameters which will work. You will notice the parameters shifting around as GA calculates the best fit. The fit is done when the numbers stop changing. If the fit is good, press the OK Keep Fit button, which will return you to the normal screens. 98
Occasionally, GA will not find a good fit, even though you can see by eye the function should fit well. This occurs when the algorithm is stuck. I won t really go into the details, but suffice it to say that the algorithm will not be able to find the solution under certain conditions (this usually occurs when a closed solution cannot be reached). To get it unstuck, you need to provide some order-of-magnitude numbers to help the fit along. The authors of the program anticipated this problem, and gave you a Pause and Aid Fit button. Press this button, and type your order-ofmagnitude guesses into the parameter text boxes. When done, you can press the ENTER key or press the Resume Auto Fit button (which only appears in the Pause mode). GA should now be able to find a good fit. (And if not, try different guesses!) Now that you have fit the data to a Gaussian function, your screen should look like Fig. B-11. Figure B-11 The fitted data is shown on the left. The floating box is shown on the right. Suppose the equation you want to verify is f = BFn + C In this equation, f is the frictional force, F N is the normal force, and B and C are constants of the appropriate unit. (This is not a real formula of any kind I just made it up off the top of my head.) Darn! That s not on the list! What to do? Happily, GA allows you to try any function you can dream up (well, almost!). You need to return to the Automatic Curve Fitting menu. Notice that you can type in the box at the top! You don t have to pick one of the preset functions! GA recognizes the following operators: plus (+), minus (-), multiplication (*), division (/), and exponentiation (^). In addition, it understands the square root function (sqrt(..)), the sine function (sin(..)), the cosine function (cos(..)), and the exponential function (exp(..)). 99
Since f is the y variable and F N is the x variable, the formula can be written as: y=(b*x)^0.5 + C (Alternatively, you could also write y=sqrt(b*x) + C.) The textbox in the Automatic Curve Fitting menu already has the y= part, so we type (B*x)^0.5 +C into the textbox. Try it out! Important notes: You must state your equation in the form y=f(x). The equation must be a function of x only. Everything other than x and constant numbers (e.g. 0.5) is assumed to be a parameter which the program can vary. Even though you have labeled the data table differently, the x variable must be called x. I.e. it cannot be called f or FN if you put this in the formula, GA will assume it is a parameter it can vary. Every separate parameter must have an operator between it and the next parameter or variable. Otherwise GA will assume it is one parameter. For example, if you type sin(bx), GA will assume that Bx is a parameter it can vary. Instead, you must type sin(b*x). GA does not understand parenthesis multiplication. For example, (M)(x) + B looks fine to us, but GA will return an error. You can either say (M)*(x) + B or M*x + B. There are many other programs which can fit functions to data. GA is a nice, simple program which we have available for your use in the lab and in the Physics Learning Center (Wat 421). As you get more sophisticated in your needs (in later courses), I suggest a more comprehensive mathematics program, such as Mathematica or MathCAD. 100