Picking a dimension from an interpolating function

I have an interpolation function. Lets think of it as f={fx,fy,fz}.

I would like to operate on the fx part of interpolation and say, multiply it by five and plot it.

I can easily separate the derivative of interpolation function, as seen below as a curl, but I can't work out how to do anything similar for the original interpolation function.

f[x_, y_, z_] := {y, x, 0}
testdata = Flatten[Table[N@{x, y, z, {y, x, 0}}, {x, -3, 3 , 0.5}, {y, -3, 3,0.5},{z, 0, 1, 0.5}], 2];

intf = Interpolation[testdata];
intfd[x_, y_, z_] = D[intf[x, y, z], {{x, y, z}}];

intfcurl[x_, y_, z_] :=
Module[{q = intfd[x, y, z]}, {q[[2, 3]] - q[[3, 2]], q[[3, 1]] - q[[1, 3]], q[[1, 2]] - q[[2, 1]]}]

VectorPlot3D[intf[x, y, z], {x, -3, 3}, {y, -3, 3}, {z, 0, 1}]
VectorPlot3D[intfcurl[x, y, z], {x, -3, 3}, {y, -3, 3}, {z, 0, 1}]

Edit for clarification: Is there a way to do use the interpolation function like the curl example? e.g r= intf[x, y, z], then r[] for the x dimension?

What I would like to do is multiply the x dimension of the interpolation function with the x dimension of the curl, i.e., I'd like to do something like:

intffunction[x_, y_, z_] :=
Module[{q = intfd[x, y, z], r= intf[x,y,z]}, {r[](q[[2, 3]] - q[[3, 2]]), r[](q[[3, 1]] - q[[1, 3]]), r[](q[[1, 2]] - q[[2, 1]])}]

Where r[], r[] and r[], refer to the x,y,z dimensions respectively. Of course, however, r[], and r[], r[] doesn't refer to the x,y,z dimensions in mathematica, but hopefully this gives an idea.

You can generate data with proper replacement and use ListVectorPlot3D.

vector = Table[intf[x, y, z] /. {x_, y_, z_} :> {x, 5 y, z},
{x, -3, 3}, {y, -3, 3}, {z, 0, 1}];
ListVectorPlot3D[vector] Or to do it in your way

intf1[x_, y_, z_] :=  Module[{q = intf[x, y, z]}, {q[], 5 q[], q[]}]

VectorPlot3D[intf1[x, y, z], {x, -3, 3}, {y, -3, 3}, {z, 0, 1}]

However

intffunction[x_, y_, z_] := Module[{q = intfd[x, y, z], r= intf[x,y,z]},
{r[](q[[2, 3]] - q[[3, 2]]), r[](q[[3, 1]] - q[[1, 3]]),
r[] q[[1, 2]] - q[[2, 1]])}]

will give you an empty output because your initial vector field is in xy plane. So its curl would be along z and $\vec{v}.(\nabla \times \vec{v})$ will be zero.

• Is there a way to do it like the curl example? e.g r= intf[x, y, z], then r[] for the x dimension? – Tomi Jun 26 '16 at 19:36
• yes and you already know the answer :). I add it to my answer. – Sumit Jun 26 '16 at 22:12

This works for me:

Clear[intfcurl];
intfcurl[x_?NumericQ, y_?NumericQ, z_?NumericQ] :=
With[{q = intfd[x, y, z]}, {q[[2, 3]] - q[[3, 2]],
q[[3, 1]] - q[[1, 3]], q[[1, 2]] - q[[2, 1]]}]

VectorPlot3D[intf[x, y, z] intfcurl[x, y, z], {x, -3, 3}, {y, -3, 3}, {z, 0, 1}]

(But it helps not to have testdata based on a function with zero curl!)