I want to define a function with lists as variables, which has the form like
m = Table[2, {i, 5}];
f[x_, y_] = m*x + x*y;
x and y are list variables; m is a constant list with same dimension. If I evaluate this function at
xx = Table[1, {i, 5}]; yy = Table[1, {i, 5}];
I want the output to be
m*xx + xx*yy
which is
{3, 3, 3, 3, 3}
But in fact if I run the function
f[xx, yy]
I will get
{{3, 3, 3, 3, 3}, {3, 3, 3, 3, 3}, {3, 3, 3, 3, 3}, {3, 3, 3, 3, 3}, {3, 3, 3, 3, 3}}
This is not the result I want. I have tried
f @@ {xx, yy}
and
f /@ {xx, yy}
Neither one works. How should I fix fix this problem?
f[x_, y_] := m*x + x*y… colon is needed. – BlacKow Jun 22 '15 at 22:23m*xevaluates to, to see why, and read Understand the difference between Set (or=) and SetDelayed (or:=) for more informations. – Karsten7 Jun 22 '15 at 22:35