# Dependent Manipulate sliders

I would like to use dependent sliders in Manipulate. First slider K0 should be independent and varied from Kmin to Kmax. Two others sliders K1 and K2 should dependend on K0 so that K1*K2 == K0 should be always true. Is it possible?

-
Strangely, I've failed to find any related post about this fairly basic question (maybe this about interrelated sliders), and the Documentation Center only has a somewhat related example. – István Zachar Nov 15 '12 at 19:08

Here's one thing you might try

 k0Old = 1; k1Old = 1; k2Old = 1; kMin = 1; kMax = 2;
Manipulate[
If[k1 != k1Old || k0 != k0Old, k2 = k0/k1; k1Old = k1; k0 = k0Old];
If[k2 != k2Old, k1 = k0/k2; k2Old = k2;];
{k0, k1, k2, k1 k2}, {k0, kMin, kMax}, {k1, 0.1, 10}, {k2, 0.1, 10}]

-

As always, here is the more customizable DynamicModule version:

DynamicModule[{k0, k1, k2, kMin = -1, kMax = 1},
Panel[Grid[{
{"k0", Slider[Dynamic[k0, (k0 = #; k2 = k0/k1) &], {kMin, kMax}], Dynamic@k0},
{"k1", Slider[Dynamic[k1, (k1 = #; k2 = k0/k1) &], {-1, 1}, Exclusions -> {0}], Dynamic@k1},
{"k2", Slider[Dynamic[k2, (k2 = #; k1 = k0/k2) &], {-1, 1}, Exclusions -> {0}], Dynamic@k2},
{Panel[Dynamic@Grid[{
{"k0", k0}, {"k1", k1}, {"k2", k2}, {"k1*k2", k1*k2}},
Alignment -> Left], ImageSize -> {250, 90}], SpanFromLeft}
}, Alignment -> Left], ImageSize -> {300, 200}]
]


Note that division by zero is handled by Exclusions -> {0}.

-
Use the Exclusions option for Slider to prevent landing on zero and division by zero. – Mike Honeychurch Nov 15 '12 at 21:24
Thanks @Mike, included! – István Zachar Nov 16 '12 at 10:44