2
$\begingroup$

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!

$\endgroup$
  • $\begingroup$ 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 $\endgroup$ – Nasser Jun 22 '14 at 18:32
  • $\begingroup$ @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. $\endgroup$ – L.. Jun 22 '14 at 18:37
5
$\begingroup$

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$

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.