#!/usr/bin/env python # ----------------------------------------------------------------------------------- # # # Python/ROOT macro for discussing size of errors in measurement of g with pendulum. # # For more information on error propagation, see: # R. J. Barlow: page 48-61 # P. R. Bevington: page 36-48 # # Author: Troels C. Petersen (NBI) # Email: petersen@nbi.dk # Date: 13th of November 2016 # # ----------------------------------------------------------------------------------- # # ----------------------------------------------------------------------------------- # # # This exercise is primarily analytical (one of the few/only), and concerns itself # with planning an experiment measuring the gravitational acceleration, g. # # 1) A simple pendulum of length L = 14m is planned to be used for a measurement of g. # Given that g = 4pi^2 L T^-2 is around 10, what is the expected period T roughly? # # 2) Try to evaluate how accurately you would be able to measure the pendulum length L? # Remember that you will have both a 14+m measuring tape and a laser distance # measurer (LDS) nominally precise to about 1mm, and that you will have several # repeated measurements from all members of the team, but also that some/most of # of the errors will not be statistical (and hence not reduce with repeated # measurements) and also that the pendulum length probably is a combination of # several length measurements. # # 3) Given your estimate in 2), calculate how accurately you will have to measure # the period T, if L and T are to contribute equally to the uncertainty on g. # # The outline code below is only in case you want to verify your above calculations, # and/or see if you can program this up yourself from (almost) scratch, and not required. # # ----------------------------------------------------------------------------------- # from ROOT import * from math import sqrt, atan, sin, cos # Define the squaring function: def sqr( a ) : return a*a #---------------------------------------------------------------------------------- # Error propagation #---------------------------------------------------------------------------------- # Setting what to be shown in statistics box: gStyle.SetOptStat(1110) # Print for stat: Entries, Mean, and RMS gStyle.SetOptFit(1111) # Print for fit: Everything! # Set parameters: Nexp = 10000 # Number of experiments pi = TMath.Pi() SavePlots = False r = TRandom3() # Define histograms: Hist_g_errorL = TH1F( "Hist_g_errorL", "Hist_g_errorL", 200, 9.0, 11.0) Hist_g_errorT = TH1F( "Hist_g_errorT", "Hist_g_errorT", 200, 9.0, 11.0) #---------------------------------------------------------------------------------- # Define parameters for two random numbers (Gaussianly distributed): #---------------------------------------------------------------------------------- L = 14.000 # Pendulum length eL = 0.0 # Error on L - estimate this yourself T = 0.0 # Pendulum period - calculate yourself eT = 0.0 # Error on T - calculate yourself #---------------------------------------------------------------------------------- # Loop over process: #---------------------------------------------------------------------------------- for i in range( Nexp ) : continue #---------------------------------------------------------------------------------- # Plot in a new window: #---------------------------------------------------------------------------------- c1 = TCanvas("c1", "", 100, 20, 1000, 600) Hist_g_errorL.Draw() Hist_g_errorT.Draw("same") c1.Update() if (SavePlots) : c1.SaveAs("PendulumErrorProb.pdf") raw_input( ' ... Press enter to exit ... ' ) #---------------------------------------------------------------------------------- # # #----------------------------------------------------------------------------------