Cody

Solution 1728455

Submitted on 16 Feb 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   Pass
A = magic(2); abserr=abs(det(A)-det2(A)); relerr=abserr/abs(det(A)); assert(abserr<1e-10 | relerr<1e-10)

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

L = 0.7391 1.0000 0 0 0 1.0000 0 0 0 0 0.1739 0.2527 0.5164 1.0000 0 0.4348 0.4839 0.7231 0.9231 1.0000 0.4783 0.7687 1.0000 0 0 U = 23.0000 5.0000 7.0000 14.0000 16.0000 0 20.3043 -4.1739 -2.3478 3.1739 0 0 24.8608 -2.8908 -1.0921 0 0 0 19.6512 18.9793 0 0 0 0 -22.2222 y = 5.0700e+06

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

L = 1.0000 0 0 0 0.5000 1.0000 1.0000 0 0.3333 1.0000 0 0 0.2500 0.9000 -0.6000 1.0000 U = 1.0000 0.5000 0.3333 0.2500 0 0.0833 0.0889 0.0833 0 0 -0.0056 -0.0083 0 0 0 0.0004

Assertion failed.

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)

L = 1.0000 0 0 0 1.0000 1.0000 0 0 0.7000 -0.8500 -0.2727 1.0000 0.3000 -0.8167 1.0000 0 U = 10.0000 7.0000 2.0000 9.0000 0 -6.0000 -1.0000 -1.0000 0 0 4.5833 3.4833 0 0 0 3.8000

Assertion failed.

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)

L = 0.8571 0.9434 -0.0120 0.5495 0.2141 -0.0116 1.0000 0 0.4286 1.0000 0 0 0 0 0 0 0.8571 0.4151 -0.0817 0.9886 -0.1996 1.0000 0 0 0.8571 0.4151 -0.4639 0.4751 1.0000 0 0 0 0.8571 0.2830 0.0601 1.0000 0 0 0 0 0.7143 0.8302 -0.0361 0.3994 0.7206 -0.0933 -0.9200 1.0000 0.1429 0.5094 1.0000 0 0 0 0 0 1.0000 0 0 0 0 0 0 0 U = 7.0000 1.0000 5.0000 6.0000 4.0000 1.0000 1.0000 1.0000 0 7.5714 0.8571 5.4286 6.2857 4.5714 0.5714 2.5714 0 0 7.8491 5.3774 -2.7736 1.5283 5.5660 7.5472 0 0 0 -4.0024 -1.0409 5.7572 4.6466 6.9615 0 0 0 0 -3.8300 -1.7808 6.2805 6.2697 0 0 0 0 0 -5.6768 -0.9793 1.0618 0 0 0 0 0 0 3.7614 -3.3477 0 0 0 0 0 0 0 -9.8560 y = -1.3421e+06