help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using quad() for multidimensional integration


From: Francesco Potorti`
Subject: Using quad() for multidimensional integration
Date: Thu, 17 Aug 1995 18:47 +0100 (MET)

   There do seem to be problems here. I tried a simpler task:

      \int_0^1 \int_0^x y dy dx   [Ans = 1/6].

   First the function definitions (note the trace prints):--
   -----------------------------------------------------------------
   #script file
   1;

   function v=V(y)
   fprintf(stdout,"V(%4.2f)\n",y);               ## printout on entry
   v=y;
   endfunction

   function u = U(x)
   fprintf(stdout,"U(%4.2f)\n",x);               ## printout on entry
   u = quad('V',0,x);
   fprintf(stdout,"U(0,%4.2f) = %4.2f\n",x,u);   ## printout on exit
   endfunction
   -----------------------------------------------------------------
   Next, execute "quad('U',0,1)". Results:--
   U(0.50)          <-----  "U" is entered here for first time
   V(0.25)          <-----  "V" here for first time
   V(0.01)
   V(0.49)
   ....      [all "V"] 21 V's in all
   V(0.39)
   V(0.18)
   V(0.32)
   U(0,0.50) = 0.12  <----- first "U" completes here
   V(0.01)
   V(0.49)
   V(0.03)
   ....      [all "V"] 86 V's in all
   V(0.00)
   V(0.00)
   V(0.00)
   V(0.00)
   ans = 0           <----- end of computation

The same on alpha gives 0.5, with approximately the same outputs.  The
problem here is that clearly quad forgets about 'U' once it calls 'V',
that is supposedly the effect of quad using some global variable as
Dutt said (I have not the sources here).  It also seems strange, as
Ted pointed out, that the first pass to get the 0.12 needs so many
iterations.
--
         Francesco Potorti`     | address@hidden (Internet)
         researcher at          | 39369::pot (DECnet)
         CNUCE-CNR, Pisa, Italy | +39-50-593203 (voice) 904052 (fax)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]