Cody

Problem 2810. Determinant without using det()

Solution 1599919

Submitted on 4 Aug 2018 by Rafael Hernandez-Walls
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)

y = 23

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

y = -10

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

y = 5.0700e+06

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

y = 1.6534e-07

6   Pass
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)

y = 1.0450e+03

7   Pass
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)

y = -1.3421e+06