# Defining tensor components generally

I would like to define a tensor according to its components, something like the following:

[F(x)]_i,j = Integrate[f(x,y)A_i(y)B_j(y),y]


where i and j are components between 1 and 3, i.e. A_i(y)B_j(y) is a 2nd rank tensor. F is also a 2nd rank tensor, with components i and j. Now, I don't want to explicitly enter the separate values for this definition, i.e.

[F(x)]_1,1 = Integrate[f(x,y)A_1(y)B_1(y),y]
[F(x)]_1,2 = Integrate[f(x,y)A_1(y)B_2(y),y]


etc. How can I do it generally? Also, I would not like to enter specific values for A and B components, but keep it general for arbitrary A and B.

### EDIT

Suppose I have the following:

f = 5 x + 3 y;
A = {8 y^2, 5 y, 17 y^3 + 3};
B = {7 y + 3, 4 y, 5 y + 3 y^2};


Now, I don't know my exact input (that's what I am asking) but it would be something like that:

F[i,j]=Integrate[f A[[i]] B[[j]],{y,0,8}]


I want it to be defined as a tensor, so that later I will be able to contract its indices with other tensors. My output should look like:

F = {{Integrate [f*A[[1]] B[[1]], {y, 0, 8}],
Integrate [f*A[[1]] B[[2]], {y, 0, 8}],
Integrate [f*A[[1]] B[[3]], {y, 0, 8}]},
{Integrate [f*A[[2]] B[[1]], {y, 0, 8}],
Integrate [f*A[[2]] B[[2]], {y, 0, 8}],
Integrate [f*A[[2]] B[[3]], {y, 0, 8}]},
{Integrate [f*A[[3]] B[[1]], {y, 0, 8}],
Integrate [f*A[[3]] B[[2]], {y, 0, 8}],
Integrate [f*A[[3]] B[[3]], {y, 0, 8}]}}


I want this to work when I don't define explicitly A, B, f. without definitions, I want Mathematica to write the answer in terms of A[[1]] etc, and understand it as a tensor, so I can use it later. I hope now it's clear.

-
Does Array or Table help? – Szabolcs Jun 18 '14 at 22:13
I was wondering if it was possible without entering the values explicitly, i.e. writing the expression using i,j and their range (1-3) and the progra would know what the 9 values I mean are – Dave Jun 18 '14 at 22:18
Can you give a specific example of an input you might have and an output you would desire, so the question is completely clear? Please use Mathematica code (what you posted is not). I'm asking this because I can imagine a number of different interpretations of your question, based on Mathematica's capabilities. An example would help a lot and would save us both time (we won't have to have a long comment thread for clarifications). – Szabolcs Jun 18 '14 at 23:42
BTW depending on how A and B are defined you may be able to use the Listable attribute, Map or MapThread. – Szabolcs Jun 18 '14 at 23:52
Thanks for the clarification. I posted an answer. Does this solve the problem? – Szabolcs Jun 19 '14 at 1:52

Or using Outer:

Outer[Integrate[f #1 #2, {y, 0, 8}] &, A, B]

{{5873664/5 + 307200 x, 3145728/5 + 163840 x, 3932160 + 991232 x},
{115200 + (96800 x)/3, 61440 + (51200 x)/3, 371712 + (294400 x)/3},
{83059424/5 + 4164232 x, 8919040 + 2230144 x, 399099392/7 + 13936480 x}}

-

You can use Table to achieve this:

f = 5 x + 3 y;
A = {8 y^2, 5 y, 17 y^3 + 3};
B = {7 y + 3, 4 y, 5 y + 3 y^2};

Table[Integrate[f a b, {y, 0, 8}], {a, A}, {b, B}]

(* {{5873664/5 + 307200 x, 3145728/5 + 163840 x,
3932160 + 991232 x}, {115200 + (96800 x)/3, 61440 + (51200 x)/3,
371712 + (294400 x)/3}, {83059424/5 + 4164232 x,
8919040 + 2230144 x, 399099392/7 + 13936480 x}} *)

-
Hey, when did Outer appear there? ;-p – Mr.Wizard Jun 19 '14 at 1:56
@Mr.Wizard About 1 second before you posted! The "new answer" notifcation really came just after I pressed the post button ... sorry – Szabolcs Jun 19 '14 at 1:59
If you include shorter form to satisfy my need for terse code I'll delete my redundant answer. – Mr.Wizard Jun 19 '14 at 2:00