Re: SetDelayed and NIntegrate

• To: mathgroup at smc.vnet.net
• Subject: [mg47831] Re: [mg47805] SetDelayed and NIntegrate
• From: Anton Antonov <antonov at wolfram.com>
• Date: Thu, 29 Apr 2004 00:33:49 -0400 (EDT)
• References: <200404270847.EAA18887@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Mukhtar Bekkali wrote:

>Very simple question.   Is it possible in Mathematica 5 to execute this
>code?
>
>f[x_,y_]:=f[x,y]  (*where f[x,y] is some known function*)
>g[x_]:=NIntegrate[f[x,y],{y,0,1}]
>h[x_]:=D[g[x],x]
>FindRoot[h[x]==0,x]
>
>I get a message that Integrand is not numeric and FindRoot stops.   I would
>like to make clear that I do not want to use Integrate.
>
>My other question is why this code does not work
>
>w=q^x;
>With[{x=2},Plot[w,{q,0,1}]
>
>Thanks. Mukhtar Bekkali
>
>
>
With this lines you are trying to find a symbolic derivative of the
result of a numerical function (which is a number):

g[x_]:=NIntegrate[f[x,y],{y,0,1}]
h[x_]:=D[g[x],x]

May be you want NIntegrate[D[f[x,y],x],{y,0,1}] ?

In this case you can try this:

In[252]:=
Clear[f, g, h, x, y]

In[253]:=
f[x_, y_] := (x - 0.5)^2*y^2
g[(x_)?NumericQ] := NIntegrate[D[f[x1, y], x1] /. x1 -> x, {y, 0, 1}]
FindRoot[g[x] == 0, {x, 1}]

Out[255]=
{x -> 0.5}

Anton Antonov
Wolfram Research, Inc.

```

• Prev by Date: RE: ListPlot3D with holes
• Next by Date: Re: FindRoot cannot find obvious solution
• Previous by thread: SetDelayed and NIntegrate
• Next by thread: RE: SetDelayed and NIntegrate