From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: help on triple integral
Date: Sun, 4 Jul 2010 02:13:04 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 19
Message-ID: <i0oqng$lm1$>
References: <i0amlt$e1b$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1278209584 22209 (4 Jul 2010 02:13:04 GMT)
NNTP-Posting-Date: Sun, 4 Jul 2010 02:13:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:650189

"Carla Soares" <> wrote in message <i0amlt$e1b$>...
> Hi! Can someone help me on a triple integral? 
> I have something like this:
> integrand is f(x,y,z)
> int over z from a to g(x,y) 
> int over y from b to f(x)
> int over x from c to d
> I've tried using triplequad and quad2d but always get error messages.
> Thanks a lot in advance!
- - - - - - - - -
  I can think of a way of using quad2d for finding two-dimensional integrals of cross sections for fixed x values and then using a one-dimensional quadrature routine (quad, quadgk, or quadl) for integrating over these cross sections from x=c to x=d.

  You would need to write a function F(x), which accepts x as a vector, to act as the integrand of the 1d quadrature routine.  Using a for-loop, for each element xi of the vector, F(xi) would be the value given by quad2d for the integral of f(xi,y,z) over the cross section b<=y<=f(xi) and a<=z<=g(xi,y).  As long as guad2d is being called on with a single fixed xi, it can solve such a cross section integral if it is called in a correct manner.

  Admittedly this won't be as efficient as a routine that is specifically designed for triple integration, but I see no reason why it shouldn't work.

  Another possibility is to find an appropriate change of variables that would change your region of integration into a three-dimensional rectangle and then use triplequad.  Being able to do that would depend on the nature of your y and z upper limit functions, f(x) and g(x,y).  (Your f(x) upper limit function is different from your f(x,y,z).)

Roger Stafford