MathGroup Archive 1998

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

Search the Archive

Re: Getting rid of annoying zeroes in algebraic expressions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg15241] Re: [mg15228] Getting rid of annoying zeroes in algebraic expressions
  • From: "Carl K.Woll" <carlw at fermi.phys.washington.edu>
  • Date: Sun, 27 Dec 1998 03:58:33 -0500
  • Organization: Department of Physics
  • References: <199812230604.BAA02100@smc.vnet.net.>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Sean,

Does Chop do what you want? For example,

In[1]:=
xx=0. + (a*f)/(0. + f) + (b*f)/(0. + f) + (c*f)/(0. + f) Out[1]=
      a f      b f      c f
0. + ------ + ------ + ------
     0. + f   0. + f   0. + f
In[2]:=
Chop[xx]
Out[2]=
a + b + c

As far as your question on Replace, I don't get the behavior you
mention:

In[15]:=
xx/.Plus[0.,q_]->q
Out[15]=
 a f      b f      c f
------ + ------ + ------
0. + f   0. + f   0. + f

Your other attempt produced an error message for me. On the other hand,
to get the behavior you want, you simply need to use ReplaceRepeated,
as in

In[16]:=
xx//.Plus[0.,q_]->q
Out[16]=
a + b + c

Carl Woll
Dept of Physics
U of Washington

Ross, Sean wrote:

> Let xx be the result of some algebraic manipulations which, for some
> reason, mathematica thinks the real zeroes ought to be kept and I think
> they ought to be dropped.
>
> xx=0. + (a*f)/(0. + f) + (b*f)/(0. + f) + (c*f)/(0. + f)
>
> xx/.Plus[0.,q_]->q
>
> returns
>
> 0. + (a*f)/(0. + f) + (b*f)/(0. + f) + (c*f)/(0. + f)
>
> while
>
> 0. + (a*f)/(0. + f) + (b*f)/(0. + f) + (c*f)/(0. + f)/.Plus[0.,q_->q]
>
> returns the expected
>
> a+b+c.
>
> xx is supposed to be equivalent to the expression, but in this case, it
> is not.
> I can't write a function to automatically drop zeroes if expressions
> behave differently when they are alone on an input line and when they
> are set equal to a symbol.  Does anyone know how to eliminate this kind
> of behavior?  I am sure it has something to do with some obscure step
> in the "standard evaluation cycle" and that there is probably a long,
> convoluted explanation as to why someone would want this behavior, but
> I don't and I would appreciate it if someone could tell me how to get
> rid of it or circumvent it.
>
> Thanks,
>
> Sean Ross
>
> Please reply to rosss at plk.af.mil as I no longer subscribe to the
> mathgroup.
>



  • Prev by Date: Re: Algebra on complex expressions: Collect
  • Next by Date: Re: strange function that defines a function---how do I do it?
  • Previous by thread: Getting rid of annoying zeroes in algebraic expressions
  • Next by thread: RE: Getting rid of annoying zeroes in algebraic expressions