Next Article in Journal
Terahertz Optoelectronic Properties of Monolayer MoS2 in the Presence of CW Laser Pumping
Previous Article in Journal
Quantum Scattering by Multiple Slits—A Lippmann–Schwinger Approach
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Communication

Derivation of the Ray Equation from Snell’s Law

by
Carmen Toro-Castillo
1,†,
Joel Cervantes-Lozano
2,
David I. Serrano-García
2 and
Héctor O. González-Ochoa
3,*
1
Departamento de Bioingeniería Traslacional, Universidad de Guadalajara, Blvd. Marcelino García Barragán 1421, Guadalajara 44430, Mexico
2
Departamento de Ingeniería Electro-Fotónica, Universidad de Guadalajara, Blvd. Marcelino García Barragán 1421, Guadalajara 44430, Mexico
3
Departamento de Física, Universidad de Guadalajara, Blvd. Marcelino García Barragán 1421, Guadalajara 44430, Mexico
*
Author to whom correspondence should be addressed.
Deceased.
Physics 2025, 7(3), 26; https://doi.org/10.3390/physics7030026
Submission received: 9 April 2025 / Revised: 19 May 2025 / Accepted: 19 June 2025 / Published: 9 July 2025
(This article belongs to the Section Physics Education)

Abstract

The one-dimensional ray equation, the differential description of Fermat’s principle, is deduced directly from Snell’s law using two methods. In the first method, we obtain the ray equation from a differential equation relating the spatial coordinates derivative with the index of refraction field. In the second method, the ray equation is deduced from the proper generalization of Snell’s law for a refractive field, that is, a differential equation relating the index of refraction field and the refraction angle. Additionally, we used an intermediate expression of the first method to find a straightforward analytical solution of the ray path to an inferior mirage.

1. Introduction

The ray equation constitutes a fundamental approach to determine the path of a light ray (or a ray of any electromagnetic wave) given the local light speed [1] and reads
n = d d s n d r d s ,
where n is the index of refraction at any point in the propagating medium, r is the position vector of the light ray and s is the arc length along the ray trajectory. Solutions to the ray equation embody the answer to the problem in geometrical optics of calculating the trajectory of a light ray given the optical properties of the medium and the initial conditions. The equation has applications ranging from light paths through steady-state non-homogeneous atmosphere, like mirages, to the design of gradient-index materials [2]. The ray equation is analogous to the Euler–Lagrange equation. The former is deduced [3,4,5] from Fermat’s principle [6], a variational principle which plays in optics the role that the principle of least action plays in classical mechanics. Fermat’s principle states that the actual path travelled by a light ray between any two points is that for which the optical path length (and equivalently the transit time) between those points is an extremum, generally a minimum.
A former approach to describe the light trajectory in more restricted situations is Snell’s law, which relates the angles of incidence and transmittance (refraction) of a ray propagating across an infinitely sharp interface separating two media with different indices of refraction. Snell’s law was initially deduced by Ibn Sahl in 984 (see, e.g., [7]) but took its name after Willebrord Snellius who rediscovered it in 1621 [8].
This paper presents a pedagogically motivated derivation of the ray equation from Snell’s law. While it is well established that Snell’s law can be derived from the ray equation, as can be encountered in the literature [9,10], our approach reverses this path by deducing the continuous ray equation from Snell’s law in the discrete case. This reversed construction, to the best of our knowledge, has not been reported in the academic literature and can serve as an accessible conceptual bridge for students in pedagogical contexts. The derivation, though restricted to the one-dimensional form of the ray equation, is significant because Snell’s law is a less-general principle compared to the ray equation, which governs the trajectory of light in continuous media with varying refractive indices. The purpose of this paper is strictly educational: to provide an alternative approach that is accessible to undergraduate students with knowledge in geometric optics and circumvents the use of variational calculus. While standard treatments derive the ray equation via Fermat’s principle and variational methods [3], approaches that are elegant but often abstract, the consideration in this paper focuses on a concrete construction using layered media and limiting procedures.
The connection between Fermat’s principle and Snell’s law is classical: Snell’s law follows as a direct result when extremizing or minimizing the time taken by a light ray between two points in media with different refractive indices. Moreover, more general derivations of ray equations under smooth, non-linear boundaries and higher dimensions have been presented [9].
We present two methods to accomplish the task. In the first method, we obtain a differential equation relating the derivative of the Cartesian coordinates and the index of refraction field, an equation obtained earlier by Peter Dyson via a different approach [11]. Instead, we follow a detailed derivation considering a two-dimensional stratified medium composed of layers with different indices of refraction. By making infinitesimal the layer width, we develop a continuous description. From the equation obtained, called throughout the Dyson’s expression, we deduce the ray equation. In the second method, we generalize Snell’s law by means of a differential equation relating the refractive index field and the refraction angle with its derivative. The expression obtained is the differential analogous to Snell’s law so its integration brings back to Snell’s law. Then, from this expression, we get the ray equation.
Snell’s law predicts that the product n sin θ , where θ is the refraction angle, remains constant when a light ray passes from one medium to another. In Ref. [12], it was demonstrated that, for the general case where the refractive properties of the medium are determined by a variable index field, this assertion only holds when the gradient of the refraction index is unidirectional. This is equivalent to the refractive index being a continuous function of a single spatial variable. The approach used here naturally reproduces the known result that n sin θ remains constant along the ray path when the gradient of the refractive index is unidirectional and is consistent with the findings of Ref. [12]. However, let us emphasize that the current study does not attempt to verify the results of Ref. [12] in the more general case of multidirectional gradients which are beyond the scope of the present study.
David Allwright obtained Fermat’s principle from Snell’s law when the propagation region is free from caustics [13]. This bears resemblance to the current study as the ray equation is commonly deduced from Fermat’s principle. With this in mind, let us emphasize key differences. Fermat’s principle connects a local refraction condition to a global variational principle governing light propagation but does not explicitly describe how rays evolve in a specific medium or situation. On the other hand, the ray equation offers a concrete mathematical tool aimed at providing a quantitative description of ray dynamics.
In the final part of this paper—in Section 3—we use Dyson’s expression to obtain an analytical solution to the path followed by a light ray in an inferior mirage. This problem is solved starting from the ray equation [14]. Although Dyson’s expression is less general than the ray equation, the Dyson’s expression can be applied more straightforwardly to the problem, this being the reason why the Dyson’s approach is chosen.

2. Derivation of the Ray Equation

2.1. Method 1

Consider an optical medium formed by a stack of k parallel layers immersed in a medium of index of refraction n 0 , as shown in Figure 1. The ith layer has a width Δ x i and index of refraction n i . A light ray impinges at the point ( x 0 , y 0 ) on the left interface of the first layer, subtending an angle θ 0 with respect to the interface normal. The transmitted ray forms a refracted angle θ 1 with respect to the normal, which can be calculated from Snell’s law:
n 0 sin θ 0 = n 1 sin θ 1 .
An elementary calculation gives the height y 1 at which the ray meets the interface between layers 1 and 2 with an angle θ 1 :
y 1 = y 0 + tan θ 1 Δ x 1 ,
where Δ x 1 = x 1 x 0 . Repeating the procedure for ray height y k , at the right interface of the kth layer, one has
y k = y 0 + i = 1 k tan θ i Δ x i ,
where Δ x i = x i x i 1 . One can express tan θ i as
tan θ i = sin θ i 1 sin 2 θ i .
Calculating the square root of 1 sin 2 θ i in Equation (5) introduces a plus–minus sign not shown in Equation (5) and subsequent equations for simplicity. The transmission angle, θ i , of the ray exiting the interface at x i 1 is equal to the incident angle with the interface at x i because the interfaces are parallel or equivalently, changes in the index of refraction only occur along the x-axis. Thus, n i sin θ i = n 0 sin θ 0 is constant. Multiplying and dividing Equation (5) by n i and substituting the result into Equation (4) leads to
y k = y 0 + i = 1 k n 0 sin θ 0 n i 2 ( n 0 sin θ 0 ) 2 Δ x i .
Taking the limit when Δ x i tends to zero, n i n ( x ) , one has
y ( x ) = y 0 + x 0 x n 0 sin θ 0 n 2 ( n 0 sin θ 0 ) 2 d x .
Differentiating Equation (7) with respect to x, one obtains Dyson’s expression
d y d x = n 0 sin θ 0 n 2 ( n 0 sin θ 0 ) 2 .
Let us emphasize that, in the transition to the continuous, n i sin θ i becomes n sin θ , where n = n ( x ) and θ = θ ( x ) are smooth functions of x, and θ is the instantaneous angle between the ray direction and the x axis. While n and sin θ are variables, their product remains constant, so
n sin θ = n 0 sin θ 0 = a .
Thus, clearing for n in Equation (8) and differentiating (9) with respect to x, one has
d n d x = a y ( y ) 2 1 + ( y ) 2 ,
where the prime denotes x-derivative. Noting that
d d x 1 y = y ( y ) 2 ,
and
d s d x = 1 + d y d x 2 ,
where s is the arc length along the ray trajectory, one rearranges Equation (10) by substitution into it of Equations (11) and (12) to get
d n d x = a d d x 1 y d x d s .
With y = tan θ and inserting the constant a = n sin θ into the derivative, one finds
d n d x = d d x n sin θ tan θ d x d s .
Let us emphasize that although we write the quantity a within the derivative in Equation (14), this does not imply that a varies with x in the case considered. Under the assumption of a unidirectional refractive index gradient, a = n sin θ = n 0 sin θ 0 remains constant along the ray path. The inclusion of a into the derivative is a formal mathematical step, introduced to facilitate the algebraic manipulation leading to the final form of the ray equation. This symbolic treatment does not contradict the physical constancy of a, as dictated by Snell’s law. The differential element of arc length along the ray path d s corresponds to the hypotenuse of an infinitesimal triangle with sides d x and d y and subtends an angle θ with the x axis (see inset of Figure 1), thus cos θ = d x / d s . Making these substitutions, one has
d n d x = d d x n d x d s d x d s .
Applying the chain rule to the right-hand-side of Equation (15), one gets
d d s n d x d s = d d x n d x d s d x d s .
and finally,
d n d x = d d s n d x d s .
which is the one-dimensional expression of the ray Equation (1).

2.2. Method 2

A different approach can start from Equation (18), the expression of Snell’s law for a refractive index field. This relates the refractive angle θ , and the index of refraction n, at an arbitrary point in the light path, with the infinitesimal change in the refractive angle d θ , when the light ray propagates an arc of differential length d s , through which the index of refraction changes an infinitesimal amount d n :
n sin θ = ( n + d n ) sin ( θ + d θ ) .
Using the angle sum identity of the sine and given that cos d θ = 1 , sin d θ = d θ , and d n d θ cos θ = 0 , one finds
d n d θ + n cot θ = 0 .
Note that integration of Equation (19) gives Snell’s law (9), as it has to. Thus, differentiating Equation (9) constitutes a more straightforward way to obtain Equation (19); however, we choose the method shown to circumvent the explicit incorporation into the equations of the constant a = n 0 sin θ 0 . Now, given that d n / d θ = ( d n / d s ) ( d s / d θ ) and cot θ = d x / d y , one has
d n d s = n y κ ,
where κ = d θ / d s is the curvature of the ray path. Using the chain rule for d n / d s = ( d n / d x ) ( d x / d s ) , the expression for curvature κ = y / [ 1 + ( y ) 2 ] 3 / 2 , and multiplying and dividing Equation (20) by y , one obtains
d n d x d x d s = n y y ( y ) 2 [ 1 + ( y ) 2 ] 3 / 2 .
Using Equations (11) and (12), one finds:
d n d x = n d d x 1 y d y d x d x d s d x d s .
By substituting ( d y / d x ) ( d x / d s ) = d y / d s = sin θ and y = tan θ into Equation (22), and inserting n sin θ into the derivative, one gets Equation (14) from which the ray Equation (17) was already obtained.

3. Analytical Solution of Mirage Ray-Path

Equation (8) is a differential equation of more natural interpretation and implementation than the one-dimensional ray Equation (17). Equation (8) allows the calculation of ray trajectory in a medium where the index of refraction is a continuous function of the spatial position. Despite its simplicity and elementary of deduction, Equation (8) is not taught in undergraduate courses and textbooks on optics (see, e.g., Refs. [1,15,16,17]). Let us apply Equation (8) to calculate the light path in an inferior mirage.
Inferior mirages form when light rays are refracted by a gradient of hot air which develops right above heating ground, typically sand or asphalt. As height increases, air becomes cooler and, in the absence of convection currents, denser, which produces an increasing index of refraction. An intuitive conclusion based on geometrical optics considerations leads to a belief that rays should remain horizontal when reaching the minimum and not bend; however, this has been discussed and solved [11,18,19,20].
According to Robert Fleagle, the air temperature profile decays exponentially with height [21], so the index of refraction can be exppressed as follows [14,22]:
n 2 ( x ) = n g 2 + n 1 2 [ 1 exp ( α x ) ] ,
where n g is the air index of refraction at the ground surface, and n 1 and α are constants. Note that, in the description given here, the x-coordinate corresponds to the height over the ground and a refractive index is chosen increasing as x increases, opposed to what is depicted in Figure 1; see Figure 2 for reference. Substitution of Equation (23) into Equation (8) gives
d y d x = p 1 q exp ( α x ) ,
where p = n 0 sin θ 0 / η , q = n 1 2 / η 2 , and η 2 = n g 2 + n 1 2 ( n 0 sin θ 0 ) 2 . Equation (24) can be solved by basic integration methods; then, one gets
y = y 0 ± p α ln 1 q exp ( α x ) + 1 1 q exp ( α x ) 1 ,
where y 0 is the integration constant determined by the initial conditions. In Equation (25), we explicitly show the plus–minus sign that appears in the radical of Equation (5) to obtain both branches of the solution.
Given the construction of the frame of reference in the consideration here, the slope of the minimum in Equation (8) is vertical, that is, parallel to the y axis, so with the aim to determine the position of the minimum, we express Equation (8) as d x / d y = 0 . Hence, one finds out the condition that the index of refraction meets at the minimum of the ray path:
d x d y = n m 2 ( n 0 sin θ 0 ) 2 n 0 sin θ 0 = 0 .
Here n m is the index of refraction at the minimum. Then,
n m = n 0 sin θ 0 .
Let us substitute n m (27) into Equation (23) to obtain the height x m over the ground of the minimum:
n 0 2 sin 2 θ 0 = n g 2 + n 1 2 [ 1 exp ( α x m ) ] ,
and thus,
x m = 1 α ln 1 + n g 2 n 0 2 sin θ 0 2 n 1 2 .
Substitution of Equation (29) into Equation (25) gives the position y m of the minimum, which can be related to the distance from the observer.
Figure 2 shows the light path of an inferior mirage, given by Equation (25) with y 0 = 0 and all other constants being set to 1. In this case, if the index of refraction at the ground meets the condition of Equation (27), the logarithm argument in Equation (29) is 1 and the height of the minimum is 0 what is represented in Figure 2.

4. Conclusions

Snell’s law constitutes a theoretical description aimed at addressing the change in direction of a light ray when passing through a sharp interface separating two media where light speed is different but constant at each side. Thus, it is not applicable to the calculation of the ray trajectory, when light velocity is a continuous function of position. The ray equation, derived from Fermat’s principle, stands as the appropriate framework for this general case. We deduce the ray equation in one dimension directly from Snell’s law using two methods: from a differential equation in terms of the Cartesian coordinates and the refractive index (Dyson’s expression) (method 1) and from the differential equivalent of Snell’s law (method 2), both obtained from Snell’s law.
In Section 3, we use Dyson’s expression to find an analytical solution for the light path in an inferior mirage. The application of Dyson’s expression to this problem is straightforward and provides a more natural approach compared to the ray equation. Throughout this study, we consider an index gradient along the x coordinate. When applied to the mirage problem, we get directly y ( x ) and the curve rotated in contrast to Ref. [14].
Let us make two final remarks. This study is strictly limited to a one-dimensional derivation of the ray equation under the assumption of a unidirectional refractive index gradient; thus, the quantity a = n sin θ remains constant in accordance with Snell’s law. The goal here is pedagogical with the aim to show how Snell’s law, typically taught as a discrete boundary condition, can lead to the ray equation when applied in the continuous limit of a stratified medium, method 1, or in the differential version of Snell’s law, method 2.

Author Contributions

Conceptualization, H.O.G.-O.; methodology, H.O.G.-O.; validation, D.I.S.-G.; formal analysis, J.C.-L.; investigation, C.T.-C.; writing—original draft, H.O.G.-O.; writing—review and editing, C.T.-C., J.C.-L., D.I.S.-G. and H.O.G.-O.; visualization, J.C.-L.; supervision, C.T.-C. and D.I.S.-G. Author C.T.-C. passed away prior to the publication of this manuscript. All other authors have read and agreed to the published version of this manuscript.

Funding

This research received no external funding.

Data Availability Statement

No research data were generated in the course of this study.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Lakshminarayanan, V.; Ghatak, A.K.; Thyagarajan, K. Lagrangian Optics; Springer Science+Business Media, LLC: New York, NY, USA, 2002. [Google Scholar] [CrossRef]
  2. Tsiboulia, A. Lenses: Gradient Index (GRIN). In Encyclopedia of Optical and Photonic Engineering; Hoffman, C., Driggers, R., Eds.; CRC Press/Taylor & Francis Group: Boca Raton, FL, USA, 2015; pp. 1367–1376. [Google Scholar] [CrossRef]
  3. Born, M.; Wolf, E. Principles of Optics: Electromagnetic Theory of Propagation, Interference, and Diffraction of Light; Cambridge University Press: Cambridge, UK, 1999. [Google Scholar] [CrossRef]
  4. Landau, L.D.; Lifshitz, E.M. Electrodynamics of Continuous Media; Pergamon Press Ltd.: Oxford, UK, 1984; Available online: https://www.sciencedirect.com/book/9780080302751/electrodynamics-of-continuous-media (accessed on 18 June 2025).
  5. Goldstein, H. Classical Mechanics; Addison–Wesley Publishing Company, Inc.: Reading, MA, USA, 1980; Available online: https://www.scribd.com/document/842804303/goldstein-h-classical-mechanics-2nd-edition (accessed on 18 June 2025).
  6. Fermat, P., de. Varia Opera Mathematica; Joannem Pech: Tolosæ (Toulouse), France, 1679. [Google Scholar] [CrossRef]
  7. Zghal, M.; Bouali, H.-E.; Ben Lakhdar, Z.; Hamam, H. The first steps for learning optics: Ibn Sahl’s, Al-Haytham’s and Young’s works on refraction as typical examples. In Proceedings of the Tenth International Topical Meeting on Education and Training in Optics and Photonics, Ottawa, ON, Canada, 3–5 June 2007; p. 966509. [Google Scholar] [CrossRef]
  8. Snellii R.F., VV. Cyclometricus; Lugduni Batavorum/Elzevir: Leiden, Dutch Republic, 1621; Available online: https://phaidra.univie.ac.at/detail/o:50507 (accessed on 18 June 2025).
  9. González-Acuña, R.G.; Chaparro-Romo, H.A. Stigmatic Optics; IOP Publishing Ltd.: Bristol, UK, 2024; Chapter 2. [Google Scholar] [CrossRef]
  10. Lemons, D.S. Perfect Form; Princeton University Press: Princeton, NJ, USA, 1997. [Google Scholar]
  11. Dyson, P.L. Comment on explaining the mirage. Am. J. Phys. 1977, 45, 879–880. [Google Scholar] [CrossRef]
  12. Noorbala, M.; Sepehrinia, R. Is n sin θ conserved along the light path? Eur. J. Phys. 2016, 37, 025301. [Google Scholar] [CrossRef]
  13. Allwright, D. From Snell’s law to Fermat’s principle. J. Sound Vibr. 2022, 536, 117101. [Google Scholar] [CrossRef]
  14. Khular, E.; Thyagarajan, K.; Ghatak, A.K. A note on mirage formation. Am. J. Phys. 1977, 45, 90–92. [Google Scholar] [CrossRef]
  15. Hecht, E. Optics; Addison–Wesley, Inc.: San Francisco, CA, USA, 2002; Available online: https://emineter.wordpress.com/wp-content/uploads/2020/04/hecht-optics-5ed.pdf (accessed on 18 June 2025).
  16. Pedrotti, F.L.; Pedrotti, L.M.; Pedrotti, L.S. Introduction to Optics; Cambridge University Press: New York, NY, USA, 2018. [Google Scholar] [CrossRef]
  17. Fowles, G.R. Introduction to Modern Optics; Holt, Rinehart and Winston, Inc.: New York, NY, USA, 1975; Available online: https://archive.org/details/introductiontomo00fowl/ (accessed on 18 June 2025).
  18. Bush, R.T.; Robinson, R.S. A note on explaning the mirage. Am. J. Phys. 1974, 42, 774–775. [Google Scholar] [CrossRef]
  19. Sastry, G.P. Teaching mirages. Am. J. Phys. 1978, 46, 765. [Google Scholar] [CrossRef]
  20. Biswas, D.; Chourasia, S.; Das, R.N.; Khaparde, R.B.; Srivastava, A.M. Mirage in geometrical optics and the horizontal ray. Stud. J. Phys. 2018, 7, 153–172. Available online: https://www.iopb.res.in/~sjp/74final/4.pdf (accessed on 18 June 2025).
  21. Fleagle, R.G. The temperature distribution near a cold surface. J. Atmosph. Sci. 1956, 13, 160–165. [Google Scholar] [CrossRef]
  22. Davis, J.F.; Greenslade, T.B., Jr. Computer modeling of mirage formation. Phys. Teach. 1991, 29, 47–48. [Google Scholar] [CrossRef]
Figure 1. Two-dimensional stratified optical material composed of k layers. Each layer has a constant index n i of refraction and width Δ x i = x i x i 1 . The inset shows the infinitesimal arc length d s along the ray path and its projections along the coordinate axes when the layer width tends to zero and the ray path becomes a smooth curve.
Figure 1. Two-dimensional stratified optical material composed of k layers. Each layer has a constant index n i of refraction and width Δ x i = x i x i 1 . The inset shows the infinitesimal arc length d s along the ray path and its projections along the coordinate axes when the layer width tends to zero and the ray path becomes a smooth curve.
Physics 07 00026 g001
Figure 2. Path of a light ray from an inferior mirage. In accordance with Figure 1 and the dependence of the index of refraction in an inferior mirage, the height over the ground is given by the x coordinate. Horizontal and vertical length are given in arbitrary units. The axes are labelled according to Equation (25), which implies rotating the image to show the habitual sight, and so the image is rotated.
Figure 2. Path of a light ray from an inferior mirage. In accordance with Figure 1 and the dependence of the index of refraction in an inferior mirage, the height over the ground is given by the x coordinate. Horizontal and vertical length are given in arbitrary units. The axes are labelled according to Equation (25), which implies rotating the image to show the habitual sight, and so the image is rotated.
Physics 07 00026 g002
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Toro-Castillo, C.; Cervantes-Lozano, J.; Serrano-García, D.I.; González-Ochoa, H.O. Derivation of the Ray Equation from Snell’s Law. Physics 2025, 7, 26. https://doi.org/10.3390/physics7030026

AMA Style

Toro-Castillo C, Cervantes-Lozano J, Serrano-García DI, González-Ochoa HO. Derivation of the Ray Equation from Snell’s Law. Physics. 2025; 7(3):26. https://doi.org/10.3390/physics7030026

Chicago/Turabian Style

Toro-Castillo, Carmen, Joel Cervantes-Lozano, David I. Serrano-García, and Héctor O. González-Ochoa. 2025. "Derivation of the Ray Equation from Snell’s Law" Physics 7, no. 3: 26. https://doi.org/10.3390/physics7030026

APA Style

Toro-Castillo, C., Cervantes-Lozano, J., Serrano-García, D. I., & González-Ochoa, H. O. (2025). Derivation of the Ray Equation from Snell’s Law. Physics, 7(3), 26. https://doi.org/10.3390/physics7030026

Article Metrics

Back to TopTop