Group Abstract Group Abstract

Message Boards Message Boards

Piecewise function

Posted 11 years ago

Dear friends

I need to define and plot a 6-piecewise function but the software only accept 3 and when i try to add more, the font color changes to red and the program does not execute. Can anyone help me? All the best

POSTED BY: Philip Majnooni
4 Replies
Posted 11 years ago

The region specifications are a list of lists. You forgot the outer brackets.

Best, David

(* this *)
Piecewise[{0, x < 1}, {1, x < 2}, {3, x < 3}, {4, x < 4}, {5, True}]

(* should be this *)
Piecewise[{{0, x < 1}, {1, x < 2}, {3, x < 3}, {4, x < 4}, {5, True}}]
POSTED BY: David Keith

Try defining a 2-part piecewise function, each piece itself being a 3-part piecewise function. Or, alternatively, 3 then 2.

POSTED BY: S M Blinder
Posted 11 years ago
POSTED BY: David Keith
Posted 11 years ago

Thanks to Blinder and David

Via your instructions, I plotted the 6-piecewise function (Blue) and a 6th order polynomial function (Pink) at the same time. but the piecewise function has a discontinuity at x=-2 and a bit right while it shouldn't be like that since it is a 3rd order polynomial!!! Any reason? enter image description here

Enclosed find the code. Any comment will be welcome.

Attachments:
POSTED BY: Philip Majnooni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard