MathGroup Archive 2008

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

Search the Archive

Re: SetDelayed

Itzhak wrote:

> Why does Mathematica reply with:
> .."Integrand [(x-Cos[y])/(1+x^2-2*x*Cos[y])^1.5 is not numerical at {y}={1.5708}", to the following:
> Clear[f]
> f[x_]:=NIntegrate[(x-Cos[y])/(1+x^2-2*x*Cos[y])^1.5,{y,0,Pi}];
> Plot[Evaluate[f[x],{x,0,2}]
> How should it be written?

   f[x_?NumericQ] :=
    NIntegrate[(x - Cos[y])/(1 + x^2 - 2*x*Cos[y])^1.5, {y, 0, Pi}]
   Plot[f[x], {x, 0, 2}]

It might be worth reading the following article, "How do I write a 
function which evaluates only when the argument is a number?"

-- Jean-Marc

  • Prev by Date: Reduce Question
  • Next by Date: Dynamic problem (possibly simple)
  • Previous by thread: Re: SetDelayed
  • Next by thread: Strange results of Integrate