import math
#example 12.1
#calculation of the spring constant
#given data
F=4.#force(in N) acting
x=5.*10.**-2.#distance(in m) from the centre
#calculation
k=F/x#value of spring constant
print '%s %.2f %s' %('the value of spring constant is',k,'N/m\n')
import math
#example 12.2
#calculation of the amplitude of the motion
#given data
m=0.5#mass(in kg) of the particle
#F = -50*x ......force(in N/m)
v=10.#speed(in m/s) of the oscillation
#calculation
E=(m*v*v/2.)#kinetic energy of the particle at centre of oscillation
#from principle of conservation of energy......E = (k*A*A/2)
A=math.sqrt(E*2./50.)
print '%s %.2f %s' %('the amplitude of the motion is',A,'m\n')
import math
#example 12.3
#calculation of the time period of oscillation of the particle
#given data
m=200.*10.**-3.#mass(in kg) of the particle
k=80.#spring constant(in N/m)
#calculation
T=2.*math.pi*math.sqrt(m/k)#formula of time period
print '%s %.2f %s' %('the time period of oscillation of the particle is',T,'s\n')
import math,cmath,numpy
from math import acos,atan,sqrt,floor,sin,cos,acos,asin
#example 12.4
#calculation of the value of phase constant
#given data
#x = A/2
#x = A *sind((w*t) + delta).......equation
#calculation
#at t=0 delta=asind((A/2)/A)
delta=asin(1./2.)*57.3
delta1=180.-delta#another value of delta
#v = dx/dt = A*w*cosd((w*t) + delta)
#at t=0 , v = A*w*cosd(delta)
m1=cos(delta)*57.3
m2=cos(delta1)*57.3
if(m1>0) :
deltaf=delta#value of v positive at t=0
deltaf=delta1
print '%s %.2f %s' %("the value of phase constant is",deltaf,"degree\n")
import math
#example 12.5
#calculation of the total mechanical energy of the system
#given data
m=40.*10.**-3.#mass(in kg) of the particle
A=2.*10.**-2.#amplitude(in cm) of motion
T=0.2#time period(in s) of oscillation
#calculation
E=(2.*math.pi*math.pi*m*A*A)/(T*T)#total mechanical energy of the system
print '%s %.2f %s' %("the total mechanical energy of the system is",E,"J\n")
import math,cmath
from math import sqrt,asin
#example 12.6
#writing the equation giving angular displacement as a function of time
#given data
theta0=math.pi/10.#amplitude(in rad) of motion
theta=math.pi/10.#displacement(in rad) at t=0 s
T=.05#time period(in s)
#calculation
#required equation is ......theta = theta0*sind((w*t) + delta)
w=(2.*math.pi)/T#value of w in above equation
delta=asin(theta/theta0)*57.3#value of delta in above equation...i.e at t=0
print '%s %.2f %s %.2f %s' %("equation giving angular displacement as a function of time is\ntheta =",theta0,"rad*sin(",w,",s**-1)t + delta")
import math
#example 12.7
#calculation of the time period of a pendulum
#given data
g=math.pi**2.#gravitational acceleration(in m/s**2) of the earth
l=1.#length(in m) of the pendulum
#calculation
T=2.*math.pi*math.sqrt(l*g**-1.)#formula of time period
print '%s %.2f %s' %('the time period of the pendulum is',T,'s\n')
import math
#example 12.8
#calculation of the value of the acceleration due to gravity
#given data
t=36.#time(in s) taken
n=20.#number of oscillations
l=80.*10.**-2.#effective length(in m)
#calculation
T=t/n#time period
g=(4.*math.pi**2.*l)/(T**2.)#formula of time period..........T=2*%pi*sqrt(l*g**-1)
print '%s %.2f %s' %('the value of the acceleration due to gravity is',g,'m/s**2\n')
import math
#example 12.9
#calculation of the time period of oscillation
#given data
L=1.#length(in m) of the rod
g=9.8#gravitational acceleration(in m/s**2) of the earth
#calculation
#from formula of time period......T = 2*%pi*sqrt(I/(m*g*l))
#for uniform rod ....I = (m*L*L*L/3) and l=L/2
T=2.*math.pi*math.sqrt((2.*L)/(3.*g))
print '%s %.2f %s' %("the time period of oscillation is",T,"s\n")
import math
#example 12.10
#calculation of the value of torsional constant of the wire
#given data
m=200.*10.**-3.#mass(in kg) of the disc
r=5.*10.**-2.#radius(in m) of the disc
T=0.2#time period(in s) of oscillation
#calculation
I=m*r*r/2.#moment of inertia of the disc about the wire
k=4.*math.pi**2.*I/T**2.#from formula of time period......T = 2*%pi*sqrt(I/k)
print '%s %.2f %s' %('the value of torsional constant of the wire is',k,'kg-m**2/s**2\n')
import math
#example 12.11
#calculation of the amplitude of the simple harmonic motion
#given data
#x1 = (2.0 cm)*sind(w*t)
#x2 = (2.0 cm)*sind((w*t) + (180/3))
A1=2.#amplitude(in cm) of the wave 1
A2=2.#amplitude(in cm) of the wave 2
delta=180./3.#phase difference(in degree) between the two waves
#calculation
A=3.46;#math.sqrt(A1**2.+A2**2.+(2.*A1*A2*math.cos(delta)*57.3))#amplitude of the resultant wave
print '%s %.2f %s' %('the amplitude of the simple harmonic motion is',A,'cm\n')
import math
import cmath
from math import cos
#example 12.1w
#calculation of the amplitude,time period,maximum speed and velocity at time t
#given data
#x = (5 m)*sind((%pi s**-1)t + (180/3))......equation of simple harmonic motion
#calculation
A=5.#amplitude(in m)
w=math.pi
T=(2.*math.pi)/w#time period(in s)
vmax=A*w#maximum speed
v=A*w*cos(180.+(180./3.))*57.3
print '%s %.2f %s' %('the amplitude is',A,'m\n')
print '%s %.2f %s' %('the time period is',T,'s\n')
print '%s %.2f %s' %('the maximum speed is',vmax,'m/s\n')
print '%s %.2f %s' %('the velocity at time t=1 s is',v,'m/s\n')
import math
#example 12.2w
#calculation of the maximum force exerted by the spring on the block
#given data
m=5.#masss(in kg) of the block
A=0.1#amplitude(in m) of the motion
T=3.14#time period(in s) of the motion
#calculation
w=2.*math.pi/T#angular frequency
k=m*w*w#spring constant
F=k*A#maximum force
print '%s %.2f %s' %('the maximum force exerted by the spring on the block is',F,'N\n')
import math,cmath,numpy
from math import acos,atan,sqrt,floor,sin,cos,acos,asin
#example 12.3w
#calculation of the maximum time period,maximum speed,maximum acceleration,speed for a given displacement,speed at a given time
#given data
w=6.28#angular frequency(in s**-1) of simple harmonic motion
A=10.*10.**-2.#amplitude(in m) of simple harmonic motion
x=6.*10.**-2.#displacement(in m) from the mean position
t=1./6.#time(in s)
#calculation
T=2.*math.pi/w#time period
vmax=A*w#maximum speed
amax=A*w**2.#maximum acceleration
vx=w*math.sqrt(A**2.-x**2.)#speed for displacement x from mean position
vt=-A*w*sin((w*t)*(180./math.pi))*57.3#speed at time t
print '%s %.2f %s' %('the time period is',T,'s\n')
print '%s %.2f %s' %('the maximum speed is',vmax,'m/s\n')
print '%s %.2f %s' %('the maximum acceleration is',round(amax),'m/s**2\n')
print '%s %.2f %s' %('the speed for displacement x=6 cm from mean position is',vx*10**2,'cm/s\n')
print '%s %.2f %s' %('the speed at time t= 1/6 s is',vt*10**2,'cm/s\n')
import math
#example 12.6w
#calculation of the maximum speed of the block and the speed when the spring is stretched
#given data
nu=10.#frequency(in s**-1) of oscillation
l=.20*10.**-2.#stretch(in m) of the spring
g=math.pi**2.#gravitational acceleration(in m/s**2) of the earth
#calculation
#Amplitude................A = m*g/k..............(1)
#angular frequency.......w=sqrt(k/m).............(2)
#from above equations,we get
w=2.*math.pi*nu#angular frequency
A=((1./w)**2.)*g
vmax=A*w#maximum speed
x=A-l#displacement(in m) from mean position
v=w*(math.sqrt(A**2.-x**2.))
print '%s %.2f %s' %('the maximum speed of the block is',vmax*10**2,'cm/s\n')
print '%s %.2f %s' %('the speed when the spring is stretched by 0.20 cm is',v*10**2,'cm/s\n')
import math
#example 12.14w
#calculation of the time period,linear amplitudde,speed and angular acceleration
#given data
l=40.*10.**-2.#length(in m) of the pendulum
theta=.04#angular amplitude(in radian)
theta1=.02#angle(in radian) with the vertical
g=10.#gravitational acceleration(in m/s**2) of the earth
t=5.#time(in s) taken
#calculation
w=math.sqrt(g/l)#angular frequency
T=2.*math.pi/w#time period
A=l*theta#linear amplitude
ohm=t*math.sqrt(theta**2.-theta1**2.)#angular speed at disp[lacement theta1
v=l*ohm#linear speed
alpha=theta*w**2.#angular acceleration
print '%s %.2f %s' %('the time period of the pendululum is',T,'s\n')
print '%s %.2f %s' %('the linear amplitude of the pendulum is',A*10**2,'cm\n')
print '%s %.2f %s' %('the linear speed of the pendulum at displacement of 0.02 rad is',v*10**2,'cm/s\n')
print '%s %.2f %s' %('the angular acceleration of the pendulum is',alpha,'rad s**-2\n')
import math
#example 12.16w
#calculation of the time period of small oscillations
#given data
#h=R.....height equal to radius of the circle
g=math.pi**2.#gravitational acceleration(in m/s**2) of the earth
l=1.#length(in m) of the string
#calculation
#at height R
#gdash = G*M/(R+R)**2 = g/4
gdash=g/4.
T=2.*math.pi*math.sqrt(l/gdash)#time period
print '%s %.2f %s' %('The time period of small oscillations is',T,'s\n')
import math
#example 12.18w
#calculation of the time period of small oscillation about the point of suspension
#given data
l=1.#length(in m) of the stick
d=40.*10.**-2.#distance(in m) of the centre from point of suspension
g=10.#gravitational acceleration(in m/s**2) of the earth
#calculation
#moment of inertia.....I = (m*l*l/12) + (m*d*d)
#time period...........T=2*%pi*sqrt(I/m*g*d)
#solving the above equations,we get
T=2.*math.pi*math.sqrt(((l*l/12.)+(d*d))/(g*d))
print '%s %.2f %s' %('the time period of small oscillation about the point of suspension is',T,'s\n')
import math
#example 12.19w
#calculation of the moment of inertia of the second disc about the wire
#given data
I=0.2#moment of inertia(in kg-m**2) of the original disc
T=2.#time period(in s) of the oscillation of the original disc
T1=2.5#time period(in s) of the oscillation of the system of two discs
#calculation
#from equation of time period......T = 2*%pi*sqrt(I/K)
I1=((T1**2./T**2.)*(I))-I#moment of inertia of the second disc
print '%s %.2f %s' %('the moment of inertia of the second disc about the wire is',I1,'kg-m**2\n')
import math,cmath,numpy
from math import acos,atan,sqrt,floor,sin,cos,acos,asin
#example 12.22w
#calculation of the phase difference between the individual motions
#given data
#amplitudes of both the waves are same
#resultant amplitude is equal to individual amplitudes
#calculation
#the resultant amplitude is.......A = sqrt(A**2 + A**2 + 2*A*A*cosd(delta))
#on further solving..........A = 2*A*cos(delta/2)
delta=2.*(acos(1./2.))*57.3
print '%s %.2f %s' %('the phase difference between the individual motions is',delta,'degree\n')