Results 1 to 4 of 4

Math Help - Mathematica, how to construct a tridiagonal matrix?

  1. #1
    Junior Member
    Joined
    Oct 2009
    From
    London
    Posts
    42

    Mathematica, how to construct a tridiagonal matrix?

    Hello I want to view the entries of a block tridiagonal matrix. The matrix is defined by

    u_{i,j-1}+u_{i-1,j}+4 u_{i,j}+u_{i+1,j}+u_{i,j+1}=h^2f_{i,j}

    1\leq i \leq 3 and 1\leq i \leq 4

    I want to examine the structure of this matrix. Obviously writing this out by hand is a laborious task so I was wondering if mathematica can help me.

    I tried

    Table[Subscript[u, i, j - 1] + Subscript[u, i - 1, j] +
    4 Subscript[u, i, j] + Subscript[u, i + 1, j] + Subscript[u, i,
    j + 1] - h^2 Subscript[f, i, j], {i, 3}, {j, 4}]

    But this doesn't quite output what I want. Can somebody tell me how I can construct this matrix more explicitly in Mathematica?
    Follow Math Help Forum on Facebook and Google+

  2. #2
    A Plied Mathematician
    Joined
    Jun 2010
    From
    CT, USA
    Posts
    6,318
    Thanks
    4
    Awards
    2
    That looks like a discretization of Poisson's equation. Am I right? If so, shouldn't the 4u_{i,j} be negative?

    I can't say I know how to visualize the matrix in Mathematica, but here's a visualization of it.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Junior Member
    Joined
    Oct 2009
    From
    London
    Posts
    42
    Thanks, thats correct, it is the discretisation of the Poisson PDE, I was really hoping mathematica could help me in trying to visualise these systems of equations and matrices. Doing it by hand is such a laborious task.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    A Plied Mathematician
    Joined
    Jun 2010
    From
    CT, USA
    Posts
    6,318
    Thanks
    4
    Awards
    2
    Try this:

    Code:
    Table[Subscript[u, i, j - 1] + Subscript[u, i - 1, j] - 
    4 Subscript[u, i, j] + Subscript[u, i + 1, j] + Subscript[u, i, 
    j + 1] - h^2 Subscript[f, i, j], {i, 3}, {j, 4}]//MatrixForm
    Last edited by Ackbeet; August 23rd 2010 at 02:38 AM. Reason: Minus Sign.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 1
    Last Post: December 4th 2010, 09:06 PM
  2. Tridiagonal matrix
    Posted in the Advanced Algebra Forum
    Replies: 0
    Last Post: January 20th 2010, 12:43 PM
  3. tridiagonal matrix problem
    Posted in the Advanced Algebra Forum
    Replies: 2
    Last Post: September 22nd 2009, 11:39 AM
  4. sysmetric tridiagonal matrix
    Posted in the Advanced Algebra Forum
    Replies: 1
    Last Post: November 18th 2008, 10:49 AM
  5. tridiagonal matrix
    Posted in the Advanced Algebra Forum
    Replies: 0
    Last Post: October 26th 2008, 07:50 AM

Search Tags


/mathhelpforum @mathhelpforum