Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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!

share|improve this question
    
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 –  Nasser Jun 22 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. –  AwfullyWeeBilly Jun 22 at 18:37

1 Answer 1

up vote 5 down vote accepted

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$

share|improve this answer
    
Ah, I had tried something similar but without the :=. Thank you very much. –  AwfullyWeeBilly Jun 22 at 18:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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