Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2001
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

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

Search the Archive

Re: Naming pieces of patterns

  • To: mathgroup at smc.vnet.net
  • Subject: [mg29830] Re: [mg29816] Naming pieces of patterns
  • From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
  • Date: Fri, 13 Jul 2001 04:19:13 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

"Simple" it isn't but:

1.

In[5]:=
{-(I/(2*a)), I/(2*a)} /. Times[Complex[0,Rational[s_,2]],Power[a,-1]]->s*A
Out[5]=
{-A,A}

2. In[6]:=
{a + b, -(a + b)} /. (s_.)*a + (s_.)*b -> s*e
Out[6]=
{e,-e}

3. In[7]:=
{-Sqrt[a + b], 1/Sqrt[a + b]} /.
  (a + b)^(Rational[s_, 2]) -> e^s
Out[7]=
     1
{-e, -}
     e

4. In[8]:=
{I, 2 I, -I} /.Complex[0,a_]->a*J
Out[8]=
{J,2 J,-J}

-- 
Andrzej Kozlowski
Toyama International University
JAPAN

http://platon.c.u-tokyo.ac.jp/andrzej/
http://sigma.tuins.ac.jp/~andrzej/


on 01.7.12 3:52 PM, Cyril Fischer at fischerc at itam.cas.cz wrote:

> How can I as simply as possible use "substitutions"
> 1.
> -(I/(2 a)) /. I/(2 a) -> A
> does not work, while
> (I/(2 a)) /. I/(2 a) -> A
> works well
> 
> 2.
> {(a + b), -(a + b)}/. a + b -> e
> gives
> {e, -a - b}
> instead of {e,-e}
> 
> 3.
> {-Sqrt[a + b], 1/Sqrt[a + b]} /. Sqrt[a + b] -> e
> gives
> {-e,1/Sqrt[a + b]}
> 
> 4.
> {I, 2 I, -I} /. I -> J
> gives
> {J, 2 \[ImaginaryI], -\[ImaginaryI]}
> 
> I know _why_ these cases do not work, but I would like to know, if there
> is a possibilty to use a common pattern rule to substitute all
> occurences of an expression.
> 
> Thank you,
> Cyril Fischer
> 
> 
> 




  • Prev by Date: Re: kernel problem for trigonometry
  • Next by Date: Re: Naming pieces of patterns
  • Previous by thread: Re: Naming pieces of patterns
  • Next by thread: Re: Naming pieces of patterns