Re: Problem with evaluation of delayed rules

*To*: mathgroup at smc.vnet.net*Subject*: [mg21678] Re: Problem with evaluation of delayed rules*From*: Eckhard Hennig <hennig at itwm.uni-kl.de>*Date*: Fri, 21 Jan 2000 04:00:38 -0500 (EST)*Organization*: ITWM*References*: <85mkef$1og@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Thanks to everyone who responded to my message regarding evaluation of delayed rules in held expressions. Unfortunately, none of the proposed solutions fully meets my requirements, either because Condition 1 (no specific solution for "If") was not taken into account or because it doesn't work for my particular application. What I posted was just a simple example, and the actual problem is indeed a bit more complicated: Let "equations" denote a list of mathematical expressions involving "If" statements (or other control statements with HoldXXX attribute). In "equations", I want to apply the following substitutions. All delayed rules must be evaluated as soon as they apply because the variable "mnavar" (a list of symbols) is local to a Block. equations /. { Derivative[_][_][x_ /; x =!= $TimeVariable] -> 0, Derivative[k_][Voltage[a_, b_, _]][$TimeVariable] | Derivative[k_][Voltage[a_, b_, _]] :> D[mnavar[[a]] - mnavar[[b]], {$TimeVariable, k}], Voltage[a_, b_, _] :> mnavar[[a]] - mnavar[[b]], Derivative[k_][Current[__, i_]][$TimeVariable] | Derivative[k_][Current[__, i_]] :> D[BranchCurrentIdentifier[i], {$TimeVariable, k}], Current[__, i_] :> BranchCurrentIdentifier[i] } Several responses to my original message suggested using a "Cases" statement to build up a list of evaluated replacement rules dynamically and then apply this list to the expression. This solution has two disadvantages: it needs more memory and it does not work for more than one delayed rule at a time, thus requiring repeated application of the "Cases" approach for each of the above rules. In my application, these drawbacks are not acceptable because the "equations" may be very large, so that memory efficiency and performance is an important issue. Any other solutions that don't involve specific solutions for the "If" statement or degrade performance? Best regards, Eckhard ----------------------------------------------------------- Dipl.-Ing. Eckhard Hennig mailto:hennig at itwm.uni-kl.de Institut fuer Techno- und Wirtschaftsmathematik e.V. (ITWM) Erwin-Schroedinger-Strasse, 67663 Kaiserslautern, Germany Voice: +49-(0)631-205-3126 Fax: +49-(0)631-205-4139 http://www.itwm.uni-kl.de/as/employees/hennig.html ITWM - Makers of Analog Insydes for Mathematica http://www.itwm.uni-kl.de/as/products/ai -----------------------------------------------------------