Window Pane Reflection Problem
Window Pane Reflection Problem
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 reection, each path can be used to construct a longer path. . . . . . . . . . . . . . . . . . (c) If the last reection point of a path is on the middle pane, then the resulting ray can only be reected 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 reections . . . . . . . . . . . . . . . . . . . Ways of having 2 reections . . . . . . . . . . . . . . . . . . . Ways of having 3 reections . . . . . . . . . . . . . . . . . . . Ways of having 4 reections . . . . . . . . . . . . . . . . . . . Ways of having 5 reections . . . . . . . . . . . . . . . . . . . Ways of having 6 reections . . . . . . . . . . . . . . . . . . . Ways of having 7 reections . . . . . . . . . . . . . . . . . . . The paths with 3 reections are built o of those with two . . Boundary points create rays that can be doubly reected . . The middle points create rays that can only be singly reected 2 2 2 2 2 3 3 3 4 4
1 of 8
Lee Gao
We have a seemingly simple problem: nd the recurrence relation an for the number of ways n for an image to be reected 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 reection. Figure 1: Ways of having 1 reections
We begin this exercise by looking at a few ways of achieving this.1 Figure 2: Ways of having 2 reections
See the end section for the code used to generate this, you can use it directly via LuaTex
2 of 8
GENERAL OBSERVATIONS
Lee Gao
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! Thats quite a sequence. Interestingly enough, it seems as if this sequence satises the recurrence an = an1 + an2 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 ns.
(b) Suppose we look at the points of reection, 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 reection 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 reections are built o of those with two
3 of 8
Lee Gao
(c) If the last reection point of a path is on the middle pane, then the resulting ray can only be reected in one direction whereas. This is the crucial insight in our system. Consider g. 9, if the last reection point is on one of the boundaries, then any oshoot ray may potentially reect along the middle or the other boundary panes. Figure 9: Boundary points create rays that can be doubly reected
However, if the last reection point is in the middle pane, then we only have one direction in which to reect to. Figure 10: The middle points create rays that can only be singly reected
This is why whenever the red arrow ends on the top pane in g. 8, that conguration ended up generating two additional paths with the same initial set of reection points while the middle point could only generate one. 3. Dividing
into subproblems
The above suggests that, if we inspect the last point reected in some path pn with n reection points, then we can build at most two additional paths pn+1 , pn+1 such that If the last reection point in pn is on the middle pane, then if we build a path pn+1 that matches pn completely up until its last reection point, then that last reection point of pn+1 must be a boundary point as observed in g. 10. If the last reection 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 reection point, then that last reection point of pn+1 can either be the opposite boundary point or the middle pane. 4 of 8
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 reected in more than one way within its next reection while the second property states that the boundary panes can generate a ray that can be reected 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 dene the set Rn to represent all possible schemes with n reections. Furthermore, we partition Rn into two disjoint sets Nn and Mn , where Nn represents the set of all schemes whose last reection is at a boundary pane and Mn the set of schemes whose last reection 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 | = |Rn1 |. Furthermore, we have |Nn | = |Mn1 | = |Rn2 |, therefore an = |Rn | = |Rn1 | + |Rn2 | = an1 + an2 (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
DIAGRAM CODE
Lee Gao
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( n1) + R( n2) 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) )
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, ( v1) 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
DIAGRAM CODE
Lee Gao
55
57
59
i f ( p[#p ] == 3 o r ( p[#p ] == 2 and p[#p1] == 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 ( n1) ; 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
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