       Manipulate in a series of commands

• To: mathgroup at smc.vnet.net
• Subject: [mg122183] Manipulate in a series of commands
• From: Lengyel Tamas <lt648 at hszk.bme.hu>
• Date: Wed, 19 Oct 2011 05:35:08 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com

```Dear Community,

I am faced with a probably very easy problem. At the bottom you can see my
code which executes in a single cell once the parameter K is set to an
integer number greater than 0.

I can't seem to make it Dynamic or use Manipulate, e.g. have a slider or
text box where I can change the number K, then have the series of commands
executed.
Any ideas?

Tamás

Code:

K = 64;
Element[n, Integers];
Degen = Piecewise[{{0,
n < -K}, {(K - Ceiling[(K - n)/2]), -K <= n <=
0}, {(K - 1 - Floor[n/2] - Ceiling[(K - n)/2]),
0 < n <= K}, {(K - Floor[n/2]), K < n <= 2 K}, {0, n > 2 K}}];
g1 = DiscretePlot[Degen, {n, -K, 2 K}, AxesOrigin -> {-K, 0},
PlotRange -> {{-K, 2 K}, {0, K^2/2.5}},
PlotStyle -> {Thickness[0.01]},
FillingStyle -> RGBColor[0.4, 1, 0.4, .9]];
NonDegen =
Piecewise[{{0,
n < -K}, {(Ceiling[(K^2 + n^2 - 2*K - 2 n + 2*K*n)/4]), -K <=
n <= 0}, {(Ceiling[(K^2 - 6 K - 2 n^2 + 2 n + 4)/4 +
Floor[(K*n)/2]]),
0 < n <= K}, {(Floor[(4 K^2 + n*n - 4 K*n)/4]),
K < n <= 2 K}, {0, n > 2 K}}];
g2 = DiscretePlot[Degen + NonDegen, {n, -K, 2 K},
AxesOrigin -> {-K, 0}, PlotRange -> {{-K, 2 K}, {0, K^2/2.5}},
PlotStyle -> {Thickness[0.01]},
FillingStyle -> RGBColor[0.01, 0.01, 2, 1]];
g3 = DiscretePlot[((K/2 - 1) + (K^2 - 6*K + 2*K*n - 2 n^2 + 2 n + 4)/
4), {n, 1, K}, AxesOrigin -> {-K, 0},
PlotRange -> {{-K, 2 K}, {0, K^2/2.5}},
ColorFunction -> (RGBColor[#2, 0.2, 1 - #2] &),
FillingStyle -> {Directive[{Thickness[0.01], Opacity[0.9] }]},
Filling -> Axis];
Show[g2, g3, g1, AxesLabel -> {"n", "Number of FWM products"},
LabelStyle -> Directive[Black, Bold, 14]]
max = FindMaxValue[((K/2 - 1) + (K^2 - 6*K + 2*K*n - 2 n^2 + 2 n + 4)/
4), n];
Floor[max]

```

• Prev by Date: Re: Low CPU usage
• Next by Date: Re: Limitation on vector length in NDSolve?
• Previous by thread: HDF4 Vdata import
• Next by thread: contour plot on a general surface