I'm fairly new to the Wolfram Language and I'm having a problem with how packages work.
I have some function that are inside a package, the goal of those function is to create random polynomial functions and plot them.
I've tested those functions in a notebook file and I had no problem with it.
If I put those functions in a package the function gives me a strange result with Private`x instead of only x (img below).
(* Inside package*)
DrawRandomPoly[] :=
Module[{p,x},
p = MakeRationalPolynomial[0,1];
Row[{"ƒ(\[FormalX]) ", p //DisplayForm, Plot[p,{x,-10,10},ImageSize->400, Epilog->{PointSize[Large],Point[{Last[FunctionDiscontinuities[p,x]],0}]}],"\!\(\*UnderscriptBox[\(\[Limit]\), \(\[FormalX]\[LongRightArrow]\[Alpha]\)]\) ƒ(\[FormalX])",Limit[p,x->Last[FunctionDiscontinuities[p,x]]]},"\[DoubleLongRightArrow]"]
]
MakeRationalPolynomial[n_,n2_] :=
Module[{num,den,f},
num=MakePolynomial[n,x];
den=MakePolynomial[n2,x];
Evaluate[num]/Evaluate[den]
]
MakePolynomial[n_Integer,x_Symbol] := Module[{z,c}, z = RandomChoice[{-1,1}] RandomInteger[{1,10}];
c = Table[RandomInteger[{-10,10}], {n}];
FromDigits[Reverse[AppendTo[c,z]],x]]
I don't understand what's the problem when I call the DrawRandomPoly function from an imported package. What can be the cause of this problem? Thanks
Begin["Private`"]
in your package when you should be usingBegin["`Private`"]
instead. $\endgroup$[\FormalX]
everywhere in your code instead of x? That would be what I think it has been introduced for... $\endgroup$