Why Plot cannot run under package?
- To: mathgroup at smc.vnet.net
- Subject: [mg39628] Why Plot cannot run under package?
- From: liwen liwen <gzgear at Yahoo.com>
- Date: Wed, 26 Feb 2003 02:43:52 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
I want to use the Plot function in Package,so I try the following package:
BeginPackage["Enhancements`DiscoverRoots1`"]
DiscoverRoots1::usage = " Try the use of Plot in package "
Begin["`Private`"]
DiscoverRoots1[CurveEquation_, RootLocation_] :=
Module[{pp},
(pp =
Plot[CurveEquation[x], RootLocation, MaxBend -> 10,
PlotDivision -> 20];
)];
End[]
EndPackage[
I run:
Needs["Enhancements`DiscoverRoots1`"]
It is OK.
But I try:
Curve1[x_] = Sin[x];
kk = {x, 0, 40};
DiscoverRoots1[Curve1, kk]
It alert such message:
Plot::plnr: Curve1[Enhancements`DiscoverRoots1`Private`x] is not a \
machine-size real number at x = 1.6666666666666667`*^-6.
Plot::plnr: Curve1[Enhancements`DiscoverRoots1`Private`x] is not a \
machine-size real number at x = 1.6226796629166318`.
Plot::plnr: Curve1[Enhancements`DiscoverRoots1`Private`x] is not a \
machine-size real number at x = 3.3923519943749474`.
General::stop: Further output of Plot::plnr will be suppressed during this \
calculation.
But if I run the function under *.nb file, it can runs well.
In[1]:=
DiscoverRoots1[CurveEquation_,RootLocation_]:=
Module[{pp},(pp=
Plot[CurveEquation[x],RootLocation,MaxBend\[Rule]10,
PlotDivision\[Rule]20];)];
In[2]:=
Curve1[x_]=Sin[x];
kk={x,0,40};
DiscoverRoots1[Curve1,kk]
I do not know why the program fails when it is in Package format.
Please help.
Regards,
Liwen