Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.maple > #1022
| 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 19:16 -0800 |
| Organization | A noiseless patient Spider |
| Message-ID | <87wq71jegq.fsf@san.rr.com> (permalink) |
| References | <m3u1gm$7ir$1@news.albasani.net> <m3uemq$54f$1@news.albasani.net> <87a93xkwix.fsf@san.rr.com> <8761elkwf3.fsf@san.rr.com> <m3uhi1$avv$1@news.albasani.net> |
rouben@shadow.(none) (Rouben Rostamian) writes:
> In article <8761elkwf3.fsf@san.rr.com>, Joe Riel <joer@san.rr.com> wrote:
>>Joe Riel <joer@san.rr.com> writes:
>>
>>> rouben@shadow.(none) (Rouben Rostamian) writes:
>>>
>>>> In article <m3uatb$st7$1@speranza.aioe.org>,
>>>> Nasser M. Abbasi <nma@12000.org> wrote:
>>>>>On 11/11/2014 5:39 PM, none Rouben Rostamian wrote:
>>>>>
>>>>>> Thanks much, Joe, this is exactly what I was hoping for.
>>>>>> I had no idea about frontend() or the Physics package.
>>>>>>
>>>>>> This brings up a somewhat related question. Doing
>>>>>> frontend(int, [x(t)^2, x(t)]);
>>>>>> we get x(t)^3/3, which is fine. The following, however,
>>>>>> issues an Error message:
>>>>>> frontend(int, [x(t)^2, x(t)=a..b]);
>>>>>>
>>>>>> Is there a way to get that to work too?
>>>>>>
>>>>>> Rouben
>>>>>>
>>>>>
>>>>>I do not use frontend() either. But if all else fails, you
>>>>>can simply use calculus
>>>>>
>>>>>------------------------------
>>>>>restart;
>>>>>f := frontend(int,[x(t)^2, x(t)]);
>>>>>f := unapply(f,t);
>>>>>limit(f(t),t=b)-limit(f(t),t=a);
>>>>>-------------------------
>>>>>
>>>>> (1/3)*x(b)^3-(1/3)*x(a)^3
>>>>
>>>> Hi Nasser, that's good but it's not exactly what
>>>> I had asked. Your result integrates over t=a..b.
>>>> I wanted x(t)=a..b, but that's easy to fix:
>>>> f := frontend(int,[x(t)^2, x(t)]);
>>>> eval(f, x(t)=b) - eval(f, x(t)=a);
>>>>
>>>> This technique, however, does not work in a more complex case.
>>>> For instance, let's write x' and x'' for the first and second
>>>> derivatives of x. We want to integrate x'' * x' * x^2 with
>>>> respect to x. So we do:
>>>>
>>>> frontend(int, [diff(x(t),t,t)*diff(x(t),t)*x(t)^2, x(t)]);
>>>>
>>>> and we get the expected 1/3 * x'' * x' * x^3.
>>>>
>>>> Now, how do we do the corresponding definite integral
>>>> where x(t)=a..b ? The expected answer is
>>>> 1/3 * x''(t) * x'(t) * (b^3 - a^3).
>>>
>>> frontend(int, [diff(x(t),t,t)*diff(x(t),t)*x(t)^2, x(t)=a..b],
>>[{`+`,`*`,`^`,`=`,`..`},{}]);
>>> 1/3*diff(x(t),`$`(t,2))*diff(x(t),t)*(-a^3+b^3)
>>
>>In this case, we could also do
>> frontend(int, [diff(x(t),t,t)*diff(x(t),t)*x(t)^2, x(t)=a..b],
>>[{Not(function)},{}]);
>> 1/3*diff(x(t),`$`(t,2))*diff(x(t),t)*(-a^3+b^3)
>
> Thank you, Joe, for your many very informative responses.
> I have not quite grasped the workings of frontend() yet
> since the next thing I tried, I got stuck again.
>
> Suppose we replace the x(t)^2 in the above with cos(x(t)),
> and change the limits to x(t)=0..Pi/2, as in:
>
> frontend(int, [diff(x(t),t,t)*diff(x(t),t)*cos(x(t)), x(t)=0..Pi/2],
> [{`+`,`*`,`^`,`=`,`..`},{}]);
>
> Neither of the suggested methods works.
> I expect the answer to be x''(t) * x'(t),
> but I get x''(t) * x'(t) * cos(x(t)) * Pi/2.
>
> I tried adding `cos` in frontend's first set
> but Maple says "Error, type `cos` does not exist".
>
> Can you help, please?
Using the print trick helps here. The O's it shows are
frozen expressions, however, separate O's may or may not
correspond to the same subexpression. In this case, the
problem is that the cos(x(t)) is being frozen. You want
it to appear as cos(O), where just the x(t) is frozen.
So one solution is to add specfunc(cos) to the set
of types not to freeze (you'll need to look up help
on type,structured to better understand the specfunc type).
So
frontend(int, [diff(x(t),t,t)*diff(x(t),t)*cos(x(t)), x(t)=0..Pi/2],
[{`+`,`*`,`^`,`=`,`..`,specfunc(cos)},{}]);
diff(x(t),`$`(t,2))*diff(x(t),t)*sin(1/2*Pi)
That can be further simplified with eval (the Pi got frozen,
which is why it didn't simplify):
eval(%);
diff(x(t),`$`(t,2))*diff(x(t),t)
Alternatively, one could use [{Not(specfunc({diff,x}))},{}]
for the third argument. That causes the derivatives and x(t)
to be temporarily frozen.
--
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