Question: Procedure + Plot

Hi,

I am trying to generate a plot using a procedure. A dummy code is as follows:

***

fun := piecewise(x+y > 1, (x+y)^2, x-y);

temp_proc := proc(x, y)
local out, ind:

ind := 9:

if x > y then ind := 1 else ind := 0 end if; 

if ind = 1 then out := eval(5*fun, {:-x=x, :-y=y}) else out := eval(-5*fun, {:-x=x, :-y=y}) end if:

return(out);
end proc:

xt := 5: yt := 2:
out1_fin := temp_proc(xt, yt);

plot(out1_fin, z=-2..3);
 

***

The issue is as follows:

1. I am getting an error message for the code above: "Error, (in temp_proc) cannot determine if this expression is true or false: 2 < z".

2. The entire procedure and the plot command work well for a fixed "z". However, it is not useful for me as I am looking for a plot for various values of z. 

3. I hope I don't have to run the procedure by manually creating a list of z and then plotting the lists of z and out1_fin. 

4. I am using the "ind" variable because it simplifies my actual code, which involves multiple conditions defining the function "fun" that I need to plot. 

I would appreciate your input on how to resolve the issue. 

Regards,

Omkar

 

Please Wait...