4k views

### How to create functions of arbitrary number of variables? [duplicate]

In the following code what would be the simplest way to generalize it to say some $N_f$ number of $z$ instead of just $z_1$ and $z_2$? ...
4k views

### How to define a Mathematica Function with varying number of input and output arguments [duplicate]

In Matlab, such issue is handled by ...
584 views

### Defining functions with changing number of variables [duplicate]

I am working with a bunch of functions of the form fn[x1_,x2_,x3_,...,xn_] := x1x2+x2x3+...+xnx1 where $n$ changes. Is there a way to create these functions ...
141 views

### Define a function of a vector without fully specifying the components of the vector [duplicate]

I have a vector $A=\{1,2,3,4,5,6\}$, and I want to define a function of $A$ as f[A_]:=A.X where $X$ is another vector. I want to define this function without ...
148 views

### How to use an expression for the argument to a function [duplicate]

I would like to define a function over a list of variables like f[a_,b_,c_]:=a+b+c However, when this list is big it makes uncomfortable to read. Can I somehow ...
110 views

### How write this Function with many arguments? [duplicate]

F[x1_,x2_,...,x99_]:=expr How to write this Function in mathematica whithout complete write it?
46 views

### Function with variable arguments [duplicate]

I wrote a function with three arguments like this f[a_,b_,c_]:=... When I call this function MMA requires the input of all three arguments (e.g. f[1,2,3]). Is ...
140k views

### Where can I find examples of good Mathematica programming practice?

I consider myself a pretty good Mathematica programmer, but I'm always looking out for ways to either improve my way of doing things in Mathematica, or to see if there's something nifty that I haven't ...
5k views

### How to avoid collision between optional arguments and options

Is it possible to create a function with optional arguments that also takes options? Here is a simple example. I have a function f with option "g". It also has ...
5k views

### Using a PatternTest versus a Condition for pattern matching

My last question to the site resulted in several answers that involve using pattern matching in Mathematica, a feature I wasn't very familiar with at the time. I am currently reading Mathematica ...
3k views

### Mathematica Destructuring

Context I'm writing a function that look something like: ...
3k views

### Can I make a default for an optional argument the value of another argument?

I'd like to define a function with several optional arguments, some of which default to the value supplied for other arguments. For example, I'd like to be able to write something like ...
2k views

### A function that accepts a pair or a list of pairs

Probably a duplicate, but it's not easy to search on "lists". I have a function that accepts a list of lists, say {{a1, b1}, {a2, b2}, {a3, b3}} and performs some ...