MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

An Argument Problem


Dear Mathgroup,

I am trying to numerically integrate a function of several variables w.r.t.  its last variable.  As NIntegrate won't work, I decided to use Simpson's 1/3 rule.  Below is my attempt for a function of 2 variables (using Mathematica 6.0):

Simpson[F_, a_, b_, n_?EvenQ] := Module[{h, evens, odds},
    h = (b - a)/n;
    evens = Table[a + i h, {i, 2, n - 2, 2}];
    odds = Table[a + i h, {i, 1, n - 1, 2}];
    h/3 {F[x, a], F[x, b], 4 F[x, #] & /@ odds,
        2 F[x, #] & /@ evens} // Flatten // Total] // Simplify // N

This works OK & returns a function of x.  My query is how to make Simpson give a function of whatever the fist argument of F is. Thus, if  F= F[r,t]=
,
Simpson would integrate w.r.t. t & give a function of r (without my having to change the x's into r's). Basically, I can't suss out how to pass the first argument of F inside the module.

Thanks for any help.

Regards.
Ajit      


  • Prev by Date: Re: Normal Probability plot
  • Next by Date: Trying to speed up a function
  • Previous by thread: Re: Normal Probability plot
  • Next by thread: Re: An Argument Problem