Re: Problems with NIntegrate

• To: mathgroup at christensen.cybernetics.net
• Subject: [mg1671] Re: Problems with NIntegrate
• From: rubin at msu.edu (Paul A. Rubin)
• Date: Tue, 11 Jul 1995 05:17:18 -0400
• Organization: Michigan State University

```In article <3ti28i\$klt at news0.cybernetics.net>,
Ian.Barringer at brunel.ac.uk (Drib) wrote:
->
->HI,
->	I have come up against a problem in Mathematica I hope someone
->	in this group may be able to explain to me.
->	I have defined a function as follows;
->	fp[p_]=Sqrt[(x^2-1)/(p^2-x^2)]
->	which I wish to integrate numerically. This I can do with
->	integer values of p:
->	NIntegrate[fp[6],{x,1,6}]
->	= 5.69279
->	However, if I set p as a real value, such as:
->	NIntegrate[fp[6.2],{x,1,6.2}]
->	I get an inexact arithmetic error, and no answer.
->
->	Does anybody know why this is happening, and if it's possible
->	to repair ?
->	If the problem was caused by the singularity a x=p then surely
->	this would effect both integer and real values of p.

It is indeed the singularity, in conjunction with the wonders of exact
representation of integers vs. approximate representation of reals.

Try redefining your function fp as follows:

fp[p_]:=(If[x>=0.999999p, Print[x]]; Sqrt[(x^2-1)/(p^2-x^2)])

Now do your NIntegrates.  Any time a value of x "near" p is substituted,
you'll see it in print.  Note that when p is the exact integer 6, Mma tries
some extended precision x values *very* close to (and just below) p.  When
p is 6.2 (as is the upper limit of x), it tries x values slightly _larger_
than 6.2, due (I assume) to the truncation error inherent in converting 6.2
to fixed precision binary.  Replacing {x,1,6.2} with {x,1,N[6.2, 30]} did
not seem to help.  Changing it to {x,1,62/10}, on the other hand, did help
(62/10 being exact).

Paul

**************************************************************************
* Paul A. Rubin                                  Phone: (517) 432-3509   *
* Department of Management                       Fax:   (517) 432-1111   *
* Eli Broad Graduate School of Management        Net:   RUBIN at MSU.EDU    *
* Michigan State University                                              *
* East Lansing, MI  48824-1122  (USA)                                    *
**************************************************************************
Mathematicians are like Frenchmen:  whenever you say something to them,
they translate it into their own language, and at once it is something
entirely different.                                    J. W. v. GOETHE

```

• Prev by Date: Re: stat package
• Next by Date: Re: I'm looking for an algorithm: Cartesian Product
• Previous by thread: Problems with NIntegrate
• Next by thread: Re: Problems with NIntegrate