Re: Is it possible to impose a condition on an iterator
- To: mathgroup at smc.vnet.net
- Subject: [mg101553] Re: [mg101499] Is it possible to impose a condition on an iterator
- From: Murray Eisenberg <murray at math.umass.edu>
- Date: Fri, 10 Jul 2009 06:43:06 -0400 (EDT)
- Organization: Mathematics & Statistics, Univ. of Mass./Amherst
- References: <200907090552.BAA16854@smc.vnet.net>
- Reply-to: murray at math.umass.edu
In any looping function, the iterator may take the form {i, lis}, where lis is an explicit list of values. So in your situation you need only construct that list, for example: avals = Complement[Range[20], Range[7, 11]]; Then: Sum[a^2 - 3 a/(4 a^2), {a, avals}] Of course you can do the entire thing at once by putting the Complement expression that constructs the list directly into the Sum expression: Sum[a^2 - 3 a/(4 a^2), {a, Complement[Range[20], Range[7, 11]]}] Mauro wrote: > I would like to perform a summation of this type, > > Sum[a^2 - 3 a/(4 a^2), {a, 1, 20}] > > excluding however some values of the iteratore, I would for instance > like to exclude the values than to greater of 6 and inferior to 12. Is > it possible? > > Thanks > -- Murray Eisenberg murray at math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305
- References:
- Is it possible to impose a condition on an iterator of the summation ?
- From: Mauro <mauro@NONOyahoo.com>
- Is it possible to impose a condition on an iterator of the summation ?