       Re: Package Problem

• To: mathgroup at smc.vnet.net
• Subject: [mg93928] Re: Package Problem
• From: "m.g." <mg at michaelgamer.de>
• Date: Fri, 28 Nov 2008 07:11:29 -0500 (EST)
• References: <12389980.1227702410661.JavaMail.root@m02> <gglt4h\$8mn\$1@smc.vnet.net>

```On 27 Nov., 11:34, "David Park" <djmp... at comcast.net> wrote:
> I'm not completely certain, but I think your problem may be that in the
> package x becomes a Private symbol. You should probably define your routi=
ne
> as:
>
> Nullstellen[f_, interval_List, variable_:Global`x]
>
> and then define and set x to variable in the package routine.
>
> Also, you might want to look at the RootSearch package by Ted Ersek on
> MathSource at the WRI site. This is a very nice routine for finding roots=
of
> 1-dimensional functions within an interval.
>
> David Park
> djmp... at comcast.nethttp://home.comcast.net/~djmpark
>
> From: m.g. [mailto:m... at michaelgamer.de]
>
> Hello Group,
>
>   I have the following problem. I made a short Module to calculate the
> zeros of a given Function.I did this simply in the following way:
>
> Nullstellen[f_, intervall_List] :=
>  Module[{func, startwerte, werte, vzwechsel, liste,
>    a = intervall[], b = intervall[]},
>   func = Function[x, Evaluate[f]];
>   werte = Table[x, {x, a, b, Abs[b - a]/100.}]; (* start-values *)
>   liste = ({#, func[x] /. x -> #} ) & /@ werte;
>   vzwechsel =    Select[Split[liste, (Sign[Last[#1]] == -Sign=
[Last
> [#2]]) &],  Length[#] == 2 &]; (* Sign Change*)
>   startwerte = Map[First, vzwechsel, {2}];
>   Map[FindRoot[func[x] == 0, {x, #[], #[]}] &, startwerte]
>   ]
>
> This works fine, but when I copy exactly this code in my own
> package... it works not. I get an output like this:
>
> Nullstellen[x^2 - 2, {-2, 2}]
>
> {{-2.,-2+x^2},{-1.8,-2+x^2},{-1.6,-2+x^2},{-1.4,-2+x^2},{-1.2,-2+x^2},
> \
> {-1.,-2+x^2},{-0.8,-2+x^2},{-0.6,-2+x^2},{-0.4,-2+x^2},{-0.2,-2+x^2},
> {\
> 1.11022*10^-16,-2+x^2},{0.2,-2+x^2},{0.4,-2+x^2},{0.6,-2+x^2},{0.8,-2+
> \
> x^2},{1.,-2+x^2},{1.2,-2+x^2},{1.4,-2+x^2},{1.6,-2+x^2},{1.8,-2+x^2},
> {\
> 2.,-2+x^2}}
>
> So the mapping of the function onto the values does not work.
>
> Can anyone explain the reason (and give me a hint how I can manage
> this function to work within a package).
>
>
> Mike from cold an rainy Germany

Thank you, David, this was clearly the problem... but I did=B4nt see it.
Anyway now it is fixed. :-)

Greetings Mike

```

• Prev by Date: Re: Floating-Point Computing
• Next by Date: Re: How to hold a form and convert it to a string
• Previous by thread: Re: Package Problem
• Next by thread: Re: Package Problem