Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a list of symbols that I have defined using

d = Table[Symbol["d" <> ToString[i]], {i, 1, n}] 


d = {d1, d2, d3, d4, d5}

where n = 5 in this case. I use this as part of an argument to an interpolation, giving me

Vchamber = 0.111549 d1 - 0.101842 d2 + 0.857554 d3 - 1.09366 d4 + 2.24236 d5 

Now I want to define a function that gives something like

 fVchamber[d1_,d2_,d3_d4_,d5_] := 0.111549 d1 - 0.101842 d2 + 0.857554 d3 - 1.09366 d4 + 2.24236 d5 

Now, n is variable. Hence, the argument list is variable, as is the expression Vchamber. I was hoping that something like


would work but it doesn't. What am I doing wrong? I have looked for answers but I haven't found one yet.

share|improve this question
Could you perhaps just work with lists instead of introducing those symbols? fVchamber[dlist_] := {0.1,0.2,0.3,0.4,0.5} . dlist – Szabolcs Nov 15 '12 at 20:06
This is just one form that I have. I have expressions that are more complicated. – user4667 Nov 15 '12 at 20:47

This seems to work:

fVchamber = Function[Evaluate@d, Evaluate@Vchamber]

So first, when you define a Function, you don't need a definition like


Second, Function apparently Holds the arguments, so you need to make sure they are evaluated. After the above definition, this seems to work:

In[10]:= fVchamber[0, 1, 0, 0, 0]
Out[10]= -0.101842
share|improve this answer
See, for example the example where they use a similar construct to set f equal to the pure function – tkott Nov 15 '12 at 20:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.