Evaluating UnitStep inside another function
- To: mathgroup at smc.vnet.net
- Subject: [mg16261] Evaluating UnitStep inside another function
- From: Doug Webb <Douglas.S.Webb at maf.nasa.gov>
- Date: Fri, 5 Mar 1999 00:41:22 -0500
- Organization: http://www.msfc.nasa.gov/
- Sender: owner-wri-mathgroup at wolfram.com
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