Question: Graphing a piecewise function

Should be that i was thinking on the use the arrow operator for a function definition and to use this for graphing this function
It becomes complicated.


 

restart;

 

the following piecewise-defined function was considered

exc set 4 task 1a
                                                                                

sin(3*x): # x <= 0 .. must be evaluated to true or false for branching to      #other second function
sin(x/3): # otherwise

h:=proc(x)
   if x<=0 then sin(3*x)
   else sin(x/3)
   fi;
end proc:

maplemint(h);

h(1); #

sin(1/3)

(1)

h(1.0);

.3271946968

(2)

Strange that this function notation e.g h(1) can be used for a expression ?, while the idea was to use this only for a function defintion with a arrow operator  ( function as a procedure )
Seems to be possible to use the notation e.g : h(1) or h(1.0) if the input parameter is numeric for a expression.

 

The condition in the if statement must be(can only) evaluated numeric..that seems to be not possible with the arrow operator definition in the procedure.

 

h(x);

Error, (in h) cannot determine if this expression is true or false: x <= 0

 

plot('h(x)'); # delay of the evaluation of h(x)

 

plot(h);

 

 


 

Download exc_set_4_task1.mw

 

Please Wait...