I want to plot a function in a Manipulate
in which the number of terms varies and a Manipulator
for the coefficient of each term is created or deleted as the terms increase and decrease.
For example, when I have three terms, I should get the equivalent of
Manipulate[
Plot[a0 + a1 x + a2 x^2, {x, 0, 10}],
{a0, 1, 10},
{a1, 1, 10},
{a2, 1, 10}]
I want to let the number of terms vary and but still control each coefficient with a Manipulator
. I tried to do it in the following way:
Manipulate[
Plot[Total[ToExpression["a" <> ToString[#]] x^# & /@ Range[0, n]], {x, 0, 10}],
{n, 1, 10, 1},
Dynamic[Sequence @@ ({ToExpression["a" <> ToString[#]], 1, 10} & /@ Range[1, n])]]
It did not work.
Can anybody suggest what I should do to make it work?
coef[1]
,coef[2]
, etc $\endgroup$