The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Inactive » comp.soft-sys.math.mathematica

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Mystifying Scoping of Piecewise Variable?
Replies: 6   Last Post: Feb 3, 2011 5:33 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Tomas Garza Hernandez

Posts: 264
Registered: 4/15/05
Re: Mystifying Scoping of Piecewise Variable?
Posted: Feb 3, 2011 5:27 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Shouldn't the argument of myFunc in the definition be x_?

> Date: Wed, 2 Feb 2011 06:08:08 -0500
> From:
> Subject: Mystifying Scoping of Piecewise Variable?
> To:
> 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

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.