# Run this Python cell by selecting it and then pressing shift-enter
# Do not change anything in this cell
# These commands load the libraries for Python to use
!pip install pandas
import pandas as pd
import numpy as np
!pip install openpyxl
Requirement already satisfied: pandas in /shared-libs/python3.9/py/lib/python3.9/site-packages (1.2.5)
Requirement already satisfied: numpy>=1.16.5 in /shared-libs/python3.9/py/lib/python3.9/site-packages (from pandas) (1.23.4)
Requirement already satisfied: python-dateutil>=2.7.3 in /shared-libs/python3.9/py-core/lib/python3.9/site-packages (from pandas) (2.8.2)
Requirement already satisfied: pytz>=2017.3 in /shared-libs/python3.9/py/lib/python3.9/site-packages (from pandas) (2022.5)
Requirement already satisfied: six>=1.5 in /shared-libs/python3.9/py-core/lib/python3.9/site-packages (from python-dateutil>=2.7.3->pandas) (1.16.0)
WARNING: You are using pip version 22.0.4; however, version 23.0.1 is available.
You should consider upgrading via the '/root/venv/bin/python -m pip install --upgrade pip' command.
Collecting openpyxl
Downloading openpyxl-3.1.2-py2.py3-none-any.whl (249 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 250.0/250.0 KB 23.3 MB/s eta 0:00:00
Collecting et-xmlfile
Downloading et_xmlfile-1.1.0-py3-none-any.whl (4.7 kB)
Installing collected packages: et-xmlfile, openpyxl
Successfully installed et-xmlfile-1.1.0 openpyxl-3.1.2
WARNING: You are using pip version 22.0.4; however, version 23.0.1 is available.
You should consider upgrading via the '/root/venv/bin/python -m pip install --upgrade pip' command.
#Code cell provided for calculations of the theoretical resonant wavelenths and frequencies.
#Show your work to receive credit.
L=1.2
mu=0.0012
F_1 = 0.1 * 9.81
F_2 = 0.2 * 9.81
lambda_1 = (2*L)/1
lambda_2 = (2*L)/2
lambda_3 = (2*L)/3
lambda_4 = (2*L)/4
lambda_5 = (2*L)/5
print(lambda_1,lambda_2,lambda_3,lambda_4,lambda_5)
f_1 = (np.sqrt(F_1/mu))/lambda_1
f_2 = (np.sqrt(F_1/mu))/lambda_2
f_3 = (np.sqrt(F_1/mu))/lambda_3
f_4 = (np.sqrt(F_1/mu))/lambda_4
f_5 = (np.sqrt(F_1/mu))/lambda_5
print(f_1,f_2,f_3,f_4,f_5)
f_6 = (np.sqrt(F_2/mu))/lambda_1
f_7 = (np.sqrt(F_2/mu))/lambda_2
f_8 = (np.sqrt(F_2/mu))/lambda_3
f_9 = (np.sqrt(F_2/mu))/lambda_4
f_10 = (np.sqrt(F_2/mu))/lambda_5
print(f_6,f_7,f_8,f_9,f_10)
2.4 1.2 0.7999999999999999 0.6 0.48
11.913315379579831 23.826630759159663 35.7399461387395 47.653261518319326 59.56657689789916
16.847972182629775 33.69594436525955 50.543916547889324 67.3918887305191 84.23986091314887
#Code cell provided for calculations of the corresponding wavelengths. Show your work to receive credit.
#It may be helpful to first calculate the wavespeed using Eq. 44 for both scenarios and then use Eq. 43 to use
#the wave speed to convert the frequencies from Table 2 into a wavelength.
#To calculate % Error, use (Corresponding - Theoretical)/ Theoretical x 100
R = np.sqrt(F_1/mu)
actualL_1 = R/11.2
actualL_2 = R/22.3
actualL_3 = R/35.5
actualL_4 = R/48.7
actualL_5 = R/61.2
print(actualL_1,actualL_2,actualL_3,actualL_4,actualL_5)
K = np.sqrt(F_2/mu)
actualL_6 = K/16.3
actualL_7 = K/33
actualL_8 = K/52.5
actualL_9 = K/70
actualL_10 = K/87.3
print(actualL_6,actualL_7,actualL_8,actualL_9,actualL_10)
pe_1 = ((actualL_1 - lambda_1)/actualL_1)*100
pe_2 = ((actualL_2 - lambda_2)/actualL_2)*100
pe_3 = ((actualL_3 - lambda_3)/actualL_3)*100
pe_4 = ((actualL_4 - lambda_4)/actualL_4)*100
pe_5 = ((actualL_5 - lambda_5)/actualL_5)*100
print(pe_1,pe_2,pe_3,pe_4,pe_5)
pe_6 = ((actualL_6 - lambda_1)/actualL_6)*100
pe_7 = ((actualL_7 - lambda_2)/actualL_7)*100
pe_8 = ((actualL_8 - lambda_3)/actualL_8)*100
pe_9 = ((actualL_9 - lambda_4)/actualL_9)*100
pe_10 = ((actualL_10 - lambda_5)/actualL_10)*100
print(pe_6,pe_7,pe_8,pe_9,pe_10)
2.55285329562425 1.2821505341251835 0.8054072369293407 0.5871038380080409 0.46718883841489534
2.480683020755304 1.22530706782762 0.7701930140630754 0.5776447605473065 0.4631744929932584
5.987547184409303 6.4072456344788895 0.6713668168610132 -2.196572591947945 -2.742180577038415
3.252451848150204 2.0653653677594077 -3.870067034194559 -3.8700670341945695 -3.632649738116401
#Code cell provided for calculations of the corresponding wavelengths
#and the theoretical resonant wavelengths and frequencies. Show your work to receive credit.
#Eq. 43 and 49 from the Lab Manual will be helpful.
#The first corresponding wavelength column is for your measured frequencies
#The second theo. wavelength column is using Eq. 49, then convert this to frequency with Eq. 43
v_air = 340.3 #m/s (speed of sound in air)
nmclamda_1 = v_air/132
nmclamda_2 = v_air/269
nmclamda_3 = v_air/405
nmclamda_4 = v_air/529
nmclamda_5 = v_air/656
print(nmclamda_1,nmclamda_2,nmclamda_3,nmclamda_4,nmclamda_5)
print(lambda_1,lambda_2,lambda_3,lambda_4,lambda_5)
Tf_1 = (v_air/((2*L)/1))
Tf_2 = (v_air/((2*L)/2))
Tf_3 = (v_air/((2*L)/3))
Tf_4 = (v_air/((2*L)/4))
Tf_5 = (v_air/((2*L)/5))
print(Tf_1,Tf_2,Tf_3,Tf_4,Tf_5)
2.578030303030303 1.2650557620817844 0.840246913580247 0.643289224952741 0.51875
2.4 1.2 0.7999999999999999 0.6 0.48
141.79166666666669 283.58333333333337 425.37500000000006 567.1666666666667 708.9583333333334
df1 = pd.read_excel("Lab11_classdata.xlsx")
#Here we take the columns of the xlsx files and separate them so that each of the resonant frequencies
#for each normal mode can be analyzed separately; we also remove any empty rows with .dropna()
mode1 = df1['number1'].dropna()
mode2 = df1['number2'].dropna()
mode3 = df1['number3'].dropna()
mode4 = df1['number4'].dropna()
mode5 = df1['number5'].dropna()
stringmodes = [mode1,mode2,mode3,mode4,mode5]
def get95PercentConfidenceInterval(mean,sigma,N):
sigma_x = sigma/np.sqrt(N)
print('The Error of the mean is '+str(sigma_x)+'.')
lbof95CI = mean - 1.96*sigma_x
print('The Lower Bound of the 95% confidence interval is '+str(lbof95CI)+'.')
ubof95CI = mean + 1.96*sigma_x
print('The Upper Bound of the 95% confidence interval is '+str(ubof95CI)+'.')
widthof95CI = ubof95CI - lbof95CI
print('The Width of the 95% confidence interval is '+str(widthof95CI)+'.')
for index,mode in enumerate(stringmodes):
mean_mode = np.mean(mode)
std_dev_mode = np.std(mode)
print('Statistics for the resonant frequency of normal mode '+str(index+1))
print('Mean: '+str(mean_mode))
print('Std. Dev.: '+str(std_dev_mode))
print('samples: ' + str(len(mode)))
get95PercentConfidenceInterval(mean_mode,std_dev_mode,len(mode))
print()
Statistics for the resonant frequency of normal mode 1
Mean: 11.4625
Std. Dev.: 0.29973947020704483
samples: 8
The Error of the mean is 0.10597390598633226.
The Lower Bound of the 95% confidence interval is 11.25479114426679.
The Upper Bound of the 95% confidence interval is 11.670208855733211.
The Width of the 95% confidence interval is 0.4154177114664215.
Statistics for the resonant frequency of normal mode 2
Mean: 22.625
Std. Dev.: 0.2680951323690898
samples: 8
The Error of the mean is 0.09478594305064422.
The Lower Bound of the 95% confidence interval is 22.439219551620738.
The Upper Bound of the 95% confidence interval is 22.810780448379262.
The Width of the 95% confidence interval is 0.371560896758524.
Statistics for the resonant frequency of normal mode 3
Mean: 33.8375
Std. Dev.: 0.30388114452858045
samples: 8
The Error of the mean is 0.10743820898544428.
The Lower Bound of the 95% confidence interval is 33.62692111038853.
The Upper Bound of the 95% confidence interval is 34.04807888961147.
The Width of the 95% confidence interval is 0.42115777922293773.
Statistics for the resonant frequency of normal mode 4
Mean: 45.1875
Std. Dev.: 0.5372092236736068
samples: 8
The Error of the mean is 0.18993214248778406.
The Lower Bound of the 95% confidence interval is 44.81523300072394.
The Upper Bound of the 95% confidence interval is 45.55976699927606.
The Width of the 95% confidence interval is 0.7445339985521144.
Statistics for the resonant frequency of normal mode 5
Mean: 56.85
Std. Dev.: 0.5267826876426377
samples: 8
The Error of the mean is 0.186245805321892.
The Lower Bound of the 95% confidence interval is 56.484958221569094.
The Upper Bound of the 95% confidence interval is 57.21504177843091.
The Width of the 95% confidence interval is 0.730083556861814.