Window Pane reflection problem | Vertex (Graph Theory) | Algorithms

# The Double Paned Reﬂection Problem

Lee Gao December 10, 2012

Contents
1 The Part with the dumb luck 2 General Observations (a) For n even, the exit arrows are all pointing down. . . . . . . . (b) Suppose we look at the points of reﬂection, each path can be used to construct a longer path. . . . . . . . . . . . . . . . . . (c) If the last reﬂection point of a path is on the middle pane, then the resulting ray can only be reﬂected in one direction whereas. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Dividing into subproblems 4 Diagram Code 2 3 3 3

4 4 5

List of Figures
1 2 3 4 5 6 7 8 9 10 Ways of having 1 reﬂections . . . . . . . . . . . . . . . . . . . Ways of having 2 reﬂections . . . . . . . . . . . . . . . . . . . Ways of having 3 reﬂections . . . . . . . . . . . . . . . . . . . Ways of having 4 reﬂections . . . . . . . . . . . . . . . . . . . Ways of having 5 reﬂections . . . . . . . . . . . . . . . . . . . Ways of having 6 reﬂections . . . . . . . . . . . . . . . . . . . Ways of having 7 reﬂections . . . . . . . . . . . . . . . . . . . The paths with 3 reﬂections are built oﬀ of those with two . . Boundary points create rays that can be doubly reﬂected . . The middle points create rays that can only be singly reﬂected 2 2 2 2 2 3 3 3 4 4

1 of 8

1

THE PART WITH THE DUMB LUCK

Lee Gao

§1. The Part with the dumb luck

We have a seemingly simple problem: ﬁnd the recurrence relation an for the number of ways n for an image to be reﬂected by internal faces between two glass panes if the ray starts oﬀ from the top. For example, these are the ways to do this with only one reﬂection. Figure 1: Ways of having 1 reﬂections

We begin this exercise by looking at a few ways of achieving this.1 Figure 2: Ways of having 2 reﬂections

Figure 3: Ways of having 3 reﬂections

Figure 4: Ways of having 4 reﬂections

Figure 5: Ways of having 5 reﬂections

See the end section for the code used to generate this, you can use it directly via LuaTex

1

2 of 8

2

GENERAL OBSERVATIONS

Lee Gao

Figure 6: Ways of having 6 reﬂections

and ﬁnally Figure 7: Ways of having 7 reﬂections

At this point, my typesetting program refuses to ﬁt the generated set of rays within the margins of this page, but if we are to continue counting the number of ways, we would get a sequence that looks like 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, . . . (1.1)

Wow! That’s quite a sequence. Interestingly enough, it seems as if this sequence satisﬁes the recurrence an = an−1 + an−2 a0 = 1, a1 = 2 (1.2)

The next few sections will be dedicated to the intuition I had on my journey of proving this property. §2. General Observations Here we present a few interesting geometric insights regarding our problem.

(a) For n even, the exit arrows are all pointing down. Likewise, the exit arrows are all pointing up for odd n’s.

(b) Suppose we look at the points of reﬂection, each path can be used to construct a longer path. For example, each of the paths in ﬁg. 3 contains points from ﬁg. 2. In fact, the highlighted arrows in ﬁg. 8 contains all of the reﬂection points in the n = 2 case. Notice how some of the highlighted paths come in pairs? Well, this brings us to our third point Figure 8: The paths with 3 reﬂections are built oﬀ of those with two

3 of 8

3

DIVIDING INTO SUBPROBLEMS

Lee Gao

(c) If the last reﬂection point of a path is on the middle pane, then the resulting ray can only be reﬂected in one direction whereas. This is the crucial insight in our system. Consider ﬁg. 9, if the last reﬂection point is on one of the boundaries, then any oﬀshoot ray may potentially reﬂect along the middle or the other boundary panes. Figure 9: Boundary points create rays that can be doubly reﬂected

However, if the last reﬂection point is in the middle pane, then we only have one direction in which to reﬂect to. Figure 10: The middle points create rays that can only be singly reﬂected

This is why whenever the red arrow ends on the top pane in ﬁg. 8, that conﬁguration ended up generating two additional paths with the same initial set of reﬂection points while the middle point could only generate one. §3. Dividing
into subproblems

The above suggests that, if we inspect the last point reﬂected in some path pn with n reﬂection points, then we can build at most two additional paths pn+1 , pn+1 such that • If the last reﬂection point in pn is on the middle pane, then if we build a path pn+1 that matches pn completely up until its last reﬂection point, then that last reﬂection point of pn+1 must be a boundary point as observed in ﬁg. 10. • If the last reﬂection point in pn is not on the middle pane, then if we build a path pn+1 that matches pn completely up until its last reﬂection point, then that last reﬂection point of pn+1 can either be the opposite boundary point or the middle pane. 4 of 8

4

DIAGRAM CODE

Lee Gao

• If two disjoint paths pn , pn are used to generate two paths pn+1 , pn+1 , then pn+1 , pn+1 are also disjoint. The ﬁrst property basically says that the middle pane cannot generate rays that can be reﬂected in more than one way within its next reﬂection while the second property states that the boundary panes can generate a ray that can be reﬂected twice, once at the middle point and again at the opposite boundary. The third property only ensures that uniqueness of the path generation notion so that we are allowed later to claim that our algorithm will not generate extra paths. This suggests a natural way of dividing up the problem into smaller subproblems. Namely, we deﬁne the set Rn to represent all possible schemes with n reﬂections. Furthermore, we partition Rn into two disjoint sets Nn and Mn , where Nn represents the set of all schemes whose last reﬂection is at a boundary pane and Mn the set of schemes whose last reﬂection is on the middle pane. The above properties then suggests that Nn Mn Nn Nn+1 Nn+1 Mn+1 (3.1) (3.2) (3.3)

where the square subset relation means that the left hand side is seen in the ﬁrst part of the paths of the right hand side. This then gives a general constraint on the cardinalities of these sets. |Nn+1 | = |Nn | + |Mn | |Mn+1 | = |Nn | |Rn | = |Mn | + |Nn | |M1 | = 1 |N1 | = 1 By eliminating (3.6) and (3.4), we have that |Rn | = |Nn+1 | ⇐⇒ |Nn | = |Rn−1 |. Furthermore, we have |Nn | = |Mn−1 | = |Rn−2 |, therefore an = |Rn | = |Rn−1 | + |Rn−2 | = an−1 + an−2 (3.7) (3.4) (3.5) (3.6)

The relationship established in (3.1), (3.2), (3.3) is also used to create the code (listing 1) used to generate the graphs earlier. §4. Diagram
Code
1

listing 1 generates the Tikz code used to draw the diagrams above Listing 1: Diagram code
R mem = {}

5 of 8

4

DIAGRAM CODE

Lee Gao

3

5

7

function R( n ) i f n < 2 then return n + 1 end i f R mem [ n ] then return R mem [ n ] end r = R( n−1) + R( n−2) R mem [ n ] = r return r end hd = [ [ \ b e g i n { f i g u r e } [H] \ c a p t i o n {Ways o f ha vin g %d r e f l e c t i o n s \ l a b e l { c%d }} \ centering \ begin { t i k z p i c t u r e } \ node ( t l ) a t ( 0 , 0 ) { } ; \ node ( t r ) a t (%dpt , 0 ) { } ; \ node [ below o f=t l , node d i s t a n c e =0.5cm ] ( ml ) { } ; \ node [ below o f=t r , node d i s t a n c e =0.5cm ] (mr) { } ; \ node [ below o f=ml , node d i s t a n c e =0.5cm ] ( b l ) { } ; \ node [ below o f=mr , node d i s t a n c e =0.5cm ] ( br ) { } ; \path [ −] ( t l ) edge ( t r ) ( ml ) edge (mr) ( b l ) edge ( br ) ; ] ] t l = [ [ \ end{ t i k z p i c t u r e } \end{ f i g u r e } ] ] −− each r e f l e c t i o n t a k e s up 5 pt , s o 5∗(2+n ∗ (R( n ) +4) )

9

11

13

15

17

19

21

23

25

27

29

31

33

35

37

function width ( n , w) i f not w then w = 5 end return w∗(2+n ∗ (R( n ) +3) ) end function path ( a , p , w) i f not w then w = 5 end l o c a l s = ( ” \ \ path[−>] (%dpt , 1 0 p t ) e d g e (%dpt ,%scm ) \n ”) : f o r m a t ( a , a+w , ( p [ 1] − 1) ∗( −0.5) ) l o c a l prev = { a+w, ( p [ 1 ] − 1 ) ∗( −0.5) } f o r i , v i n i p a i r s ( p ) do i f ( i ˜=1) then l o c a l next = { prev [ 1 ] +w, ( v−1) ∗ −0.5} s = s . . ( ” (%dpt ,%scm ) e d g e (%dpt ,%scm ) \n ”) : f o r m a t ( p r e v [ 1 ] , prev [ 2 ] , next [ 1 ] , next [ 2 ] ) prev = next end end −− check l a s t two

39

41

43

45

47

49

51

53

6 of 8

4

DIAGRAM CODE

Lee Gao

55

57

59

i f ( p[#p ] == 3 o r ( p[#p ] == 2 and p[#p−1] == 1 ) ) then s = s . . ( ” (%dpt ,%scm ) e d g e (%dpt , 1 0 p t ) ; ” ) : f o r m a t ( p r e v [ 1 ] , p r e v [ 2 ] , p r e v [ 1 ] +w) else s = s . . ( ” (%dpt ,%scm ) e d g e (%dpt , −1.5cm) ; ” ) : f o r m a t ( p r e v [ 1 ] , p r e v [ 2 ] , p r e v [ 1 ] +w) end return s , prev [ 1 ] + 2 ∗w end PATH = {{N={{3}} ,M={{2}}} ,{N= { { 3 , 1 } , { 2 , 1 } } ,M={{3 ,2}}}} −− r e t u r n s N and M function g e t a l l p a t h ( n ) i f n == 0 then return {N={} ,M={}}; end i f PATH[ n ] then return PATH[ n ] end l o c a l p = g e t a l l p a t h ( n−1) ; −− f o r each i n M, add i t i n t o N −− f o r each i n N, add i n t o both M and N local N = {}; local M = {}; f o r i , n i n i p a i r s ( p .N) do −− add 2 i n t o M l o c a l t = { unpack ( n ) } ; t a b l e . i n s e r t ( t , 2) ; t a b l e . i n s e r t (M, t ) ; t = { unpack ( n ) } ; −− add t h e o p p o s i t e i f t [# t ] == 3 then table . insert (t ,1) else table . insert (t ,3) end t a b l e . i n s e r t (N, t ) ; end f o r i , n i n i p a i r s ( p .M) do −− add t h e same o f t h e l a s t 2 l o c a l t = { unpack ( n ) } i f t [# t −1] == 3 then table . insert (t ,3) else table . insert (t ,1) end t a b l e . i n s e r t (N, t ) ; end PATH[ n ] = {N=N,M M} = return PATH[ n ] end function l a t e x ( n , w) i f not w then

61

63

65

67

69

71

73

75

77

79

81

83

85

87

89

91

93

95

97

99

101

103

105

7 of 8

4

DIAGRAM CODE

Lee Gao

107

109

111

113

115

117

119

121

w = 5 end wd = width ( n , w) paths = g e t a l l p a t h (n) s = hd : format ( n , n , wd) . . ” \ n” lastw = w f o r i , v i n i p a i r s ( p a t h s .N) do ps , l a s t w = path ( l a s t w , v , w) s = s . . ps . . ”\n” end f o r i , v i n i p a i r s ( p a t h s .M) do ps , l a s t w = path ( l a s t w , v , w) s = s . . ps . . ”\n” end s = s .. tl return s end

8 of 8