# Error Trapping Complex Infinity Error due to Divide by Zero in Manipulate

I want to use a Manipulate that has two controllers that end up as a difference in the denominator of an expression. It is easy enough to set up the initial conditions such that the two controls are not equal in value, but upon user manipulation the two controls, if set the same give an error. The following code illustrates:

  table = Range[0, 6];
divideByZeroProblem =
Manipulate[
10/(time2 - time1), {{time1, 0}, Most[table],
ControlType -> PopupMenu}, {{time2, time1 + 1},
Drop[table, Position[table, time1][[1, 1]]],


But of course if I change time1 to be 1, then I get the following:

I naively thought that I might be able to utilize Initialization to get around the problem by basing the initial value of time2 on a function, but that doesn't update the initial value set for time2.

The best lead that I have found in my searching for the answer on Mathematica.SE is Control variable and body variable decoupling in Manipulate, but I didn't succeed in translating that answer into a solution for my problem. It did lead me to try some things though.

For example, my initial attempts at writing this question resulted in a simpler code that works as I would like it to.[Note added in later edit: I swear that it worked once this way, but I cannot get it to work again. It has the exact same kind of error. Must have been dreaming.]

    divideByZeroProblem2 =
Manipulate[
10/(time2 - time1), {{time1, 0}, Range[0, 5],


I played around quite a bit with using Dynamic and Setting in opportune spots to see if I could get it to work, but failed to find an appropriate combination.

Any help that folks could provide would be much appreciated.

Manipulate[10/(time2 - time1),

• That looks great, Simon. It is also necessary for time2 > time1. – Andy Mobley Mar 20 '14 at 17:11