Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.maple > #1011
| From | Joe Riel <joer@san.rr.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.maple |
| Subject | Re: Differentiating with respect to an expression |
| Date | 2014-11-11 14:35 -0800 |
| Organization | A noiseless patient Spider |
| Message-ID | <87sihpl61w.fsf@san.rr.com> (permalink) |
| References | <m3u1gm$7ir$1@news.albasani.net> |
rouben@shadow.(none) (Rouben Rostamian) writes:
> The following issue comes up quite often in the context of
> analytical mechanics. I have a clunky solution for it.
> I wonder if there is a clever way.
>
> Let's say we have L = x^2 + x'^2 * x''^2, where x is a function of t,
> and in the usual mathematical notation, x' and x'' are the first and
> second derivatives of x.
>
> We want to compute the derivative of L with respect to x'. The
> answer should be 2*x'*x''^2. Here is the way I do it in Maple:
>
> restart;
> L := x(t)^2 + diff(x(t),t)^2 * diff(x(t),t,t)^2;
> subs(diff(x(t),t,t)=Z2, diff(x(t),t)=Z1, %);
> diff(%, Z1);
> subs(Z1=diff(x(t),t), Z2=diff(x(t),t,t), %);
>
> The L shown above is simple enough so that we don't need a
> CAS to compute the derivative. The L in a real example will
> be the result of a long chain of calculations, will depend on
> several functions and their derivatives, and will take up a
> couple of screenfuls.
>
> If there is a clever way to compute that derivative, I would
> like to know.
A low-level way to do this is with frontend:
frontend(diff, [L,diff(x(t),t)]);
2*diff(x(t),t)*diff(diff(x(t),t),t)^2
An alternative method is to use the Physics package:
with(Physics):
diff(L, diff(x(t),t));
2*diff(x(t),t)*diff(diff(x(t),t),t)^2
# alternatively, with Physics
diff(L, D(x)(t));
2*D(x)(t)*`@@`(D,2)(x)(t)^2
--
Joe Riel
Back to comp.soft-sys.math.maple | Previous | Next — Previous in thread | Next in thread | Find similar
Differentiating with respect to an expression rouben@shadow.(none) (Rouben Rostamian) - 2014-11-11 22:10 +0000
Re: Differentiating with respect to an expression Joe Riel <joer@san.rr.com> - 2014-11-11 14:35 -0800
Re: Differentiating with respect to an expression rouben@shadow.(none) (Rouben Rostamian) - 2014-11-11 23:39 +0000
Re: Differentiating with respect to an expression "Nasser M. Abbasi" <nma@12000.org> - 2014-11-11 18:50 -0600
Re: Differentiating with respect to an expression "Nasser M. Abbasi" <nma@12000.org> - 2014-11-11 19:44 -0600
Re: Differentiating with respect to an expression rouben@shadow.(none) (Rouben Rostamian) - 2014-11-12 01:55 +0000
Re: Differentiating with respect to an expression Joe Riel <joer@san.rr.com> - 2014-11-11 18:00 -0800
Re: Differentiating with respect to an expression Joe Riel <joer@san.rr.com> - 2014-11-11 18:03 -0800
Re: Differentiating with respect to an expression rouben@shadow.(none) (Rouben Rostamian) - 2014-11-12 02:44 +0000
Re: Differentiating with respect to an expression Joe Riel <joer@san.rr.com> - 2014-11-11 19:16 -0800
Re: Differentiating with respect to an expression rouben@shadow.(none) (Rouben Rostamian) - 2014-11-12 04:53 +0000
Re: Differentiating with respect to an expression Joe Riel <joer@san.rr.com> - 2014-11-11 17:45 -0800
Re: Differentiating with respect to an expression Joe Riel <joer@san.rr.com> - 2014-11-11 17:52 -0800
Re: Differentiating with respect to an expression rouben@shadow.(none) (Rouben Rostamian) - 2014-11-12 02:03 +0000
csiph-web