MathGroup Archive 2012

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

Search the Archive

Re: Rules on integer elemens of the list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg128854] Re: Rules on integer elemens of the list
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Fri, 30 Nov 2012 05:58:45 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <20121129110747.2A45D6912@smc.vnet.net>

Generalize the form of the pattern to encompass both cases.

list=1/(2+3 z)+1./(2+4 z)+2./(2+5 z);

Cases[list,_.*Power[Plus[_,Times[_,z]],-1]]

{1/(2 + 3*z), 1./(2 + 4*z),
  2./(2 + 5*z)}


DeleteCases[list,_.*Power[Plus[_,Times[_,z]],-1]]

0


Or to do literally what you asked

list/.x_?(IntegerQ[Numerator[#]]&):>
N[Numerator[x]]/Denominator[x]

1./(2 + 3*z) + 1./(2 + 4*z) +
  2./(2 + 5*z)



Bob Hanlon


On Thu, Nov 29, 2012 at 6:07 AM,  <bar at antyspam.ap.krakow.pl> wrote:
>
> Hi,
> I have a list:
>
> list = 1/(2 + 3 z) + 1./(2 + 4 z) + 2./(2 + 5 z)
> Cases[list, Times[_, Power[Plus[_, Times[_, z]], -1]]]
>
> OUT:
>
> {1./(2 + 4 z), 2./(2 + 5 z)}
>
> The problem is different between:
> 1/x//FullForm   gives Power[x,-1]
> 1./x//FullForm gives Times[1.,Power[x,-1]]
>
> I have a list with big number of such expression and i have to exclude  elements like (a/(b+c x))
> a cause of numerators equal 1 (not 1.)
>
> Is a simple way to convert Numeratots 1 to 1. ??
>
> N[2/x] works fine gives 2./x
> but
> N[1/x] doesn,t work :-(
>
> Regards , Olaf
>



  • Prev by Date: Re: Difficult antiderivative
  • Next by Date: digit-precision for gaussian inputs converting cartesian matrix from
  • Previous by thread: Rules on integer elemens of the list
  • Next by thread: Re: retina display