The path light follows as it travels through a substance depends on the substance's index of refraction. This path is commonly known as the optical path length (OPL). In geometrical optics, the laws of reflection and refraction are simple examples for understanding the path of light travel from source to detector for constant values of the traveled substances' refraction indices. In more complicated situations, the Euler equation can be quite useful and quite important in optics courses. Here, the well-known Euler differential equation (EDE) is used to obtain the OPL for several index of refraction models. For pedagogical completeness, the OPL is also obtained through a modified Monte Carlo (MC) method, versus which the various results obtained through the EDE are compared. The examples developed should be important in projects involving undergraduate as well as graduate students in an introductory optics course. A simple matlab script (program) is included that can be modified by students who wish to pursue the subject further.

1.
E.
Hecht
,
Optics
, 5th ed. (
Pearson Education Inc.
,
Hoboken, NJ
,
2017
), pp.
109
113
.
2.
Richard P.
Feynman
,
Robert B.
Leighton
, and
Matthew
Sands
,
The Feynman Lectures on Physics
(
Addison-Wesley
,
Reading, MA
,
1964
), Vol.
1
, pp.
26-1
26-7
.
3.
A. G.
Rojo
, “
Hamilton's principle: why is the integrated difference of the kinetic and potential energy minimized?
,”
Am. J. Phys.
73
(
9
),
831
836
(
2005
).
4.
R.
Newburgh
, “
Optical path, phase, and interference
,”
Phys. Teach.
43
,
496
498
(
2005
).
5.
M.
Marklund
,
D.
Anderson
,
F.
Cattani
,
M.
Lisak
, and
L.
Lundgren
, “
Fermat's principle and the variational analysis of an optical model for light propagation exhibiting a critical radius
,”
Am. J. Phys.
70
(
7
),
680
683
(
2002
).
6.
G. W.
Forbes
, “
On variational problems in parametric form
,”
Am. J. Phys.
59
(
12
),
1130
1140
(
1991
).
7.
S. A.
Carvalho
and
S. D.
Leo
, “
The use of the stationary phase method as a mathematical tool to determine the path of optical beams
,”
Am. J. Phys.
83
(
3
),
249
255
(
2015
).
8.
C. G.
Gray
and
E. F.
Taylor
, “
When action is not least
,”
Am. J. Phys.
75
(
5
),
434
458
(
2007
).
9.
A.
Small
and
K. S.
Lam
, “
Simple derivations of the Hamilton-Jacobi equation and the eikonal equation without the use of canonical transformations
,”
Am. J. Phys.
79
(
6
),
678
681
(
2011
).
10.
D.
Anderson
,
F.
Andersson
,
P.
Andersson
, and
A.
Billander
, “
The optimal journey from A to B
,”
Am. J. Phys.
76
(
9
),
863
866
(
2008
).
11.
J.
Hanc
,
E. F.
Taylor
, and
S.
Tuleja
, “
Deriving Lagrange's equations using elementary calculus
,”
Am. J. Phys.
72
(
4
),
510
513
(
2004
).
12.
M. L.
Boas
,
Mathematical Methods in the Physical Sciences
, 2nd ed. (
Wiley
,
New York
,
1983
), pp.
386
388
.
13.
J. B.
Marion
and
S. T.
Thornton
,
Classical Dynamics of Particles and Systems
, 5th ed. (
Brooks/Cole
,
Belmont, CA
,
2004
), pp.
230
233
.
14.
J. E.
Hasbun
,
Classical Mechanics with MATLAB Applications
(
Jones & Bartlett
,
Sudbury, MA
,
2009
), pp.
470
490
.
15.
R. M.
Marinho
, Jr.
, “
Noether's theorem in classical mechanics revisited
,”
Eur. J. Phys.
28
,
37
42
(
2007
).
16.
M.
Born
and
E.
Wolf
,
Principles of Optics
, 7th ed. (
Cambridge U. P.
,
New York
,
1999
) pp.
853
869
.
17.
H.
Gould
and
J.
Tobochnick
,
An Introduction to Computer Simulation Methods
, 2nd ed. (
Addison-Wesley
,
Reading, MA
,
1996
), pp.
206
210
.
18.
MATLAB is a commercial product of Mathworks can be determined at <http://www.mathworks.com/>, and much of the code (with some occasional modifications) is compatible with Octave, the open source platform that's freely available from <https://www.gnu.org/software/octave/>. A Python translation of the Appendix MATLAB code, thanks to Steve Spicklemire, can be found here: <https://github.com/sspickle/MC_Optics_Hasbun>.
19.
J. R
Taylor
,
Error Analysis
, 2nd ed. (
University Science Books
,
Sausalito, CA
,
1997
) p.
187
.
AAPT members receive access to the American Journal of Physics and The Physics Teacher as a member benefit. To learn more about this member benefit and becoming an AAPT member, visit the Joining AAPT page.