Cody

Problem 2810. Determinant without using det()

Solution 1948875

Submitted on 25 Sep 2019
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
assert(isempty(regexpi(evalc('type det2'),'det *(')))

2   Pass
A = 23; abserr=abs(det(A)-det2(A)); relerr=abserr/abs(det(A)); assert(abserr<1e-10 | relerr<1e-10)

3   Fail
A = magic(2); abserr=abs(det(A)-det2(A)); relerr=abserr/abs(det(A)); assert(abserr<1e-10 | relerr<1e-10)

Error using assert The condition input argument must be a scalar logical. Error in Test3 (line 4) assert(abserr<1e-10 | relerr<1e-10)

4   Fail
A = magic(5); abserr=abs(det(A)-det2(A)); relerr=abserr/abs(det(A)); assert(abserr<1e-10 | relerr<1e-10)

Error using assert The condition input argument must be a scalar logical. Error in Test4 (line 4) assert(abserr<1e-10 | relerr<1e-10)

5   Fail
A = hilb(4); abserr=abs(det(A)-det2(A)); relerr=abserr/abs(det(A)); assert(abserr<1e-10 | relerr<1e-10)

Error using assert The condition input argument must be a scalar logical. Error in Test5 (line 4) assert(abserr<1e-10 | relerr<1e-10)

6   Fail
A = [10 7 2 9; 10 1 1 8; 7 10 1 10; 3 7 6 7]; abserr=abs(det(A)-det2(A)); relerr=abserr/abs(det(A)); assert(abserr<1e-10 | relerr<1e-10)

Error using assert The condition input argument must be a scalar logical. Error in Test6 (line 4) assert(abserr<1e-10 | relerr<1e-10)

7   Fail
A = [6 8 5 8 8 8 9 5; 3 8 3 8 8 5 1 3; 6 4 4 3 6 3 3 8; 6 4 1 3 3 3 7 8; 6 3 5 3 4 8 6 9; 5 7 4 7 5 6 4 3; 1 4 9 9 1 4 6 9; 7 1 5 6 4 1 1 1]; abserr=abs(det(A)-det2(A)); relerr=abserr/abs(det(A)); assert(abserr<1e-10 | relerr<1e-10)

Error using assert The condition input argument must be a scalar logical. Error in Test7 (line 5) assert(abserr<1e-10 | relerr<1e-10)