       Re: linear equations with indexed variables?

• To: mathgroup at smc.vnet.net
• Subject: [mg6963] Re: [mg6896] linear equations with indexed variables?
• From: jpk at max.mpae.gwdg.de
• Date: Wed, 30 Apr 1997 22:25:23 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```> From hxie at gradin.cis.upenn.edu Fri Apr 25 23:44:18 1997
> Date: Fri, 25 Apr 1997 14:00:30 -0400 (EDT)
> From: hxie at gradin.cis.upenn.edu (Hong-liang Xie)
> To: mathgroup at smc.vnet.net
> Subject: [mg6896] linear equations with indexed variables?
>
> 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
>
>
>
>
>
>
Hi Hong,

You had a system of recurence equations with constant coeficients and
a boundary problem for this system. The recurence equations with constant
coefficients can be solved usualy by the ansatz x(i)=zeta^i. By insertion
of this ansatz in Your recurence equation  You get the two solutions
zeta=1/2 and zeta=1. This step looks in Mathematica 3.0 so

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

In:= fdsol=Solve[
Cancel[\[Zeta]^(-i)*#] & /@
(fdeqn /. x[i_]:>\[Zeta]^i),
\[Zeta]
]
Out=
{{\[Zeta] -> 1/2},
{\[Zeta] -> 1}}

With this solutions for zeta You can construct the general solution

as x[i]=C*zeta^i+C*zeta^i

The two arbitary constants C and C must be determined from the
boundary conditons. We make our solution a bit more Mathematica like
with

In:=
sol=x[i_]:>
Evaluate[Plus
@@(Map[Apply[Times,#] &,
Transpose[{{C,C},\[Zeta] ^i/.fdsol}]])]

Out=
x[i_] :> C/2^i + C

Now lets determine C and C

In:=
boundsol=Solve[bound={x==1,x==0} /. sol,{C,C}]

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

Now one gets the final solution

In:= finalsol= First[x[i] /. sol /.boundsol]

Out=16/15 - 2^(4 - i)/15

That's all.

Hope that helps
Jens

```

• Prev by Date: Re: Integrate product of Gaussian*Sin
• Next by Date: Re: Re: possible bug in Cases/pattern matching??
• Previous by thread: Re: Integrate product of Gaussian*Sin