Consider a table with n columns and function f[x] depending on n coordinates, $x = x_{1},...,x_{n}$. I want to interpret the table as a set of points in n-dimensional space and calculate the function f[] at each point from the set. Does there exist any command which allows me to do this in one string?

The table is the dataset {{x11, x12, x13, ...}, {x21, x22, x23, ...}}, and I would like to associate the number of the row with the coordinate set in n-dimensional space, so that f[5] -> f[x51, x52, x53, ...].

  • $\begingroup$ 1) What do you mean by string? String in MMA is a well defined command. 2) If your data is, e.g., {{1, 2}, {3, 4}}, then f @@@ {{1, 2}, {3, 4}}. $\endgroup$ – corey979 Jun 11 '18 at 17:21
  • 1
    $\begingroup$ f[n_] := dosomething[table[[n]]] would go in that general direction. $\endgroup$ – MarcoB Jun 11 '18 at 17:43
  • 1
    $\begingroup$ That doesn't change much in the approach, but makes the issue more precise. Note you cannot have the symbol f in two meanings like in the very last part of your question. You can do (with, e.g., data = {{1, 2}, {3, 4}}): g[k_] := (f @@@ data)[[k]]. Then g[1] yields f[1,2] etc. With your definition of f you'll have g[5] yielding f[x51,x52,x53,....] etc. $\endgroup$ – corey979 Jun 11 '18 at 17:44
  • 1
    $\begingroup$ Or, in order not to compute f @@@ data every time: h[k_] := f @@ data[[k]], then h[2] yields f[3, 4] etc. $\endgroup$ – corey979 Jun 11 '18 at 18:24
  • 1
    $\begingroup$ You have already defined the function f[x] somehow, have not you? As much as I understand this prevents you from defining the function returning you f[5] = f[x51, x52, x53, ...] if it is denoted by the same symbol. What about another symbol? Say, g=Map[f,lst] and then g[[5]] returns you `f[{x51, x52, x53, ...}]' ? $\endgroup$ – Alexei Boulbitch Jun 12 '18 at 8:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.