Plots for terms of polynomials. Slider initial values?
- To: mathgroup at smc.vnet.net
- Subject: [mg124725] Plots for terms of polynomials. Slider initial values?
- From: Chris Young <cy56 at comcast.net>
- Date: Thu, 2 Feb 2012 04:58:00 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
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 at 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]}}
}
]
]