Path: utzoo!attcan!uunet!mcvax!ukc!cam-cl!nmm From: nmm@cl.cam.ac.uk (Nick Maclaren) Newsgroups: comp.lang.pascal Subject: Re: Mathematical Functions for Integration Message-ID: <755@scaup.cl.cam.ac.uk> Date: 25 May 89 11:41:28 GMT References: <19715@adm.BRL.MIL> <210@maytag.waterloo.edu> Sender: news@cl.cam.ac.uk Reply-To: nmm@cl.cam.ac.uk (Nick Maclaren) Organization: U of Cambridge Comp Lab, UK Lines: 30 dmurdoch@watstat.waterloo.edu (Duncan Murdoch) writes: >Numerical Recipes, by Press et al, suggests using the identity > b 1/a 1 1 > I f(x) dx = I - f(-) dt > a 1/b t^2 t >which works provided a and b have the same sign, to turn an upper limit of >infinity into a lower limit of zero. If a=0, you'll have to break the integral >into two parts, i.e. 0 to c, c to infinity, and sum the results. This sort of thing is the reason that 'cookbooks for the naive' are so dangerous, and it is much better to get access to a good (and hence probably expensive) numerical library or consult a numerical analyst. Yes, this transformation may work and may even give the right answer. Alternatively, it may just APPEAR to work, and give an answer that is almost unrelated to the correct one. For example, it is extremely common to get functions of the general nature of f(x)exp(-ax)sin(bx) or f(x)sin(ax)/(x^n). If you apply this transformation to such functions, you end up with a function that is very nasty indeed (as far as numerical integration is concerned). Many free numerical integration routines will happily return an answer, but it may be nonsense. This area is a minefield, and should be treated as such. It is critical to work out at least the gross properties of a function before trying to integrate it, especially over an infinite range. Nick Maclaren University of Cambridge Computer Laboratory nmm @ uk.ac.cam.cl