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

Home » Public Forums » archive » Re: indefinite integration with IDL
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: indefinite integration with IDL [message #38219] Fri, 27 February 2004 23:40
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
marco.grossi@roma1.infn.it (Marco Grossi) writes:


>> I have a function of two variables f=f(E,y) and I want to calculate
> the
>> integral respect to y, where y ranges between 0. and a value which
> is a >function of E, f(E).
>> How can I calculate such an integral with IDL, since I want to plot
> my result >as a function of E?
>
>
>> That's what I have tried so far without any luck.
>> Here I have defined a very simple function for a start:
>
> FUNCTION delta, y, E
> RETURN, y / ( 2. * E * (1 - y) )
> END
>
> pro integral
> E=findgen(11) + 1.
> ymin=0.0
> ymax = 1. - 1./E
> result=qromb('delta',ymin,ymax)
>
> ;plot,E,result
>
> END
>
>> when I run it, it gives an error saying that the function E has not
> been >defined.

Which is true. Your E exists in the scope of the INTEGRAL procedure,
but does not exist within DELTA. That is why you got the error.

The second problem is that you are trying to pass a scalar YMIN and
vector YMAX. If you read the documentation for QROMB, you can guess
that the extra elements of YMAX beyond the first are ignored.

I do not understand it, but RSI makes it very hard to pass private
data into user functions. This is not just for integration routines
but also for fitting and optimization.

One solution is to use a COMMON block, but that is bad style.

Another is to use a "better" routine like QPINT1D. Better is in many
respects. One is that you can pass private data in, via several
means. Also, the integration routine is adaptive.

Example (using your same DELTA and YMIN):
for i = 0, n_elements(E)-1 do $
result(i) = qpint1d('delta', YMIN, 1 - 1/e(i), e(i))

Good luck,
Craig

http://cow.physics.wisc.edu/~craigm/idl/idl.html (under math)

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
[Message index]
 
Read Message
Previous Topic: indefinite integration with IDL
Next Topic: PRINTER device changed in IDL 6

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

Current Time: Sun Oct 12 02:57:56 PDT 2025

Total time taken to generate the page: 1.59992 seconds