Cody

# Problem 451. Is this matrix orthogonal?

Solution 2050409

Submitted on 8 Dec 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   Fail
x = orth(randn(3)); y_correct = true; assert(isequal(isOrthogonal(x),y_correct))

x_size = 3 x = -0.2297 -0.1727 -0.9578 -0.1455 0.9792 -0.1417 0.9623 0.1068 -0.2501 ans = -0.2297 -0.1455 0.9623 -0.1727 0.9792 0.1068 -0.9578 -0.1417 -0.2501

Assertion failed.

2   Fail
x = orth(randn(4)); y_correct = true; assert(isequal(isOrthogonal(x),y_correct))

x_size = 4 x = -0.1982 -0.9242 -0.2677 0.1867 0.7156 -0.2984 0.6112 0.1590 0.5328 0.1778 -0.6650 0.4923 -0.4059 0.1586 0.3354 0.8352 ans = -0.1982 0.7156 0.5328 -0.4059 -0.9242 -0.2984 0.1778 0.1586 -0.2677 0.6112 -0.6650 0.3354 0.1867 0.1590 0.4923 0.8352

Assertion failed.

3   Fail
x = orth(randn(5)); y_correct = true; assert(isequal(isOrthogonal(x),y_correct))

x_size = 5 x = -0.0038 0.3620 -0.9001 -0.2330 -0.0669 0.1536 0.1764 -0.0485 0.1853 0.9532 -0.1322 0.3566 0.3523 -0.8440 0.1373 -0.1150 0.8343 0.2386 0.4362 -0.2085 0.9725 0.1207 0.0802 -0.0933 -0.1568 ans = -0.0038 0.1536 -0.1322 -0.1150 0.9725 0.3620 0.1764 0.3566 0.8343 0.1207 -0.9001 -0.0485 0.3523 0.2386 0.0802 -0.2330 0.1853 -0.8440 0.4362 -0.0933 -0.0669 0.9532 0.1373 -0.2085 -0.1568

Assertion failed.

4   Pass
x=sqrt([3,1;1,1]); y_correct = false; assert(isequal(isOrthogonal(x),y_correct))

x_size = 2 x = 1.7321 1.0000 1.0000 1.0000 ans = 1.7321 1.0000 1.0000 1.0000

5   Pass
x = magic(6); y_correct = false; assert(isequal(isOrthogonal(x),y_correct))

x_size = 6 x = 35 1 6 26 19 24 3 32 7 21 23 25 31 9 2 22 27 20 8 28 33 17 10 15 30 5 34 12 14 16 4 36 29 13 18 11 ans = 35 3 31 8 30 4 1 32 9 28 5 36 6 7 2 33 34 29 26 21 22 17 12 13 19 23 27 10 14 18 24 25 20 15 16 11

6   Pass
x = randn(2)+1; y_correct = false; assert(isequal(isOrthogonal(x),y_correct))

x_size = 2 x = 1.1191 -0.1980 0.6725 -0.8240 ans = 1.1191 0.6725 -0.1980 -0.8240