MathGroup Archive 2008

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

Search the Archive

RE: Package Problem

  • To: mathgroup at
  • Subject: [mg93881] RE: [mg93825] Package Problem
  • From: "David Park" <djmpark at>
  • Date: Thu, 27 Nov 2008 05:35:10 -0500 (EST)
  • References: <12389980.1227702410661.JavaMail.root@m02>

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 routine

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
djmpark at 

From: m.g. [mailto:mg at] 

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[[1]], b = intervall[[2]]},
  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, #[[1]], #[[2]]}] &, 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}]


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).

Many thanks in advance

Mike from cold an rainy Germany

  • Prev by Date: Re: CUDA support in 7.0?
  • Next by Date: Re: A problem in Pi digits as Lattice space filling
  • Previous by thread: Package Problem
  • Next by thread: Re: Package Problem