from __future__ import division
from numpy import sqrt
# ratio
ri=9/16 #ratio of intensities
ra=sqrt(ri) #ratio of amplitude
a1=1 #assume
a2=ra*a1 #
rim=(a1+a2)**2/(a1-a2)**2 #
print "Ratio of maximum intensity and minimum intensity in fringe system is %d"%rim,":",a1
from math import cos, pi
# intensity
I=1 #assume
a1=1*I #
a2=4*I #
ph1=0 #degree
i1=(a1+a2)+a2*cos(ph1*pi/180) #
print "Intensity where phase difference is zero =",i1,"*I"
ph2=90 #degree
i2=(a1+a2)+a2*cos(ph2*pi/180) #
print "Intensity where phase difference is pi/2 =",i2,"*I"
ph3=180 #degree
i3=(a1+a2)+a2*cos(ph3*pi/180) #
print "Intensity where phase difference is pi is =",i3,"*I"
# Wavelength and frequency
#given data :
d=30 # in cm
lamda=2*d*10**-2
v=330 # in m/s
print "The wavelength = %0.2f m " %lamda
n=v/lamda
print "The frequency, n = %0.2f vibrations/s " %n
# number of beats and time interval
from fractions import Fraction
n1=300 #Hz
n2=303 #Hz
bfs=n2-n1 #
print "Beat frequency = %0.2f per second " %bfs
ti=Fraction(1/bfs).limit_denominator(3) #second
print "Time interval =",ti,"second "
# Frequency
#given data :
n1=256 # in Hz
x=4 # in beats per sec
n2a=n1+x
n2b=n1-x
print "The frequency, n2a = %0.2f Hz " %n2a
print "The frequency, n2b = %0.2f Hz "% n2b
# Frequency
#given data :
nA=256 # in Hz
x=5 # in beats per sec
nB1=nA+x
nB2=nA-x
print "The frequency, nB = %0.f Hz or %0.f Hz" %(nB1, nB2)
# Frequency
#given data :
nB=512 # in Hz
x=5 # in beats per sec
nA1=nB+x
nA2=nB-x
print "The frequency of A, nA = %0.f Hz or %0.f Hz" %(nA1, nA2)
# Velocity of sound
#given data :
lamda1=1 # in m
lamda2=1.01 # in m
a=10/3 # in beats/sec
v=a/((lamda2-lamda1)/(lamda1*lamda2))
print "The velocity of sound, v = %0.1f m/s " %v
# Frequency
n=273 #
b1=4 #beats per second
b2=b1-1 #
t1=15 #degree celsius
t2=10 #degree celsius
v1510=sqrt((n+t1)/(n+t2)) #
n=((b2*v1510-b1)/(1-v1510)) #
print "Frequency = %0.2f Hz " %n
# Frequency
b1=10 #beats per second
f1=300 #Hz
b2=15 #beats per second
f2=325 #Hz
n1=f1-b1 #Hz
n2=f1+b1 #Hz
n3=f2-b2 #Hz
n4=f2+b2 #Hz
print "Frequency = %0.2f Hz " %n2
# Velocity of sound
#given data :
lamda1=5 # in m
lamda2=5.5 # in m
a=6 # beats/sec
v=a/((lamda2-lamda1)/(lamda1*lamda2))
print "The velocity of sound, v = %0.2f m/s " %v
# Frequency
b1=5 #beats per second
fr=384 #Hz
fo=fr-b1 #Hz
print "Frequency = %0.2f Hz " %fo
# Frequency
b1=4 #beats per second
fr=256 #Hz
fo1=fr+b1 #Hz
fo2=fr-b1 #Hz
print "Frequency = %0.f Hz or %0.f Hz" %(fo1,fo2)
#Frequency,wavelength, velocity and amplitude
#given data :
a=6 # in cm
lamda=10 # in cm
T=1/10 # in sec
print "Wavelength of progressive wave = %0.2f cm " %lamda
n=1/T
print "Frequency of progressive wave, n = %0.2f per sec " %n
v=n*lamda
print "The velocity, v = %0.2f cm/s " %v
print "The amplitude, a = %0.2f cm " %a
#Velocity
#given data :
c=3*10**8 # in m/s
lamda1=4000 # in Angustrom
lamda2=5000 # in Aungustrom
mu1=1.540
mu2=1.530
vg=c*((mu1*lamda1)-(mu2*lamda2))/(mu1*mu2*(lamda1-lamda2))
print "The velocity, vg = %0.3e m/s " %vg
#Velocity
#given data :
v=1.8*10**8 # in m/s
lamda=3.6*10**-7 # in m
dv_dlamda=3.8*10**13 # in per sec
vg=v-(lamda*dv_dlamda)
print "The group velocity, vg = %0.2e m/s " %vg