Re: Beginner question: operating on piecewise defined functions
- To: mathgroup at smc.vnet.net
- Subject: [mg41684] Re: Beginner question: operating on piecewise defined functions
- From: Jan Rychter <jan at rychter.com>
- Date: Fri, 30 May 2003 03:56:28 -0400 (EDT)
- References: <bb1v7e$9hc$1@smc.vnet.net> <bb4v3o$44t$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
>>>>> "David" == David W Cantrell <DWCantrell at sigmaxi.org> writes:
David> Jan Rychter <jan at rychter.com> wrote:
>> If I define a piecewise function as, say:
>>
>> f[x_] := 1/x^2 /; x >= 1 f[x_] := 1 /; x < 1
>>
>> then how can I get Mathematica to operate on it, as in:
>>
>> Limit[f[x], {x->Infinity}]
>>
>> Just trying that returns the expression unevaluated
David> Good question!
David> I had thought that the answer might lie in rewriting your
David> function in terms of the UnitStep function: 1 + (-1 +
David> x^(-2))*UnitStep[-1 + x] . Alas, that doesn't work; again the
David> limit is returned unevaluated. (BTW, my rewriting above isn't
David> quite equivalent to your function since my form is undefined at
David> x = 0.)
David> Here's what does work (except again at x = 0): Rewrite your
David> function as (1 + x^2 - (1 + x)*Abs[-1 + x])/(2*x^2) .
David> Thankfully, Mathematica can find the limit of that as x ->
David> Infinity.
David> But there must be a better way. I'll be interested in seeing
David> other replies.
I'd like to thank everyone that responded. But I'm still surprised that
Mathematica doesn't do this out of the box. The Mathematica Book
encourages one to define functions using /; -- and yet one can't do much
with such a definition later on.
This is even more surprising because in most cases it shouldn't pose a
problem for Mathematica -- obviously when I'm asking for a limit at
Infinity, that could be matched to the restrictions and the appropriate
function form could be chosen?
I wonder if that an area where Mathematica will be improved in the
future.
--J.