Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Manipulate in a series of commands
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Lengyel Tamas

Posts: 10
Registered: 2/23/11
Manipulate in a series of commands
Posted: Oct 19, 2011 5:01 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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]




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.