Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm developing code for manipulating graphs. Spot the difference in the 2 Manipulates below:

 {n, m},
 {{n, 10, "no of vertices"}, 1, 18, 1},
 {{m, n, "number of edges"}, n, n (n - 1)/2 , 1}
 (* using the +/-/slider for the number of edges does not generate Reals 
    but only Integers as expected *)]

first image of Manipulate

this first example works as expected but

 {n, m},
 {{n, 10, "no of vertices"}, 1, 18, 1},
 {{m, n, "number of edges"}, n - 1, n (n - 1) /2, 1}
 (* using the +/-/slider for the number of edges now generates Reals 
    not Integers: what gives? *)]

second image of Manipulate

turns my nice integers into reals as soon as I change the number of edges. I can turn this back into an integer when that's what I need, but I'd prefer not to. Naturally I have a more complex task to complete but these examples are simple enough to illustrate the issue.

Version: Mathematica

Platform: Mac

share|improve this question
Possibly related: – Szabolcs Mar 12 '14 at 18:43
yes, I saw that before posting my question but was a bit alarmed by it and it didn't seem obviously the same problem at first sight (I didn't realise I was using the 2nd argument to Dynamic...). Also, Remap{Value,Variable} didn't appear on closer inspection of the Manipulates – fairflow Mar 12 '14 at 18:46
Yes, I was checking that too. I don't know if the underlying problem is the same in the two cases but the symptoms are very similar. – Szabolcs Mar 12 '14 at 18:51
I don't know, it's all too unclear to me now, but the behaviour is definitely undesirable. You could try asking support about it and let us know what they said ... I'm trying to come up with a more fundamental example to at least figure out the difference between the two Manipulates. – Szabolcs Mar 12 '14 at 18:59
Good idea. I'll post when I get a reply. – fairflow Mar 12 '14 at 19:01
up vote 3 down vote accepted

This is an example of unintended behavior in Mathematica that the developers are aware of. There are a number of workarounds. The simplest is to wrap a function around the appropriate bounds; instead of

Manipulate[m, {n, {10}}, {m, n - 1, 2 n, 1}]

which illustrates the problem, try

Manipulate[Floor@m, {n, {10}}, {m, n - 1, 2 n, 1}]

A solution can also be pushed into the controller itself:

Manipulate[m, {n, {10}}, {{m, 9}, Dynamic[Slider[#1, {n - 1, 2 n, 1}]] &}]

Thanks for this feedback and suggestions are due to Karl Isensee.

share|improve this answer
But the bug is still now. – yode Oct 13 '15 at 10:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.