       Re: linear equations with indexed variables?

• To: mathgroup at smc.vnet.net
• Subject: [mg6940] Re: [mg6896] linear equations with indexed variables?
• From: "w.meeussen" <w.meeussen.vdmcc at vandemoortele.be>
• Date: Tue, 29 Apr 1997 20:48:19 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```At 14:00 25-04-97 -0400, 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
>
>
For larger (or unbounded) ranges of i,

In:=
<<DiscreteMath`RSolve`
In:=
RSolve[  {3x[i] == 2x[i+1] + x[i-1] ,x[4 ]  == 1,
x   == 0},x[i],i]

Solve::"svars":
"Equations may not give solutions for all \"solve\" variables."

Out=
4 - i
{{x[i] -> 2 + 2      (-1 + C) - C +

14 If[i == 0, 1, 0] - 15 C If[i == 0, 1, 0] -

(-6 + 7 C - C) If[i == 1, 1, 0] -

(-2 + 3 C - C) If[i == 2, 1, 0]}}
*****
the occurence of undetermined constants C[..] shows that the eqn is
underdetermined,
the profusion of "If[i=..,..,..]" shows it is not "simple" or "clean".
*****
In:=Table[{i,x[i]/.%2},{i,0,10}]//Simplify
Out=
{{0, {0}}, {1, {C}}, {2, {C}}, {3, {C}}, {4, {1}},

1                    1
{5, {- (3 - C)}}, {6, {- (7 - 3 C)}},
2                    4

1                       1
{7, {- (15 - 7 C)}}, {8, {-- (31 - 15 C)}},
8                       16

1                          1
{9, {-- (63 - 31 C)}}, {10, {-- (127 - 63 C)}}}
32                         64

why not play 'round with the package, and see what it can do for you.

Dr. Wouter L. J. MEEUSSEN
eu000949 at pophost.eunet.be
w.meeussen.vdmcc at vandemoortele.be

```

• Prev by Date: Re: linear equations with indexed variables?
• Next by Date: Re: linear equations with indexed variables?
• Previous by thread: Re: linear equations with indexed variables?
• Next by thread: Re: linear equations with indexed variables?