Question: Maple doesnt see variable inside procedure

Hello,

please, help me understand why the procedure does not see a variable.

If you do this, then everything works:

 

restart;
F := 8*y^2*(3*R^2+2*y^2)/r^4; 
G := 24*R^2*y^4/r^6;
sigma := simplify(subs(r = sqrt(x^2+y^2), (1-k[1]+k[2])*R^2*(3-(3*R^2+18*y^2)/r^2+F-G)/(2*r^2)+k[2]*R^2*(1-2*y^2/r^2)/r^2)):
k[1] := E[2]*((3-nu[2])*E[1]+(5+nu[1])*E[2])/((E[1]+2*E[2])^2-(nu[2]*E[1]+(1-nu[1])*E[2])^2);
k[2] := E[2]*((3*nu[2]-1)*E[1]+(1-3*nu[1])*E[2])/((E[1]+2*E[2])^2-(nu[2]*E[1]+(1-nu[1])*E[2])^2);
nu[1] := 1/3; nu[2] := 1/3;
s := simplify(sigma);
si := proc (x, y) if R <= x^2+y^2 then -(3/2)*R^2*(-(1/3)*y^6+(R^2+(11/3)*x^2)*y^4+(-6*R^2*x^2+3*x^4)*y^2+R^2*x^4-x^6)*(E[1]-E[2])/((x^2+y^2)^4*(E[1]+2*E[2])) else E[2]*((3*nu[2]-1)*E[1]+(1-3*nu[1])*E[2])/((E[1]+2*E[2])^2-(nu[2]*E[1]+(1-nu[1])*E[2])^2) end if end proc:
R := 1; M := 5;
E[2] := (1/10)*E[1];
plot3d(si, -M .. M, -M .. M, axes = frame);

 

and we get a beautiful plot:

 

If inside the procedure after 'then' I try to enter the variable s, then the procedure does not see it .... global, local, return (s), value(s), inside the procedure or outside, Ive tried everything .... help plzl!

 

restart;
F := 8*y^2*(3*R^2+2*y^2)/r^4; 
G := 24*R^2*y^4/r^6;
sigma := simplify(subs(r = sqrt(x^2+y^2), (1-k[1]+k[2])*R^2*(3-(3*R^2+18*y^2)/r^2+F-G)/(2*r^2)+k[2]*R^2*(1-2*y^2/r^2)/r^2)):
k[1] := E[2]*((3-nu[2])*E[1]+(5+nu[1])*E[2])/((E[1]+2*E[2])^2-(nu[2]*E[1]+(1-nu[1])*E[2])^2);
k[2] := E[2]*((3*nu[2]-1)*E[1]+(1-3*nu[1])*E[2])/((E[1]+2*E[2])^2-(nu[2]*E[1]+(1-nu[1])*E[2])^2);
nu[1] := 1/3; nu[2] := 1/3;
s := simplify(sigma);
si := proc (x, y) if R <= x^2+y^2 then s else E[2]*((3*nu[2]-1)*E[1]+(1-3*nu[1])*E[2])/((E[1]+2*E[2])^2-(nu[2]*E[1]+(1-nu[1])*E[2])^2) end if end proc:
R := 1; M := 5
E[2] := (1/10)*E[1];
plot3d(si, -M .. M, -M .. M, axes = frame);

Please Wait...