# 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.
Requirement already satisfied: openpyxl in /root/venv/lib/python3.9/site-packages (3.1.2)
Requirement already satisfied: et-xmlfile in /root/venv/lib/python3.9/site-packages (from openpyxl) (1.1.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.
#Code cell provided for calculations of the theoretical resonant wavelenths and frequencies.
#Show your work to receive credit.
L = 1.2
u = 0.0012
v = np.sqrt((9.8*.1)/u)
waveL1 = (2*L)/1
f1 = v/waveL1
waveL2 = (2*L)/2
f2 = v/waveL2
waveL3 = (2*L)/3
f3 = v/waveL3
waveL4 = (2*L)/4
f4 = v/waveL4
waveL5 = (2*L)/5
f5 = v/waveL5
v2 = np.sqrt((9.8*.2)/u)
newf1 = v2/waveL1
newf2 = v2/waveL2
newf3 = v2/waveL3
newf4 = v2/waveL4
newf5 = v2/waveL5
print(waveL1, waveL2, waveL3, waveL4, waveL5)
print(f1, f2, f3, f4, f5)
print(newf1, newf2, newf3, newf4, newf5)
2.4 1.2 0.7999999999999999 0.6 0.48
11.907241805196007 23.814483610392013 35.721725415588025 47.62896722078403 59.536209025980035
16.83938285136409 33.67876570272818 50.51814855409227 67.35753140545636 84.19691425682045
#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.
v = np.sqrt((9.8*.1)/u)
waveL100_1 = v/11.2
waveL100_2 = v/22.3
waveL100_3 = v/35.5
waveL100_4 = v/48.7
waveL100_5 = v/61.2
v2 = np.sqrt((9.8*.2)/u)
waveL200_1 = v2/16.3
waveL200_2 = v2/33
waveL200_3 = v2/52.5
waveL200_4 = v2/70
waveL200_5 = v2/87.3
#To calculate % Error, use (Corresponding - Theoretical)/ Theoretical x 100
error1 = (waveL100_1 - waveL1)/(waveL1 * 100)
error2 = (waveL100_2 - waveL2)/(waveL2 * 100)
error3 = (waveL100_3 - waveL3)/(waveL3 * 100)
error4 = (waveL100_4 - waveL4)/(waveL4 * 100)
error5 = (waveL100_5 - waveL5)/(waveL5 * 100)
errornew1 = (waveL200_1 - waveL1)/(waveL1 * 100)
errornew2 = (waveL200_2 - waveL2)/(waveL2 * 100)
errornew3 = (waveL200_3 - waveL3)/(waveL3 * 100)
errornew4 = (waveL200_4 - waveL4)/(waveL4 * 100)
errornew5 = (waveL200_5 - waveL5)/(waveL5 * 100)
print(waveL100_1, waveL100_2, waveL100_3, waveL100_4, waveL100_5)
print(waveL200_1, waveL200_2, waveL200_3, waveL200_4, waveL200_5)
print(error1, error2, error3, error4, error5)
print(errornew1, errornew2, errornew3, errornew4, errornew5)
2.5515518153991446 1.2814968758955343 0.8049966290836736 0.5868045242807066 0.4669506590272943
2.4794183339431783 1.2246823891901155 0.7698003589195012 0.5773502691896258 0.46293836017495776
0.000631465897496436 0.0006791406324627862 6.245786354592136e-05 -0.000219924595321556 -0.0002718612702647012
0.00033090972476324345 0.00020568657658429635 -0.00037749551350623465 -0.00037749551350623557 -0.00035545082968837957
#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)
cWaveL1 = v_air/132
cWaveL2 = v_air/269
cWaveL3 = v_air/405
cWaveL4 = v_air/529
cWaveL5 = v_air/656
print(cWaveL1, cWaveL2, cWaveL3, cWaveL4, cWaveL5)
L = 1.22
waveL1 = (2*L)/1
f1 = v_air/waveL1
waveL2 = (2*L)/2
f2 = v_air/waveL2
waveL3 = (2*L)/3
f3 = v_air/waveL3
waveL4 = (2*L)/4
f4 = v_air/waveL4
waveL5 = (2*L)/5
f5 = v_air/waveL5
print(waveL1, waveL2, waveL3, waveL4, waveL5)
print(f1, f2, f3, f4, f5)
2.578030303030303 1.2650557620817844 0.840246913580247 0.643289224952741 0.51875
2.44 1.22 0.8133333333333334 0.61 0.488
139.46721311475412 278.93442622950823 418.4016393442623 557.8688524590165 697.3360655737705
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.