Re: Piecewise and multiple values

*To*: mathgroup at smc.vnet.net*Subject*: [mg90022] Re: Piecewise and multiple values*From*: dh <dh at metrohm.ch>*Date*: Thu, 26 Jun 2008 04:45:46 -0400 (EDT)*References*: <g3t6vs$imi$1@smc.vnet.net>

Hi Giaccomo, you should give an explicite example. But I think your problems come from the fact, that you are not replacing single values, but lists. E.g. m+k/.data will replace m by {3,5,6} and k by {1,2,7}, giving {3,5,6}+{1,2,7} what evaluates to: {4, 7, 13}. If your parameter m appears in e.g. x<m the replacement gives x<{3,5,6} what will not work. Therefore, you must write the replacements rule in the form:{{m->1,k->1},{m->2,k->3},..}. This can be don e.g. by: Thread/@ data //Transpose hope this helps, Daniel Giacomo Ciani wrote: > Hi all, > > in brief my problem: I'm using mathematica to create the solutions for > problems that actually came in few different versions (meaning that > the problem in the same, but the initial data change). Suppose I ave > version 1 in which m=3,k=1,..., version 2 in which m=5,k=2,... and so > on... Typically, I use an approach like: > > data={m->{3,5,6},k->{1,2,7},...} > > Then I write and solve the general symbolic equations, and the replace > the values with the above rule, like: > > sol = Solve[...] > sol/.data > > obtaining a list of numerical solutions corresponding to the different > set of data contained in the "data" list, like: > > {(num sol corresponding to m=3,k=5,...),(num sol corresponding to > m=5,k=2,...)} > > This works very well for me, because it allows me to solve the problem > once and check the numerical solution for all the different versions > at a glance. > > The problem arises in the case I have to use a Piecewise function. In > this case I define: > > | f x<z > h = | > | g x>z > > but when I evaluate > > f/.data > > I obtain something like: > > | {f1,f2,...} x<{z1,z2,...} > h = | > | {g1,g2,...} x>{z1,z2,...} > > that I don't know how to plot or "disentagle", i.e. obtain expressions > like: > > | f1 x<z1 > h1 = | > | g1 x>z1 > > > | f2 x<z2 > h2 = | > | g2 x>z2 > > and so on... > > Do you have any suggestion? I would prefer to retain my data > replacement scheme, and just understand how to create "disentangled" > piecewise functions... > > Thaks > > Giacomo > -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail:<mailto:dh at metrohm.com> Internet:<http://www.metrohm.com>