Professional Documents
Culture Documents
Lenses: Python Code
Lenses: Python Code
Lenses: Python Code
Simulation
1) Create a python code that will generate a value for the location, magnification and height of the
image formed, as well as the nature of the image produced given the focal length of the lens,
type of lens and object distance as input.
Python Code
import numpy as np
from matplotlib import pyplot as plt
O= 15
f= 15
ho = 1
#IMAGE DISTANCE
if(O!=f):
I = 1/((1/f)-(1/O))
#MAGNIFICATION
M = I/O
#IMAGE HEIGHT
hi = M*ho
print("Image distance:", I)
print("Image Height:", hi)
print("Magnification:", M)
Questions:
1. Compare your theoretical values (from Python) with the experimental values. Comment on the
similarities and differences. Explain the cause of difference in results.
Our python code proved our theoretical values to be accurate as our results only varied by
magnitudes up to 5mm. The slight inaccuracy’s are most likely due to our readings being
misinterpreted, as our method for gathering Image distance was done by estimating(without a
computer).
2. Double-lens System
i) 2 lenses of focal lengths of focal lengths 75 mm and 150 mm are 35 cm apart from each other. If
an object is placed in 15 cm front of the 75 mm – lens, determine the following for the final image
produced by the lens system:
a) Distance of the final image from the 150 mm – lens
60 cm
b) Distance of the final image from the 75 mm – lens
95cm
c) Magnification of the final image with respect to the object
ML1 = 15cm/15cm = 1
ML2 = 60cm/15cm = 4
MT = 4*1 = 4
ii) Show your working that includes ray diagram for the system.
Our experimental results showed the final image to be at a distance of 59 cm from the 150mm lens,
this value has a 1.68% percentage difference to our theoretical result. The slight inaccuracy’s are
most like likely due to the uncertainty’s in measurements, as we have four different variables(75mm
lense,150mm lensed, object, target) that could be slightly off, skewing our results.