#Example 22_1
import math
#To find the position and size of the image
d1=5 #units in cm
d2=30 #units in cm
i=(d1*d2)/(d2-d1) #Units in cm
d3=2 #units in cm
I=(i/d2)*d3 #units in cm
print "The position of the image is i=",round(i)," cm\nThe Size of the image is I=",round(I,2)," cm High"
#Example 22_2
import math
#To find the location of the image
d1=10 #units in cm
d2=5 #units in cm
i=(d1*d2)/(d2-d1) #Units in cm
print "The position of the image is i=",round(i)," cm"
#Example 22_3
import math
#To find the location of the image and its relative size
r=100.0 #Unts in cm
d1=-r/2 #units in cm
d2=75.0 #units in cm
i=(d1*d2)/(d2-d1) #Units in cm
p=75 #units in cm
sizee=-i/p #units in cm
print "The location of the image is i=",round(i)," cm\n The relative size of the image is I_O=",round(sizee,2)," cm"
#Example 22_4
import math
#To find the angle at which the light emerge in to the air
theta=37 #Units in degrees
n1=1.33 #Units in constant
n2=1 #Units in constant
thetaa=math.asin((n1*math.sin(theta*math.pi/180))/n2)*180/math.pi #units in degrees
print "The angle at which the light emerges in air is theta=",round(thetaa)," degrees"
#Example 22_5
import math
#At what angle does the light emerges from the bottom of the dish
print "We have Theta1=Theta4 \nWhich shows that A unform layer of transparent material does not change the direction of the beam of light"
#Example 22_6
import math
#To draw a ray diagram to locate the image
print "From the diagram we notice that eyes will assume that the three rays come from image position indicated and as we see the image is virtual, erect and enlarged"
d1=10 #units in cm
d2=5 #units in cm
i=(d1*d2)/(d2-d1) #Units in cm
print "\nThe image is located at i=",round(i,2)," cm"
#Example 22_7
import math
#To find the image position by means of the ray diagram
print "From the ray diagram we have noticed that the image is virtual, erect and dimnished in size"
d1=5 #units in cm
d2=-10 #units in cm
i=(d1*d2)/(d2-d1) #Units in cm
print "\nThe image is located at i=",round(i,2)," cm"
#Example 22_8
import math
#To find the image positon and size
d1=-20 #units in cm
d2=40.0 #units in cm
i=(d1*d2)/(d2-d1) #Units in cm
print "\nThe image is located at i=",round(i,2)," cm"
d3=3.0 #units in cm
I=(-i*d3)/d2 #units in cm
print "\nThe Size of the image is I=",round(I)," cm"