MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Why Plot cannot run under package?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg39636] Re: Why Plot cannot run under package?
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Thu, 27 Feb 2003 00:27:19 -0500 (EST)
  • Organization: Universitaet Leipzig
  • References: <b3hshl$ild$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

it fail, because 

>Plot[CurveEquation[x], RootLocation, MaxBend -> 10,
>             PlotDivision -> 20]

refer to a symbol x in the private context 
(Enhancements`DiscoverRoots1`Private`x) of the package
while the list in the RootLocation argument refer to 
the global symbol x (Global`x)

You may use
DiscoverRoots1[CurveEquation_, {x1_,x2_}] :=
    Module[{pp,x},
       (pp =
           Plot[CurveEquation[x], {x,x1,x2}, MaxBend -> 10,
             PlotDivision -> 20];
        )];

and all works fine.

Regards
  Jens

liwen liwen wrote:
> 
> 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


  • Prev by Date: RE: Simplification of vector and scalar products
  • Next by Date: Re: Why Plot cannot run under package?
  • Previous by thread: Re: Why Plot cannot run under package?
  • Next by thread: Re: Why Plot cannot run under package?