1

I'm making a demonstration with the following code:

a = Pi/4;
b = 3 Pi/2;
f[x_, n_] = Piecewise[{{x + Sin[x] + n, x >= Pi}, {x + Sin[x], x < Pi}}];
Manipulate[
    Plot[
        f[x, n], {x, -Pi, 2 Pi + 1},
        PlotRange -> {{-1, 2 Pi + 1}, {-1, 2 Pi}},
        Epilog -> {
            Table[{Dotted, Line[{{-1, q}, {2 Pi + 1, q}}]}, {q, {f[a, n], f[b, n]}}],
            If[n == 0, {Dashed, Line[{{-1, f[c, n]}, {2 Pi + 1, f[c, n]}}]}, {Dashed, Line[{{-1, k}, {2 Pi + 1, k}}]}]
            },
        Ticks -> False,
        Axes -> False
        ],
    {{n, 0}, {0, Pi/2}},
    {{c, Pi}, a, b},
    {{k, f[a, n], "K"}, f[a, n], f[b, n]}
    ]

When n=0 is selected, the k slider does nothing; when n=Pi/2, the c slider does nothing. Is there some way to hide the k and c sliders under the conditions for which they're inactive?

(Bonus points: For convenience, I'd like to post an animation of what happens for users who can't run it in Mathematica on their own, so if someone could post instructions or a link to where I can learn to make a screen-cap, I would greatly appreciate it!)

user170231
  • 1,611
  • 1
  • 11
  • 17

0 Answers0