Re: Problem with using /.
- To: mathgroup at smc.vnet.net
- Subject: [mg69273] Re: Problem with using /.
- From: Peter Pein <petsie at dordos.net>
- Date: Tue, 5 Sep 2006 05:30:35 -0400 (EDT)
- References: <edadil$pd0$1@smc.vnet.net><eddqil$3uh$1@smc.vnet.net> <edg849$gel$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Nag schrieb:
> Peter Pein wrote:
>> Hi Nag,
>>
>> you try to assign a value to Sum[...]; this becomes Set[Sum[...],0] --
>> but Sum is a Protected function. Furthermore, Set is not Rule.
>>
>> I guess you wanted:
>>
>> M[j_, t_, k_] := FullSimplify[D[MGF[t, k], {t, j}] /. u -> 0,
>> Sum[Subscript[p, i], {i, 0, k}] == 1];
>>
>> You can use Simplfy instead of FullSimplify too.
>>
>> Peter
>
> Hi Peter:
>
> The = was a typo. It should have been a ->
> With -> there is no error but the substitution doesn't happen.
> The substitution works when I use == as you suggested.
>
> Why does -> not work but == work?
>
> Thanks
> Nag
>
Hi Nag,
if Sum[..]->1 is in the list of rules, the pattern matcher recognizes it
only in exactly this form. If Sum[..]==1 is given as second parameter of
(Full)Simplify, Mathematica tries to use the _information_, not the
_pattern_ inside the call to Simplify.
expr = (x^2 - y^2)/(1 + x);
The pattern "x+y" doesn't occur, so the outcome is expr:
expr /. x + y -> 1
--> (x^2 - y^2)/(1 + x)
FullSimplify uses x+y==1, to get rid of the squares:
FullSimplify[expr, x + y == 1]
--> (1 - 2*y)/(1 + x)
You can isolate y in x+y==1 and use that as rule
(same as expr /. Solve[x + y == 1, y][[1]] // Together):
Together[expr /. y -> 1 - x]
--> (-1 + 2*x)/(1 + x)
or isolate x:
Together[expr /. x -> 1 - y]
--> (-1 + 2*y)/(-2 + y)
hth,
Peter