Integration Problem in Mathematica

In summary: In the integration s needs to have been assigned a value.As I suggested in my original post, you can accomplish this by writingf[s_] := NIntegrate[ E^(-g*s)*g^2*(g^2 + g)^(3/2)*BesselK[3, 2 Sqrt[g^2 + g]], {g, 0, Infinity}]Then when you evaluate, for example, f[0], it will perform the NIntegrate with s replaced by 0. The numerical integration is sufficiently fast that for examplePlot[f[x], {x, 0, 10}]works perfectly.In the integration s
  • #1
EngWiPy
1,368
61
Hello,

I have the following integration:

[tex]\int_0^{\infty}\text{e}^{-\gamma(p+s)}\gamma^a(\gamma^2+\gamma)^{b/2}K_b\left(\beta\sqrt{\gamma^2+\gamma}\right)\,d\gamma[/tex]

I want this integral to be evaluated numerically in Mathematica as a function of [tex]s[/tex], how can I do that?

Regards
 
Physics news on Phys.org
  • #2
Something like:

f[s_] := NIntegrate[ Exp[-x(p + s)] ... /. {p -> NumericalValueForP, a -> NumericalValueForA, b -> NumericalValueForB}, {x, 0, Infinity}]

(where you need to make sure that all variables except x and s have a numerical value inside the integration)?
 
  • #3
CompuChip said:
Something like:

f[s_] := NIntegrate[ Exp[-x(p + s)] ... /. {p -> NumericalValueForP, a -> NumericalValueForA, b -> NumericalValueForB}, {x, 0, Infinity}]

(where you need to make sure that all variables except x and s have a numerical value inside the integration)?

I wrote it as:

Code:
NIntegrate[
    E^(-g ((gB*(j2 + 1) + gA*(j1 + 1))/(gA*gB) + s))*g^(
     NA + k2 + p + m - n - 1)*(g^2 + g)^((n - m + 1)/2)*
     BesselK[(n - m + 1), 
      N[2*Sqrt[((g^2 + g) (j1 + 1) (j2 + 1))/(gA*gB)]]] , {g, 0, 
     Infinity} /. s -> gp/Sin[y]^2

where all variables has numerical values except g and s, but it gives me the following error:

Code:
NIntegrate::inumr: The integrand \[ExponentialE]^(-g (4.+s)) \
Sqrt[g+g^2] BesselK[1,4. Sqrt[g+g^2]] has evaluated to non-numerical \
values for all sampling points in the region with boundaries {{\
\[Infinity],0.}}. >>

NIntegrate::inumr: The integrand \[ExponentialE]^(-g (4.+s)) \
Sqrt[g+g^2] BesselK[1,4. Sqrt[g+g^2]] has evaluated to non-numerical \
values for all sampling points in the region with boundaries {{\
\[Infinity],0.}}. >>

NIntegrate::inumr: The integrand \[ExponentialE]^(-g (4.+s)) g^-n \
(g+g^2)^((1+n)/2) BesselK[1+n,4. Sqrt[g+g^2]] has evaluated to \
non-numerical values for all sampling points in the region with \
boundaries {{\[Infinity],0.}}. >>

General::stop: Further output of NIntegrate::inumr will be suppressed \
during this calculation. >>

Regards
 
  • #4
Are you sure about that? It looks like n, for one, does not have a value (I see it in your output).

Try something like
Code:
Block[{g = 1},
 N[ yourIntegrand ]
]
and check if it gives a number. If it gives an expression, assign a value to the variable names you still see and repeat until you get a number :)
 
  • #5
CompuChip said:
Are you sure about that? It looks like n, for one, does not have a value (I see it in your output).

Try something like
Code:
Block[{g = 1},
 N[ yourIntegrand ]
]
and check if it gives a number. If it gives an expression, assign a value to the variable names you still see and repeat until you get a number :)

Actually, it is not that easy, since the integral inside multiple summations, and in for loop. But strange, all other summation indices like n have no problem, but why n has problem? Let us make the problem easier as in the following code:

Code:
NIntegrate[
 E^(-g*s)*g^2*(g^2 + g)^(3/2)*BesselK[3, 2 Sqrt[g^2 + g]], {g, 0, 
  Infinity}]

this code gives me the following error:

Code:
NIntegrate::inumr: The integrand \[ExponentialE]^(-g s) g^2 \
(g+g^2)^(3/2) BesselK[3,2 Sqrt[g+g^2]] has evaluated to non-numerical \
values for all sampling points in the region with boundaries {{\
\[Infinity],0.}}. >>

What is the problem? Is it the s variable? If yes, how to generate a function of s from this integral?

Regards
 
  • #6
In the integration s needs to have been assigned a value.
As I suggested in my original post, you can accomplish this by writing
Code:
f[s_] := NIntegrate[
 E^(-g*s)*g^2*(g^2 + g)^(3/2)*BesselK[3, 2 Sqrt[g^2 + g]], {g, 0, 
  Infinity}]
Then when you evaluate, for example, f[0], it will perform the NIntegrate with s replaced by 0. The numerical integration is sufficiently fast that for example
Code:
Plot[f[x], {x, 0, 10}]
works perfectly.
 
  • #7
CompuChip said:
In the integration s needs to have been assigned a value.
As I suggested in my original post, you can accomplish this by writing
Code:
f[s_] := NIntegrate[
 E^(-g*s)*g^2*(g^2 + g)^(3/2)*BesselK[3, 2 Sqrt[g^2 + g]], {g, 0, 
  Infinity}]
Then when you evaluate, for example, f[0], it will perform the NIntegrate with s replaced by 0. The numerical integration is sufficiently fast that for example
Code:
Plot[f[x], {x, 0, 10}]
works perfectly.

Let me explain my problem well, as you can see this integral is a complicated one, and I couldn't solve it in closed form, so I have no choice but numerical integration. What I suppose to do is to multiply f(s) which is the result of this integral by another function of s, say g(s), and then integrate over s.

Again this integral is just a sample of long equation which is multiple summations of this integral with differnt parameters, so I need to find the whole function in term of s, multiply it with another, simpler function of s, and then integrate over s.

Regards
 

FAQ: Integration Problem in Mathematica

1. What is an "Integration Problem" in Mathematica?

An integration problem in Mathematica refers to the process of finding the antiderivative or indefinite integral of a given function. This involves finding a function whose derivative is equal to the given function, and is an essential concept in calculus and other areas of mathematics.

2. How does Mathematica solve integration problems?

Mathematica uses a combination of powerful algorithms and symbolic manipulation techniques to solve integration problems. It can handle a wide range of functions and can also provide step-by-step solutions for more complex integrals.

3. Can Mathematica handle definite integrals?

Yes, Mathematica can also handle definite integrals, which involve finding the area under a curve between two specific points. It uses the same algorithms and techniques as for indefinite integrals, but with the additional step of plugging in the limits of integration to find a numerical solution.

4. Are there any limitations to Mathematica's integration capabilities?

While Mathematica is a powerful tool for solving integration problems, it may not be able to find an exact solution for every function. In some cases, it may provide a result in terms of special functions or numerical approximations. Additionally, some integrals may be too complex for Mathematica to handle.

5. Can I customize the integration settings in Mathematica?

Yes, Mathematica allows users to adjust integration settings such as the method used, precision, and accuracy. This can be useful for finding more accurate solutions or for handling specific types of integrals. The "Options" command can be used to access and modify these settings.

Similar threads

Replies
1
Views
1K
Replies
4
Views
1K
Replies
13
Views
2K
Replies
2
Views
2K
Replies
19
Views
891
Replies
2
Views
338
Replies
2
Views
2K
Replies
6
Views
6K
Replies
5
Views
2K
Back
Top