Message Boards Message Boards

0
|
5340 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

plotting a piecewise function

Posted 9 years ago

I want to plot a function whose domain and range is N ( natural number ) with piecewise different condition for odd and even natural number. How can I do that??

POSTED BY: rakesh yadav

This is not the role of the Piecewise function: it is more appropriate to simply use patterns in constructing your function. Here is an example:

f[n_Integer?EvenQ] := n 

f[n_Integer?OddQ] := (n^2) 

and take a look at a ListPlot of a table of values

ListPlot[Table[f[i], {i, 0, 10}]] 
POSTED BY: David Reiss
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract