Group Abstract Group Abstract

Message Boards Message Boards

0
|
73 Views
|
6 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Using NIntegrate with nested integrals

I need to evaluate the following integral:

Integral_0_1 f(y)*Integral_0_y g(x) dx dy

where e.g.

Integral_a_b g(x) dx 

is the definite integral of f(x) over x= a,b.

In the case of the functions I am working with, there is no closed form solution to the integral of g(x), so I need to evaluate this integral numerically.

NIntegrate[f(y)*NIntegrate[g(x),{x,0,y}],{y,0,1}]

this results in an error message stating that x=y is not a valid limit of integration, because the inner Nintegrate function recognizes y as a variable rather than a numerical value assigned to it. What are my options for numerically integrating functions of this type, i.e. where

 Integral_0_y g(x) dx  = F(y)

cannot be computed explicitly but is part of the integrand? I've attached a notebook (with an example) in case my notation isn't clear. The numerical integration evaluates to something, but I'm not confident that the result is meaningful because of the error in having a variable y as the integrand.

POSTED BY: MAXIM SHPAK
6 Replies

Regards M.I.

POSTED BY: Mariusz Iwaniuk

Thank you for providing a detailed analysis of the integration problem.

However, I was trying to get at a more general question about how to use Mathematica's NIntegrate function for scenarios like the one in my notebook where the limits of the inner integral are a variable rather than a constant and where there is no closed for analytical solution or approximation to the inner integral. Is there some way to do this with NIntegrate (or some other function) that will avoid the error associated with having a variable as an integral limit?

However, the good news seems to be that despite throwing the error about integral limits, NIntegrate returns the same result as your solution based on hypergeometric functions. Perhaps

"NIntegrate::nlim: z = y is not a valid limit of integration" 

is a warning rather than an error per se, and the numerical integration proceeds using the numerical value of y in each interval as was hoped?

POSTED BY: MAXIM SHPAK

POSTED BY: Mariusz Iwaniuk

Thank you, this is the solution that I was looking for.

POSTED BY: MAXIM SHPAK

Have you considered transforming the iterated integrals into a double integral?

You gave two different spellings to var. Choose one.

POSTED BY: Gianluca Gorni

Unless I'm missing something obvious (quite possible), it seems to me that turning this into a double integral would require having a closed-form expression in terms of two different variables. Because the inner integral evaluates into a function of the outer integral and doesn't have an explicit, analytical expression, this isn't the case

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