Quick question about determinants in mathematica

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
6 replies · 4K views
Amok
Messages
254
Reaction score
1
Sup guys,

So, I'm totally new to mathematica. I need to use it in order to compute a determinant of a
4x4 matrix that is made up entirely of functions. I almost managed to do this in wolfram alpha, but for a 4x4 matrix, the input is too long. Do you guys know how to do this (and if it even possible)?
 
Physics news on Phys.org
Is this example enough to show you how to do this?

In[1]:= Det[{{Sin[t],Log[t]},{t^2,1+t}}]

Out[1]= -t^2 Log[t] + Sin[t] + t Sin[t]
 
Are you totally new to mathematics, too? Working out a determinant for a 4x4 matrix by hand is not much of a problem.
 
gsal said:
Are you totally new to mathematics, too? Working out a determinant for a 4x4 matrix by hand is not much of a problem.

I assume the functions are rather lengthy, and Mathematica is great for simplifying. I think you are assuming its a 4x4 of constants.

The above example should be enough.
Det[] is the function.
Tables/Matrices are entered as:

nameofmatrix = {{1,2,3,4},{5,6,7,8},{9,1,2,3},{4,5,6,7}}

for a 4x4 of constants. You can put the functions in by yourself, or define them prior:

F[1,1] = x^2;
F[1,2] = 3 x + 4;
F[1,3] = Sin[x];
F[1,4] = x^2;
F[2,1] = 3 x + 4;
F[2,2] = Sin[x];
F[2,3] = x^2;
F[2,4] = 3 x + 4;
and so forth for all 16 functions;

Then if you have all 16 functions defined as F[i,j] do:

matrix = Table[F[i,j],{i,1,4},{j,1,4}];
det = Det[matrix]

And you can simplify with :

detS = Simplify[det]

oor detFS = FullSimplify[det]And if you don't know, since you're new, to execute the command you use "SHIFT ENTER" to run the statement.
 
gsal said:
Are you totally new to mathematics, too? Working out a determinant for a 4x4 matrix by hand is not much of a problem.

Honestly, that was uncalled for. If you want to know, I want to compute more than one determinant (I have a linear combination of them) and then collect terms and look for pattern in these functions. Moreover there are four different variables involved. I've been trying by hand, but it's obviously a lengthy procedure and keeping track of all the variables and indexes without making a single mistake is hard...

Hepth said:
The above example should be enough.
Det[] is the function.
Tables/Matrices are entered as:

nameofmatrix = {{1,2,3,4},{5,6,7,8},{9,1,2,3},{4,5,6,7}}

for a 4x4 of constants. You can put the functions in by yourself, or define them prior:

F[1,1] = x^2;
F[1,2] = 3 x + 4;
F[1,3] = Sin[x];
F[1,4] = x^2;
F[2,1] = 3 x + 4;
F[2,2] = Sin[x];
F[2,3] = x^2;
F[2,4] = 3 x + 4;
and so forth for all 16 functions;

Then if you have all 16 functions defined as F[i,j] do:

matrix = Table[F[i,j],{i,1,4},{j,1,4}];
det = Det[matrix]

And you can simplify with :

detS = Simplify[det]

oor detFS = FullSimplify[det]And if you don't know, since you're new, to execute the command you use "SHIFT ENTER" to run the statement.

Thank you for you reply. I tried something like that, but I don't have the explicit form of the functions, I have to write something like f1(x1)*a(y1), f2(x2)*a(y2), f3(x3)*a(y3)... (and permutations). I see that you wrote Sin[X] and not sin(x), so that might help. Gonna try it ASAP

:P

EDIT: Waddya know, it worked! Thx a bunch.
EDIT2: Holy crap! This program is awesome, it actually simplifies stuff :)
EDIT3: Hey, it worked while I called my matrix 'mat' and my determinant 'det', but then I changed them to matrix, or mat1 or det1 and the name became blue and the operations didn't work anymore. I'm having a hard time defining two matrices to use in my computations. Do I have to open a new cell to define each one of them? Or variables for that matter? Why do some names become blue, while others are black? I've read an intro to mathematica, but I'm still confused about this.
 
Last edited:
blue = undefined variable, black = defined variable

You need to set a blue variable to something to make it black. You can do it in the same cell as the previous work, separating with a ; or you can create a new cell. I suggest practicing on simple operations if you are unfamiliar with Mma. Like

Expand[(1+x)^4]
Factor[x^2+x-2]
 
lpetrich said:
blue = undefined variable, black = defined variable

You need to set a blue variable to something to make it black. You can do it in the same cell as the previous work, separating with a ; or you can create a new cell. I suggest practicing on simple operations if you are unfamiliar with Mma. Like

Expand[(1+x)^4]
Factor[x^2+x-2]

I found out that I need to use subscripts in order to label variables and especially functions, because mathematica was getting confused about wether the numbers were labels or actual numbers (hence variables that remained undefined). Everything's working fine now. Thanks.