MathGroup Archive 2011

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

Search the Archive

Re: algebraic ReplaceAll?

  • To: mathgroup at
  • Subject: [mg122309] Re: algebraic ReplaceAll?
  • From: Richard Fateman <fateman at>
  • Date: Mon, 24 Oct 2011 05:15:20 -0400 (EDT)
  • Delivered-to:
  • References: <j7u4qc$t5h$>

On 10/22/2011 3:10 AM, Dushan Mitrovich wrote:
> Is there a way to get ReplaceAll to actalgebraically, so it recognizes
> the negative of a replaced quantity as well as the positive?  For
> example, this works
>       In:   x-w /. x-w->y
>       Out: y
> but these don't
>       In:   -x+w /. x-w->y
>             w-x  /. x-w->y
>       Out: w-x
>             w-x
> - Dushan
   How would you wish the replacement to work on this:

  -x  /. x-w->y   ??

would -y-w    be ok with you?

If so, try

-x /.  x-> y+w.

x-w /.  x-> y+w

w-x /.  x-> y+w


You can make the pattern work from  w-> x-y    alternatively.

Or if you want to know if some expression e can be expressed as 
Q*(x-w)+R, you can do this by polynomial division.

Three points:
1. Your request is ambiguous.
2. The pattern matcher basically sucks for this, as Andrzej observes.
3. Alternatives (e.g. semantica, or )
exist, but item 1. above needs some thought either way.


  • Prev by Date: Re: Simplifying radicals
  • Next by Date: Re: Full simplify problem
  • Previous by thread: Re: algebraic ReplaceAll?
  • Next by thread: Re: algebraic ReplaceAll?