Re: Mystifying Scoping of Piecewise Variable?

*To*: mathgroup at smc.vnet.net*Subject*: [mg116152] Re: Mystifying Scoping of Piecewise Variable?*From*: Bob Hanlon <hanlonr at cox.net>*Date*: Thu, 3 Feb 2011 05:32:43 -0500 (EST)

Your function definition uses different variables on LHS and RHS. Use myFunc[x_] = Piecewise[{{x^2, x < 0}, {x, x >= 0}}]; and both plots will work. Bob Hanlon ---- Frank Iannarilli <frankeye at cox.net> wrote: ============= Perhaps I'm tired, but this is weird: Clear[myFunc] myFunc[y_] = Piecewise[{{x^2, x < 0}, {x, x >= 0}}] (Same behavior below for either Set(=) or SetDelayed(:=) ) Plot[myFunc[y], {y, -10, 10}] (returns empty plot) Plot[myFunc[x], {x, -10, 10}] (returns "expected" piecewise function plot) What is the scoping of the Piecewise variable, in this case "x"? How can one write a Module that creates and returns a Piecewise function? The scope of its argument is unclear to me. Thanks