2
$\begingroup$

I've got an $Assumptions variable that I'd like to apply to my whole notebook, looking like so at the moment:

$Assumptions = a > 0 && a ∈ Reals && m > 0 && m ∈ Reals ;

I've actually got a number of variables, and would like to treat all of them as Real and greater than zero. Is there a way to apply such assumptions in batch for a set of variables?

EDIT: comments suggested that only the > checks were required, and that {a,m} > 0 can be used. The greater comment appears to be true, but the set greater than doesn't appear to work:

ClearAll[ a, m, x, psi] ;

psi[x_, a_]  = E^(-x^2/2/a^2) / Sqrt[ a Sqrt[Pi]] ;

$Assumptions = a > 0 && a ∈ Reals  ;
Integrate[ psi[x, a]^2, {x, -Infinity, Infinity}]

$Assumptions = a > 0   ;
Integrate[ psi[x, a]^2, {x, -Infinity, Infinity}]

$Assumptions = {a, m} > 0   ;
Integrate[ psi[x, a]^2, {x, -Infinity, Infinity}] // Simplify

Integrate[psi[x, a]^2, {x, -Infinity, Infinity}] // FullSimplify

(This gives 1,1, Abs[a]/a, and 1/Sign[a] respectively).

So the question is reduced to how to list a set of variables in Assumptions so that all of them are > 0 (without writing a > 0 && b > 0 && c > 0 && ...).

$\endgroup$
  • 2
    $\begingroup$ a > 0 already implies a ∈ Reals, so you only have to include the former assumption. $\endgroup$ – J. M. is in limbo Nov 27 '15 at 3:08
  • $\begingroup$ $Assumptions = {a, b, c} > 0; Simplify[Element[b, Reals]] evaluates to True $\endgroup$ – Bill Nov 27 '15 at 3:58
  • $\begingroup$ Add //Simplify after each operation and you are there. Have fun! $\endgroup$ – Alexei Boulbitch Nov 27 '15 at 9:03
  • $\begingroup$ Tried adding both // Simplify and // FullSimplify (as now mentioned in an update). Simplify doesn't change the result, and FullSimplify still seems to not know about the a > 0 assumption. $\endgroup$ – Peeter Joot Nov 27 '15 at 13:13
  • 1
    $\begingroup$ I can't reproduce the behavior you report. I get 1 for all. Which version are you using? Also, try Thread[{a,m}>0] or even And@@Thread[{a,m}>0]as a workaround. $\endgroup$ – sebhofer Nov 27 '15 at 13:20
1
$\begingroup$

This seems to work (based on https://mathematica.stackexchange.com/a/5263/10)

ClearAll[a, m, x, psi];

psi[x_, a_] = E^(-x^2/2/a^2)/Sqrt[a Sqrt[Pi]];

$Assumptions = And @@ (# > 0 &) /@ {a, m} ;
Integrate[psi[x, a]^2, {x, -Infinity, Infinity}]

One of the comments suggested that {a,m} > 0 would work, but that doesn't appear to be the case for me (Mathematica 9).

$\endgroup$
  • $\begingroup$ I can reproduce this with version 9.0.1. Thread[{a,m}>0] works though. $\endgroup$ – sebhofer Nov 27 '15 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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