MathGroup Archive 1998

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

Search the Archive

functions as arguments to functions

  • To: mathgroup at
  • Subject: [mg14995] functions as arguments to functions
  • From: sean_ross_at_pl-04m3 at
  • Date: Wed, 2 Dec 1998 03:59:15 -0500
  • Sender: owner-wri-mathgroup at

[Contact the author to obtain the notebook mentioned below - mod.]

     I am looking for some answers in regards to a really mysterious 
     problem I have regarding passing functions into functions when the 
     calls are nested or the functions are complicated.
     The basic idea is this:
     I have a root finding routine findroot[f,{x,{x1,x2}}], where f is an 
     expression in the variable x.  Inside findroot, I make an 
     "overfunction" which shields the actual numerical routines from 
     undefined regions, complex values, and out of range values.
     I have a second function lspmopo, which calls on findroot.
     I have a third function Dkdfm, which calls on lspmopo.
     I have a fourth function which tries to use 
     findroot[Dkdfm[....,x...],{x,{x1,x2}}].  This makes a function call to 
     findroot embedded inside a findroot operation.
     lspmopo returns a good answer when called on directly or inside Dkdfm. 
      When it is called on inside of the 
     findroot[Dkdfm[....,x...],{x,{x1,x2}}], it returns a ridiculous answer 
     1.545+Null which causes the entire procedure to crash.
     I am attaching the notebook which has all the code.
     I would really appreciate help, but don't waste your time if you can't 
     look at the notebook.  The general procedure I use works for simple

     functions, but not for complicated ones, so please don't send me any 
     simple examples.  This problem only arises when trying to find the 
     roots of functions that themselves must resort to root finding methods 
     for their values.  All of the methods I use work when tried 
     individually, but not inside multiple nested function calls, so please 
     don't send me isolated examples that work by themselves.
     I believe the problem is in passing functions as arguments to 
     functions.  If anyone knows how Wolfram programmers do it, such as in 
     the Integrate function, please let me know.  I am sure that I do not 
     have the correct combination of Holds, Releases, pure functions etc. 
     that will robustly pass functions without modification through 
     multiple function calls.
     Please respond to rosss at as I no longer subscribe to the 
     Thanks, Sean Ross

  • Prev by Date: mathlink example for visual c++
  • Next by Date: Re: PlotLabel question
  • Previous by thread: mathlink example for visual c++
  • Next by thread: Re: PlotLabel question