# Package Function Confusion

I am a freshman working with Mathematica. I have written a package with a function like this:

SolidShapeFunction2d[Coords_List] :=
Module[{u, p1, p2, p3, u1, u2, u3},
u = p1 + p2 * x + p3 * y;
x1 = Coords[[1, 1]];
y1 = Coords[[1, 2]];
x2 = Coords[[2, 1]];
y2 = Coords[[2, 2]];
x3 = Coords[[3, 1]];
y3 = Coords[[3, 2]];
solut1 =
Solve[{
(u /. x -> x1 /. y -> y1) == u1,
(u /. x -> x2 /. y -> y2) == u2,
(u /. x -> x3 /. y -> y3) == u3},
{p1, p2, p3}];
u = u /. solut1;
N1 = Coefficient[u, u1];
N2 = Coefficient[u, u2];
N3 = Coefficient[u, u3];
{{N1, 0, N2, 0, N3, 0}, {0, N1, 0, N2, 0, N3}}]


This function is designed to obtain the shape function in FEM. But when I use this in a notebook, the answer doesn't seem correct:

<< MyFem
Nshape = SolidShapeFunction2d[Coords]

{{{1 - MyFemPrivatex}, 0, {MyFemPrivatex - MyFemPrivatey}, 0,
{MyFemPrivatey}, 0},
{0, {1 - MyFemPrivatex}, 0, {MyFemPrivatex - MyFemPrivatey}, 0,
{MyFemPrivatey}}}


What does the MyFemPrivate mean? And how can eliminate it?

• Begin statement in your package makes new symbols to create in given context. You don't want to see this context or what? I rather think there is a problem in definition, unless you really want symbolic output. – Kuba Mar 30 '15 at 8:38
• @ Kuba.In this function,I do want the symbolic output. Because in the next function(I don't post here),some value will be bound to the "X" and "Y".And the function will be evaluted to obtain numerical answer. – Yang Mar 30 '15 at 8:50
• I think this is in fact a good question. – Kuba Mar 30 '15 at 8:58
• It's your use of an undefined x and y while in the Private part of the context of your package. It's rather bad practice to use and return those. If you want to return symbols from a global context I guess it would be better to introduce those as parameters to functions that you call from this package. So, function template should look like SolidShapeFunction2d[Coords_List,x_,y_]  – Sjoerd C. de Vries Mar 30 '15 at 9:00
• @SjoerdC.deVries.Thanks for your answer. I will hava a try and report later. – Yang Mar 30 '15 at 9:04

SolidShapeFunction2d[Coords_List,x_,y_]
`