#import modules
import math
#Variable declaration
S=4; #SHM described by a particle(cm)
x=0; #mean position
v=12; #velocity at mean position(cm/s)
#Calculation
A=S/2; #amplitude of motion(cm)
omega=v/A; #angular frequency(sec-1)
T=(2*math.pi)/omega; #time period(sec)
T=math.ceil(T*10**3)/10**3; #rounding off to 3 decimals
#Result
print "time period of motion is",T, "sec"
print "time period of motion is pi/3 sec"
#import modules
import math
#Variable declaration
T=0.1; #time period(sec)
A=4; #amplitude of motion(cm)
x=0.2; #distance from mean position(cm)
#Calculation
omega=(2*math.pi)/T; #angular frequency(sec-1)
a=(omega**2)*x; #acceleration(cm/sec^2)
a=math.ceil(a*10**2)/10**2; #rounding off to 2 decimals
#maximum velocity is when particle is in the mean position
v_max=omega*A; #maximum velocity(cm/sec)
v_max=math.ceil(v_max*10**2)/10**2; #rounding off to 2 decimals
#Result
print "acceleration is",a, "cm/sec^2"
print "maximum velocity is",v_max, "cm/sec"
#answers given in the book are wrong
#import modules
import math
import numpy as np
#Variable declaration
A1 = 40; #First amplitude of oscillation(cm)
An_plus_1 = 4; #Amplitude after 100 oscillations(cm)
n = 100; #Number of oscillations
T = 2.5; #Time period of oscillations(s)
#Calculation
t = T/4; #Time taken to reach the first amplitude from the mean position(s)
#Now A1 = x0*math.exp(-lambda*t) and An_plus_1 = x0*math.exp(-lambda*(t+nT))
#A1/An_plus_1 = math.exp(n*lambda*T)
x=A1/An_plus_1;
lamda=np.log(x)/(n*T); #Damping constant(per sec)
lamda=lamda*10**2;
lamda=math.ceil(lamda*10**3)/10**3; #rounding off to 3 decimals
#Result
print "Damping constant is",lamda,"*10**-2 per sec"
#import modules
import math
#Variable declaration
x1 = 3; #First position of the particle(cm)
x2 = 4; #Second position of the particle(cm)
v1 = 16; #Velocity of particle executing SHM at 1st position(cm/s)
v2 = 12; #Velocity of particle executing SHM at 2nd position (cm/s)
#Calculation
#As v = omega*sqrt(A**2 - x**2) so
#(v1/v2)**2=(A**2 - x1**2)/(A**2 - x2**2)
#RHS gives (A**2-9)/(A**2-16)
#(v2**2)*(A**2 - x1**2)=(v1**2)*(A**2 - x2**2), on solving we get
A=math.sqrt((((v1**2)*(x2**2))-((v2**2)*(x1**2)))/((v1**2)-(v2**2))); #amplitude in cm
omega=v1/math.sqrt(A**2-x1**2); #Angular speed of the particle(per sec)
T=2*math.pi/omega; #Time period of oscillation(sec)
T=math.ceil(T*10**3)/10**3; #rounding off to 3 decimals
#Result
print "The amplitude of SHM is",A, "cm"
print "The time period of oscillation is",T, "sec"
#import modules
import math
#Variable declaration
m = 0.3; #Mass attached to the string(kg)
g = 9.8; #Acceleration due to gravity(m/sec**2)
x = 0.15; #Stretchness produced in the spring(m)
s = 0.1; #spring is stretched and released(m)
#Calculation
F = m*g; #Restoring force acting on the mass(N)
k = F/x; #Spring constant(N/m)
A = s; #amplitude equals to the spring stretched and released
omega = math.sqrt(k/m); #Angular frequency of oscillation(rad per sec)
v0 = omega*A; #Maximum velocity during the oscillations(m/s)
v0=math.ceil(v0*100)/100; #rounding off to 2 decimals
#Result
print "The spring constant is",k, "N/m"
print "The amplitude of oscillation is",A, "m"
print "The maximum velocity during oscillations is",v0, "m/s"
#import modules
import math
#Variable declaration
lambda1 = 400; #Lower limit of wavelength of visible region(nm)
lambda2 = 700; #Upper limit of wavelength of visible region(nm)
c = 3*10**8; #Speed of light in vacuum(m/s)
#Calculation
lambda1 = lambda1*10**-9 #Lower limit of wavelength(m)
lambda2 = lambda2*10**-9 #upper limit of wavelength(m)
new_1 = c/lambda1; #Upper limit of frequency of visible region(m)
new_2 = c/lambda2; #Lower limit of frequency of visible region(m)
#Result
print "The frequency equivalent of 400 nm is",new_1, "Hz"
print "The frequency equivalent of 700 nm is",new_2, "Hz"
#import modules
import math
from __future__ import division
#Variable declaration
#Comparing the standard equation u(x,t) = A*sin(2*%pi(x/lambda-t/T)) with the given equation, we get
A = 1.5*10**-3; #Amplitude of the sound wave(m)
lamda = 8; #Wavelength of the sound wave(m)
T = 1/40; #Time period of the sound wave(s)
#Calculation
A = A*10**3;
new = 1/T; #Frequency of the sound wave(Hz)
v = new*lamda; #Velocity of the sound wave(m/s)
T=math.ceil(T*100)/100; #rounding off to 2 decimals
#Result
print "The amplitude of the sound wave is",A,"*10**-3 m"
print "The wavelength of the sound wave is",lamda, "m"
print "The time period of the sound wave is",T, "s"
print "The frequency of the sound wave is",new, "Hz"
print "The velocity of the sound wave is",v, "m/s"
#import modules
import math
from __future__ import division
#Variable declaration
A = 2; #Amplitude of the wave(cm)
T = 0.5; #Time period of the wave(sec)
v = 200; #Wave velocity(cm/s)
#Calculation
f = 1/T; #Frequency of the wave(Hz)
lamda = v/f; #Wavelength of the wave(cm)
#Result
print "frequency of wave is",f, "Hz"
print "wavelength of wave is",lamda, "cm"
print "The Equation of the wave moving along X-axis :"
print "u = ",A,"*sin*2*math.pi*(x/",lamda,"- t/",T,")" #x and y are in cm and t is in sec
#import modules
import math
from __future__ import division
#Variable declaration
T = 1000; #Tension in the wire(N)
M=15; #mass of the wire(kg)
l=300; #length of the wire(m)
lamda = 0.30; #Wavelength of wave along wire(m)
#Calculation
m = M/l; #Mass per unit length of the wire(kg/m)
v = math.sqrt(T/m); #Velocity of wave through wire(m/s)
v=math.ceil(v*100)/100; #rounding off to 2 decimals
new = v/lamda; #Frequency of wave through string(Hz)
new=math.ceil(new*100)/100; #rounding off to 2 decimals
#Result
print "The velocity of the wave through wire is",v, "m/s"
print "The frequency of the wave through wire is",new, "Hz"
#answer for frequency of the wave is wrong in the textbook