Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

Re: NIntegrate - problems with HoldAll property(?)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg73176] Re: NIntegrate - problems with HoldAll property(?)
  • From: gotcha <david.shorthouse at credit-suisse.com>
  • Date: Tue, 6 Feb 2007 03:27:06 -0500 (EST)

thanks Carl

While this fixes the problem, it's a weird fix! Why does this make NIntegrate resolve the "i" to a number before it calls f1[]?

For instance, this still does not work even with the "NumericQ":
f1[x_?NumericQ] := Module[{res,y},
  res=First[Position[{1, 3, 5, 7, 9, Infinity}, y_ /; y>= x, Infinity, 1]][[1]];
  {res,{1,2,3}}
]

Now when we integrate:
NIntegrate[f1[i][[1]], {i, 0,7}]
we still get problems!

It gives the wrong answer (24.5), because NIntegrate does not resolve the "i" to a number before the call, so NIntegrate cannot see my definition of f1[]. So f1[i][[1]] gets resolved to "i"!
So it ends up doing:
NIntegrate[i, {i, 0,7}]
wow!

So I am back to my original question, how do I make NIntegrate "reliably" resolve the i to a number before it calls the f1[] function, for complex functions,

Looking at the debugger, when f1[x_] returns a number, the trick works and "i" is resolved to a number before the call. But if it returns a list, it does not work, and it does not even get into the function

Can u help?

rgds
D


  • Prev by Date: String to number
  • Next by Date: Re: Re: Re: Re: Remote Kernel does nothing
  • Previous by thread: Re: NIntegrate - problems with HoldAll property(?)
  • Next by thread: RE: NIntegrate - problems with HoldAll property(?)