MHB Find Recurrence Relation for Flipping n Switches

find_the_fun
Messages
147
Reaction score
0
A circuit has n switches, all initially off. In order to be able to flip the ith switch, the (i-1)th switch must be on and all earlier switches off. The first switch can always be flipped. Find a recurrence relation for the total number of times the n switches must be flipped to get the nth switch on and all the others off.

I got [math]f_n=f_{n-1}+2[/math] with initial condition [math]f_1=1[/math] Is this right? This makes sense because to get the nth switch on, you need the (n-1)th switch on, and then you need to turn on the nth switch itself and turn off the (n-1)th switch. I have trouble explaining this using math though.
 
Last edited:
Physics news on Phys.org
Re: Finding a recurrence relation where (k-1)th switch must be on to turn on kth switch

find_the_fun said:
I got [math]f_n=f_{n-1}+2[/math] with initial condition [math]f_1=1[/math] Is this right? This makes sense because to get the nth switch on, you need the (n-1)th switch on, and then you need to turn on the nth switch itself and turn off the (n-1)th switch.
You can't turn off the $(n-1)$th switch by flipping it alone.
 
Re: Finding a recurrence relation where (k-1)th switch must be on to turn on kth switch

Speaking in general, what's the point of recurrence relations? Why not use a regular equation? Is it because in some situations it may be easier to derive/discover a recurrence relation?
 
Re: Finding a recurrence relation where (k-1)th switch must be on to turn on kth switch

find_the_fun said:
Is it because in some situations it may be easier to derive/discover a recurrence relation?
Yes. Recurrence relation is itself a function defined by recursion, i.e., the definition of such function refers to the function itself. And recurrence relation naturally accompany definitions by recursion, which may not even involve numbers (structural recursion). For example, it is easy to describe a recursive algorithm for solving Hanoi towers puzzle; a corresponding recurrence relation may count the required number of moves.

So, why is recursion useful?

(1) Recursive definitions are often simpler. For example, it is easy to come up with the recurrence relation for Fibonacci numbers from the description of the rabbit population growth, as in the original puzzle. Deriving Binet's formula is harder.

(2) Certain constructions of objects (numbers, lists, etc.) naturally lead to recursive definitions. Such constructions define how to build an object from existing ones: e.g., a list is either empty or a pair of a number and a list. Functions that take lists as arguments are often defined by recursion.

(3) The "divide-and-conquer" and dynamic programming techniques of building algorithms (e.g., binary search) use recursion to increase efficiency.

(4) Functions defined by recursion often can't be expressed using only operations from the definition. For example, the definition of factorial uses only 1 and multiplication, but the factorial is different from the four arithmetic operations. Concerning hailstone numbers, nobody knows if every starting number eventually turns into 1.

Remark: Some people make distinction between recurrence and recursion: the former is a special case of the latter. Since natural numbers can be considered built from 0 by using successor, a definition that gives f(n+1) from f(n) is a definition by recurrence, while the one that produces f(n) from f(n/2) uses more general recursion.
 
Hi all, I've been a roulette player for more than 10 years (although I took time off here and there) and it's only now that I'm trying to understand the physics of the game. Basically my strategy in roulette is to divide the wheel roughly into two halves (let's call them A and B). My theory is that in roulette there will invariably be variance. In other words, if A comes up 5 times in a row, B will be due to come up soon. However I have been proven wrong many times, and I have seen some...
Thread 'Detail of Diagonalization Lemma'
The following is more or less taken from page 6 of C. Smorynski's "Self-Reference and Modal Logic". (Springer, 1985) (I couldn't get raised brackets to indicate codification (Gödel numbering), so I use a box. The overline is assigning a name. The detail I would like clarification on is in the second step in the last line, where we have an m-overlined, and we substitute the expression for m. Are we saying that the name of a coded term is the same as the coded term? Thanks in advance.
Back
Top