MathGroup Archive 2011

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

Search the Archive

Re: How to NSolve equation which involves NIntegrate?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg120084] Re: How to NSolve equation which involves NIntegrate?
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Fri, 8 Jul 2011 04:50:50 -0400 (EDT)
  • References: <201106250929.FAA20235@smc.vnet.net>
  • Reply-to: drmajorbob at yahoo.com

Clear[f, g]
f[a_?NumericQ] := NIntegrate[Sin[a x], {x, 0, 1}]
g[a_] := a*a
FindRoot[f[a] - g[a], {a, 1}]

{a -> 0.490073}

a) NumericQ eliminates the error you mentioned,

b) NSolve is limited to algebraic problems, and

c) I had to come up with a starting point for the search.

(a) and (b) are related, in that NSolve wanted to keep a symbolic in  
solving the problem, but f[a] is undefined, when a is symbolic.

Bobby

On Thu, 07 Jul 2011 09:58:23 -0500, Ted Sariyski <tsariysk at craft-tech.com>  
wrote:

> I am sorry, I should made up an example. Here it is:
>
> f[a_] := NIntegrate[Sin[a x], {x, 0, 1}]
> g[a_] := a*a
> NSolve[f[a] == g[a], a]
>
> Out[]: NIntegrate::inumr: "The integrand Sin[a x] has evaluated to  
> non-numerical values for all sampling points in the region with  
> boundaries {{0,1}}."
>
> Thanks,
> --Ted
>
> On 7/7/2011 10:26 AM, DrMajorBob wrote:
>> You left out the definition of h, so how can we possibly tell you why  
>> it evaluates to non-numerical values?
>>
>> Bobby
>>
>> On Thu, 07 Jul 2011 06:31:38 -0500, Ted Sariyski  
>> <tsariysk at craft-tech.com> wrote:
>>
>>> Hi,
>>> I need  a numerical solution for a system of equations which involve
>>> numerical integrals. For one parameter the equation would be:
>>>
>>> f[a]==g[a]
>>>      where
>>> f[a_]:=NIntegrate[h[x, a] , {x, x1, x2}]
>>>
>>> NSolve returns: "The integrand  has evaluated to non-numerical values".
>>>
>>> Is there a built-in procedures for this type of problems or I need to
>>> make explicit iterations?
>>>
>>> Thanks in advance,
>>> --Ted
>>>
>>>
>>>
>>>
>>>
>>
>>
>


-- 
DrMajorBob at yahoo.com


  • Prev by Date: Re: Grouping terms under the radical
  • Next by Date: Re: How to write a "proper" math document
  • Previous by thread: Re: How to NSolve equation which involves NIntegrate?
  • Next by thread: Re: How to NSolve equation which involves NIntegrate?