Message Boards Message Boards

0
|
3862 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

One question with Manipulate function

Posted 10 years ago

Can anyone tell me how to define a function to produce a sum of n terms with a slider of each term ex. for 3 terms only Manipulate[Evaluate[Sum[Subscript[a, i], {i, 1, 3}]], {Subscript[a, 1], 0, 1}, {Subscript[a, 2], 0, 1}, {Subscript[a, 3], 0, 1}] This previous example is a model of the required function. I need to define a function of n terms This is my try f[n_] := Manipulate[Evaluate[Sum[Subscript[a, i], {i, 1, n}]], Table[{Subscript[a, i], 0, 1}, {i, 1, n}]]

but the problem in the Table function which will produce (for example n=3) {{Subscript[a, 1], 0, 1}, {Subscript[a, 2], 0, 1}, {Subscript[a, 3], 0, 1}} here the exact problem that the two successive brackets "{{" and, "}}" which should be only one bracket "{" and, "}" as shown in the attached notebook. So, please, anyone know how to overcome this problem inform me Thanks a lot

Attachments:
POSTED BY: Hosam Hefnawy
3 Replies
Posted 10 years ago

The problem is how to write a correct code for the second argument in Manipulate function as follows f[n_] := Manipulate[Evaluate[Sum[Subscript[a, i], {i, 1, n}]], ...........] i.e. what to be written in the space shown in the above function definition. in other words it is needed to define a function can generate the following set {Subscript[a, 1], 0, 1}, {Subscript[a, 2], 0, 1}, {Subscript[a, 3], 0, 1}.....{Subscript[a, 3], 0, 1} to be written in the Manipulate command

POSTED BY: Hosam Hefnawy

After reading more carefully about the subscripted terms, something like the following?

(* Mathematica 7 *)
f[n_] :=  Sum[ Subscript[a, j], {j, 0, n}](*Define the function*)
Manipulate[ f[n], {n, 0, 4, 1}, ControlType -> RadioButton]
POSTED BY: Isaac Abraham

Something like this?

(* Mathematica 7 *)
f[x_] := 1 + 2 x + 3 x^2 + 4 x^4 (*Define the function*)

Manipulate[ 
 Take[f[x], n](*Take n terms*)/. x -> m (*replacing x with some value m*), {n, 1, 4, 1}, {m, 1, 3, 1}, 
 SaveDefinitions -> True,
 ControlType     -> RadioButton ]
POSTED BY: Isaac Abraham
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract