Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I need to do some really easy in WolfarmAlpha online. I want to to plot 2x for {1 to 3} and x^2 for {3 to 5}. I tried multiple combinations, none of them gave me what I want. The following input did not work either.

Plot[(2*x),{x, 1, 3}], Plot[(x^2),{x, 3, 5}]
share|improve this question

closed as off-topic by Yves Klett, belisarius, Sjoerd C. de Vries, m_goldberg, rasher Jul 7 at 21:03

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Yves Klett, belisarius, Sjoerd C. de Vries, m_goldberg, rasher
If this question can be reworded to fit the rules in the help center, please edit the question.

1  
See the first example in Piecewise. –  kguler Jul 7 at 16:38

1 Answer 1

As suggested by kguler, using Piecewise is easiest; however, you can also use Show or Boole.

Show[
 Plot[(2*x), {x, 1, 3}],
 Plot[(x^2), {x, 3, 5}],
 PlotRange -> All,
 AxesOrigin -> {0, 0}]

enter image description here

Plot[
 2 x Boole[1 < x < 3] +
  x^2 Boole[3 < x < 5], {x, 0, 5},
 AxesOrigin -> {0, 0},
 PlotStyle -> Red]

enter image description here

share|improve this answer

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