Saturday, May 22, 2010

HP 50G Basic linear algebra: Matrices

  1. How do I create a matrix easily?

    The matrix writer is the easiest method to not only create, but also view and edit
    a matrix in the HP50G.

    You can access it via the LSH MTRW buttons.
    After entering the elements of the matrix completely, press the ENTER key
    then store it into a variable to avoid reentering the values.

    Special commands such as deleting a row or a column may be learned from
    the HP 48G User's guide, Chapter 14.

  2. I want to create a matrix directly. How do I enter the elements of the matrix?

    Press LSH [] LSH [] to mark the delimiters of the matrix.
    Enter the elements of the first row, using SPC to separate them. (no need to type a comma in RPN mode)
    Press RIGHT button to to move the cursor after the ] row delimiter.
    Press LSH [] to start a new row. When done, press ENTER.

  3. How do I create an identity matrix?

    The identity matrix of size (n x n) may be created by the function idn(n).

  4. How do I create a constant matrix?

    The constant matrix of size(m x n) with all values c may be created by the function
    con({m,n}, c).

  5. How do I create a matrix with specified elements along the diagonal?

    Use the diag->({m,n),[d1, ..., dn] function. It requires the dimension of the matrix and a vector or the diagonal elements.



    Q. Define a zero matrix of size 4,4

  6. How do I define a square matrix of random integers?

    Use the randm(n) function which will return an (n x n) matrix.

  7. How do I transpose a matrix?
    Use the trn(M) function. This will also return the conjugate transpose for complex matrices.

  8. How to I invert a matrix M.

    There is more than one way to do it: 1/M, M^-1, inv(M)

  9. How do I define a Vandermonde matrix?
    The command for creating a square Vandermonde matrix is to specify the vector X. The output
    is the matrix consisting of columns of 1, ang the columns of powers of X. Thus vandermonde([3,4,5]) will output

    $$\begin{array}{lll} 1 &3 &9 \\1 &4 &16 \\1 &5 &25 \\ \end{array}$$

  10. How do I multiply each element of a matrix M by a constant k?
    Simply type k * M.


  11. How do I add or subtract a constant from all elements of a matrix M?
    There seeems to be no direct way. Create a constant matrix of the same size and
    perform the corresponding addition or subtraction.

  12. How do I swap rows or columns of a matrix M?
    Consult the manual for the commands RSWAP and CSWAP functions.


No comments:

Post a Comment