2
$\begingroup$

How to NDSolve a set of equations, one of which itself contains NIntegrate of a desired function waited to be solved by NDSolve first? For example,

f[x_]:=NIntegrate[g[x0],{x0,0,x}]; NDSolve[{f'[x]==g[x],g'[x]==f[x],f[0]==0,g[0]==0},{f,g},{x,0,1}]; 

You can construct many specific examples like this one, mayebe my question are too general.

$\endgroup$

1 Answer 1

3
$\begingroup$

Why not

{sol} = NDSolve[{f'[x] == g[x], g'[x] == f[x], f[0] == 1, g[0] == 0}, {f, g}, {x, 0, 1}] 

omitting the definition of f?

Check:

{Inactivate@NIntegrate[g[x0], {x0, 0, x}], f[x]} /. sol /. x -> 0.5 // Activate (* {0.521095, 0.521095} *) 
$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.