1
$\begingroup$

I wanted to solve a differential equation involving a term with integration over its parameters. I want to call the integral expression but I get the wrong result:

 ysol4 = ParametricNDSolveValue[{D[y[t], t] == y[t]*x + 
Integrate[y[t], {x, 0, 1}], 
y[0] == 1}, Integrate[y[t], {x, 0, 1}], {t, 0, 30}, {x}];
Plot[Evaluate[ysol4[0.1]], {t, 0, 1}]

I know that the result is wrong since the plot is sensitive to x. It should not be since I called the expression that is an integral of x. Any help will be appreciated.

$\endgroup$
1
  • $\begingroup$ It's because Integrate[y[t], {x, 0, 1}] is just y[t] - in other words, it's treating y[t] like a constant in the integral. $\endgroup$
    – flinty
    Aug 24 '20 at 16:21
1
$\begingroup$

Generally speaking, we have here integrodifferential equation, so function $y=y(x,t)$, and we can consider equation and its solution as follows

ysol = NDSolveValue[{D[y[x, t], t] == 
    y[x, t]*x + Integrate[y[x, t], {x, 0, 1}], y[x, 0] == 1}, 
  y[x, t], {t, 0, 30}, {x, 0, 1}]

It looks like NDSolve can recognize and solve it (?), and we can visualize solution as

Plot3D[ysol, {t, 0, 1}, {x, .0, 1}, AxesLabel -> Automatic,  
 Mesh -> None, ColorFunction -> "Rainbow"]

Figure 1

$\endgroup$
2
  • $\begingroup$ This seems to work. Thanks! $\endgroup$
    – khvillegas
    Aug 25 '20 at 4:01
  • $\begingroup$ @khvillegas You are welcome! $\endgroup$ Aug 25 '20 at 10:15
0
$\begingroup$

How about this:

DSolve[{D[y[t], t] == y[t]*x + 
Integrate[y[t], {x, 0, 1}], 
y[0] == 1},y[t],t]
$\endgroup$

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.