Re: Hold[] ReleaseHold[] ? or what ?
- To: mathgroup at smc.vnet.net
- Subject: [mg60192] Re: [mg60168] Hold[] ReleaseHold[] ? or what ?
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Wed, 7 Sep 2005 04:03:50 -0400 (EDT)
- Reply-to: hanlonr at cox.net
- Sender: owner-wri-mathgroup at wolfram.com
Turn off the warnings with Off[NIntegrate::inum]. Note that your problem can be solved exactly. int=Integrate[Sin[x+u],{x,1,2}] 2*Sin[1/2]*Sin[u + 3/2] Off[Solve::ifun]; soln=Sort[Solve[D[int,u]==0,u],(int/.#1)<(int/.#2)&][[1]]; {int/.soln,soln}//Simplify {-2*Sin[1/2], {u -> (1/2)*(-3 - Pi)}} %//N {-0.958851077208406, {u -> -3.0707963267948966}} Bob Hanlon > > From: "lupos" <lupos at cheerful.com> To: mathgroup at smc.vnet.net > Date: 2005/09/05 Mon PM 10:27:25 EDT > Subject: [mg60192] [mg60168] Hold[] ReleaseHold[] ? or what ? > > hi all, > > why does the following code work as hoped ? > > In[1] > fn[u_Real] := NIntegrate[Sin[x + u], {x, 1, 2}]; > FindMinimum[fn[u], {u, 0}] > > Out[2]= > {-0.9588510772084058, {u -> -3.070796346594197}} > > > > but the next line generates some warnings/errors altough calculating > correctly. > how can the situation be fixed in a nice way ? > maybe some Hold[] / ReleaseHold[] ? > > In[3]:= > FindMinimum[NIntegrate[Sin[x + u], {x, 1, 2}], {u, 0}] > > Out[3]:= > NIntegrate::inum : Integrand Sin[u+x] is not numerical at {x} = {1.5`}. > NIntegrate::inum : Integrand Sin[u+x] is not numerical at {x} = {1.5`}. > NIntegrate::inum : Integrand Sin[u+x] is not numerical at {x} = {1.5`}. > {-0.958851077208406, {u -> -3.0707963268148295}} > > > thanks for any hints > robert. > >