[Date Index]
[Thread Index]
[Author Index]
Re: NIntegrate in NDSolve?
*To*: mathgroup at smc.vnet.net
*Subject*: [mg89065] Re: NIntegrate in NDSolve?
*From*: Szabolcs <szhorvat at gmail.com>
*Date*: Sun, 25 May 2008 03:19:26 -0400 (EDT)
*References*: <g18hon$kg7$1@smc.vnet.net>
On May 24, 9:57 am, EcoTheory <carroll.... at gmail.com> wrote:
> Hello, This is my first Mathematica question ... of many to come, I'm sure=
. My question is, can you use NIntegrate within NDSolve? My attempts lead to=
this error:
>
> NIntegrate::inum : Integrand is non - numerical etc.
>
> Here is a simple example:
> NDSolve[{y'[t] == NIntegrate[z y[t], {z, 0, 1}], y[0] == 1}, y[t],=
{t, 0, 1}]
>
> As far as I can tell, Mathematica does not believe that y[t] is a number. =
But shouldn't the numerical solver give y[t] as a number to NIntegrate?
Yes, it does, but even before it gets a chance to substitute a number
for y[t], the NIntegrate[ ... ] expression gets evaluated. We must
prevent this somehow. Here is a possibility:
fun[y_?NumericQ] := NIntegrate[z y, {z, 0, 1}]
(This function only gets evaluated for numeric arguments)
NDSolve[{y'[t] == fun[y[t]], y[0] == 1}, y, {t, 0, 1}]
>
> Obviously, Mathematica can do this problem easily enough using Integrate i=
nstead of NIntegrate, but it cannot integrate the messier double integral in=
the actual system of ODE's I want to solve. Thanks for suggestions.
Prev by Date:
**Re: Re: Range of Use of Mathematica**
Next by Date:
**Re: Dot Product of Vectors**
Previous by thread:
**Re: NIntegrate in NDSolve?**
Next by thread:
**Re: NIntegrate in NDSolve?**
| |