Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #10982 > unrolled thread

NDSolve with NIntegrate where Integral is a function of x

Started byNikthecrab <nikhil.dexter@gmail.com>
First post2012-07-19 07:50 +0000
Last post2012-07-20 07:56 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  NDSolve with NIntegrate where Integral is a function of x Nikthecrab <nikhil.dexter@gmail.com> - 2012-07-19 07:50 +0000
    Re: NDSolve with NIntegrate where Integral is a function of x psycho_dad <s.nesseris@gmail.com> - 2012-07-20 07:56 +0000

#10982 — NDSolve with NIntegrate where Integral is a function of x

FromNikthecrab <nikhil.dexter@gmail.com>
Date2012-07-19 07:50 +0000
SubjectNDSolve with NIntegrate where Integral is a function of x
Message-ID<ju8e8b$98m$1@smc.vnet.net>
I am trying to solve a differential equation using NDSolve . It is of the form:

NDSolve[{y'[x]=f(x)*Integrate[g(x,t),{t,0,infinity}],y[0]=0.04},y[x],{x,0,10}]

here f is a function of x and g is a function of x and a dummy variable t for integration.
The integral cannot be solved directly in terms of x.So I tried using NIntegrate.But NIntegrate requires x to be a number while NDSolve clearly has to vary x from 0 to 10. Can anyone suggest a suitable solution to this problem? 

[toc] | [next] | [standalone]


#10998

Frompsycho_dad <s.nesseris@gmail.com>
Date2012-07-20 07:56 +0000
Message-ID<jub2vr$eit$1@smc.vnet.net>
In reply to#10982
Hi dude,
Your solution had a few problems I'm afraid. For example, in NDSolve you should always write y'[x]==... and not y'(x)=..  (note the == and the [] instead of = and () ). Also, the same applies for the initial condition y[x]=..

The following seems to work (with a few warnings).

f[x_]:=x^2
g[x_?NumberQ,t_?NumberQ]:=Sin[x*t]
sol=NDSolve[{y'[x]==f[x]*NIntegrate[g[x,t],{t,0,1}],y[0]==0.04},y[x],{x,0,10}][[1]];
Plot[y[x]/.sol,{x,0,10}]

Cheers

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web