Cody

# Problem 1057. Given a matrix, return the last eigen value

Solution 170956

Submitted on 30 Nov 2012
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
%% x = [ 36 2 7 27 20 25 4 33 8 22 24 26 32 10 3 23 28 21 9 29 34 18 11 16 31 6 35 13 15 17 5 37 30 14 19 12]; y_correct = -9.7980e+00; assert(isequal(last_eig(x),y_correct))

``` V = 0.4082 -0.2887 0.4082 0.1507 0.4714 -0.4769 0.4082 0.5774 0.4082 0.4110 0.4714 -0.4937 0.4082 -0.2887 0.4082 -0.2602 -0.2357 0.0864 0.4082 0.2887 -0.4082 0.4279 -0.4714 0.1435 0.4082 -0.5774 -0.4082 -0.7465 -0.4714 0.0338 0.4082 0.2887 -0.4082 0.0171 0.2357 0.7068 D = 117.0000 0 0 0 0 0 0 27.0000 0 0 0 0 0 0 -27.0000 0 0 0 0 0 0 9.7980 0 0 0 0 0 0 -0.0000 0 0 0 0 0 0 -9.7980 ans = -9.7980 ```

2   Fail
%% x = [ 1 2 3 4 5 2 3 4 5 6 73 34 12 66 3 92 298 22 1 4 0 0 3 4 2 ]; y_correct = -3.06262 + 0.00000i; assert(isequal(last_eig(x),y_correct))

```Error: Assertion failed. ```

3   Pass
%% x = [ 3 5 0 8 0 43 12 69 19 20 1000000 1243 3941 1939 -100 1951 1975 1977 1986 1 3450 124 379 485 692 ]; y_correct = 684.5438; assert(isequal(last_eig(x),y_correct))

``` V = -0.0007 -0.0021 + 0.0021i -0.0021 - 0.0021i -0.0011 0.0002 -0.0125 -0.0029 - 0.0257i -0.0029 + 0.0257i -0.7616 0.0270 -0.8763 0.7826 0.7826 0.2774 -0.0253 -0.4684 -0.4683 - 0.3940i -0.4683 + 0.3940i 0.4787 -0.0036 -0.1116 -0.1111 + 0.0015i -0.1111 - 0.0015i -0.3375 0.9993 D = 1.0e+03 * 5.7403 0 0 0 0 0 0.1127 + 1.6756i 0 0 0 0 0 0.1127 - 1.6756i 0 0 0 0 0 -0.0161 0 0 0 0 0 0.6845 ans = 684.5438 ```