RE: Solving for Sum element

• To: mathgroup at smc.vnet.net
• Subject: [mg27270] RE: [mg27260] Solving for Sum element
• From: "David Park" <djmp at earthlink.net>
• Date: Fri, 16 Feb 2001 03:58:20 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```Ben,

Here is one approach:

Attributes[SumTermSolve] = {HoldFirst};
SumTermSolve[sumequation_, index_] :=
Module[{seqn = Hold[sumequation], i, t, start, end},
seqn = ReleaseHold[seqn /. Sum -> sum];
seqn = seqn /. sum[t_, {i_, start_, end_}] ->
sum[t, {i, start, index - 1}] + term[index] +
sum[t, {i, index + 1, end}];
Solve[seqn, term[index]] /. sum -> Sum]

f[i_] := i

SumTermSolve[Sum[f[i], {i, 1, n}] == 0, 3]
{{term[3] -> -3 - 1/2*(-3 + n)*(4 + n)}}

SumTermSolve[Sum[a[i], {i, 0, 6}] == x, 2]
{{term[2] -> x - a[0] - a[1] - a[3] - a[4] - a[5] -
a[6]}}

David Park

> From: Ben Jacobson [mailto:bjacobson at illumitech.com]
To: mathgroup at smc.vnet.net
>
> I want to solve for one element in an equation involving long sums.  The
> actual equation is of course complicated, but a very simplified example
> would be
>
> Sum[a[i],{i,0,n}]==x
>
> where I want to solve for a[0].  The solution should be something like
> a[0]->x-Sum[a[i],{i,1,n}.
>
> Solve[Sum[a[i], {i, 0, n}] == x, a[0]]
>
> works fine if, for example, n=3, but it returns an empty result for
> symbolic n.  Is there a way to tell Solve to assume that n>1 and to solve
> accordingly?  The best I've been able to do so far is to explicitly remove
> the element I'm interested in from the sum:
>
> In: Solve[a[0] + Sum[a[i], {i, 1, n}] == x, a[0]]
> Out: {{a[0] -> x - Sum[a[i], {i, 1, n}]}}
>
> This works nicely, but becomes awkward when I try to solve for more
> elements and longer sums.  Thanks.
>
> Ben Jacobson
> Illumitech Inc.
>

```

• Prev by Date: ParallelMap inefficient?
• Next by Date: Re Complicated Rotation
• Previous by thread: Solving for Sum element
• Next by thread: Re: RE: Solving for Sum element