Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #12805 > unrolled thread

Working with indefinite number of variables

Started byBenjamin Hell <hellben@gmx.de>
First post2012-12-15 10:47 +0000
Last post2012-12-17 07:54 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Working with indefinite number of variables Benjamin Hell <hellben@gmx.de> - 2012-12-15 10:47 +0000
    Re: Working with indefinite number of variables David Bailey <dave@removedbailey.co.uk> - 2012-12-17 07:54 +0000

#12805 — Working with indefinite number of variables

FromBenjamin Hell <hellben@gmx.de>
Date2012-12-15 10:47 +0000
SubjectWorking with indefinite number of variables
Message-ID<kahkfe$d6j$1@smc.vnet.net>
Hi,
I have been wrapping my head around this for a while now and I have not found a solution so far.
I want to work with an indefinite number of variables in mathematica and use some built in functions.

To make things more specific for starters I want to do the following:

Define a sum with n summands each containing a new variable x[i] (in the i-th summand): 
sum[n_] = Sum[i*x[i], {i, 1, n}]

Then I want to differentiate the expression with respect to some x[i] like: 
D[sum[n],x[2]]

Mathematica return 0 instead of 2. If I supply a specific n like: 
D[sum[2],x[2]]
everything works fine.

I thought about using Assumptions for n, but with no success so far.

How can I do that right?

[toc] | [next] | [standalone]


#12826

FromDavid Bailey <dave@removedbailey.co.uk>
Date2012-12-17 07:54 +0000
Message-ID<kamj4d$qs5$1@smc.vnet.net>
In reply to#12805
On 15/12/2012 10:47, Benjamin Hell wrote:
> Hi,
> I have been wrapping my head around this for a while now and I have not found a solution so far.
> I want to work with an indefinite number of variables in mathematica and use some built in functions.
>
> To make things more specific for starters I want to do the following:
>
> Define a sum with n summands each containing a new variable x[i] (in the i-th summand):
> sum[n_] = Sum[i*x[i], {i, 1, n}]
>
> Then I want to differentiate the expression with respect to some x[i] like:
> D[sum[n],x[2]]
>
> Mathematica return 0 instead of 2. If I supply a specific n like:
> D[sum[2],x[2]]
> everything works fine.
>
> I thought about using Assumptions for n, but with no success so far.
>
> How can I do that right?
>
Clearly D[sum[n],x[2]] should ideally return something like:

If[n>=2,2,0]

not

2

The problem is, of course, that the Sum command can't evaluate if n is 
undefined!

Possibly it would help if you supplied a bit more context regarding what 
you are trying to do.

David Bailey
http://www.dbaileyconsultancy.co.uk

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web