Re: Piecewise and multiple values
- To: mathgroup at smc.vnet.net
- Subject: [mg89994] Re: Piecewise and multiple values
- From: "David Park" <djmpark at comcast.net>
- Date: Thu, 26 Jun 2008 04:40:25 -0400 (EDT)
- References: <g3t6vs$imi$1@smc.vnet.net>
data = {f -> {f1, f2, f3}, g -> {g1, g2, g3}, z -> {z1, z2, z3}};
Piecewise[{{f, x < z}, {g, x >= z}}]
% /. Thread /@ data
--
David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/
"Giacomo Ciani" <jackspam79 at gmail.com> wrote in message
news:g3t6vs$imi$1 at smc.vnet.net...
> 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
>