Replace in an elegant way
- To: mathgroup at smc.vnet.net
- Subject: [mg122865] Replace in an elegant way
- From: Mirko <dashiell at web.de>
- Date: Sun, 13 Nov 2011 04:43:13 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
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).
- Follow-Ups:
- Re: Replace in an elegant way
- From: Heike Gramberg <heike.gramberg@gmail.com>
- Re: Replace in an elegant way
- From: DrMajorBob <btreat1@austin.rr.com>
- Re: Replace in an elegant way
- From: Bob Hanlon <hanlonr357@gmail.com>
- Re: Replace in an elegant way
- From: Ulrich Arndt <ulrich.arndt@data2knowledge.de>
- Re: Replace in an elegant way
- From: Andrzej Kozlowski <akoz@mimuw.edu.pl>
- Re: Replace in an elegant way