MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Automatic generation of piecewise functions



Maybe I did not understand your question but why don't you define your
function this way: f[x_]=x a[Floor@x]+b[Floor@x]

Hope this helps


----------------------------------------------- Jean-Marie THOMAS
Conseil et Audit en Ingenierie de Calcul www.cybercable.tm.fr/~jmthomas
------------------------------------------------


-----Message d'origine-----
De:	William F. Campbell [SMTP:valentin@wam.umd.edu] Date:	samedi 14 mars
1998 19:56
A:	mathgroup@smc.vnet.net
Objet:	[mg11549] Automatic generation of piecewise functions

  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=Table[f[x_]=a[i]*x+b[i]/;Evaluate[x>=i-1&&x<=i],{i,2}]

The output returned looked correct:
{b[1]+a[1] x/;x>=0&&x<=1,b[2]+a[2] x/;x>=1&&x<=2}

When I looked at the definition for f, it seemed correct as well: ?f

Global `f

f[x_]=b[1]+a[1] x/;x>=0&&x<=1

f[x_]=b[2]+a[2] x/;x>=1&&x<=2

But when I attempted to use the definition, f[0.5]

0.5 a[1]+b[1]/;0.5>=0&&0.5<=1

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>=i-1&&x<=i,b[2]+a[2] x/;x>=i-1&&x<=i}. -- Bill
Campbell                          Correlation is not cause.




  • Prev by Date: Calculus`FourierTransform`
  • Next by Date: RE: Re: Introducing: Conix 3D Explorer!
  • Prev by thread: Automatic generation of piecewise functions
  • Next by thread: Re: Automatic generation of piecewise functions