I'm here with another probably simple question. So I am taking derivatives of a function with respect to another variable not used in that function. So first I define that derivative
D[r[n, k, h, L, \[Mu]], lam] = v[n, k, h, L, \[Mu]], lam]/n
So this is all well and good but then when I actually try to use that derivative in the context of another function, whoopsies it seems like mathematica has forgotten
In[773]:= D[3*r[n, k, h, L, \[Mu]], lam]
Out[773]= 0
So I checked if the original derivative is still defined and lo and behold
In[774]:= D[r[n, k, h, L, \[Mu]], lam]
Out[774]= v/n
(where v is the function of v) How do I make mathematica do this pattern matching correctly? I'm sure this has been asked before but I didn't see quite where.
I thanks to daniel have figured that using
D[f_ : 1 r[n, k, h, L, \[Mu]], lam] ^= v/n
Gives also the wrong answer in that D[r[n, k, h, L, [Mu]], lam] gives the exact same answer as D[3*r[n, k, h, L, [Mu]], lam] which is obviously wrong
Edit: I am still unable to get this to work correctly so I've uploaded my notebook to git. You can find my full code here: https://github.com/pjdog/mathematicaStuff/blob/main/danielsonderivatives.nb
D
what is protected. You must use "UpSet": "^=". Further, MMA is a pattern matcher. If you want to match the pattern "3*r[..]" you must say:D[f_^ : 1 r[n, k, h, L, \[Mu]], lam] ^= v/n;
$\endgroup$