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: Plots for terms of polynomials. Slider initial values?
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Christopher O. Young

Posts: 182
Registered: 2/13/11
Plots for terms of polynomials. Slider initial values?
Posted: Feb 2, 2012 5:05 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I hope to get this working for a variable number of terms. Probably
this would work fine in a Manipulate block; I just took it from some
demo of how to rearrange sliders.

Is there any way to set initial values when you create sliders with
Slider[ ] rather than via Manipulate[ ]?

Any suggestions for better ways to do this are welcome.

Chris Young
cy56@comcast.net

DynamicModule[
{a, b, c, d,
f,
x,
xRange, yRange,
opt},

f[1][x_] = a x^3 + b x^2 + c x + d;
f[2][x_] = b x^2 + c x + d;
f[3][x_] = c x + d;
f[4][x_] = d;

opt = Appearance -> "Labeled";

Panel @ Grid
[
{
{Row @ {"a \!\(\*SuperscriptBox[\(x\), \(3\)]\) + b \
\!\(\*SuperscriptBox[\(x\), \(2\)]\) + c x + d = ",
Dynamic @ f[1][x]}},
{
Column[
Row @ {
StringTake[ToString[#], 1] <> " ",
Manipulator[Dynamic @ #, {-2, 2, 0.125}]
} & /@ {a, b, c, d}
]
},
{
Dynamic @
Show[
Plot[
{f[1][x], f[2][x], f[3][x], f[4][x]},
{x, -xRange, xRange},
PlotStyle -> {Red, Darker[Orange, 0.1], Darker[Green, 0.1],
Blue},
PlotRange -> {{-xRange, xRange}, {-yRange, yRange}},
AspectRatio -> 1,
PlotRangeClipping -> False
],
Graphics @ {Red, PointSize[Large], Point[{x, f[1][x]}]}
]
},
{Row @ {"x ",
Slider[Dynamic @ x, {-6, 6}, opt]}}, {Row @ {"x plot range ",
Slider[Dynamic @ xRange, {2, 100},
opt]}}, {Row @ {"y plot range ",
Slider[Dynamic @ yRange, {2, 100}, opt]}}
}
]
]





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.