# Cross product of two vector functions [closed]

I have two vector functions

f[x_, y_, z_] := {x, y, z}
g[x_, y_, z_] := {y, 10, x}


I want to take the cross product of these two vectors at every point. This should result in another vector function.

How would I do so without creating a loop using Cross? This seems inefficient.

Edit:

The question was in regard to interpolation functions. The method suggested in the comments does not work

(*create data to interpolate*)
(*each corressponds to the values in \
that direction for each function *)
fx = Table[1, 1000];
fx = ArrayReshape[fx, {10, 10, 10}];
fy = Table[1, 1000];
fy = ArrayReshape[fy, {10, 10, 10}];
fz = Table[1, 1000];
fz = ArrayReshape[fz, {10, 10, 10}];
gx = Table[-1, 1000];
gx = ArrayReshape[gx, {10, 10, 10}];
gy = Table[-1, 1000];
gy = ArrayReshape[gy, {10, 10, 10}];
gz = Table[-1, 1000];
gz = ArrayReshape[gz, {10, 10, 10}];

(*interpolate to get vector interpolation function *)
iff = ListInterpolation /@ {fx, fy, fz};
ifg = ListInterpolation /@ {gx, gy, gz};

gif[x_, y_, z_] := (#[x, y, z] & /@ ifg) ;
fif[x_, y_, z_] := (#[x, y, z] & /@ iff) ;

VectorPlot3D[{gif[x, y, z], fif[x, y, z]}, {x, 1, 10}, {y, 1, 10}, {z,
1, 10}]

(*this does not work *)
f[x,y,z]\[Cross]g[x,y,z] (*credit to kglr*)


I would like the cross produce between f & g.

## closed as off-topic by yohbs, happy fish, MarcoB, gwr, rhermansApr 26 '17 at 11:20

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – yohbs, happy fish, MarcoB, gwr, rhermans
If this question can be reworded to fit the rules in the help center, please edit the question.

• f[x, y, z]\[Cross]g[x, y, z] or Cross @@ Through[{f, g}@##] &[x, y, z]? – kglr Apr 22 '17 at 0:21
• This works for the example I gave. The issue is I have a 3D interpolation function. The same method does not work. I will edit the equation to reflect this and give a MWE. My mistake. Apologies. – Tomi Apr 22 '17 at 0:27
• did you try fif[x,y,z] \[Cross] gif[x,y,z]? – kglr Apr 22 '17 at 10:55
• @kglr's method Cross[gif[x, y, z], fif[x, y, z]] works perfectly more me. Just like cross[] in Marius' answer. – Michael E2 Apr 22 '17 at 12:23
• I did try last night, however, I must've made an error. Both methods work. – Tomi Apr 22 '17 at 12:28

As I wrote about in this answer, the normal way to combine InterpolatingFunctions is to use FunctionInterpolation. But before I show how to do this, let me try to rephrase the InterpolatingFunctions you have used.

What you want from your example is one constant vector field $$\mathbf{f}(x,y,z) = (1,1,1)$$ and another constant vector field $$\mathbf{g}(x,y,z) = (-1,-1,-1)$$ if I understand correctly. The way I think one should do that is

coordinatePoints = Tuples[Range[1, 10], 3];
fInterpol = Interpolation[Tuples[{coordinatePoints, {{1, 1, 1}}}]];
gInterpol = Interpolation[Tuples[{coordinatePoints, {{-1, -1, -1}}}]];


Now these are InterpolatingFunctions that have vectors as output, e.g.

fInterpol[1,2,3]


{1,1,1}

as you can see when you define them:

Now, I could actually not get Mathematica 10.0.2 to make an InterpolatingFunction out of the cross product like I usually would, because it does not seem to support vector output; I get error messages when I try to do

crossFailed = FunctionInterpolation[fInterpol[x, y, z]~Cross~gInterpol[x, y, z], {x, 1, 10}, {y, 1, 10}, {z, 1, 10}]


But of course this is not needed: you can simply do:

cross[x_, y_, z_] := fInterpol[x, y, z]~Cross~gInterpol[x, y, z]


However, unless we choose some other values for $\mathbf{f}$ and/or $\mathbf{g}$, the result is always {0,0,0} :p

f[x, y, z]\[Cross]g[x, y, z]


{x y - 10 z, -x^2 + y z, 10 x - y^2}

or

Cross @@ Through[{f, g}@##] &[x, y, z]


{x y - 10 z, -x^2 + y z, 10 x - y^2}