 +
Curve Fitting

Developed by Eric Ayars - Published August 1, 2016

Being able to fit a model to experimental data is an extremely important laboratory skill. Most physics students are familiar with linear curve fitting, often with a spreadsheet or data-collection software such as _Data Studio_ (PASCO Scientific) or _Logger Pro_ (Vernier Software). This set of exercises takes students beyond these introductory tools into the realm of arbitrary-function curve fitting, with error bars and estimates of parameter uncertainties.
Subject Areas Mathematical/Numerical Methods and Experimental Labs Beyond the First Year Python Non Linear Curve Fitting Students who complete this module will gain experience in * Reading data files into the computer. * Fitting data to arbitrary functions. * Using uncertainty in data points as part of the calculation of the curve fit. * Reporting parameter values _with uncertainty_. 90 min

These exercises are not tied to a specific programming language. Example implementations are provided under the Code tab, but the Exercises can be implemented in whatever platform you wish to use (e.g., Excel, Python, MATLAB, etc.).

## Exercise 1: Linear fit The data set "calibration.txt" shows the _reported_ position of a rotational sensor (in units of $\frac{1}{1024}$ of a rotation) after $N$ revolutions. If the rotational sensor is properly calibrated, this should be a horizontal line at 0, but it's not. * By how much per revolution is the sensor miscalibrated? Plot a graph of the data, with a linear curve fit, to answer. Be sure to include errorbars on the graph, and report the uncertainty in your fit parameters. ## Exercise 2: Power fit Students in a first-semester physics course collected this data showing the angular velocity of a rotating "point mass" $m$ and the force $F_c$ required to keep the mass rotating in a circle of radius $R$. If you plot this data, it _looks_ linear (except for that one point at (0,0)) but for theoretical reasons we believe that the equation for centripetal force should be $$F_c = mR\omega^2$$ * Does this data fit the model for $F_c$? Plot a graph to support your answer. * Statistically, the errorbars should intersect the curve fit for about 63% of the data points: Are your errorbars reasonable? * The rotating mass had $m=200$ grams, and the radius of rotation was $R=18$ cm. Is this consistent with parameters from your curve fit? ## Exercise 3: Exponential fit Barium 137 is radioactive. Activity of a sample of Barium 137 was measured as a function of time, and the results are shown in file 'decay.txt'. We would expect that for radioactive decay, $$N = N_o e^{-t/\tau}$$ where $\tau= \frac{t_{1/2}}{\ln(2)}$. * Find the half-life $t_{1/2}$ for Barium 137. Support your answer with a graph and a curve fit, of course! ## Exercise 4: Challenge! The data in file damped_oscillation.txt is shows the position of a magnetic rotor in a fixed magnetic field. One model for the behavior of this rotor would be "exponentially-damped oscillation", $$\theta = \theta_o e^{-\beta t} \cos(\omega t + \phi) + \varphi$$ Find the resonant frequency $\omega$ and the damping constant $\beta$ for this apparatus. You may assume the uncertainty in position is negligible. _Hint: Your initial guesses need to be in the right ballpark!_

### Share a Variation

Did you have to edit this material to fit your needs? Share your changes by Creating a Variation

### Credits and Licensing

Eric Ayars, "Curve Fitting," Published in the PICUP Collection, August 2016.

The instructor materials are ©2016 Eric Ayars.

The exercises are released under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 license 