Det in Mathematica

  • Mathematica
  • Thread starter EngWiPy
  • Start date
  • #1
1,367
61

Main Question or Discussion Point

Hello,

I have the following code in Mathematica:

Code:
G[k_, l_] := 
  MatrixForm[Table[If[i == j, 1, 0], {i, 1, 3}, {j, 1, 3}]];

Print[\!\(
\*UnderoverscriptBox[\(\[Sum]\), \(k = 1\), \(3\)]\(
\*UnderoverscriptBox[\(\[Sum]\), \(l = 1\), \(3\)]Det[G[k, l]]\)\)];
but it does not evaluate the determinant as a number, how to force it to do that?

Thanks in advance
 

Answers and Replies

  • #2
Hepth
Gold Member
448
39
Get rid of that "MatrixForm". A table is by definition a matrix, the matrixform just changes display type. So you're operating on a display object rather than a mathematical object.

Then it works.

Remember also the way you have it, k and l are NOT the indices of the matrix. So those sums are just going to give you 9.

G[k_, l_] :=
Table[If[i == j, 1, 0], {i, 1, 3}, {j, 1, 3}][[k]][[l]];

would give you an indexable matrix but then you cannot operate on it like a matrix (det wont work). You'd have to male it a table again:
Det[Table[G[i, j], {i, 1, 3}, {j, 1, 3}]]
 
  • #3
1,367
61
Yes, I know that the equations do not make sense, it is complicated to explain. But it is working now. The actual code is here, which gives an error (why?) and a very large number (not expected, I guess)!!:

Code:
P = {1.6, 1.8, 2};
p = 1;
f1[k_, l_, i_, j_] := Gamma[4]*\!\(
\*UnderoverscriptBox[\(\[Sum]\), \(m = 0\), \(3\)]
\*FractionBox[\(1\), \(m!\)]*NIntegrate[
\*SuperscriptBox[\(Log[1 + p*y]\), \(2\)]*
\*SuperscriptBox[\(y\), \(3 - j\)]*Exp[\(-y\)]*
\*SuperscriptBox[\((
\*FractionBox[\(1\), \(P[\([\)\(i\)\(]\)] + y\)])\), \(-\((3 + 1 - 
           m)\)\)], {y, 0, Infinity}]\);
f2[k_, l_, i_, j_] := If[j == k, f3[k, l, i, j], f4[k, l, i, j]];
f3[k_, l_, i_, j_] := 
  Exp[1/P[[i]]]*
   NIntegrate[(Log[1 + (p*u)]*u^(3 - j))/(1/(P[[i]] + u))^(3 + 1)*
     Gamma[3 + 1, 1/(P[[i]]*u)], {u, 0, Infinity}];
f4[k_, l_, i_, j_] := 
  N[Gamma[3 - j + 1]*Exp[1/P[[i]]]*P[[i]]^j*Gamma[j, 1/P[[i]]]];
G[k_, l_] := 
  Table[If[k == l == j, f1[k, l, i, j], f2[k, l, i, j]], {i, 1, 
    3}, {j, 1, 3}];

Print[\!\(
\*UnderoverscriptBox[\(\[Sum]\), \(k = 1\), \(3\)]\(
\*UnderoverscriptBox[\(\[Sum]\), \(l = 1\), \(3\)]Det[G[k, l]]\)\)];
Best regards
 

Related Threads for: Det in Mathematica

Replies
6
Views
3K
Replies
9
Views
2K
  • Last Post
Replies
4
Views
2K
Replies
2
Views
2K
Replies
0
Views
9K
Replies
3
Views
3K
  • Last Post
Replies
4
Views
2K
Top