Re: Re: Re: Replacing Values Close to One

*To*: mathgroup at smc.vnet.net*Subject*: [mg105321] Re: [mg105298] Re: [mg105292] Re: Replacing Values Close to One*From*: Murray Eisenberg <murray at math.umass.edu>*Date*: Sat, 28 Nov 2009 01:05:03 -0500 (EST)*Organization*: Mathematics & Statistics, Univ. of Mass./Amherst*References*: <hekug7$921$1@smc.vnet.net> <200911261114.GAA24561@smc.vnet.net> <200911271127.GAA04372@smc.vnet.net>*Reply-to*: murray at math.umass.edu

I think all the proposed solutions begged a fundamental question arising here: what does "close to 1" (or to any other specified number mean). That is, was the original poster asking about absolute error or relative error? Of course in the case that the target is 1, there will be no distinction, but for other targets, where will be. Yuri Kandrashkin wrote: > Hi, > Here is another version with Chop > {num, eps} = {1, 0.1} > Chop[{-8, .7, 0, 1.003} - num, eps] + num > > > 2009/11/26 M.Roellig <markus.roellig at googlemail.com> > >> On 26 Nov., 05:00, Gregory Lypny <gregory.ly... at videotron.ca> wrote: >>> Hello everyone, >>> >>> Is there a replacement rule that I can apply to >>> >>> {-8, .7, 0, 1.003} /. [what goes here?] -> 1 >>> >>> to replace values that are close to 1, like 1.003, by 1? >>> >>> Regards, >>> >>> Gregory >> Hi, >> >> you can use Chop which sets numbers close to zero to zero: >> >> {-8, .7, 0, 1.003} /. x_ :> (Chop[x - 1, 0.01] + 1) >> >> >> here I gave 0.01 as tolerance. Change it to your needs. >> >> Cheers, >> >> Markus >> >> -- 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**:**Re: Replacing Values Close to One***From:*"M.Roellig" <markus.roellig@googlemail.com>

**Re: Re: Replacing Values Close to One***From:*Yuri Kandrashkin <spinalgebra@gmail.com>