Skip to main content

Timeline for Question about forcing derivatives

Current License: CC BY-SA 4.0

17 events
when toggle format what by license comment
Apr 30, 2021 at 15:46 comment added Paul Hughes Let us continue this discussion in chat.
Apr 30, 2021 at 13:29 comment added Paul Hughes I got TagSetDelayed::tagnf: Tag r not found in D[((1-h_^2-k_^2) ([Mu]_/n_^2)^(1/3))/(1+Cos[L_] k_+h_ Sin[L_]),p1___Symbol,lam,p2___Symbol,NonConstants->spec_]. I wonder if it has to do with defining the vector as the derivative?
Apr 30, 2021 at 13:25 comment added Paul Hughes INteresting when I clear r it works. I wonder if theres something that deals with already having defined r or attempting to make it a nonconstant before defining the derivative. I am on mathematica 12.0
Apr 30, 2021 at 3:59 comment added thorimur @PaulHughes try r /: D[r[n_, k_, h_, L_, \[Mu]_], p1___Symbol, lam, p2___Symbol, NonConstants -> spec_] := Switch[Hold[p1, p2], Hold[], v/m, _, D[v/m, p1, p2, NonConstants -> spec]]. What do you get then?
Apr 29, 2021 at 23:56 comment added thorimur @PaulHughes you mean my code gives you that error? hmmm. copy-pasting my code to a fresh kernel, and adding the dependence on arguments for v works fine for me, no error messages. what version of mathematica are you in? and have you tried ClearAll[r] before evaluating?
Apr 29, 2021 at 22:01 comment added Paul Hughes hmm that's what I thought would fix it but I actually get the exact same problem as I describe above even if I directly copy your code, so now I don't think its actually the problem of th ecomplexity.
Apr 29, 2021 at 19:17 comment added thorimur also, replacing v with v[n, k, h, L, \[Mu]] (no underscores) should solve the first problem you mention!
Apr 29, 2021 at 19:15 comment added thorimur Feel free, though, to edit your question to include the more general cases that are behaving badly, and I'll try to edit my answer to help out when I have the chance :)
Apr 29, 2021 at 19:14 comment added thorimur @PaulHughes ah, I see. That usually happens when the thing you're trying to assign upvalues to only occurs deeper than the first level of the expression. So, for example, a /: f[a] := 1 will work, but a /: f[g[a]] := 1 will give you that error. Here, even though r appeared deeper, the upvalue assignment to r succeeded because r was present as a head on the first level of the expression, namely as D[r[...], ...]. If you're not assigning derivatives to functions directly like that, you might have to add a definition to D after all!
Apr 29, 2021 at 15:36 comment added Paul Hughes my defined derivatives are more complex than the ones I used in my example, and v is actually a function of the same variables as r.Additionally there are special derivatives of r wrt each of the variables because L and lam are related and those derivatives are geometric if that makes sense. I was attempting to figure out how to take the code you generously wrote and plug and play it to fix my code but as have not figured out how to get it to function correctly. Mathematica is giving me the error that the Nonconstants -> {x.... y...) ] is too deep for an assigned rule to be found.
Apr 28, 2021 at 22:34 history edited thorimur CC BY-SA 4.0
added 2 characters in body
Apr 28, 2021 at 21:39 history edited thorimur CC BY-SA 4.0
deleted 3 characters in body
Apr 28, 2021 at 20:41 history edited thorimur CC BY-SA 4.0
added 114 characters in body
Apr 28, 2021 at 20:31 history edited thorimur CC BY-SA 4.0
added 359 characters in body
Apr 28, 2021 at 19:56 history edited thorimur CC BY-SA 4.0
added 20 characters in body
Apr 28, 2021 at 19:50 history edited thorimur CC BY-SA 4.0
added 376 characters in body
Apr 28, 2021 at 19:40 history answered thorimur CC BY-SA 4.0