MathGroup Archive 2011

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

Search the Archive

Re: Replace in an elegant way

  • To: mathgroup at smc.vnet.net
  • Subject: [mg122871] Re: Replace in an elegant way
  • From: Ulrich Arndt <ulrich.arndt at data2knowledge.de>
  • Date: Sun, 13 Nov 2011 07:18:10 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201111130943.EAA29993@smc.vnet.net>

not sure if we consider this as elegant but at least it is clear what is 
done...

expression = ((1 + theta[m])^2)/(1 - m) -
  lambda*((theta[
       m] + ((lambda + m - lambda*m)*(1 + theta[m])*(1 + theta[m] -
           lambda*theta[m]))/(1 - m) + (m*Derivative[1][theta][m])/
       lambda));

expression /. theta[m] -> dummy /. m -> gg /. dummy -> theta[m]


Ulrich

Am 13.11.2011 um 10:43 schrieb Mirko:

> Hi all,
> I have following equation:
>
> ((1 + theta[m])^2)/(1 - m) - lambda*((theta[m] + ((lambda + m - 
lambda*m)*(1 + theta[m])*(1 + theta[m] - lambda*theta[m]))/(1 - m) +
>     (m*Derivative[1][theta][m])/lambda))
>
> I want to replace all m that are not an argument of theta[m] or the 
Derivative. However, if I use
> /., it replaces all m. If I use Replace[expr,m->qq] it doesn't replace 
anything. (qq is the one I want to replace with). If I specify any 
level, it doesn't change anything, unless I use -1, but then I replace 
everything.
>
> Do you know how I solve this problem?
> Right now I use:
> //. Derivative[y_][theta][m] -> Derivative[y][theta][dd] //.
>    theta[m] -> theta[dd] /. m -> qq //.
>  Derivative[y_][theta][dd] -> Derivative[y][theta][m] //.
> theta[dd] -> theta[m]
>
> but this is not elegant at all (and takes slightly longer).
>

--
Ulrich Arndt
Mobile: +49 172 287 6630
ulrich.arndt at data2knowledge.de
www.data2knowledge.de

data2knowledge GmbH
Fahrenheitstr. 1
D-28359 Bremen

Gesch=E4ftsf=FChrung: Ulrich Arndt
Sitz der Gesellschaft: Bremen, Amtsgericht Bremen, HRB 26480 HB





  • Prev by Date: Re: Replace in an elegant way
  • Next by Date: Re: how to plot new data points to pre-existing figure
  • Previous by thread: Re: Replace in an elegant way
  • Next by thread: Re: Replace in an elegant way