Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2013

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

Search the Archive

Re: Using NIntegrate in a function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg130062] Re: Using NIntegrate in a function
  • From: psycho_dad <s.nesseris at gmail.com>
  • Date: Thu, 7 Mar 2013 22:47:21 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <kh9kqs$1qe$1@smc.vnet.net>

Hi dude,

That's not a serious problem. Just define your function as:
f[a_?NumberQ]:=NIntegrate[Exp[-((a-1/3)^2+1)*x^4],{x,-1,1}]

Notice the ?NumberQ part that tells Math to only evaluate the function when "a" is a number. This will stop the errors from coming up.

Cheers



  • Prev by Date: Re: Issue with the submatrix in mathematica(version 7)
  • Next by Date: Fixed Typo in Code---> Re: updating a simulation within Manipulate.
  • Previous by thread: Re: Using NIntegrate in a function
  • Next by thread: Re: Using NIntegrate in a function