I want that Mathematica assumes every symbol like Subscript[s,i] to be evaluate as a real and positive number. I have tried

$Assumptions = {Element[{h, k}, Integers], h > -1, k > -1, 
  Element[{Subscript[m, _], Subscript[s, _]}, Reals], Subscript[s, _] > 0}


Subscript[g, i_][x_] := 
  1/√(2 π Subscript[s, i]) Exp[-((x - Subscript[m, i])^2/(2 Subscript[s, i]))];

Simplify@Integrate[Subscript[g, i][x] Subscript[g, j][x], {x, -∞, ∞}]

still gives conditional expression for the integrand. Any suggestion? Thanks!


Patterned assumptions seem to need to match the ConditionalExpression's condition exactly to work out for some cases.

The ∈ Reals-assumptions do work as you gave them, while the inequality Subscript[s,_]>0 does not, but observe the different behavior of Subscript[s,_]>=0:

Evaluating without any assumptions first:

f = 1/\[Sqrt](2 \[Pi] Subscript[s, 
   i]) Exp[-((x - Subscript[m, i])^2/(2 Subscript[s, i]))]
expr=Integrate[f, {x, -∞, ∞}]
(* ConditionalExpression[1, Re[Subscript[s, i]] >= 0] *) 

(Note, that the assumptions about h, k and m have no effect and are therefore superfluous.)

Now, bringing in the patterned assumptions in two versions:

greaterOnly = And @@ {Subscript[s, _] > 0, Element[Subscript[s, _], Reals]}
greaterEqual = And @@ {Subscript[s, _] >= 0, Element[Subscript[s, _], Reals]}

(* ConditionalExpression[1, Subscript[s, i] >= 0] *) 
(* 1 *)

So, the Element-part of assumptions is used in any case, while the inequality requires a "perfect" match.

Hope this helped!

Note: The behavior seems to depend on the Mathematica version. The code above works in 10.1, but behaves differently in 9.x and 8.x (see comments).

| improve this answer | |
  • $\begingroup$ Which version are you using? In v9.0.1, both of the assumptions failed. And in v8.0.4, the result is on the contrary! $\endgroup$ – xzczd Apr 13 '15 at 8:03
  • $\begingroup$ @xzczd: I am using 10.1. $\endgroup$ – Jinxed Apr 13 '15 at 8:07

The document never promises that pattern-matching is supported inside Assumptions. (Though in some cases it does seem to be!) So the only stable way I can think of is as following:

Subscript[g, i_][x_] := 
    ($Assumptions = Union[$Assumptions~Join~
     {{Subscript[m, i], Subscript[s, i]} ∈ Reals, Subscript[s, i] > 0}]; 
   Exp[-((x - Subscript[m, i])^2/(2 Subscript[s, i]))]/Sqrt[2 π Subscript[s, i]]);

Simplify[Integrate[Subscript[g, i][x] Subscript[g, j][x], {x, -∞, ∞}]]
| improve this answer | |
  • $\begingroup$ This still gives a conditional expression in Mathematica 9. $\endgroup$ – Fabio Apr 13 '15 at 12:14
  • $\begingroup$ @Fabio Well, the above code has been tested in v9.0.1, vista 32bit. Have you tried it with a fresh kernel? $\endgroup$ – xzczd Apr 13 '15 at 12:25
  • $\begingroup$ Yes, I have tried. I'm running Linux 64bit. Apparently, Mathematica behaves differently! $\endgroup$ – Fabio Apr 14 '15 at 17:13

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.