Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Integration Problem in Mathematica

  1. Aug 5, 2009 #1
    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
     
  2. jcsd
  3. Aug 5, 2009 #2

    CompuChip

    User Avatar
    Science Advisor
    Homework Helper

    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)?
     
  4. Aug 5, 2009 #3
    I wrote it as:

    Code (Text):
    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 (Text):
    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
     
  5. Aug 5, 2009 #4

    CompuChip

    User Avatar
    Science Advisor
    Homework Helper

    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 (Text):
    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 :)
     
  6. Aug 5, 2009 #5
    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 (Text):
    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 (Text):
    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
     
  7. Aug 5, 2009 #6

    CompuChip

    User Avatar
    Science Advisor
    Homework Helper

    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 (Text):
    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 (Text):
    Plot[f[x], {x, 0, 10}]
    works perfectly.
     
  8. Aug 5, 2009 #7
    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
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Integration Problem in Mathematica
Loading...