Re: Evaluating UnitStep inside another function
- To: mathgroup at smc.vnet.net
- Subject: [mg16333] Re: Evaluating UnitStep inside another function
- From: "Peltio" <pelt.ioNOS at PAMiol.it>
- Date: Sun, 7 Mar 1999 01:05:51 -0500
- Organization: Peltio Inc.
- References: <7bo033$dnr@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Doug, Your problem stems from this: Attributes[UnitStep] {Orderless} This should provide a cure: Unprotect[UnitStep]; Attributes[UnitStep]={Orderless,Listable}; Protect[UnitStep]; It seems to work, now F1[ 3 + UnitStep[ x-3 ], x ] {3,3,4} F1[x^2,x] {0,4,25} I haven't tried any other examples, anyway. Peltio, peltioNOS at PAMusa.net Doug Webb wrote in message <7bo033$dnr at smc.vnet.net>... >Hello, > I am trying to define a function such as this, where lst and xvlu have >already been defined earlier as lists (which the user wont really know >about or be able to see): > >lst = {1, 2, 3} >xvlu = {0, 2, 5} > >F1[ func_, var_ ] := ( > lst = func /. var -> xvlu; > Return[ lst ] >); > >And func can be any arbitrary function the user wants to enter, which is >based on variable var. This all works fine for cases such as this: > >F1[ x^2, x ] > >returns: > >{0, 4, 25} > >What I'm having problems with is the UnitStep function. After loading >the DiracDelta package: > ><<Calculus`DiracDelta` > >The following input > >F1[ 3 + UnitStep[ x-3 ], x ] > >Gives this output: > >3 + UnitStep[ {-3, -1, 2} ] > >Rather than what I want: > >{3, 3, 4} > >If I enter it directly as this: > >3 + UnitStep[ xvlu - 3 ] > >then I get the "correct" answer of {3, 3, 4}. Evidently the UnitStep >isn't getting evaluated inside the F1[] function. I've tried >combinations of Evaluate[], Hold[], N[], etc. in all they ways I can >think of inside the F1[] function, and still no luck. What can I do >inside F1[] to get the UnitStep case evaluated, without possible >"messing up" a simpler case with something like x^2? Thanks for any >suggestions. > > Doug > Douglas.S.Webb at maf.nasa.gov > D_Webb at prodigy.net > > >