Re: Finding bounds of the domain of a Piecewise function

*To*: mathgroup at smc.vnet.net*Subject*: [mg72903] Re: Finding bounds of the domain of a Piecewise function*From*: dh <dh at metrohm.ch>*Date*: Wed, 24 Jan 2007 17:41:37 -0500 (EST)*References*: <ep4k3m$pbl$1@smc.vnet.net>

Hi, if your definition is the only one for f, it can be get by: Downvalues[f]. Assuming further, that your function is defined as below, then the right side of all your inequalities can be extracted by: DownValues[f][[1, 2, 1, All, 2, 3]] wrapping Max around this will give what you want. Daniel . wrote: > Hi All, > > I have a routine that builds up a complicated Piecewise function, f[x]. > All the pieces in the piecewise are restricted to some finite range > (the ranges for each piece may be very different). I want to find the > absolute extreme x values which will give me a non-zero f[x]. > > So have something along the lines of: > > f[x_]:=Piecewise[{ > {f1[x], a <= x <= b}, > {f2[x], c <= x <= d}, > {f3[x], e <= x <= g} > }] > > We can assume that a < b, c < d and e < g (all bounds are real and have > a numeric value). We can also assume that the ranges are > non-overlapping (it seems PiecewiseExpand takes care of that). > However, we can *not* assume that the segments are sorted by the x > range. Note also that the real problem will have many more segments > than just 3. > > For the purposes of discussion, assume that Max[b,d,g] == b. I want to > find a robust and reasonably fast way of extracting b. > > One idea is: > Max[ > Reap[ > f[x][[1,All,2]]/.{r_?NumericQ :> Sow[r]} > ][[2]] > ] > > However, this seems like a bit of a hack (it is very much limited to > the details of this particular problem). Is there a better way which > doesn't require quite so many assumptions? > > Thanks! >