comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Multiple parameters for ZEROFCN
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Multiple parameters for ZEROFCN [message #78899] Mon, 02 January 2012 14:41 Go to next message
Rick Walton is currently offline  Rick Walton
Messages: 3
Registered: November 2011
Junior Member
I would like to find the root of a function f(x) that depends on the
values from an array. Using th IMSL function ZEROFCN appears to only
allow a single parameter to be defined, which is x. But I would like
to vary one of the constants in the function but when I try to use a
userdefined expression for this it causes an error. To demonstrate
what I`m trying to acheive see the function and code below. If anyone
has a simple solution to this I would really appreciate the help.
Thanks in advance.

FUNCTION f, x, y
RETURN, ((sinh((1.4 +x-0.25)/(0.4))/(sinh((x-0.25)/0.4)))-y
END

;array containing data for constant y
Y=fltarr(252)

;new file to input zeros
zero=fltarr(252)

;function to determine zeros in f(x)
FOR i=0, 251 DO BEGIN
zero(i)=ZEROFCN("f", y(i))
Re: Multiple parameters for ZEROFCN [message #78985 is a reply to message #78899] Sun, 15 January 2012 07:57 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
I give an example of using common blocks to pass parameters below. Since IDL does not have the PV_WAVE ZEROFCN function, I substituted ZBRENT just to have a function that works for me.

Note that another limitation of the built-in IMSL/Numerical Recipes functions in IDL is that the user-supplied function must return a *scalar* value. So be careful that your extra Y parameter is also a scalar. --Wayne


FUNCTION f, x
common fparam, y
RETURN, X^3 + y
END

pro test
common fparam,y

FOR i = 0, 9 DO BEGIN
Y = i
print, Zbrent(-5,5,func_name="F")
ENDFOR
END
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Creating procedure with arbitrary number of input parameters
Next Topic: Where is where?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 08:13:55 PDT 2025

Total time taken to generate the page: 0.55786 seconds