       Re: linear equations with indexed variables?

• To: mathgroup at smc.vnet.net
• Subject: [mg6931] Re: linear equations with indexed variables?
• From: Eugene Lee <elee at aw.sgi.com>
• Date: Tue, 29 Apr 1997 20:48:12 -0400 (EDT)
• Organization: Alias Wavefront
• Sender: owner-wri-mathgroup at wolfram.com

```Hong-liang Xie wrote:
>
> I am new to Mathematica and I need to solve a system of
> linear equations whose variables are indexed (i.e., x,
> x, x), for example,
>
>        3x[i] = 2x[i+1] + x[i-1] ( 1 <= i <= 3)
>        x[4 ]  = 1
>        x   = 0
>
> The above is a system of 5 linear equations with
> 5 variables x, x, x, x, x.  I can certainly
> rewrite it into 5 equations using 5 variables x0, x1, x2,
> x3, x4.  However, if the range of i gets bigger, or, worse,
> if each x has two indexes as in x[i,j], this rewriting could
> get of hand quickly.  I tried different equation solving
> functions in Mathematica but with no luck.  I would therefore
> appreciate help from experts here on how to solve this kind of
> equations directly.  Thanks a lot!
>
> Hong
> CIS Dept
> Univ of Pennsylvania

Using the boundary conditions, your system is a matrix equation:

A.X == b, where for your example,

A={{-3,2,0},{1,-3,2},{0,1,-3}}; b={0,0,-2};

Let X=Array[x,3], then you just use Solve:

In:=
Solve[A.X==b, X]
Out=
8           14          4
{{x -> --, x -> --, x -> -}}
15          15          5

YIf the range of i is large, no problem arises, since the matrix is
tridiagonal and has the same pattern.

Eugene Lee

```

• Prev by Date: Re: MMa 3.0 and special font symbol on Mac - Problem.
• Next by Date: Re: linear equations with indexed variables?
• Previous by thread: linear equations with indexed variables?
• Next by thread: Re: linear equations with indexed variables?