Monday 12 August 2013

Special Matrix plots! : Hibert, Magic, Pascal, Toeplitz, Vandermonde, Wilkinsons just enter command and view it





This just time pass to learn some of the special matrices of Algebra, code follows:
In linear algebra, a Hilbert matrix, introduced by Hilbert (1894), is a square matrix with entries being the unit fractions
For example, this is the 10 × 10 Hilbert matrix:

hilb(10); % Hibert Matrix
h = hilb(10);
plot(h)
title('Hilbert Matix')
axis off
hi = invhilb(10) % Inverse Hilbert matrix

hi =

   1.0e+12 *

    0.0000   -0.0000    0.0000   -0.0000    0.0000   -0.0000    0.0000   -0.0000    0.0000   -0.0000
   -0.0000    0.0000   -0.0000    0.0000   -0.0002    0.0005   -0.0008    0.0008   -0.0004    0.0001
    0.0000   -0.0000    0.0001   -0.0010    0.0043   -0.0112    0.0178   -0.0166    0.0085   -0.0018
   -0.0000    0.0000   -0.0010    0.0082   -0.0379    0.1010   -0.1616    0.1529   -0.0788    0.0171
    0.0000   -0.0002    0.0043   -0.0379    0.1768   -0.4772    0.7713   -0.7359    0.3821   -0.0832
   -0.0000    0.0005   -0.0112    0.1010   -0.4772    1.3015   -2.1210    2.0378   -1.0644    0.2330
    0.0000   -0.0008    0.0178   -0.1616    0.7713   -2.1210    3.4807   -3.3640    1.7661   -0.3884
   -0.0000    0.0008   -0.0166    0.1529   -0.7359    2.0378   -3.3640    3.2679   -1.7233    0.3804
    0.0000   -0.0004    0.0085   -0.0788    0.3821   -1.0644    1.7661   -1.7233    0.9123   -0.2021
   -0.0000    0.0001   -0.0018    0.0171   -0.0832    0.2330   -0.3884    0.3804   -0.2021    0.0449

plot(hi)
title('Inverse Hilbert Matix')
axis off

%In recreational mathematics, a magic square is an arrangement of numbers (usually integers) in %a square grid, where the numbers in each row, and in each column, and the numbers in the forward %and backward main diagonals, all add up to the same number. A magic square has the same number %of rows as it has columns, and in conventional math notation, "n" stands for the number of rows (and %columns) it has. Thus, a magic square always contains n2 numbers, and its size (the number of rows %[and columns] it has) is described as being "of order n". A magic square that contains the integers %from 1 to n2 is called a normal magic square.

m = magic(10)% Magic Matrix

m =

    92    99     1     8    15    67    74    51    58    40
    98    80     7    14    16    73    55    57    64    41
     4    81    88    20    22    54    56    63    70    47
    85    87    19    21     3    60    62    69    71    28
    86    93    25     2     9    61    68    75    52    34
    17    24    76    83    90    42    49    26    33    65
    23     5    82    89    91    48    30    32    39    66
    79     6    13    95    97    29    31    38    45    72
    10    12    94    96    78    35    37    44    46    53
    11    18   100    77    84    36    43    50    27    59

plot(m)
plot(m)
title('Magic Matrix')
axis off

In mathematics, particularly matrix theory and combinatory, the Pascal matrix is an infinite matrix containing the binomial coefficients as its elements. There are three ways to achieve this: as either an upper-triangular matrix, a lower-triangular matrix, or asymmetric matrix

pascal(10) % Pascal Matrix

ans =

           1           1           1           1           1           1           1           1           1           1
           1           2           3           4           5           6           7           8           9          10
           1           3           6          10          15          21          28          36          45          55
           1           4          10          20          35          56          84         120         165         220
           1           5          15          35          70         126         210         330         495         715
           1           6          21          56         126         252         462         792        1287        2002
           1           7          28          84         210         462         924        1716        3003        5005
           1           8          36         120         330         792        1716        3432        6435       11440
           1           9          45         165         495        1287        3003        6435       12870       24310
           1          10          55         220         715        2002        5005       11440       24310       48620

plot(ans)
title('Pascal Matrix')
axis off

%A matrix equation of the form
%
%is called a Toeplitz system if A is a Toeplitz matrix. If A is an   Toeplitz matrix, then the %system has only 2n−1 degrees of freedom, rather than n2. We might therefore expect that the %solution of a Toeplitz system would be easier, and indeed that is the case.

t = toeplitz(10) % Toeplitz Matrix

t =

    10


A Vandermonde matrix is a type of matrix that arises in the polynomial least squares fitting, Lagrange interpolating polynomials (Hoffman and Kunze p. 114), and the reconstruction of a statistical distribution from the distribution's moments

v = vander(10) % Vandermonde Matrix

v =

     1

In linear algebra, Wilkinson matrices are symmetric, tridiagonal, order-N matrices with pairs of nearly, but not exactly, equal eigenvalues. It is named after the British mathematician James H. Wilkinson

w = wilkinson(10) % Wilkinsons eigen value test matrix

w =

    4.5000    1.0000         0         0         0         0         0         0         0         0
    1.0000    3.5000    1.0000         0         0         0         0         0         0         0
         0    1.0000    2.5000    1.0000         0         0         0         0         0         0
         0         0    1.0000    1.5000    1.0000         0         0         0         0         0
         0         0         0    1.0000    0.5000    1.0000         0         0         0         0
         0         0         0         0    1.0000    0.5000    1.0000         0         0         0
         0         0         0         0         0    1.0000    1.5000    1.0000         0         0
         0         0         0         0         0         0    1.0000    2.5000    1.0000         0
         0         0         0         0         0         0         0    1.0000    3.5000    1.0000
         0         0         0         0         0         0         0         0    1.0000    4.5000

plot(w)
title('Wilkinson Matrix')

axis off

No comments:

Post a Comment