RE: Beginner question: operating on piecewise defined functions
- To: mathgroup at smc.vnet.net
- Subject: [mg41625] RE: [mg41609] Beginner question: operating on piecewise defined functions
- From: "David Park" <djmp at earthlink.net>
- Date: Thu, 29 May 2003 08:13:50 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Jan, There are several approaches and I am not certain which is the best. Needs["NumericalMath`NLimit`"] Clear[f]; f[x_] := 1/x^2 /; x >= 1 f[x_] := 1 /; x < 1 NLimit[f[x], x -> Infinity] 0. Usually with piecewise functions it is better to use UnitStep than multiple definitions. Then the calculus functions will work. But apparantly not Limit. Clear[f]; f[x_] := 1 - (1 - 1/x^2)UnitStep[x - 1] We have to do the following to obtain an answer. Limit[FullSimplify[f[x], x > 1], x -> Infinity] 0 Or you could use this... Limit[f[x] /. UnitStep[expr_] :> UnitStep[expr /. x -> Infinity], x -> Infinity] 0 I'm not certain why Mathematica can't perform the simplification, for simple cases at least, by evaluating the UnitStep at the limit. If we use NLimit with the UnitStep definition we obtain a residual quantity. NLimit[f[x], x -> Infinity] -2.220446049250313*^-16 which you could eliminate by using Chop. Of course, with your specific function you don't really need to use the Limit routine. With either definition you could just use... f[Infinity] 0 David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: Jan Rychter [mailto:jan at rychter.com] To: mathgroup at smc.vnet.net 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, even though defining: g[x_] := 1/x^2 and trying: Limit[g[x], {x -> Infinity}] Yields, as expected: Out[7]= {0} thanks, --J.