Let A1A2A3A4A5A6A7A8 be a regular octagon. Let M1,M3,M5, and M7 be the midpoints of sides A1A2,A3A4,A5A6, and A7A8, respectively. For i=1,3,5,7, ray Ri is constructed from Mi towards the interior of the octagon such that R1⊥R3,R3⊥R5,R5⊥R7, and R7⊥R1. Pairs of rays R1 and R3,R3 and R5,R5 and R7, and R7 and R1 meet at B1,B3,B5, and B7, respectively. If B1B3=A1A2, then cos2∠A3M3B1 can be written in the form m−n, where m and n are positive integers. Find m+n.
Scale so that A1A2=2. A 90∘ rotation about the center carries the whole configuration to itself, so B1B3B5B7 is a square and the distances a=MiBi and b=MiBi−2 do not depend on i. Both B3 and B1 lie on ray R3 (at distances a and b from M3), so b−a=B1B3=2. Also, R1⊥R3 makes triangle M1B1M3 right-angled at B1, so a2+b2=M1M32.
Lines A1A2 and A3A4 meet at a point C at a right angle, and triangle A2CA3 is an isosceles right triangle with legs A2C=A3C=2, so M1C=M3C=1+2 and a2+b2=M1M32=2(1+2)2. Then (a+b)2=2(a2+b2)−(b−a)2=4(1+2)2−4=8+82.
Since triangle M1CM3 is an isosceles right triangle and A3 lies on segment M3C, we have ∠A3M3M1=45∘, while tan∠M1M3B1=ba from the right triangle. The tangent addition formula gives tan∠A3M3B1=1−ba1+ba=b−aa+b, so tan2∠A3M3B1=48+82=2+22. Therefore cos2∠A3M3B1=1+tan2∠A3M3B11−tan2∠A3M3B1=3+22−1−22=−(1+22)(3−22)=5−42=5−32, and m+n=5+32=37.