I believe sympy.physics.mechanics.msubs(….)  also does not go ‘inside’ the time 
derivatives (?)

 

From: sympy@googlegroups.com <sympy@googlegroups.com> On Behalf Of Chris Smith
Sent: Thursday, September 18, 2025 3:13 PM
To: sympy <sympy@googlegroups.com>
Subject: [sympy] Re: Subs for variable without affecting it's derivative

 

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 
<mailto: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 
<mailto:sympy+unsubscr...@googlegroups.com> .
To view this discussion visit 
https://groups.google.com/d/msgid/sympy/5c5ba19e-00de-4a79-8fb0-10a256c3412dn%40googlegroups.com
 
<https://groups.google.com/d/msgid/sympy/5c5ba19e-00de-4a79-8fb0-10a256c3412dn%40googlegroups.com?utm_medium=email&utm_source=footer>
 .

-- 
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/015401dc289e%24ee48bb40%24cada31c0%24%40gmail.com.

Reply via email to