04-Graphing and analyzing data

4.1 gnuplot

gnuplot is one of the most widely used programs, and is available for a wide variety of platforms (even for Android!). It has a quick learning curve for simple graphs, but anything elaborate or requiring some serious computations, even if possible, gets to be quite difficult quickly. The current version of gnuplot is 5.2 and there is an excellent reference book:

We have already seen some basic use in the previous part of the course. Here's a slightly more elaborate example which involves fitting and some annotation.

gnuplot also has some programming ability. Here's an example of a recursively-defined function. It plots a truncated FT decomposition of a square wave, to an arbitrary order of truncation:

Of course, there are also excellent plotting capabilities within python, matlab/octave and maple environments, all with much more sophisticated computational capabilities. We will learn these as we go along. However, the flexibility and the ability to generate both screen-friendly bitmap (e.g. PNG) plots and publication-quality scalable vector (SVG, Encapsulated PostScript, LaTeX, etc.) plots makes gnuplot (and/or eXtrema, see Section 4.3 below) useful additions to the scientific toolbox.

4.2 Homework: analysis of the Cavendish experiment

Lord Cavendish was the designer of the original experiment that used a pair of lead spheres and a very sensitive torsional balance to measure the universal gravitational constant, $G$. A manual for a modern version of such a torsional balance is here. As described there, in Fig.18 on p.13, the following set of data was obtained. The distance to the board on which the position of the laser dot was recorded was $L=10.31$m.

Produce an eXtrema or a gnuplot macro that would plot and analyze the data, and calculate $G$ from it. It appears that a good fit would result from fitting $S(t)=S_0+Ae^{-(t-t_0)/\tau}\cos [\omega (t-t_0)]$ to each segment of the experiment with $S_0$, $A$, $t_0$, $\tau$ and $\omega$ the parameters of the fit. Without knowing the exact geometry of the experiment, $\Delta S$ between the two equilibrium positions cannot be used, but perhaps the oscillation period can be extracted and used in the analysis. Use the average of the two values obtained for both sections of the data.

A more careful examination reveals that there might be a small drift in the data. Model it by a small linear-in-time correction term, $\alpha(t-t_0)$, and see if the precision of the fit improves.

4.3 eXtrema

The same, of course, can be done in eXtrema:

Run eXtrema and enter @Cavendish command to (re-)generate the plot before executing the next cell to include the output in this notebook. Unfortunately, extrema_kernel does not exist, so we cannot run eXtrema within the noteboolk directly. If you execute a cell like this

! extrema

eXtrema will launch, but you will need to quit it before you can return to this jupyter notebook, so it's best to launch it separately, outside of this notebook.