MathGroup Archive 1999

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

Search the Archive

Re: Re: Simplifying constants...bug?


Hello Alan

calvitti at boes.ces.cwru.edu schrieb:
> 
> here's some intersting behavior in 3.0:
> 
>     (a + c*d)/(b + c*d) //. c*d -> -z
> 
> gives (as expected):
> 
>     (a - z)/(b - z)
> 
> yet
> 
>     (a + c*d)/(c*d) //. c*d -> -z
> 
> no longer simplifes the denominator:
> 
>     (a+b-z)/(c*d)
> 
> anyone know why?
> 
Well Alan, this is a very common problem, when using Mathematica. 
What you input (and think) is not always what you get. To see that (and
to get used thinking in Mathematica structures, I recommend to often) look at
the expression with FullForm:

In[3]:= (a + c*d)/(c*d) //FullForm
Out[3]//FullForm=
Times[Power[c,-1],Power[d,-1],Plus[a,Times[c,d]]]

So Times[c,d] can't match the 'denominator' (there is no division in
Mathematica!). Knowing that you can try:

In[4]:= (a + c*d)/(c*d) //. {c*d -> -z, 1/(c*d)->-1/z}

admitted ...that's ugly. See, the following also won't work :

In[10]:= a+(c*d)^5 /. c*d-> -z
Out[10]= a + c^5*d^5

But that will help you a little bit further:

In[18]:= (a + c*d)/(c*d) //. c^n_. * d^n_. :> (-z)^n
Out[18]= -((a - z)/z)

In[19]:= a + (c*d)^5 /. c^n_. * d^n_. :> (-z)^n
Out[19]= a - z^5

---regards, hw



  • Prev by Date: Re: Livegraphics3D
  • Next by Date: Re: Re: Simplifying constants...bug?
  • Previous by thread: Re: Re: Simplifying constants...bug?
  • Next by thread: Re: Re: Simplifying constants...bug?