# separation of variables in case of vector components

I have a function f in two variables y and theta, where y=z^2+x^2. There are numerical values for x,z,and theta ( x and z are the dimensions),I have to do calculations to obtain the velocity, so I need a way to express the vector of velocity in two components x and z separately.The following is a simple example of my task:

f[y_,θ_] = 2 y Cos θ + 4 y^2 (1 - 3 Cos θ)

v[y_, θ_] = f[y, θ]/gradf[y, θ]


I made the below way, but it is not correct.

v[(z^2 + x^2) _, θ_] = f[y, θ]/gradf[y, θ]


I need separation of variables as components of vector, where:

z = {0.026239934196048018, 0.031239934196048022,
0.03623993419604802, 0.04123993419604802, 0.04623993419604802,
0.05123993419604802};
x = {-0.0065135092956195365, -0.0065135092956195365,
-0.0065135092956195365, -0.0065135092956195365,
-0.0065135092956195365, -0.0065135092956195365};

k = Sqrt[y]= Sqrt[z^2 + x^2]
θ = ArcCos[z/k]


Thank you.

• Can you clarify what you want to do exactly? Do you just want to replace y by z^2+x^2 ? Jan 27, 2020 at 11:30
• Hi Banone, My goal is to get the velocity in two variables z and x only. In other words, it is to obtain v [z_,x_]
Jan 27, 2020 at 20:07
• and what about θ? Jan 28, 2020 at 7:18
• I already have numerical data for z,x, and θ. I don't know if I can evaluate the function using the values of θ and then the function will be v[(z^2 + x^2)] , so I'll get two parts (because of gradient) both of them in (z^2 + x^2). Then how can I obtain v[x_,z_]?
Jan 28, 2020 at 14:00
• Ok, I understand. I suggest making an interpolation function for θ(x,z) and include it in your definition. Can you provide your data or equivalent example data? Jan 28, 2020 at 14:43

I was wrong in the comments, since you have an analytical expression for θ, there is no need for an InterpolationFunction.

f[y_, θ_] = 2 y Cos[θ] + 4 y^2 (1 - 3 Cos[θ]);


There was a typo, the Cos didn't have brackets in the first line, also I added v0 to save the evaluated expression before adding the other definitions:

y = z^2 + x^2;
k = Sqrt[z^2 + x^2];
θ = ArcCos[z/k];


Then you can just:

v[x_, z_] = v0


to evaluate the function you just map it to your x,z-data:

mesh = Transpose[{x, z}]
v[Sequence @@ #] & /@ mesh


or like this:

v[#[], #[]] & /@ mesh


Let me know if you have any questions.

• Thank you very much!