MathGroup Archive 2006

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

Search the Archive

Re: Re: Ask Mathematica to sub for a long expression


On 3 Dec 2006, at 20:26, aaronfude at gmail.com wrote:

> Hi,
>
> Thanks for all the responses. It doesn't quite work for me, but maybe
> with a little extra expertise it will. The problem is that that  
> pattern
> is not always obvious w/o extra algebra. The basic problem is
> summarized in the fact that the following doesn't work the way I'd  
> like
> it to:
>
> -a-b/.a+b->c
>
> 2a+2b/.a+b->c
>
> Many thanks in advance!
>
> Aaron Fude
>

(Since I expect Daniel Lichtblau  must have got tired of posting this  
again and again, I thought I might save him some labour. )

Take a look at this:

http://forums.wolfram.com/mathgroup/archive/2006/Aug/msg00283.html

For example:

replacementFunction[-a-b,a+b-c,{a,b,c}]

-c


replacementFunction[2a+2b,a+b-c,{a,b,c}]


2 c

where

replacementFunction[expr_, rep_, vars_] := Module[
   {num = Numerator[expr], den = Denominator[expr],
     poly = Numerator[Together[rep]]},
   PolynomialReduce[num, poly, vars][[2]] /
     PolynomialReduce[den, poly, vars][[2]]
   ]


Andrzej Kozlowski


  • Prev by Date: Re: Problem with Minimize function
  • Next by Date: Re: Using FindRoot in complex funtion
  • Previous by thread: Re: Ask Mathematica to sub for a long expression
  • Next by thread: Re: Ask Mathematica to sub for a long expression