MATLAB Answers

matrix retrieving given certain determinant

2 views (last 30 days)
saleh salous
saleh salous on 12 Feb 2018
Answered: John D'Errico on 9 Feb 2021
dear all i want to retrieve matrix 3x3 with given determinant thanks

Answers (2)

Torsten
Torsten on 12 Feb 2018
Edited: Torsten on 12 Feb 2018
determinant = -30;
diagonal = abs(determinant)^(1/3);
A = zeros(3);
A(1,1) = diagonal;
A(2,2) = diagonal;
A(3,3) = sign(determinant)*diagonal;
det(A)

John D'Errico
John D'Errico on 9 Feb 2021
You want to generate a random matrix with a known determinant?
n = 7; % The size of the matrix
Dtarget = 12; % My target determinant
A = randn(n);
DA = det(A);
A = A*sign(DA)*nthroot(Dtarget/abs(DA),n)
A = 7×7
0.9922 0.4403 -0.2089 -0.2847 -1.4401 -0.8839 -0.3974 0.9601 -0.5051 -0.9957 -1.5741 -0.5598 0.1125 0.6553 -1.7138 -0.6681 -0.8090 -0.3641 0.9679 -0.7558 0.1677 -0.2605 0.3534 1.4410 -0.7409 -2.2699 0.1544 -0.9737 -0.1658 -0.3712 0.7740 -0.8034 -2.3909 -0.4586 0.3298 -1.6123 -0.7431 -0.8667 0.8437 0.6098 0.9010 0.1605 -0.7253 1.2699 0.4742 1.2487 0.7657 -0.0548 -1.4604
Was I successful?
det(A)
ans = 12.0000
Do you want another solution?
n = 5;
A = rand(n);
Dtarget = 17; % My target determinant
[L,U] = lu(A);
L(1,:) = L(1,:)*sign(prod(diag(U)));
U(1:n+1:end) = nthroot(Dtarget,n);
A = L*U
A = 5×5
0.0052 0.1007 1.7623 0.7457 0.2337 0.4085 1.0351 0.5421 2.0212 0.6587 0.7567 1.9360 0.1143 0.1061 0.1833 0.8062 0.6791 1.5897 0.2229 2.2088 1.7623 0.4045 0.3056 0.0629 0.9404
det(A)
ans = 17

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!