MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Replacing Values Close to One

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105292] Re: Replacing Values Close to One
  • From: "M.Roellig" <markus.roellig at googlemail.com>
  • Date: Thu, 26 Nov 2009 06:14:30 -0500 (EST)
  • References: <hekug7$921$1@smc.vnet.net>

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


  • Prev by Date: Re: Replacing Values Close to One
  • Next by Date: Re: Replacing Values Close to One
  • Previous by thread: Re: Replacing Values Close to One
  • Next by thread: Re: Re: Replacing Values Close to One