mikkelstouby shared this idea 7 years ago
I already know how to nest if-statements to draw a piecewise-defined function but my students find this way hard.
I would therefore suggest a new command Piecewise where i.e. f(x)=Piecewise[x<1,x+2,x>=1,x] would be interpreted the same way as f(x)=If[x<1,x+2,If[x>=1,x]]. Such a command exists in Maple and I can see that my students have far less trouble using this.
- Feedback & Questions
- +43 677 6137 2693
f(x)=Piecewise[<relation>,<expression>,<relation>,<expression>,...] for multiple pieces, or perhaps more useful to learning
f(x)=Piecewise[<expression1>,<relation1>,<expression2>,<relation2>,...] to match the way these type of function are expressed mathematically. Looking at your algebra view.
BTW, g(x)=x+2,x>=1 work for individual equations
This may be a reason it will not be done.
have tried If[x<1,x+2,x>=1,x] really?
I did not know that, Mathmagic! That is indeed a nice feature. Thank you! My students will be thrilled.
I think this should be documented in the wiki.
Noel, the use that is documented is limited to If[condition, expression, expression]. That you can also use the syntax If[condition, expression, condition, expresion...] is not obvious.
Yes, I tried to give the simplest example but I guess it became a little too simple. :)
Comments have been locked on this page!