Mupad partial time derivative

Hi, I've been working with mupad for some time, but I'm really surprised by the recent situation:
I've been doing some time derivative, but when the expression includes higher devirative of the same variable, it suddenly equals zero, idk why.
Any ideas how to fix this?
this is what i mean:
code:
A:=q(t)
AA:=diff(A|[q(t)=s],s)|[s=q(t)]
B:=(q(t)*diff(q(t),t))
BB:=diff(B|[q(t)=s],s)|[s=q(t)]
I'd expect diff(q(t),t)) instead of 0.

 Accepted Answer

Walter Roberson
Walter Roberson on 16 Oct 2020
You substitute s for q(t), so B transforms into s*diff(s,t) . s is constant with respect to t so diff(s,t) is 0 and s*0 is 0 (provided that s is finite) so s*diff(s,t) is going to collapse to 0. Then you take the derivative of that 0 with respect to s, which is going to be 0.

6 Comments

Thank you for your explanation Walter.
Can you say how the code supposed to be composed?
If you were to take q(t)*diff(q(t),t) and somehow differentiate with respect to function q(t), then I would expect that by the chain rule,
diff(q(t),t)*diff(q(t),t) + q(t)*diff(q(t),t,t)
which would be
diff(q(t),t)^2 + q(t)*diff(q(t),t,t)
not diff(q(t),t) ?
This is true when you differentiate with respect to time.
When you differentiate expression q(t)*diff(q(t),t) with respect to q(t) the resoult is 1*diff(q(t),t).
You helped me a lot, so far, Walter. I know what's the problem now!
I even have an idea how to get rid of this problem. Maybe you can help me out further.
When differentiating ' q(t)*diff(q(t),t) ' with respect to q(t), ' diff(q(t),t) ' sould be treated like any other constant, that's why it equals 1*diff(q(t),t).
B:=(q(t)*diff(q(t),t))
BB:=diff(B|[q(t)=s],s)|[s=q(t)]
To obtain such a resoult, I need to not only assign q(t)=s in B, but for the moment of differentiation, diff(q(t),t) should be replaced by some constant, for instance 'c'.
The resoult will be 'c'.
Then afterwards, I will assign diff(q(t),t) for 'c', again.
Do you know how to assign q(t)=s and diff(q(t),t)=c simultaneously?
OK, I've happened to found an answer.
B:=(q(t)*diff(q(t),t))
BB:=diff(B|diff(q(t),t)=c|[q(t)=s],s)|[s=q(t)]|[c=diff(q(t),t)]
Be well!
By the way, as of R2020b, the MATLAB interface to diff() can differentiate with respect to a function derivative.
Good to know, It must make those operations way easier!

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!