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
.
Answer
You can modify the global system variable $Assumptions
, to get the effect you want:
$Assumptions = aa[t] > 0
Then
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_] :=
Function[code,
Block[{$Assumptions = $Assumptions && assumptions}, code],
HoldAll];
We now create one:
$Assumptions = True;
env = createEnvironment[aa[t] > 0];
To use it, prefix the intergal with it:
env@Integrate[D[yy[x,t],t]^2,{x,0,18}]
10.1601 (aa^\[Prime])[t]^2
This is a bit more work since you have to prefix, but it is safer.
Comments
Post a Comment