from __future__ import division
q=-50 # Near point of an eye in cm
p=25 #object location in cm
#a) focal length calculation
#Using Thin Lens equation 1/f=((1/p)+(1/q))
f=p*q/(p+q)
print "a) focal length f = %0.2f cm"%f
#b) power of the lens
f1=50*10**-2# focal length in meters
P=1/f1
print "b) Power of the lens = %0.2f diopters"%P
f=10 # focal length in cm
#a)Maximum angular magnification
M_max=1+(25/f)
print "a) Maximum angular magnification of the lens : %0.2f"%M_max
m=25/f
print "Angular Magnification of lens when eye is relaxed : %0.2f"%m
#interchangeable objectives
f1=2 # focal length in cm
f2=0.2 #focal length in cm
#data of two eye pieces
f3=5 #focal length in cm
f4=2.5 #focal length in cm
L=18 # length of microscope
#Calculation of magnification for four combinations of lens
#magnification of compound microscope m =-(L/fo)*(25cm/fe) where fo is shortest focal length compared to fe
#combination of two long focal lengths
m1=-(L/f1)*(25/f3)
print "Magnification of microscope with two long focal lengths : %0.2f"%m1
#combination of 20 mm objective and 2.5 cm eyepiece
m2=-(L/f1)*(25/f4)
print "Magnification of microscope with a combination of 20 mm objective and 2.5 cm eyepiece : %0.2f"%m2
#combination of 2 mm objective and 5 cm eyepiece
m3=-(L/f2)*(25/f3)
print "Magnification of microscope with a combination of 20 mm objective and 2.5 cm eyepiece : %0.2f "%m3
#combination of two short focal lengths
m4=-(L/f2)*(25/f4)
print "Possible magnification of microscope with two short focal lengths : %0.2f"%m4
d=8 #diameter of objective mirror of reflecting telescope in inches
fo=1500 #focal length of objective mirror of reflecting telescope in mm
fe=18 #focal length of eyepiece
m=fo/fe
print "Angular magnification of the telescope : %0.2f"%m
l=589*10**-9 #Wavelength of sodium light m
d=90*10**-2 #diameter of the aperture in m
L=400*10**-9 #Wavelength of desirable Visble light
n=1.33 #refractive index of water
#a) Calculation of limiting angle of resolution
#Limiting angle of resolution of the circular aperture is Theta_min=1.22*(l/d)
Theta_min1=1.22*(l/d)
print "a) Limiting angle of resolution in radians : %0.2e"%Theta_min1
#b) Calculation of maximum limit of resolution for the microscope
Theta_min2=1.22*(L/d)
print "b) Maximum limit of resolution for the microscope in radians : %0.2e"%Theta_min2
#c)Effect of water b/w the object and objective on resolving power of microscope
lw=l/n
Theta_min3=1.22*(lw/d)
print "c) Limiting angle of resolution for the microscope when water filled the space b/w the object and objective in radians : %0.2e"%Theta_min3
f1=1000# focal length of objective of telescope A in mm
f2=1250# focal length of objective of telescope B in mm
f3=6# focal length of eyepiece of telescope A in mm
f4=25# focal length of eyepiece of telescope Bin mm
#C) Calculation of magnification of the telescope
m_A=f1/f3
m_B=f2/f4
print "Magnification of telescope A is : %0.2f"%m_A
print "Magnification of telescope B is : %0.2f"%m_B
L1=589 # wavelength of first bright line in sodium spectrum in nm
L2=589.59 # wavelength of second bright line in sodium spectrum in nm
m=2 # order of the spectrum
delta_L=L2-L1
R=L1/delta_L
print "a) Resolving poer of grating inorder to distinguish the wavelengths = %0.2f"% R
N=R/m
print "b) No.of lines of the grating illuminated to resolve the lines in the second order spectrum are %d"%N