Mathematica variable arguments

In summary, the conversation discusses defining a complete Bell polynomial in Mathematica, which is a function that calculates the sum of partial Bell polynomials. This function is defined as CBellY[n, {x1, ...xn}] = Sum[BellY[n, k, {x1, ...xn-k+1}], {k, 1, n}]. The code for this is temporarily hidden to show the details.
  • #1
anthony2005
25
0
Hello,
how do you define a function or make a list with n elements, where n is any? More precisely there is a function in mathematica, BellY

[itex]BellY[n,k,\{x_{1},...x_{n-k+1}\}][/itex]

which gives the partial Bell polynomial. I would like to define in mathematica the complete Bell polynomial defined as

[itex]CBellY[n,\{x_{1},...x_{n}\}]=\sum_{k=1}^{n}BellY[n,k,\{x_{1},...x_{n-k+1}\}][/itex]

How can I do that?
Thank you.
 
Physics news on Phys.org
  • #2
Temporarily I have Mathematica forget it knows BellY so you can see the details.

In[1]:= CBellY[n_,v_]:=Sum[BellY[n,k,Take[v,n-k+1]],{k,1,n}]

In[2]:= CBellY[3,{1,2,3}]

Out[2]= BellY[3,1,{1,2,3}]+BellY[3,2,{1,2}]+BellY[3,3,{1}]
 
  • #3
Great, thank you very much!
 

Related to Mathematica variable arguments

1. What are variable arguments in Mathematica?

Variable arguments in Mathematica are arguments that can have an indefinite number of values passed to them. This means that the number of arguments can vary from one function call to another.

2. How do I declare a function with variable arguments in Mathematica?

To declare a function with variable arguments in Mathematica, you can use the "___" pattern in the function definition. This indicates that the function can take any number of arguments of any type.

3. Can I specify a specific number of arguments for a variable argument function in Mathematica?

Yes, you can specify a specific number of arguments for a variable argument function in Mathematica by using the "___" pattern with a number inside brackets. For example, "func[x___]" would specify that the function can take a minimum of one argument, while "func[x___, y___]" would specify that the function can take a minimum of two arguments.

4. How do I access the variable arguments inside a function in Mathematica?

To access the variable arguments inside a function in Mathematica, you can use the "Sequence" function. This function converts the variable arguments into a list, which can then be manipulated using standard list operations.

5. Can I use variable arguments in combination with other types of arguments in a Mathematica function?

Yes, you can use variable arguments in combination with other types of arguments in a Mathematica function. The variable arguments must always be placed last in the function definition, after any fixed arguments.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
Replies
32
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
Replies
5
Views
492
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Replies
2
Views
600
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
Replies
3
Views
1K
Replies
12
Views
765
Back
Top