Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

For example, if I have Piecewise[{{x^2, x < 0}, {x, x > 0}}], how do I select only the function that is for x < 0? I want to set a new function equal to the x^2 only, not the entire piecewise function.

share|improve this question

2 Answers 2

You can use, for example

Refine[Piecewise[{{x^2, x < 0}, {x, x > 0}}], x < 0]
share|improve this answer

As you may know, Part ([[ ]]) works on non-lists as well. So, you can index your Piecewise like so:

Piecewise[{{x^2, x < 0}, {x, x > 0}}][[1, 1, 1]]


With Cases you can pick out the part with a specific condition:

Cases[Piecewise[{{x^2, x < 0}, {x, x > 0}}], {a_, x < 0} -> a, {2}] // First


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.