52 States in 8 Months

Maple: How to differentiate with respect to x(t)?

Posted in University stuff by Ulf on May 7, 2009

107mapleleafAlthough Matlab is the toy of choice for control engineers, we sometimes have to use Maple or some other symbolic manipulation program. Now, there is one thing about Maple which I absolutely don’t like: If I define a time-dependent variable such as x(t), I cannot directly use Maples symbolic differentiation tool for differentiating w.r.t. x(t):

diff( sin(x(t)), x(t) );
Error, invalid input: diff received x(t), which is not valid for its 2nd argument

Today I found a really neat solution on mapleprimes.com. They are simply defining a new function sdiff which basically does what I also did a lot of times, substituting x(t)=x and differentiating w.r.t. x:

sdiff := proc(expr, sym)
local t;
subs(t=sym, diff( subs(sym=t,expr), t) );

It is called like this:

sdiff( sin(x(t)), x(t));

The solution comes from Chapter 12 of the Maple Book by Walter Gander and Jiří Hrebicek. Thank you!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: