Question: Query regarding the output of a procedure

Hi, 
I am struggling with the output of a procedure. A dummy code is as follows:

*****

fun := x^2+y^2;

temp_proc := proc(x, y)
local out1, out2, out3:

if x > 0 then out1 := fun; out2 := 2*fun; out3 := k*fun;
elif x <= 0 then out1 := fun; out2 := -2*fun; out3 := -k*fun;
end if:

return(out1, out2, out3);
end proc:

xt := -1: yt := 2:
out1_fin := temp_proc(xt, yt)[1];
out2_fin := temp_proc(xt, yt)[2];
out3_fin := temp_proc(xt, yt)[3];


*****

xt and yt are numerical input parameters. I expect to obtain "out1_fin" and "out2_fin" in numerical form and "out3_fin" in symbolic form. All three outputs should substitute xt and yt for x and y, respectively, wherever relevant. 

However, currently, the output I am getting is not after substituting the values of xy and yt. The output is as follows:

*****

out1_fin := x^2+y^2

out2_fin := -2*x^2-2*y^2          

out3_fin := -k*(x^2+y^2)

*****

May I get some help in resolving the issue? 

Also, would a procedure be a good idea for this task, or would a module be better? 

I would appreciate any guidance in this regard. Thank you. 

Regards,

Omkar

Please Wait...