A step function to illustrate the piecewise()
function of Math:
The plotting function can be written
plot( x => piecewise( [], ... )(x), [] )
if more clarity is desired in explicitly indicating the argument of the piecewise function.
Complete code for this example:
<div class="mathcell" style="height: 5in">
<script>
var parent = document.currentScript.parentNode;
var id = generateId();
parent.id = id;
MathCell( id, [] );
parent.update = function( id ) {
var data = [ plot( piecewise( [ x => 0, [0,1] ], [ x => 1, [1,2] ],
[ x => 2, [2,3] ], [ x => 3, [3,4] ],
[ x => 4, [4,5] ] ),
[0,5] ) ];
var config = { type: 'svg' };
evaluate( id, data, config );
}
parent.update( id );
</script>
</div>