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

Mathematica : Numerically Integrate function with undefined variables?

  1. Feb 6, 2013 #1

    Hepth

    User Avatar
    Gold Member

    I have a LARGE function that I must integrate over 2 variables, {x,y} both from 0 to 1.

    The Function looks like :

    F[x_,y_] = A[q] G[x,y] + B[q] G2[x,y] + (...)

    Where (...) MAY be 100's of terms long, if not thousands. But the fact is each term is separable, in SOME way to a function of x and y (and no other units or unknown variables).

    Each G function is quite complicated as well, and so far takes over 3 minutes each to integrate algebraically, though can be numerically integrated in under a second or two. They're all well behaved in the integration region.

    Is there a way, other than expand F, and dividing out A[q] etc for each, doing the NIntegrate, then multiplying it again, to numerically integrate this equation so it ends up being:

    result = (0.14325) A[q] + (-4.5602134) B[q] + (....)

    Can I tell NIntegrate to integrate around variables?

    I know something like NIntegrate[ a x^2,{x,0,1}] will throw an error due to an undefined "a" inserted.
     
  2. jcsd
  3. Feb 8, 2013 #2
    Re: Mathematica : Numerically Integrate function with undefined variab

    What if you temporarily

    substitute Aq for A[q], Bq for B[q]
    use CoefficientList to extract the expressions that are multiplied by Aq, Bq and neither
    use NIntegrate on those parts individually
    reassemble the parts
    substitute A[q] for Aq, B[q] for Bq

    http://reference.wolfram.com/mathematica/ref/CoefficientList.html
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Mathematica : Numerically Integrate function with undefined variables?
Loading...