from __future__ import division
# Speed
#given data :
vl=166 #m/s
v=(2*vl) #m/s
print "Speed = %0.f m/s " %v
# frequency
#given data :
f1=90 #vibrations/second
f2=(1+(1/10))*f1 #vibrations/s
print "Frequency = %0.f vibrations/s "%f2
# frequency
#given data :
N=400 #hZ
V=340 #M/S
VS=60 #M/S
N2=((V/(V-VS))*N) #Hz
print "Frequency when engine is approaching to the listner = %0.f Hz " %round(N2)
N3=((V/(V+VS))*N) #Hz
print "Frequency when engine is moving away from the listner = %0.f Hz " %N3
#WAVELENGTH
x=1/5 #
h=60 #cm
h1=((1-x)*h) #cm
h2=((1+x)*h) #cm
print "Wavelength of waves in north-direction = %0.f cm " %h1
print "Wavelength of waves in south-direction = %0.f cm" %h2
#frequency
v=340 #m/s
n=600 #Hz
vs=36 #km h**-1
vs1=vs*(1000/3600) #m/s
apf=((v)/(v-vs1))*n #Hz
vs2=54 #km h**-1
vs3=vs2*(1000/3600) #m/s
apf1=((v)/(v+vs3))*n #Hz
print "Two apparent frequencies are",round(apf,1),"Hz and",round(apf1,2),"Hz."
df=apf-apf1 #Hz
print "Difference in frequencies = %0.2f Hz" %df
#second apparent frequency and difference is calculated wrong in the textbook
#frequency
v=330 #m/s
n=500 #Hz
vs=30 #km h**-1
vs1=vs*(1000/3600) #m/s
n3=((v+vs1)/(v-vs1))*n #Hz
print "Frequency when cars are approaching = %0.f Hz " %round(n3)
n1=((v-vs1)/(v+vs1))*n #Hz
print "Frequency when cars have crossed = %0.f Hz" %round(n1)
#frequency
v=330 #m/s
n=600 #Hz
vs=20 #m/s
apf=((v)/(v+vs))*n #Hz
print "Frequency when source is moving away from the observer = %0.f Hz " %round(apf)
apf1=((v)/(v-vs))*n #Hz
print "Frequency when siren reaching at the cliff = %0.f Hz " %round(apf1)
bf=apf1-apf #Hz
print "Beat frequency = %0.f Hz " %round(bf)
from math import pi
#frequency
r=3 #m
w=10 #s**-1
vs=r*w #m/s
A=6 #m
fd=5/pi #s**-1
vmax=A*2*pi*fd #m/s
v=330 #m/s
n=340 #Hz
nmax=((v+vmax)/(v-vs))*n #Hz
nmin=((v-vmax)/(v+vs))*n #Hz
print "Maximum frequency = %0.f Hz " %nmax
print "Minimum frequency = %0.f Hz " %nmin
#speed
n12=3 #
n=340 #Hz
v=340 #m/s
vs=((n12*v)/(2*n)) #m/s
print "Speed = %0.2f m/s " %vs
from math import sqrt
#frequency
sa=1.5 #km
oa=1 #km
so=sqrt(oa**2+sa**2) #km
csd=sa/so #
v=0.33 #km/s
n=400 #Hz
vlov=120*(1000/3600) #m/s
vs1=(1/30)*csd #km/s
nd=((v)/(v-vs1))*n #vibrations/sec
print "Apparent frequency = %0.f vibrations/second " %round(nd)
#frequency
v=1200 #km/h
w=40 #km/h
vs=40 #km/h
n=580 #Hz
nd=((v+vs)/((v+vs)-vs))*n #Hz
print "Frequency of the whistle as heared by an observer on the hill = %0.2f Hz " %nd
x=29/30 #km
print "Distance = %0.2f m " %(x*1000)
ndd=((v-w)+vs)/((v-w))*nd #Hz
print "Frequency heared by driver = %0.2f Hz " %ndd
#distance is calculated wrong in the textbook
#doppler shift and velocity
h1=6010 #Å
h2=6000 #Å
ds=h1-h2 #Å
print "Doppler shift = %0.f Å " %ds
c=3*10**8 #m/s
v=((ds/h2)*c) #m/s
print "Speed = %0.e m/s " %v
#doppler shift and velocity
h1=3737 #Å
h2=3700 #Å
ds=h1-h2 #Å
print "Doppler shift = %0.f Å " %ds
c=3*10**8 #m/s
v=((ds/h2)*c) #m/s
print "Speed = %0.e m/s " %v
#speed is calculated wrong in the textbook
#speed
dv=10**3 #Hz
v=5*10**9 #Hz
c=3*10**8 #m/s
v=((dv)/(2*v))*c #m/s
print "Velocity = %0.f m/s " %v