Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #16431

Re: Simple question

From Alexei Boulbitch <Alexei.Boulbitch@iee.lu>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Simple question
Date 2014-01-18 10:02 +0000
Message-ID <lbdjep$53f$1@smc.vnet.net> (permalink)
Organization Time-Warner Telecom

Show all headers | View raw


Dear  All

I have a long expression. Below is just a short part of it:

K11 Ue + (K12 - K21) Uex +
 K22 Uexx + (K23 + K32) Uexy + (K13 - K31) Uey + K33 Ueyy

I want to replace Ue->U[x,y,z,t]. and Uex->D[U[x,y,z,t],x] and Uexy->D[U[x,y,z,t],{x,y}] and so on. I want to make a command to scan the expression and do the conversion autmatically. I don't want to use Replace or ReplaceAllcommands, because as I said, the command is very long and I have so many functions to deal with.

Many thanks in advance for your help.

HMQ

Hi,
It is not quite clear, why you do not want the classic replacement. From your question
I have the impression that it is mainly the length of the replacement operator that you do not
like. If I am right, you might overcome this by collecting all rules into one list and
giving it a name as well as giving a name to your expression to be transformed.

This is the list of rules:

listOfRules = {Ue -> U[x, y, z, t], Uex -> D[U[x, y, z, t], x] ,
   Uexy -> D[U[x, y, z, t], {x, y}], Uexx -> D[U[x, y, z, t], {x, y}],
    Uey -> D[U[x, y, z, t], y], Uexy -> D[U[x, y, z, t], {x, y}],
   Ueyy -> D[U[x, y, z, t], {y, y}]};

It may be as long as you need. Here is your expression:

f = K11 Ue + (K12 - K21) Uex +
   K22 Uexx + (K23 + K32) Uexy + (K13 - K31) Uey + K33 Ueyy;

And here is a rather short replacement command:

f /. listOfRules

Try it. Have fun.

Alexei BOULBITCH, Dr., habil.
IEE S.A.
ZAE Weiergewan,
11, rue Edmond Reuter,
L-5326 Contern, LUXEMBOURG

Office phone :  +352-2454-2566
Office fax:       +352-2454-3566
mobile phone:  +49 151 52 40 66 44

e-mail: alexei.boulbitch@iee.lu


Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Simple question Alexei Boulbitch <Alexei.Boulbitch@iee.lu> - 2014-01-18 10:02 +0000

csiph-web