Home > Archive > Mathematica > September 2007 > Integrate not very aggressive about taking constants out of integrals
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Integrate not very aggressive about taking constants out of integrals
|
|
| Darryl Yong 2007-09-22, 4:27 am |
| Try the following three few lines of code in Mathematica:
temp1 = Integrate[-Exp[p[s]] , {s,0,t}];
temp2 = Integrate[Exp[p[s]] , {s,0,t}];
temp1+temp2
Out[3] = Integrate[-E^p[s], {s, 0, t}] + Integrate[E^p[s], {s, 0, t}]
FullSimplify[temp1+temp2]
Out[4] = Integrate[-E^p[s], {s, 0, t}] + Integrate[E^p[s], {s, 0, t}]
You'll notice that Mathematica doesn't take the negative sign out of
the integral in temp1, so the result of temp1+temp2 is not zero unless
you define something for p[s] and let it actually work out both
integrals.
Does anyone know of a way to help Mathematica be more aggressive about
taking constants out of integrals?
Thanks, Darryl
| |
| dimitris 2007-09-23, 4:38 am |
| On 22 , 10:26, "Darryl Yong" <darryly...@gmail.com> wrote:
> Try the following three few lines of code in Mathematica:
>
> temp1 = Integrate[-Exp[p[s]] , {s,0,t}];
> temp2 = Integrate[Exp[p[s]] , {s,0,t}];
> temp1+temp2
>
> Out[3] = Integrate[-E^p[s], {s, 0, t}] + Integrate[E^p[s], {s, 0, t}]
>
> FullSimplify[temp1+temp2]
>
> Out[4] = Integrate[-E^p[s], {s, 0, t}] + Integrate[E^p[s], {s, 0, t}]
>
> You'll notice that Mathematica doesn't take the negative sign out of
> the integral in temp1, so the result of temp1+temp2 is not zero unless
> you define something for p[s] and let it actually work out both
> integrals.
>
> Does anyone know of a way to help Mathematica be more aggressive about
> taking constants out of integrals?
>
> Thanks, Darryl
Hi.
How about?
In[42]:=
temp1 = Integrate[-Exp[p[s]], {s, 0, t}];
temp2 = Integrate[Exp[p[s]], {s, 0, t}];
In[49]:=
temp1 + temp2 /. t -> 0
Out[49]=
0
and
In[45]:=
D[temp1 + temp2, t]
Out[45]=
0
Cheers
Dimitris
| |
| Andrzej Kozlowski 2007-09-23, 4:38 am |
|
On 22 Sep 2007, at 16:23, Darryl Yong wrote:
> Try the following three few lines of code in Mathematica:
>
> temp1 = Integrate[-Exp[p[s]] , {s,0,t}];
> temp2 = Integrate[Exp[p[s]] , {s,0,t}];
> temp1+temp2
>
> Out[3] = Integrate[-E^p[s], {s, 0, t}] + Integrate[E^p[s], {s, 0, t}]
>
> FullSimplify[temp1+temp2]
>
> Out[4] = Integrate[-E^p[s], {s, 0, t}] + Integrate[E^p[s], {s, 0, t}]
>
> You'll notice that Mathematica doesn't take the negative sign out of
> the integral in temp1, so the result of temp1+temp2 is not zero unless
> you define something for p[s] and let it actually work out both
> integrals.
>
> Does anyone know of a way to help Mathematica be more aggressive about
> taking constants out of integrals?
>
> Thanks, Darryl
>
Actually, Integrate is only "aggressive" about integrating and pretty
apathetic about doign anything else. If you really need this for
something serious (at least more than you example above) then rather
than modifyign Integrate or defining your own version you could take
advantage of the fundamental theorem of calculus. To illustrate on a
slighly less trivial example, let
p = Integrate[f[s], {s, 0, t}] + Integrate[-g[s], {s, 0, t}];
then by the FTC this is the same as:
Integrate[D[p, t] /. t -> s, {s, 0, t}]
Integrate[f[s] - g[s], {s, 0, t}]
Andrzej Kozlowski
|
|
|
|
|