You had to create dqdt manually (or else it would have evaluated to 0 already) so instead of using `q` use `f(q)` where `f=Function('f')`. When you do this something like `(q*Derivative(f(q),t)).subs(q,2)` it will now become `2*Derivative(f(2),t)` instead of 0.
Else, as you say, the masking is easy: reps = {a:Dummy() for a in eq.atoms(Derivative)};eq.xreplace(reps).subs(q,2).xreplace({v:k for k,v in reps.items()})` /c On Wednesday, September 17, 2025 at 3:15:04 PM UTC-5 frank....@gmail.com wrote: > Hi all, > > I constantly run into something like cos(q)*dqdt and I want to substitute > a specific value for q without it affecting dqdt say q = 0 but dqdt is > non-zero. Is there a way to do this without having to make a change of > variables (ie dqdt = u1 then subs for q =0)? > > Thank, > Frank > -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/sympy/5c5ba19e-00de-4a79-8fb0-10a256c3412dn%40googlegroups.com.