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

• To: mathgroup at smc.vnet.net
• Subject: [mg71929] Re: [mg71906] Re: Ask Mathematica to sub for a long expression
• From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
• Date: Mon, 4 Dec 2006 06:39:09 -0500 (EST)
• References: <ekp4o4\$2fq\$1@smc.vnet.net><ekrkia\$s72\$1@smc.vnet.net> <200612031126.GAA08096@smc.vnet.net>

```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][] /
PolynomialReduce[den, poly, vars][]
]

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