# How to tell Mathematica that a function is dependent on other variables?

I am trying to derive some turbulence model dependencies and I am using Reynolds averaged Navier-Stokes equations. What I am trying to do is to tell Mathematica that OverBar[u] is dependent on x,y,z coordinates and time. However when doing further derivations I would like to avoid writing for example

D[ OverBar[u][x,y,z,t],t]


But rather write just

D[ OverBar[u], t]


But Mathematica should be aware that OverBar is dependent on other variables, because in other case it just writes that D[ OverBar[u],t] is zero.

EDIT: OverBar[u] is not any particular function. It is just time averaged velocity vector which is in general dependent to spatial coordinates and time. There are no any expressions describing it. It is just bare $\bar u$ that I will find using numerical methods. But for now I want to adjust the turbulence model and derive the difference equation, and I do not want to have D[$\bar{u}$,t] output as zero, but rather $\frac{\partial\bar{u}}{\partial{t}}$. Is that possible in Mathematica?

-

Perhaps:

uu := u[x, y, z, t]
uu[x_, y_, z_, t_] := u[x, y, z, t]


So that

D[uu, t] // InputForm
(*
- >Derivative[0, 0, 0, 1][u][x, y, z, t]
*)


and

Dt[uu, t] // InputForm
(*
->          Derivative[0, 0, 0, 1][u][x, y, z, t] +
Dt[z, t]*Derivative[0, 0, 1, 0][u][x, y, z, t] +
Dt[y, t]*Derivative[0, 1, 0, 0][u][x, y, z, t] +
Dt[x, t]*Derivative[1, 0, 0, 0][u][x, y, z, t]
*)


and

 uu[1, 1, 1, 1]
(*
-> u[1, 1, 1, 1]
*)

-
Nice: +1 (and some more characters) –  Fabian Sep 11 '12 at 22:12
That is the smart solution I was looking for. Thanks :] –  Misery Sep 12 '12 at 7:57

I'd look at optional arguments for your function, especially if x, y, and z are not changing or are changing infrequently.

So if I define a function as

function[u_, t_, x_: x, y_: y, z_: z] := u*x^2 + 2*u*y^2 - z^2 + 2*t


I can easily call it without x,y,z arguments:

function[5, 1]

(*2 + 5 x^2 + 10 y^2 - z^2*)


However, if I assign values to x, y, z then the function will update when called.

x = 1;
y = 2;
z = 3;
function[5, 1]

(*38*)


Or, I can call it with temporary values:

function[5, 1, 2, 3, 4]

(*96*)

function[5, 1, a, b, c]

(*2 + 5 a^2 + 10 b^2 - c^2*)


Just remember, the values of x, y, and z must be updated either within the function or before calling it if they change.

-
I don't really understand what you mean. And it doesn't work either :( –  Misery Sep 11 '12 at 18:40
@Misery, to tell a function what values it needs to calculate an output, the function either must have those values pre-defined or included as input. So with the simple function I have up in my answer, the arguments x, y, and z are optional. If they are not specified, they assume whatever values the Global x, y, and z have, either symbolic or numerical –  kale Sep 11 '12 at 18:44
OK, but still D[u,t] is zero. I think I'll just agree with u[t,x,y,z] :[ Thanks for help :) –  Misery Sep 11 '12 at 18:46
@Misery, if you put your function in the Question, I'll adjust the answer to include it. –  kale Sep 11 '12 at 18:46