Re: small question

• To: mathgroup at smc.vnet.net
• Subject: [mg74904] Re: small question
• From: dh <dh at metrohm.ch>
• Date: Tue, 10 Apr 2007 06:03:03 -0400 (EDT)
• References: <evd3or\$5fo\$1@smc.vnet.net>

```
Hi,

here is a rule that replaces N1 x by  a new symbol:

rules = {(n_Symbol)*(x_Symbol) :> Symbol[StringJoin["N", SymbolName[x],

StringDrop[SymbolName[n], 1]]] /; StringMatchQ[SymbolName[n],"N*"]}

However, there is a pitfall. Ther rule assumes that the constant and

variable are directly multiplied in your expression, that is like e.g.:

N1 x + N2 y, but not like x(N1 + N2) or N1(x+y).

Daniel

KFUPM wrote:

> Dear Group

>

> I have two variables multiplied by each other

>

> N1 x    (N1 times x) which is a part of an equation.

>

> What i want to do is to replace  this multiplication by Nx1 (one

> variable) and i want to do this automatically using Mathematica,

> because i have a huge number of such terms, for example, N2 y, N3 z,

> N4 x, N5 y.... etc.

>

> Thereofore, i need to get this transformation:

>

> N1 x ------> Nx1

> N2 y ------> Ny2

> N3 z ------> Nz3

> and so on.

>

> Please notice that the letter N doesn't change only numbers(1,2,...)

> and (x,y,z....) do.

>

>

> Any help in this regard is highly appreciated.

>

>

```

• Prev by Date: Re: Can Maximize return a function
• Next by Date: Re: optimizing
• Previous by thread: Re: small question
• Next by thread: NDSolve can't solve a complex ODE correctly?