Re: Replace not spotting a replacement
- To: mathgroup at smc.vnet.net
- Subject: [mg103427] Re: Replace not spotting a replacement
- From: Szabolcs Horvát <szhorvat at gmail.com>
- Date: Mon, 21 Sep 2009 05:51:51 -0400 (EDT)
- References: <h94vil$nfi$1@smc.vnet.net>
On 2009.09.20. 12:19, claranet news wrote: > Hi Folks, > > Seems the replace function is being a bit dim here. This fails: > > Sqrt[2 \[Pi]] \[Tau]^(3/2) /. Sqrt[ 2 \[Pi] \[Tau]] -> \[Mu] > > Apologies if this is an FAQ - I couldn't see anything about it. What do I > need to do here to coerce Mathematica into making this replacement? I tried using the > Collect function on tau first, but that didn't seem to work. I also tried > re-writing the replacement rule as > > Sqrt[2 \[Pi]] \[Tau]^(3/2) /. Sqrt[ 2 \[Pi] ] t^(1/2) -> \[Mu] > > But still no joy. > Hi, ReplaceAll does structural replacements only, it does not take into account any mathematical relations. (a+b+c /. a+c->d only works because Plus has the attributes Flat and Orderless. It is still merely a structural replacement, not a mathematical one). In other words, for ReplaceAll to work, the part of the expression to be replaced must be written exactly as it appears. I think the replacement you want to do is not clearly defined mathematically. I know you want mu tau as the result, but I'm not sure how to formulate the problem in a clear way to the computer. If we're taking mathematical relations into account, it could just as well return mu^3/(2Pi). Here's how to eliminate a variable completely: Solve[e == Sqrt[2 \[Pi]] \[Tau]^(3/2) && Sqrt[2 \[Pi] \[Tau]] == \[Mu], e, \[Tau]]