MathGroup Archive 2007

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

Search the Archive

Re: Problem when NIntegrate matrix

  • To: mathgroup at smc.vnet.net
  • Subject: [mg81346] Re: Problem when NIntegrate matrix
  • From: "jf.alcover at gmail.com" <jf.alcover at gmail.com>
  • Date: Thu, 20 Sep 2007 03:46:12 -0400 (EDT)
  • References: <fcqrrj$2jc$1@smc.vnet.net>

On 19 sep, 11:58, chiron1201 <hua... at cse.buaa.edu.cn> wrote:
> Hi all!
>
> I can not understand why there is a NIntegrate::inum error when I try to evaluate the following code
>
> TEST = Piecewise[{
>      {{{1, 2, 3}, {2, 3, 4}, {3, 4, 5}}, #1 < 0.00},
>      {{{2, 3, 4}, {3, 4, 5}, {4, 5, 6}}, #1 >= 0.00},
>      }] &;
>
> NIntegrate[TEST[x], {x, -1, +1}]
>
> However, I can get the correct result by modifying the code manually. That is
>
> NIntegrate[{{1, 2, 3}, {2, 3, 4}, {3, 4, 5}}, {x, -1, 0}]+NIntegrate[{{2, 3,4}, {3, 4, 5}, {4, 5, 6}}, {x, 0, 1}]
>
> However, it is impossible for me to manually split the integration range to thousands of segments. Why this happens? What should I do if I want the first code be evaluated correctly?
>
> Thanks!

Good day,

Here is my suggestion :

In[1]:=m1={{1, 2, 3}, {2, 3, 4}, {3, 4, 5}};
m2={{2, 3,4}, {3, 4, 5}, {4, 5, 6}};

In[3]:=test[x_]=MapThread[Piecewise[{{#1,x<0.},{#2,x>=0.}}]&,{m1,m2},
2];

In[4]:=NIntegrate[#,{x,-1,1}]& /@test[x]

Out[4]={{3., 5., 7.}, {5., 7., 9.}, {7., 9., 11.}}

V.Astanoff




  • Prev by Date: Re: Some font/pdf pb.
  • Next by Date: Re: Connecting 3D graphs together
  • Previous by thread: Problem when NIntegrate matrix
  • Next by thread: Re: Problem when NIntegrate matrix