from __future__ import division
from numpy import sqrt
# Speed
#given data :
m1=0.1 # in kg
g=9.81 # in m/s**2
T=m1*g # N
A=10**-6 # in m**2
p=9.81*10**3 # in kg/m**3
m=A*p # in kg/m
v=sqrt(T/m)
print "The speed of transverse waves, v = %0.f m/s " %v
# tensile stress
#given data :
p=8000 # in kg/m**3
v=340 # in m/s
TbyA=v**2*p*10**-2
print "Tensile stress = %0.2e N/m^2 " %TbyA
# Tension
#given data :
M=2*10**-3 # in kg
l=35*10**-2 # in m
n=500 # in Hz
m=M/l # in kg/m
T=4*n**2*l**2*m
print "Tension, T = %0.f N " %T
# Frequency
#given data :
T=625 # in N
T1=100 # in N
l=1/2
n=240 # in Hz
n1=1/l*(sqrt(T1/T))*n
print "The frequency, n1 = %0.f Hz " %n1
# initial tension
rt=2/3 #ratio
mi=5 #kg wt
M=((1/rt)**2)-1 #
mo=mi/M #kg wt
print "Initial tension in string = %0.2f kg-wt " % mo
# speed,stress and change in frequency
n=175 #Hz
l=1.5 #m
v=2*n*l #m/s
d=7.8*10**3 #kg/m**3
st=v**2*d #N/m**2
per=3 #% increament
T=1 #assume
td=(1+per/100)*T #
x=(((1/2)*(per/100))) #
td=x*100 #
print "Velocity = %0.2f m/s " % v
print "Stress = %0.2e N/m^2 " %st
print "Percentage change in frequency = %0.1f %% " %td
# Frequency
#given data :
l=.50 # in m
m1=25 # in kg
m2=1.44*10**-3 # in kg
g=9.81 # in m/s**2
T=m1*g
m=m2/l
p=2
n=(p/(2*l))*sqrt(T/m)
print "The frequency, n = %0.1f " %n
# frequency
l1=90 #cm
d1=0.05 #cm
d2=0.0625 #cm
l2=60 #cm
n1=200 #Hz
n2=((l1*d1*n1)/(l2*d2)) #Hz
print "Frequency = %0.2f Hz " % n2
# tension
n21=3/2 #
r21=3/4 #
t1=2.048 #kg. wt
t2=(n21*r21)**2*t1 #kg weight
n31=9/4 #
r31=2/4 #
t3=(n31*r31)**2*t1 #kg-weight
n41=27/8 #
r41=1/4 #
t4=(n41*r41)**2*t1 #kg-weight
print "Tension, T2 = %0.3f kg weight"%t2
print "Tension, T3 = %0.3f kg weight"%t3
print "Tension, T4 = %0.3f kg weight"%t4
from math import sqrt
# velocity
l1=20 #cm
v1=600 #cm**-1
n1=v1/4 #
v1=2*n1*l1*10**-2 #m/sec
v2=sqrt(2)*v1 #m/s
print "Velocity of the waves = %0.f m/s " %v1
print "Velocity of waves when tension of the string is doubled = %.f m/s " %round(v2)
# frequency
nb=6 #beats
l1=20 #cm
l2=21 #cm
x=l2/l1 #
n=(x*nb+nb)/(x-1) #
print "Frequency = %0.f Hz " %n
# frequency
nb=4 #beats
l1=70 #cm
l2=70-1 #cm
x=l2/l1 #
n=(x*nb)/(1-x) #
print "Frequency = %0.f Hz " %n
# length
n123=1/3/15 #
tl=105 #cm
l123=15/5/1 #
k=tl/21 #
l1=15*k #cm
l2=5*k #cm
l3=k #cm
print "l1 length = %0.f cm"%l1
print "l2 length = %0.f cm"%l2
print "l3 length = %0.f cm"%l3
#length l2 is calculated wrong in the textbook
from math import sqrt
# frequency
l=2.5 #m
m1=0.001 #kg
tn=4 #N
m=m1/l #kg/m
n=((1/(2*l))*sqrt(tn/m)) #Hz
print "Frequency = %0.2f Hz " %n
print "Frequencies stopped are",5*n,"Hz, ",10*n,"Hz, ",15*n,"Hz"
from math import pi
# frequency
l=1 #m
m1=0.5 #kg
tn=200 #N
m=m1/l #kg/m
n=((1/(2*l))*sqrt(tn/m)) #Hz
print "Frequency = %0.2f Hz " %n
w=2*pi*n #
print "Ratio of three frequencies is %0.1f:%0.1f:%0.1f"%(w,2*w,3*w)