I'm having issues during integration due to the fact that Mathematica doesn't know if an undefined variable is positive or not (it gives me complexes which bothers me in the end).

For example I do this:

yy[x_, t_] = aa[t]*(Cos[0.1*x]-Cosh[0.1 x]-Sin[0.1 x]+Sinh[0.1 x])

Integrate[D[yy[x, t], t]^2, {x, 0, 18}]

gives me:

(10.1601 + 0.I) aa'[t]²

while the 0.I shouldn't be here. By using:

Integrate[D[yy[x, t], t]^2, {x, 0, 18}, Assumptions -> aa[t] > 0]

I get rid of the imaginary part but this has to be done cell by cell.

Then comes my questions, is it possible to define, in that case, aa[t] as a posivite variable in the whole notebook and not cell by cell?
Note that in this expample the I is not bothering at all, but with concrete numbers it messes everything up, even by using Chop.


1 Answer 1


You can modify the global system variable $Assumptions, to get the effect you want:

$Assumptions = aa[t] > 0


Integrate[D[yy[x, t], t]^2, {x, 0, 18}]
10.1601 Derivative[1][aa][t]^2

This may, however, be somewhat error-prone. Here is how I'd do this with local environments. This is a generator for a local environment:

createEnvironment[assumptions_] :=
     Block[{$Assumptions = $Assumptions && assumptions}, code],

We now create one:

$Assumptions = True;
env = createEnvironment[aa[t] > 0];

To use it, prefix the intergal with it:

 10.1601 (aa^\[Prime])[t]^2

This is a bit more work since you have to prefix, but it is safer.

  • $\begingroup$ Thanks a lot!I've been looking around on google for ages, and you replied me within 3 mins, thanks! $\endgroup$
    – Öskå
    Jun 4, 2012 at 11:17
  • $\begingroup$ @Öskå Have a look at the addition I made with environments. This is an intermediate variant - more convenient than setting Assumptions in Integrate explicitly, and safer than modifying $Assumptions globally. $\endgroup$ Jun 4, 2012 at 11:19
  • $\begingroup$ I did, & edited comment too, once again, thank you. $\endgroup$
    – Öskå
    Jun 4, 2012 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.