[Date Index]
[Thread Index]
[Author Index]
Re: Replacement Rule with Sqrt in denominator
*To*: mathgroup at smc.vnet.net
*Subject*: [mg114337] Re: Replacement Rule with Sqrt in denominator
*From*: Bill Rowe <readnews at sbcglobal.net>
*Date*: Wed, 1 Dec 2010 02:13:15 -0500 (EST)
On 11/20/2010 3:11 AM, kj wrote:
>I don't know a way to write the replacement rule so that it works
>for both Sqrt[x] and 1/Sqrt[x], but maybe someone else does.
This is easy using Alternatives. For example:
In[2]:= a Sqrt[x] /. Sqrt[x] | Power[x, _] -> b
Out[2]= a b
In[3]:= a/Sqrt[x] /. Sqrt[x] | Power[x, _] -> b
Out[3]= a b
Note, I've only shown a simple way to solve the specific issue.
I did not make the alternative using Power sufficiently
restrictive to prevent say x^2 from being replaced by b. If
there is to be made to cover the possibility of that something
like x^2 will be present but should not be replaced, the
alternative using Power would need to be more specific.
Prev by Date:
**Re: Cuda offline installation in M8**
Next by Date:
**Re: basic pattern matching**
Previous by thread:
**Re: Replacement Rule with Sqrt in denominator**
Next by thread:
**Re: Replacement Rule with Sqrt in denominator**
| |