Re: QROMB problem [message #31398] |
Mon, 08 July 2002 15:56 |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
fskhk@puknet.puk.ac.za (Helena Kruger) writes:
> I am working with Windows 98 and IDL 5.1. I want to get the integral
> of a function by using the QROMB or QSIMP function. I want to
> integrate to PHI, with R as a variable. How can I change the value of
> R each time calling the function. Here is my program (where I get the
> same answer each time, of cause):
Hi Helena--
You are running into a fundamental limitation of the IDL version of
QROMB, which is that it doesn't allow any user data, R in your case,
to be passed to to your function.
You have a couple of options.
Common blocks will work, but are stylistically problematic.
The IDL Astronomy library has both QTRAP and QSIMP procedures, which
do adaptive integration, and allow user data to be passed.
Finally, I have a numerical integrator called QPINT1D, which also
allows user data to be passed. Here is a simple example, which
doesn't even require a separate function to be compiled:
a=0.0
b=!pi*2.0
R=0.1
answer = fltarr(20)
for i = 0, 19 do begin
answer(i) = qpint1d('1./SQRT(1.+p.R^2.*p.alfa^2.*(cos(x-p.R))^2.)', $
/expression, a, b, epsrel=0.001, $
{alfa:1.0, R:R})/b
R = R*1.1
endfor
Good luck,
Craig
http://cow.physics.wisc.edu/~craigm/idl/idl.html (under Mathematics)
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|