# Defining a function (but not explicitly)

I have a question that must have a simple answer, but googling and searching this website did not produce an answer, so I'm asking it here.

I'm working with three variables $x, y, \theta$, and I want to tell mathematica that I have a function $f$, which is a function of $x$ and $y$ alone. I do not have an expression for $f$; all I want is for mathematica to produce outputs like $f_x, f_y, f_{xx}$, etc, when asked to differentiate $f$, for instance.

But I do want to get $0$ when I ask mathematica for $f_{\theta}$, since $f$ doesn't depend on $\theta$. How do I define this $f$?

Thank you very much!

• You mean like this? ClearAll[f]; D[f[x, y], theta] which gives zero, and D[f[x, y], x] and D[f[x, y], {x, 2}] etc.. !Mathematica graphics Jun 22 '14 at 18:32
• @Nasser the derivatives were mainly an example of the behavior I expected, not the end goal. What I mean is to have the symbol $f$ with that behavior that I can call whenever I want. The answer below takes care of it.
– L..
Jun 22 '14 at 18:37

The name f can be used for two "different" functions, one depending on three variables and the other depending on two:

f[x_, y_, θ_] := f[x, y]

D[f[x, y, θ], x]


$f^{(1,0)}(x,y)$

D[f[x, y, θ], y]


$f^{(0,1)}(x,y)$

D[f[x, y, θ], θ]


$0$

• Ah, I had tried something similar but without the :=. Thank you very much.
– L..
Jun 22 '14 at 18:36