0
$\begingroup$

I am trying to solve an ODE having a term of integration of an interpolating function multiplied by the variable, as shown below. However, I get the following error:

Integrate::ilim: Invalid integration variable or limit(s) in {0.,0,4}.

Code:

data = Table[{x, x + Sin[2 Pi x]}, {x, 0, 4.82, 0.1}];
f = Interpolation[data];

NDSolve[{Integrate[f[x]*ϕ[x], {x, 0, 4}] + ϕ'[x] == 1, ϕ[0] == 0}, ϕ, {x, 0, 4}]

Thanks for your help in anticipation.

$\endgroup$
2
  • $\begingroup$ My equation is more complicated, however, the basic question is how to deal with a term inside NDSOLVE in which exist terms containing an integration of an interpolating function multiplied by the variable. $\endgroup$
    – qahtah
    Jan 29 '17 at 17:37
  • 4
    $\begingroup$ Use a different symbol for the "dummy" variable of integration $\endgroup$
    – Carl Woll
    Jan 29 '17 at 17:44
1
$\begingroup$

The issue is with the integral part Integrate[f[x]*ϕ[x], {x, 0, 4}]. To solve it as a stand alone definite integral, the output should be some constant, but in fact, x is the independent variable of the ode and f itself is a set of data. Which you want to integrate over the domain of the ode. This can be done like this,

data = Table[{y, y + Sin[2 Pi y]}, {y, 0, 4.82, 0.1}];
f = Interpolation[data];
sol = NDSolve[{Integrate[f[y]*ϕ[x], {y, 0, x}] + ϕ'[x] == 
    1, ϕ[0] == 0}, ϕ, {x, 0, 4}]
Plot[Evaluate[ϕ[x] /. sol], {x, 0, 4}]

enter image description here

$\endgroup$
2
  • $\begingroup$ Many thanks for your help. $\endgroup$
    – qahtah
    Jan 29 '17 at 22:12
  • 2
    $\begingroup$ @qahtah So the modified integral Integrate[f[y]*ϕ[x], {y, 0, x}] is what you want? $\endgroup$
    – xzczd
    Jan 30 '17 at 3:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.