Skip to main content
added 126 characters in body
Source Link
xzczd
  • 68.4k
  • 9
  • 174
  • 489

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 = {};(*This is to guarentee the Join below will work*)
Subscript[g, i_][x_] := 
    ($Assumptions := 
    ($Assumptions = Union[$Assumptions~Join~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, -∞, ∞}]]

Tested in v9.0.1 and v12.3.1, Windows 10.

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, -∞, ∞}]]

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:

$Assumptions = {};(*This is to guarentee the Join below will work*)
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, -∞, ∞}]]

Tested in v9.0.1 and v12.3.1, Windows 10.

Source Link
xzczd
  • 68.4k
  • 9
  • 174
  • 489

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, -∞, ∞}]]