0
$\begingroup$

I have a function f of one variable x and a 4 x 3 array A storing constants. I'd like to make an array or table of functionsfunctionTablethat uses both the arrayAand functionf`. I tried something like this, but Mathematica doesn't seem to be reading the array entries.

functionTable = 
  Table[With[{i = i, j = j}, Function[x, A[i, j] + A[i, j]*f[x]]], 
    {b, 1, 3}, {x, 1, 4}, {m, 1, 3}]

How can I go about doing this?

$\endgroup$
3
  • 3
    $\begingroup$ i and j are never defined and b and m are never used. $\endgroup$
    – bill s
    Jul 23, 2015 at 22:34
  • 1
    $\begingroup$ Plus, to access list elements you need to use [[ and ]] instead of [ and ]. $\endgroup$
    – Sektor
    Jul 23, 2015 at 22:35
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 0) Browse the common pitfalls question 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ Jul 24, 2015 at 5:49

2 Answers 2

3
$\begingroup$

Probably.

A = Array[a, {3, 4}];
functionTable = A + A f@# &;
functionTable[x]

Mathematica graphics

$\endgroup$
1
$\begingroup$

Perhaps this is what you are looking for.

arry = Array[a, {4, 3}]
{{a[1, 1], a[1, 2], a[1, 3]},
 {a[2, 1], a[2, 2], a[2, 3]}, 
 {a[3, 1], a[3, 2], a[3, 3]},
 {a[4, 1], a[4, 2], a[4, 3]}}
funcTable = 
  Map[With[{a = #}, Function[x, a (1 + f[x])]] &, arry, {2}];

This shows how the functions in funcTable can be evaluated at an arbitrary value t.

Table[funcTable[[i, j]][t], {i, 4}, {j, 3}]
{{a[1, 1] (1 + f[t]), a[1, 2] (1 + f[t]), a[1, 3] (1 + f[t])}, 
 {a[2, 1] (1 + f[t]), a[2, 2] (1 + f[t]), a[2, 3] (1 + f[t])}, 
 {a[3, 1] (1 + f[t]), a[3, 2] (1 + f[t]), a[3, 3] (1 + f[t])}, 
 {a[4, 1] (1 + f[t]), a[4, 2] (1 + f[t]), a[4, 3] (1 + f[t])}}
$\endgroup$

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