Message Boards Message Boards

0
|
5429 Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Why do NIntegrate and Integrate give me wildly different numerical results?

Posted 9 years ago

NIntegrate(DensitykCV10) 4 (kCV) (aCV) [Pi (1 - r^2/aCV^2)^( 1/2), {r, 2.1 kpc, 24.9999999999999 kpc}] Integrate(DensitykCV10) 4 (kCV) (aCV) [Pi (1 - r^2/aCV^2)^( 1/2), {r, 2.1 kpc, 24.9999999999999 kpc}] 1.3348843716738612*^41 -1.1649126556873091*^47

Where : DensitykCV10 = -2.1655374175670179*^-23 + 9.613409467968622654005528082224298190313253612527733315.\ 954589770191005*^360/r^19 - 1.567517760674831950180279448212079973184957663035191315.\ 954589770191005*^341/r^18 - 8.0208474170851387655219288097721768593499534319653315.\ 954589770191005^320/r^17 + 1.022460848859555*^301/r^16 - 2.004321573660638^280/r^15 + 7.091924433038064*^260/r^14 + 1.6123999421508397^241/r^13 - 2.0336725599764065*^221/r^12 + 3.793457090853046^201/r^11 - 2.7135337192132066*^181/r^10 - 7.802829964572928^159/r^9 - 2.3354562182435446*^141/r^8 + 9.899828618979645^120/r^7 + 1.2639092458127386*^101/r^6 - 4.106075496892548^80/r^5 - 3.85804411886524*^60/r^4 - 1.8194736266132835^40/r^3 - 1.7566983400633786*^19/r^2 + 726222.7515032793/r - ( 758323.4007837623E^(7.7141939551.489350545012236*^14/r))/r + ( 32098.992477704156E^(1.5428387951.489350545012236*^16/r))/r + ( 1.9234697286706819E^(1.5428387951.489350545012236*^18/r))/r + ( 0.012818838810693135E^(1.5428387951.489350545012236*^19/r))/r + ( 1.7261847240186006E^(3.85709697551.489350545012236*^19/r))/r - ( 0.04215954423293189E^( 5.14279596666666666666666666666666666666666666666666666666666666666\ 66666666666751.489350545012236*^19/r))/r - ( 2.7696321850969334E^(7.7141939551.489350545012236*^19/r))/r + ( 1.2275953267560438E^(1.5428387951.489350545012236^20/r))/r - 3.5170173861515377*^-43 r + 8.030590056582523^-64 r^2 - 5.459043511271203*^-85 r^3 + 9.656815327898565*^-107 r^4

POSTED BY: Louis Barrett
3 Replies

A 19th order polynomial expressed as a power series with approximate numerical coefficients is not an object from which I would expect to extract any mathematical sense.

POSTED BY: John Doty

As written the problem is near to be mystic. Do we have a product of two integrals? And what about the units (kpc = kiloparsec?) in the iterator of the integrals? Does kpc have a numerical value?

POSTED BY: Hans Dolhaine

Integrate and NIntegrate are very different functions and it's not uncommon for them to disagree.

I'm having trouble using the code as it was pasted. Would it be possible for you to either add the code in a code section or to attach a notebook?

As a general guideline, If you have floating point numbers in your formula, you don't want to use Integrate. Integrate does symbolic calculations and those very often aren't numerically stable for floating point numbers. If you want to use Integrate as a sanity check for the values coming out of NIntegrate, you might consider turning the floating point numbers in the integrand into rational numbers using the Rationalize function:

Rationalize[DensitykCV10, 0]

I do this kind of thing for tractable integrals just to see that the values agree.

Without being able to play with the function, I can't tell what's happening. Maybe there's a reason why it might not be numerically integrating well.

POSTED BY: Sean Clarke
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract