       Re: linear equations with indexed variables?

• To: mathgroup at smc.vnet.net
• Subject: [mg6934] Re: linear equations with indexed variables?
• From: sherod at boussinesq.Colorado.EDU (Scott Herod)
• Date: Tue, 29 Apr 1997 20:48:14 -0400 (EDT)
• Organization: /usr/local/lib/rn/organization
• Sender: owner-wri-mathgroup at wolfram.com

```Just off the bat, you could easily convert your equations to a full
system using something like

====================================================================
In:=
eqns = Table[3 x[i] == 2 x[i+1] + x[i-1], {i,1,3}]

Out=
{3 x==x+2 x,3 x==x+2 x,3 x==x+2 x}

In:=
moreEqns = Flatten[Union[eqns, {x == 0, x == 1}]]

Out=
{x==0,3 x==x+2 x,3 x==x+2 x,3 x==x+2 x,x==1}

In:=
Solve[%]
======================================================================

But I notice that you are solving a difference equation with a pair
of boundary conditions.  It might be easier to do something like the
following if this is always the case.

====================================================================
In:= x[i_] := r^i

In:= Factor[3 x[i] - 2 x[i+1] - x[i-1]]

-1 + i
Out= -((-1 + r) r       (-1 + 2 r))

In:= Solve[% == 0, r]

Solve::ifun: Inverse functions are being used by Solve, so some solutions may
not be found.

1                    1/(-1 + i)
Out= {{r -> -}, {r -> 1}, {r -> 0          }}
2

(* I need to figure out a slick way to get rid of the r^(i-1) term. *)

In:= y[i_] := (C x[i] /. Out[]) + (C x[i] /. Out[])

In:= y[i]

C
Out= ---- + C
i
2

In:= Solve[{y == 0, y == 1}]

16           16
Out= {{C -> -(--), C -> --}}
15           15

=======================================================================

Scott Herod
Applied Math

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In article <5jqr2i\$hb8 at smc.vnet.net> hxie at gradin.cis.upenn.edu (Hong-liang Xie) writes:
>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
>
>
>
>
>
>

```

• Prev by Date: Re: linear equations with indexed variables?
• Next by Date: Re: Help - Axes coordinates values
• Previous by thread: Re: linear equations with indexed variables?