Message Boards Message Boards

0
|
4815 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Finding a function with given traits

Consider a function:

                            f(x)=0 for 0 ? x < 1
                            f(x)=1 for 1 ? x < 2

What is the function?

any help would really be appreciated. Thanks!

POSTED BY: Casey Smith
3 Replies
Posted 9 years ago

You have defined the function on the range 0<=x<2. Following that, this function definition in Mathematica syntax matches only for the argument in that range. Then Piecewise is used to define the map. I suggest looking up Condition and Piecewise in the documentation for a full understanding.

f[x_ /; 0 <= x < 2] := Piecewise[{{0, x < 1}, {1, x < 2}}]

Plot[f[x], {x, -1, 3}, PlotStyle -> Thickness[.01]]

enter image description here

POSTED BY: David Keith

enter image description here

POSTED BY: Simon Cadrin

You have a perfectly good function definition. There seems to be no actual question here.

POSTED BY: John Doty
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