Re: Automatic generation of piecewise functions
- To: mathgroup@smc.vnet.net
- Subject: [mg11603] Re: Automatic generation of piecewise functions
- From: Allan Hayes <hay@haystack.demon.co.uk>
- Date: Tue, 17 Mar 1998 10:43:37 -0500
- References: <6ek6o3$jen@smc.vnet.net>
William F. Campbell wrote: > > I am trying to generate a single function f[x], which has different > definitions depending on the values of x (i.e. a piecewise function). > I proceeded as follows: > > Clear[f]; > sampleÚble[f[x_]«i]*x+b[i]/;Evaluate[x>-1&&x<-,{i,2}] > > The output returned looked correct: > {b[1]+a[1] x/;x>&x<b[2]+a[2] x/;x>&x<- > > When I looked at the definition for f, it seemed correct as well: ?f > > Global `f > > f[x_]»1]+a[1] x/;x>&x< > > f[x_]»2]+a[2] x/;x>&x<- > > But when I attempted to use the definition, f[0.5] > > 0.5 a[1]+b[1]/;0.5>&0.5< > > whose full form is > FullForm[f[0.5]] > > Condition[Plus[Times[0.5,a[1]],b[1]], > And[GreaterEqual[0.5,0],LessEqual[0.5,1]]] > > Why doesn't the Condition evaluate? How can I change the construct used > in sample above to obtain a working definition for a piecewise > function? BTW, If I fail to put Evaluate[] around the condition in the > definition of sample above, the output is even further from what I > want, {b[1]+a[1] x/;x>-1&&x<,b[2]+a[2] x/;x>-1&&x<-. -- > Bill Campbell Correlation is not cause. Bill: Some points. 1) With Set ( Condition must be on left side: r[x_] x/;x> l[x_]/;x>