Re: integrals involving vectors and matrices
- To: mathgroup at smc.vnet.net
- Subject: [mg29280] Re: [mg29275] integrals involving vectors and matrices
- From: BobHanlon at aol.com
- Date: Mon, 11 Jun 2001 04:38:24 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
In a message dated 2001/6/9 3:28:09 AM, cozzi at almaden.ibm.com writes: >I am trying to do integrals involving vectors and matrices and here is >a >.m file that i have created. When i run it I get the following error >message >"Unable to check convergence". I am new to mathematica and any pointers >or help would be appreciated. thanks, -shiv > >Z = Array[z, {2, 1}] >X = Array[x, {3, 1}] >L = Array[l, {3, 2}] >S = Diagonal Matrix[{s1, s2, s3}] >le1 = Transpose[X - (L.Z)] >ri1 = X - (L.Z) >M = Array[m, {2, 1}] >Q = Array[q, {2, 2}] >le2 = Transpose[Z - M] >ri2 = Z - M >Integrate[Exp[(-1/2)(le1).(Inverse[S]).(ri1)]Exp[(-1/2)(le2).(Inverse[Q]).(ri 2)], >{z, -Infinity, Infinity}] > varArray[var_Symbol,{dim1_Integer?Positive,dim2_Integer?Positive}]:= Module[{v=ToString[var]}, Table[ToExpression[ v<>If[dim1==1,"",ToString[d1]]<> If[dim2==1,"",ToString[d2]]],{d1,dim1},{d2,dim2}]]; Z = varArray[z,{2,1}] {{z1}, {z2}} Note that varArray provides a more compact notation and makes it clearer that there is no variable z but rather two variables, z1 and z2. Did you intend to integrate over a region with both variables going from -Infinity to Infinity? X=varArray[x,{3,1}]; L=varArray[l,{3,2}]; S=DiagonalMatrix[{s1,s2,s3}]; ri1=X-(L.Z); le1=Transpose[ri1]; M=varArray[m,{2,1}]; Q=varArray[q,{2,2}]; ri2=Z-M; le2=Transpose[ri2]; The order of the definitions was changed to make use of previous definitions. Using specific values for several of the variables to simplify the problem expr = Exp[(-1/2)(le1).(Inverse[S]).(ri1)]Exp[(-1/ 2)(le2).(Inverse[Q]).(ri2)] /. {m1->0,m2->0, s1 -> 1, s2 -> 1, s3 -> 1, Sequence@@(#->1& /@ Flatten[L]), Sequence@@(#->0& /@ Flatten[X])} {{E^((1/2)*((-z2)*((q11*z2)/(q11*q22 - q12*q21) - (q12*z1)/(q11*q22 - q12*q21)) - z1*((q22*z1)/(q11*q22 - q12*q21) - (q21*z2)/(q11*q22 - q12*q21))) - (3/2)*(-z1 - z2)^2)}} The double integral for the simplified expression is then Integrate[expr, {z1,-Infinity,Infinity}, {z2,-Infinity,Infinity}]//Simplify {{(4*Pi)/(Sqrt[(3*q22*q11 + q11 - 3*q12*q21)/(q11*q22 - q12*q21)]* Sqrt[-(((12*q21 + 1)*q12^2 + 2*(6*q21^2 + 6*q11*q21 + 6*q22*q21 + q21 - 6*q11*q22)*q12 + q21^2 - 12*q11*q21*q22 - 4*q11*q22*(3*q11 + 3*q22 + 1))/((q11*q22 - q12*q21)* (3*q22*q11 + q11 - 3*q12*q21)))])}} The more general integral may take a very long time to integrate and the output may be very long and complex. Bob Hanlon Chantilly, VA USA