MathGroup Archive 2007

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

Search the Archive

Re: integration of piecewise convex bivariate function with 6 parameters

  • To: mathgroup at smc.vnet.net
  • Subject: [mg78923] Re: integration of piecewise convex bivariate function with 6 parameters
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Fri, 13 Jul 2007 05:56:00 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <f74t0t$91f$1@smc.vnet.net>

Michael Chen wrote:
> Dear there,
> 
> I spent roughly one week to manually integrate a piecewise convex function
> with 6 parameters, and I can't imagine how happy I would be if Mathematica
> can do it for me too. Following is the function, and the Mathematica command
> I tried.
> 
> f(h1,h1)= if  (h1 - x1 <= 0 or h2 - x2 <= 0) then | h1 - x1| + | h2 - x2 |
> else max( h1 - x1, h2 - x2), where x1, x2 are real parameters. And I
> integrate the function f(h1, h2) over rectangular region {h1, B1, U1}, {h2,
> B2, U2}, where B1, U1, B2, U2 are reals, and B1 < U1, B2 < U2.
> 
> I tried this in Mathematica 6.0:
> 
> g[x1_Real, x2_Real] :=  Integrate[
>   If [h1 - x1 <= 0 || h2 - x2 <= 0, abs[h1 - x1] + abs[h2 - x2] ,
>     max[h1 - x1, h2 - x2]], {h1, B1, U1}, {h2, B2, U2},
>    Assumptions ->
>     Im[B1] == 0 && Im[B2] == 0 && Im[U1] == 0 && Im[U2] == 0 &&
>      Im[h1] == 0 && Im[h2] == 0  && B1 < U1 && B2 < U2 ];
> 
> However there is simply no response from Mathematica 6.0 after I press
> Shift+Enter. Could anybody give me any suggestions? Thanks  a lot.
[snip]

Note that /Built in/ Mathematica functions start with a capital letter. 
That is you must write Abs rather than abs and Max rather than max.

g[x1_Real, x2_Real] :=
   Integrate[
     If[h1 - x1 <= 0 || h2 - x2 <= 0,
        Abs[h1 - x1] + Abs[h2 - x2], Max[h1 - x1, h2 - x2]],
     {h1, B1, U1}, {h2, B2, U2},
     Assumptions ->
          Im[B1] == 0 && Im[B2] == 0 && Im[U1] == 0 && Im[U2] == 0 &&
            Im[h1] == 0 && Im[h2] == 0 && B1 < U1 && B2 < U2];

Above, you have just /define/ the function g of two real arguments: the 
syntax is check but nothing is really computed. To evaluate the function 
g, you must call it with some arguments, as in g[0, 1] and hit shift-enter.

Regards,
Jean-Marc


  • Prev by Date: Re: Plotting a hyperbolic paraboloid (saddle)
  • Next by Date: Export
  • Previous by thread: integration of piecewise convex bivariate function with 6 parameters
  • Next by thread: Re: integration of piecewise convex bivariate function with 6 parameters