Re: inum error from NIntegrate?
- To: mathgroup at smc.vnet.net
- Subject: [mg28396] Re: inum error from NIntegrate?
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Mon, 16 Apr 2001 03:28:48 -0400 (EDT)
- References: <9b8p5s$7fj@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
This is not an isolated problem, it also occurs with some other functions, for example Plot. The following demonstrates the problem and its solution lst= {x,x^2}; NIntegrate[{x,x^2}, {x,0,1}] {0.5,0.333333} NIntegrate[lst, {x,0,1}] NIntegrate::inum: Integrand {0.5,0.25} is not numerical at {x} = {0.5}. NIntegrate[lst,{x,0,1}] What happens is that NIntegrate looks at lst before it is evaluated (NIntgegrate has attribute HoldAll), finds that it is not a list and then works on the assumption that lst will become numerical when x is numerical: this is false -- it becomes a *list* of two numbers. The solution is to make lst evaluate before NIntegrates inspects its integrand NIntegrate[Evaluate[lst], {x,0,1}] {0.5,0.333333} The problem does not arise with Integrate, which evaluates lst before inspecting it. Integrate[lst, {x,0,1}] {1/2, 1/3} The same kind of problem arises with other functions that hold their entries, for example Plot: compare Plot[lst,{x,0,1}]; Plot[Evaluate[lst],{x,0,1}]; -- Allan --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565 "Carl Gold" <cgold at cns.caltech.edu> wrote in message news:9b8p5s$7fj at smc.vnet.net... > Hi - has anyone gotten an error like this before: > > I am using NIntegrate and get > > NIntegrate[g[t1, t2], {t1, -5 , 5}, {t2, -5 , 5}] > NIntegrate::"inum": "Integrand \!\({\({0.01831563888873418`}\)}\) is not > \ > numerical at \!\({t1, t2}\) = \!\({0.`, 0.`}\)." > > But if I evaluate the function: > > g[0, 0] > \!\({{1\/\[ExponentialE]\^4}}\) > > So the problem is not that the integrand doesn't have a value. > > The documentation on the inum error only discusses a case where you hae > an undefined parameter in your equation, which is not my situation.. > Any ideas what could be causing this error? > > Thanks for your help if you have any! > > -Carl > >