Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: nested SetDelayed

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113378] Re: nested SetDelayed
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Tue, 26 Oct 2010 05:33:44 -0400 (EDT)

On 10/25/10 at 6:40 AM, kakabomba at gmail.com (O) wrote:

>hello, maybe somebody can explain what i'm doing wrong in this
>SIMPLE example:

>In[1] := f[v_, k_] := Sin[v*k]
>In[2] := test[v_] := NIntegrate[f[v, k], {k, 0, Pi}]
>In[3] := FindRoot[test[x] == 1, {x, 1}]

>I have NIntegrate errors:

<error messages snipped>

>Why expression `test` is evaluated with nonnumerical arguments??

>I guess my VisualBasic oriented brain can't understand how
>SetDelayed work and how i should use it.

The issue isn't the use of SetDelayed. Change the definition of
test to be:

test[v_?NumericQ] := NIntegrate[f[v, k], {k, 0, Pi}]

and the error messages you saw will be eliminated.



  • Prev by Date: Can Mathematica do this (infinite series)?
  • Next by Date: Re: More Mathematica CAN'T do than CAN???
  • Previous by thread: nested SetDelayed
  • Next by thread: Re: nested SetDelayed